首次提交

This commit is contained in:
2026-06-16 13:38:08 +08:00
commit ec32ae543d
192 changed files with 13162 additions and 0 deletions
+104
View File
@@ -0,0 +1,104 @@
#ifndef Global_H
#define Global_H
#include "BackEnd/BackEnd.h"
#include "YSGraphic_Core/GlobalTypes.h"
#include <QApplication>
#include <QDebug>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QPainter>
#include <QVBoxLayout>
#include <QVector>
#include <QWidget>
#include <QWindow>
#include <QtWidgets>
#include <QtWidgetsDepends>
#include <functional>
#include "psc_global_include/Singleton.hpp"
// template <typename Derived>
// class Singleton {
// public:
// static Derived* instance() {
// Derived* temp = instance_.load(std::memory_order_acquire);
// if (temp == nullptr) {
// std::lock_guard<std::mutex> lock(mutex_);
// temp = instance_.load(std::memory_order_relaxed);
// if (temp == nullptr) {
// temp = new Derived;
// instance_.store(temp, std::memory_order_release);
// }
// }
// return temp;
// }
// Singleton(const Singleton&) = delete;
// Singleton& operator=(const Singleton&) = delete;
// protected:
// Singleton() = default;
// ~Singleton() = default;
// private:
// static std::atomic<Derived*> instance_;
// static std::mutex mutex_;
// };
// template<typename Derived>
// std::atomic<Derived*> Singleton<Derived>::instance_(nullptr);
// template<typename Derived>
// std::mutex Singleton<Derived>::mutex_;
//template<typename T>
//class Singleton {
//public:
// static T *instance() {
// if(!mInstance) {
// mInstance = new T();
// }
// return mInstance;
// }
// virtual ~Singleton() = default;
// Singleton(T &&) = delete;
// Singleton(const T &) = delete;
// void operator=(const T &) = delete;
//protected:
// Singleton() = default;
// static T* mInstance;
//};
//template<typename T> T* Singleton<T>::mInstance = nullptr;
class Global : public Psc::Singleton<Global> {
public:
explicit Global();
int adaptHeight(int fullScreenHeight);
int adaptWidth(int fullScreenWidth);
};
QVBoxLayout* createVBoxLayout(const QVector<QWidget*>& children = {}, QWidget *parent = nullptr);
QHBoxLayout* createHBoxLayout(const QVector<QWidget*>& children = {}, QWidget *parent = nullptr);
QRect getMaxRect(const QRect& rect, double WHRate);
int calculateOptimalFontSize(const QString& text, const QSize& spaceSize, const QFont& font);
int calculateOptimalFontSize(const QVector<QString>& textList, const QSize& spaceSize, const QFont& font);
QPushButton* createButton(const QString& text, int fontSize, const std::function<void(void)>& mFunc = nullptr);
namespace YSG{
template <typename T>
class RollObject;
}
class BaseWidgetMenu;
void initClickButton(QPushButton* button, const QString &text, int fontSize, const std::function<void(void)> &mFunc, YSG::RollObject<QPushButton>*);
QPushButton *createClickButton(const QString &text, int fontSize, const std::function<void(void)> &mFunc, YSG::RollObject<QPushButton>*);
QPushButton* createNormal(const QString& text, int fontSize, const std::function<void(void)>& mFunc = nullptr);
#endif