| 1 | #ifndef ADDONSCONTROLLER_HXX |
| 2 | #define ADDONSCONTROLLER_HXX |
| 3 | |
| 4 | #include <QObject> |
| 5 | #include <QStringList> |
| 6 | |
| 7 | #include "AddonsModel.hxx" |
| 8 | #include "PathListModel.hxx" |
| 9 | |
| 10 | class CatalogListModel; |
| 11 | class LauncherMainWindow; |
| 12 | class LaunchConfig; |
| 13 | |
| 14 | #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) |
| 15 | Q_MOC_INCLUDE("CatalogListModel.hxx") |
| 16 | #endif |
| 17 | |
| 18 | class AddOnsController : public QObject |
| 19 | { |
| 20 | Q_OBJECT |
| 21 | |
| 22 | Q_PROPERTY(PathListModel* aircraftPaths READ aircraftPaths CONSTANT) |
| 23 | Q_PROPERTY(PathListModel* sceneryPaths READ sceneryPaths CONSTANT) |
| 24 | Q_PROPERTY(QStringList modulePaths READ modulePaths WRITE setModulePaths NOTIFY modulePathsChanged) |
| 25 | |
| 26 | Q_PROPERTY(CatalogListModel* catalogs READ catalogs CONSTANT) |
| 27 | Q_PROPERTY(AddonsModel* modules READ modules NOTIFY modulesChanged) |
| 28 | Q_PROPERTY(bool isOfficialHangarRegistered READ isOfficialHangarRegistered NOTIFY isOfficialHangarRegisteredChanged) |
| 29 | Q_PROPERTY(bool showNoOfficialHangar READ showNoOfficialHangar NOTIFY showNoOfficialHangarChanged) |
| 30 | Q_PROPERTY(bool havePathsFromCommandLine READ havePathsFromCommandLine CONSTANT) |
| 31 | |
| 32 | public: |
| 33 | explicit AddOnsController(LauncherMainWindow *parent, LaunchConfig* config); |
| 34 | |
| 35 | PathListModel* aircraftPaths() const; |
| 36 | PathListModel* sceneryPaths() const; |
| 37 | QStringList modulePaths() const; |
| 38 | |
| 39 | CatalogListModel* catalogs() const |
| 40 | { return m_catalogs; } |
| 41 | |
| 42 | AddonsModel* modules() const |
| 43 | { return m_addonsModuleModel; } |
| 44 | |
| 45 | Q_INVOKABLE QString addAircraftPath() const; |
| 46 | Q_INVOKABLE QString addSceneryPath() const; |
| 47 | Q_INVOKABLE QString addAddOnModulePath() const; |
| 48 | |
| 49 | Q_INVOKABLE void openDirectory(QString path); |
| 50 | |
| 51 | bool isOfficialHangarRegistered(); |
| 52 | |
| 53 | bool showNoOfficialHangar() const; |
| 54 | |
| 55 | Q_INVOKABLE void officialCatalogAction(QString s); |
| 56 | |
| 57 | bool havePathsFromCommandLine() const; |
| 58 | signals: |
| 59 | void modulePathsChanged(QStringList modulePaths); |
| 60 | void modulesChanged(); |
| 61 | |
| 62 | void isOfficialHangarRegisteredChanged(); |
| 63 | void showNoOfficialHangarChanged(); |
| 64 | |
| 65 | public slots: |
| 66 | void setModulePaths(QStringList modulePaths); |
| 67 | void setAddons(AddonsModel* addons); |
| 68 | void onAddonsChanged(void); |
| 69 | |
| 70 | void collectArgs(); |
| 71 | |
| 72 | private: |
| 73 | void setLocalAircraftPaths(); |
| 74 | bool shouldShowOfficialCatalogMessage() const; |
| 75 | void onCatalogsChanged(); |
| 76 | |
| 77 | LauncherMainWindow* m_launcher; |
| 78 | CatalogListModel* m_catalogs = nullptr; |
| 79 | AddonsModel* m_addonsModuleModel = nullptr; |
| 80 | LaunchConfig* m_config = nullptr; |
| 81 | |
| 82 | PathListModel* m_aircraftPaths = nullptr; |
| 83 | PathListModel* m_sceneryPaths = nullptr; |
| 84 | QStringList m_addonModulePaths; |
| 85 | }; |
| 86 | |
| 87 | #endif // ADDONSCONTROLLER_HXX |