aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-05-15 23:29:46 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2018-05-16 08:10:05 +0000
commit9338e1285e47060f3998ac19d047e93a11252ffb (patch)
tree507d94919d8f0d83b78606564fe1cf408d78ddd0
parent9d442922425f36d96f68f4fff83f3aca90aea6df (diff)
Rename QQuickTheme::current to instance
Avoid giving a wrong impression that the theme instance could be changed on the fly. Change-Id: Ifb5078422385d2f15da6a416d89cc9d6f46b0f40 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/quickcontrols2/qquickstyleplugin.cpp6
-rw-r--r--src/quicktemplates2/qquicktheme.cpp15
-rw-r--r--src/quicktemplates2/qquicktheme_p.h3
-rw-r--r--src/quicktemplates2/qquicktheme_p_p.h2
-rw-r--r--tests/auto/font/tst_font.cpp4
-rw-r--r--tests/auto/palette/tst_palette.cpp4
-rw-r--r--tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp4
7 files changed, 16 insertions, 22 deletions
diff --git a/src/quickcontrols2/qquickstyleplugin.cpp b/src/quickcontrols2/qquickstyleplugin.cpp
index 6bf93046..c42ba88d 100644
--- a/src/quickcontrols2/qquickstyleplugin.cpp
+++ b/src/quickcontrols2/qquickstyleplugin.cpp
@@ -58,8 +58,8 @@ QQuickStylePlugin::QQuickStylePlugin(QObject *parent)
QQuickStylePlugin::~QQuickStylePlugin()
{
Q_D(QQuickStylePlugin);
- if (QQuickTheme::current() == d->theme)
- QQuickTheme::setCurrent(nullptr);
+ if (QQuickTheme::instance() == d->theme)
+ QQuickThemePrivate::instance.reset();
}
void QQuickStylePlugin::registerTypes(const char *uri)
@@ -89,7 +89,7 @@ void QQuickStylePlugin::initializeEngine(QQmlEngine *engine, const char *uri)
p->defaultPalette.reset(QQuickStylePrivate::readPalette(settings));
}
#endif
- QQuickTheme::setCurrent(d->theme);
+ QQuickThemePrivate::instance.reset(d->theme);
}
}
}
diff --git a/src/quicktemplates2/qquicktheme.cpp b/src/quicktemplates2/qquicktheme.cpp
index 30185fe2..bfa34001 100644
--- a/src/quicktemplates2/qquicktheme.cpp
+++ b/src/quicktemplates2/qquicktheme.cpp
@@ -42,7 +42,7 @@
QT_BEGIN_NAMESPACE
-QScopedPointer<QQuickTheme> QQuickThemePrivate::current;
+QScopedPointer<QQuickTheme> QQuickThemePrivate::instance;
static QPlatformTheme::Font platformFont(QQuickTheme::Scope scope)
{
@@ -126,20 +126,15 @@ QQuickTheme::~QQuickTheme()
{
}
-QQuickTheme *QQuickTheme::current()
+QQuickTheme *QQuickTheme::instance()
{
- return QQuickThemePrivate::current.data();
-}
-
-void QQuickTheme::setCurrent(QQuickTheme *theme)
-{
- QQuickThemePrivate::current.reset(theme);
+ return QQuickThemePrivate::instance.data();
}
QFont QQuickTheme::themeFont(Scope scope)
{
const QFont *font = nullptr;
- if (QQuickTheme *theme = current())
+ if (QQuickTheme *theme = instance())
font = QQuickThemePrivate::get(theme)->resolveThemeFont(scope);
else if (QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
font = theme->font(platformFont(scope));
@@ -157,7 +152,7 @@ QFont QQuickTheme::themeFont(Scope scope)
QPalette QQuickTheme::themePalette(Scope scope)
{
const QPalette *palette = nullptr;
- if (QQuickTheme *theme = current())
+ if (QQuickTheme *theme = instance())
palette = QQuickThemePrivate::get(theme)->resolveThemePalette(scope);
else if (QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
palette = theme->palette(platformPalette(scope));
diff --git a/src/quicktemplates2/qquicktheme_p.h b/src/quicktemplates2/qquicktheme_p.h
index 32044b67..eb10d766 100644
--- a/src/quicktemplates2/qquicktheme_p.h
+++ b/src/quicktemplates2/qquicktheme_p.h
@@ -63,8 +63,7 @@ public:
QQuickTheme();
virtual ~QQuickTheme();
- static QQuickTheme *current();
- static void setCurrent(QQuickTheme *theme);
+ static QQuickTheme *instance();
enum Scope {
System,
diff --git a/src/quicktemplates2/qquicktheme_p_p.h b/src/quicktemplates2/qquicktheme_p_p.h
index e9593865..e43c8034 100644
--- a/src/quicktemplates2/qquicktheme_p_p.h
+++ b/src/quicktemplates2/qquicktheme_p_p.h
@@ -65,7 +65,7 @@ public:
const QFont *resolveThemeFont(QQuickTheme::Scope scope);
const QPalette *resolveThemePalette(QQuickTheme::Scope scope);
- static QScopedPointer<QQuickTheme> current;
+ static QScopedPointer<QQuickTheme> instance;
bool hasResolvedFonts = false;
bool hasResolvedPalettes = false;
diff --git a/tests/auto/font/tst_font.cpp b/tests/auto/font/tst_font.cpp
index eb37857a..048739ff 100644
--- a/tests/auto/font/tst_font.cpp
+++ b/tests/auto/font/tst_font.cpp
@@ -45,7 +45,7 @@
#include <QtQuickTemplates2/private/qquickapplicationwindow_p.h>
#include <QtQuickTemplates2/private/qquickcontrol_p.h>
#include <QtQuickTemplates2/private/qquickpopup_p.h>
-#include <QtQuickTemplates2/private/qquicktheme_p.h>
+#include <QtQuickTemplates2/private/qquicktheme_p_p.h>
using namespace QQuickVisualTestUtil;
@@ -305,7 +305,7 @@ void tst_font::defaultFont()
// The call to setData() above causes QQuickDefaultTheme to be set as the current theme,
// so we must make sure we only set our theme afterwards.
- QQuickTheme::setCurrent(new TestFontTheme);
+ QQuickThemePrivate::instance.reset(new TestFontTheme);
QScopedPointer<QObject> object(component.create());
QVERIFY2(!object.isNull(), qPrintable(component.errorString()));
diff --git a/tests/auto/palette/tst_palette.cpp b/tests/auto/palette/tst_palette.cpp
index 1b1f5168..4c067e17 100644
--- a/tests/auto/palette/tst_palette.cpp
+++ b/tests/auto/palette/tst_palette.cpp
@@ -45,7 +45,7 @@
#include <QtQuickTemplates2/private/qquickcontrol_p.h>
#include <QtQuickTemplates2/private/qquickcontrol_p_p.h>
#include <QtQuickTemplates2/private/qquickpopup_p.h>
-#include <QtQuickTemplates2/private/qquicktheme_p.h>
+#include <QtQuickTemplates2/private/qquicktheme_p_p.h>
using namespace QQuickVisualTestUtil;
@@ -301,7 +301,7 @@ void tst_palette::defaultPalette()
// The call to setData() above causes QQuickDefaultTheme to be set as the current theme,
// so we must make sure we only set our theme afterwards.
- QQuickTheme::setCurrent(new TestTheme);
+ QQuickThemePrivate::instance.reset(new TestTheme);
QScopedPointer<QObject> object(component.create());
QVERIFY2(!object.isNull(), qPrintable(component.errorString()));
diff --git a/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp b/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp
index 1700829c..742ad9fd 100644
--- a/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp
+++ b/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp
@@ -50,7 +50,7 @@
#include <QtQuickTemplates2/private/qquickpopup_p.h>
#include <QtQuickTemplates2/private/qquicktextarea_p.h>
#include <QtQuickTemplates2/private/qquicktextfield_p.h>
-#include <QtQuickTemplates2/private/qquicktheme_p.h>
+#include <QtQuickTemplates2/private/qquicktheme_p_p.h>
#include "../shared/util.h"
#include "../shared/visualtestutil.h"
@@ -571,7 +571,7 @@ public:
void tst_QQuickApplicationWindow::defaultFont()
{
- QQuickTheme::setCurrent(new TestTheme);
+ QQuickThemePrivate::instance.reset(new TestTheme);
QQmlEngine engine;
QQmlComponent component(&engine);