File indexing completed on 2024-09-08 09:44:55
0001 // SPDX-FileCopyrightText: (C) 2020 Carl Schwan <carl@carlschwan.eu> 0002 // 0003 // SPDX-License-Identifier: GPL-3.0-or-later 0004 0005 #pragma once 0006 0007 #include <QObject> 0008 #include <KPackage/Package> 0009 #include "gamesmodel.h" 0010 0011 class QQmlEngine; 0012 class QQuickItem; 0013 class KLocalizedContext; 0014 0015 0016 /** 0017 * Singleton class exposing global variables to the QML application. 0018 */ 0019 class Arkade : public QObject 0020 { 0021 Q_OBJECT 0022 0023 Q_PROPERTY(GamesModel *gamesModel READ gamesModel NOTIFY gamesModelChanged) 0024 Q_PROPERTY(QString gameId READ gameId WRITE setGameId NOTIFY gameIdChanged) 0025 Q_PROPERTY(QQuickItem *gameItem READ gameItem NOTIFY gameItemChanged) 0026 0027 public: 0028 Arkade(QQmlEngine *engine); 0029 ~Arkade() = default; 0030 0031 GamesModel *gamesModel() const; 0032 void setGamesModel(GamesModel *gamesModel); 0033 0034 QString gameId() const; 0035 void setGameId(const QString &gameId); 0036 0037 QQuickItem *gameItem(); 0038 QString qmlPath(); 0039 0040 Q_SIGNALS: 0041 void gamesModelChanged(); 0042 void gameIdChanged(); 0043 void gameItemChanged(); 0044 0045 private: 0046 QQuickItem *createGui(const QString &qmlPath); 0047 0048 GamesModel *m_gamesModel; 0049 QQmlEngine *m_engine; 0050 KLocalizedContext *m_contextObj = nullptr; 0051 QString m_gameId; 0052 KPackage::Package m_gamePackage; 0053 };