Theme: Use QVariantMap for theme properties

QML can directly mirror this into a JavaScript object, so there is no
need to manually copy the values into a different container. Also,
QQmlPropertyMap is very expensive as it will listen to changes to any
value in the map. We never use this. It would be entirely enough to
update the whole map at once if we ever want to update the theme at
runtime.

Change-Id: Ie2b549e9af51d620801808c87d6f659cc7a06c04
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2016-11-08 14:39:17 +01:00
parent 062512a246
commit 08b780205a
13 changed files with 42 additions and 57 deletions

View File

@@ -158,7 +158,6 @@ private:
void sceneGraphError(QQuickWindow::SceneGraphError, const QString &message);
void facilitateQml(QQmlEngine *engine);
void addPages(const QList<IWelcomePage *> &pages);
void applyTheme();
void addKeyboardShortcuts();
QWidget *m_modeWidget;
@@ -166,7 +165,6 @@ private:
QMap<Id, IWelcomePage *> m_idPageMap;
QList<IWelcomePage *> m_pluginList;
int m_activePlugin;
QQmlPropertyMap m_themeProperties;
QStringList m_recentProjectsShortcuts;
QStringList m_sessionsShortcuts;
};
@@ -197,7 +195,6 @@ WelcomeMode::WelcomeMode()
layout->setSpacing(0);
m_welcomePage = new QQuickWidget;
applyTheme(); // initialize background color and theme properties
m_welcomePage->setResizeMode(QQuickWidget::SizeRootObjectToView);
m_welcomePage->setObjectName(QLatin1String("WelcomePage"));
@@ -217,13 +214,6 @@ WelcomeMode::WelcomeMode()
setWidget(m_modeWidget);
}
void WelcomeMode::applyTheme()
{
const QVariantHash creatorTheme = Utils::creatorTheme()->values();
for (auto it = creatorTheme.constBegin(); it != creatorTheme.constEnd(); ++it)
m_themeProperties.insert(it.key(), it.value());
}
void WelcomeMode::addKeyboardShortcuts()
{
const int actionsCount = 9;
@@ -294,7 +284,7 @@ void WelcomeMode::facilitateQml(QQmlEngine *engine)
QQmlContext *ctx = engine->rootContext();
ctx->setContextProperty(QLatin1String("welcomeMode"), this);
ctx->setContextProperty(QLatin1String("creatorTheme"), &m_themeProperties);
ctx->setContextProperty(QLatin1String("creatorTheme"), Utils::creatorTheme()->values());
ctx->setContextProperty(QLatin1String("useNativeText"), true);
}