themeinterface: move registration to themeinterface

Move setup call and registration from subsurface-helper
to themeInterface, in order to keep the registration where the code
are.

Signed-off-by: jan Iversen <jan@casacondor.com>
This commit is contained in:
jan Iversen 2020-01-28 15:04:22 +01:00 committed by Dirk Hohndel
parent f69e1e31f0
commit 1d35942249
3 changed files with 10 additions and 8 deletions

View file

@ -8,11 +8,14 @@ themeInterface *themeInterface::instance()
return self;
}
void themeInterface::setup()
void themeInterface::setup(QQmlContext *ct)
{
// Register interface class
ct->setContextProperty("ThemeNew", instance());
// get current theme
m_currentTheme = qPrefDisplay::theme();
update_theme();
instance()->m_currentTheme = qPrefDisplay::theme();
instance()->update_theme();
}
void themeInterface::set_currentTheme(const QString &theme)

View file

@ -4,6 +4,7 @@
#include <QObject>
#include <QColor>
#include <QSettings>
#include <QQmlContext>
class themeInterface : public QObject {
Q_OBJECT
@ -69,7 +70,7 @@ class themeInterface : public QObject {
public:
static themeInterface *instance();
void setup();
static void setup(QQmlContext *ct);
public slots:
void set_currentTheme(const QString &theme);

View file

@ -187,11 +187,9 @@ void register_qml_types(QQmlEngine *engine)
if (engine != NULL) {
QQmlContext *ct = engine->rootContext();
// Register qml interface class
// Register qml interface classes
QMLInterface::setup(ct);
themeInterface::instance()->setup();
ct->setContextProperty("ThemeNew", themeInterface::instance());
themeInterface::setup(ct);
}
REGISTER_TYPE(QMLManager, "QMLManager");