xuqiang 5 mesi fa
parent
commit
f1f442b8a5
3 ha cambiato i file con 52 aggiunte e 0 eliminazioni
  1. 23 0
      include/appcontext.h
  2. 26 0
      src/appcontext.cpp
  3. 3 0
      src/main.cpp

+ 23 - 0
include/appcontext.h

@@ -0,0 +1,23 @@
+#ifndef __APPCONTEXT_H__
+#define __APPCONTEXT_H__
+
+#include <QObject>
+#include "pluginmanager.h"
+
+class AppContext : public QObject
+{
+    Q_OBJECT
+
+    explicit AppContext(QObject *parent = nullptr);
+    ~AppContext();
+
+public:
+    static AppContext &instance();
+    const PluginManager &pluginManager();
+
+private:
+    PluginManager m_pluginMgr;
+
+};
+
+#endif  // APPCONTEXT_H

+ 26 - 0
src/appcontext.cpp

@@ -0,0 +1,26 @@
+#include "appcontext.h"
+#include <QDir>
+#include <QDebug>
+
+AppContext::AppContext(QObject *parent)
+    : QObject{parent}
+{
+
+}
+
+AppContext::~AppContext()
+{
+
+}
+
+AppContext  &AppContext::instance()
+{
+    static AppContext instance;
+    return instance;
+}
+
+const PluginManager &AppContext::pluginManager()
+{
+    return m_pluginMgr;
+}
+

+ 3 - 0
src/main.cpp

@@ -1,6 +1,7 @@
 #include <QApplication>
 #include "mainwindow.h"
 #include "logger.h"
+#include "appcontext.h"
 
 #define SCREEN_WIDTH    1280
 #define SCREEN_HEIGHT   720
@@ -13,6 +14,8 @@ int main(int argc, char *argv[])
     QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
     QApplication app(argc, argv);
     Logger::setup();
+
+    AppContext &appCtx = AppContext::instance();
     
     MainWindow w;
     w.resize(SCREEN_WIDTH, SCREEN_HEIGHT);