mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
f69e1e31f0
commit
1d35942249
3 changed files with 10 additions and 8 deletions
|
@ -8,11 +8,14 @@ themeInterface *themeInterface::instance()
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
void themeInterface::setup()
|
void themeInterface::setup(QQmlContext *ct)
|
||||||
{
|
{
|
||||||
|
// Register interface class
|
||||||
|
ct->setContextProperty("ThemeNew", instance());
|
||||||
|
|
||||||
// get current theme
|
// get current theme
|
||||||
m_currentTheme = qPrefDisplay::theme();
|
instance()->m_currentTheme = qPrefDisplay::theme();
|
||||||
update_theme();
|
instance()->update_theme();
|
||||||
}
|
}
|
||||||
|
|
||||||
void themeInterface::set_currentTheme(const QString &theme)
|
void themeInterface::set_currentTheme(const QString &theme)
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QQmlContext>
|
||||||
|
|
||||||
class themeInterface : public QObject {
|
class themeInterface : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -69,7 +70,7 @@ class themeInterface : public QObject {
|
||||||
public:
|
public:
|
||||||
static themeInterface *instance();
|
static themeInterface *instance();
|
||||||
|
|
||||||
void setup();
|
static void setup(QQmlContext *ct);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void set_currentTheme(const QString &theme);
|
void set_currentTheme(const QString &theme);
|
||||||
|
|
|
@ -187,11 +187,9 @@ void register_qml_types(QQmlEngine *engine)
|
||||||
if (engine != NULL) {
|
if (engine != NULL) {
|
||||||
QQmlContext *ct = engine->rootContext();
|
QQmlContext *ct = engine->rootContext();
|
||||||
|
|
||||||
// Register qml interface class
|
// Register qml interface classes
|
||||||
QMLInterface::setup(ct);
|
QMLInterface::setup(ct);
|
||||||
|
themeInterface::setup(ct);
|
||||||
themeInterface::instance()->setup();
|
|
||||||
ct->setContextProperty("ThemeNew", themeInterface::instance());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER_TYPE(QMLManager, "QMLManager");
|
REGISTER_TYPE(QMLManager, "QMLManager");
|
||||||
|
|
Loading…
Add table
Reference in a new issue