aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2016-03-17 15:46:46 +0100
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2016-03-18 22:14:34 +0000
commit09e83913e9bfee232d436773a9a08f153aa00a70 (patch)
tree0b907bd45dd57a2d7f410f755a0f2868aa5147c5
parent94136244c58ed035be44183bd8eb00314bccf7df (diff)
Cleanup QQuickProxyStyle
Install and remove the proxy theme automatically to eliminate the need for TestTheme do it in tst_applicationwindow. Furthermore, fix some Qt coding conventions, align header guards, remove unneeded empty destructor, and add missing explicit keywords for one-parameter constructors and cleanup somemeaningless ones in paremeterless ctors. Change-Id: Ib95dad003e35e468e941f3a0d2be5b21323fcccd Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
-rw-r--r--src/controls/qquickproxytheme.cpp51
-rw-r--r--src/controls/qquickproxytheme_p.h9
-rw-r--r--src/imports/controls/material/qquickmaterialtheme.cpp4
-rw-r--r--src/imports/controls/material/qquickmaterialtheme_p.h11
-rw-r--r--src/imports/controls/material/qtlabsmaterialstyleplugin.cpp9
-rw-r--r--src/imports/controls/universal/qquickuniversaltheme.cpp4
-rw-r--r--src/imports/controls/universal/qquickuniversaltheme_p.h11
-rw-r--r--src/imports/controls/universal/qtlabsuniversalstyleplugin.cpp9
-rw-r--r--tests/auto/applicationwindow/tst_applicationwindow.cpp1
9 files changed, 35 insertions, 74 deletions
diff --git a/src/controls/qquickproxytheme.cpp b/src/controls/qquickproxytheme.cpp
index dccd7f22..03ccb3b2 100644
--- a/src/controls/qquickproxytheme.cpp
+++ b/src/controls/qquickproxytheme.cpp
@@ -36,19 +36,21 @@
#include "qquickproxytheme_p.h"
-#include <QtGui/qguiapplication.h>
+#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qpixmap.h>
#include <QtGui/qfont.h>
QT_BEGIN_NAMESPACE
QQuickProxyTheme::QQuickProxyTheme(QPlatformTheme *theme)
- : m_theme(theme)
+ : m_theme(theme ? theme : QGuiApplicationPrivate::platform_theme)
{
}
QQuickProxyTheme::~QQuickProxyTheme()
{
+ if (QGuiApplicationPrivate::platform_theme == this)
+ QGuiApplicationPrivate::platform_theme = m_theme;
}
QPlatformTheme *QQuickProxyTheme::theme() const
@@ -60,48 +62,42 @@ QPlatformMenuItem *QQuickProxyTheme::createPlatformMenuItem() const
{
if (m_theme)
return m_theme->createPlatformMenuItem();
- else
- return QPlatformTheme::createPlatformMenuItem();
+ return QPlatformTheme::createPlatformMenuItem();
}
QPlatformMenu *QQuickProxyTheme::createPlatformMenu() const
{
if (m_theme)
return m_theme->createPlatformMenu();
- else
- return QPlatformTheme::createPlatformMenu();
+ return QPlatformTheme::createPlatformMenu();
}
QPlatformMenuBar *QQuickProxyTheme::createPlatformMenuBar() const
{
if (m_theme)
return m_theme->createPlatformMenuBar();
- else
- return QPlatformTheme::createPlatformMenuBar();
+ return QPlatformTheme::createPlatformMenuBar();
}
void QQuickProxyTheme::showPlatformMenuBar()
{
if (m_theme)
m_theme->showPlatformMenuBar();
- else
- QPlatformTheme::showPlatformMenuBar();
+ QPlatformTheme::showPlatformMenuBar();
}
bool QQuickProxyTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const
{
if (m_theme)
return m_theme->usePlatformNativeDialog(type);
- else
- return QPlatformTheme::usePlatformNativeDialog(type);
+ return QPlatformTheme::usePlatformNativeDialog(type);
}
QPlatformDialogHelper *QQuickProxyTheme::createPlatformDialogHelper(QPlatformTheme::DialogType type) const
{
if (m_theme)
return m_theme->createPlatformDialogHelper(type);
- else
- return QPlatformTheme::createPlatformDialogHelper(type);
+ return QPlatformTheme::createPlatformDialogHelper(type);
}
#ifndef QT_NO_SYSTEMTRAYICON
@@ -109,8 +105,7 @@ QPlatformSystemTrayIcon *QQuickProxyTheme::createPlatformSystemTrayIcon() const
{
if (m_theme)
return m_theme->createPlatformSystemTrayIcon();
- else
- return QPlatformTheme::createPlatformSystemTrayIcon();
+ return QPlatformTheme::createPlatformSystemTrayIcon();
}
#endif
@@ -118,64 +113,56 @@ const QPalette *QQuickProxyTheme::palette(QPlatformTheme::Palette type) const
{
if (m_theme)
return m_theme->palette(type);
- else
- return QPlatformTheme::palette(type);
+ return QPlatformTheme::palette(type);
}
const QFont *QQuickProxyTheme::font(QPlatformTheme::Font type) const
{
if (m_theme)
return m_theme->font(type);
- else
- return QPlatformTheme::font(type);
+ return QPlatformTheme::font(type);
}
QVariant QQuickProxyTheme::themeHint(QPlatformTheme::ThemeHint hint) const
{
if (m_theme)
return m_theme->themeHint(hint);
- else
- return QPlatformTheme::themeHint(hint);
+ return QPlatformTheme::themeHint(hint);
}
QPixmap QQuickProxyTheme::standardPixmap(QPlatformTheme::StandardPixmap sp, const QSizeF &size) const
{
if (m_theme)
return m_theme->standardPixmap(sp, size);
- else
- return QPlatformTheme::standardPixmap(sp, size);
+ return QPlatformTheme::standardPixmap(sp, size);
}
QPixmap QQuickProxyTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size, QPlatformTheme::IconOptions iconOptions) const
{
if (m_theme)
return m_theme->fileIconPixmap(fileInfo, size, iconOptions);
- else
- return QPlatformTheme::fileIconPixmap(fileInfo, size, iconOptions);
+ return QPlatformTheme::fileIconPixmap(fileInfo, size, iconOptions);
}
QIconEngine *QQuickProxyTheme::createIconEngine(const QString &iconName) const
{
if (m_theme)
return m_theme->createIconEngine(iconName);
- else
- return QPlatformTheme::createIconEngine(iconName);
+ return QPlatformTheme::createIconEngine(iconName);
}
QList<QKeySequence> QQuickProxyTheme::keyBindings(QKeySequence::StandardKey key) const
{
if (m_theme)
return m_theme->keyBindings(key);
- else
- return QPlatformTheme::keyBindings(key);
+ return QPlatformTheme::keyBindings(key);
}
QString QQuickProxyTheme::standardButtonText(int button) const
{
if (m_theme)
return m_theme->standardButtonText(button);
- else
- return QPlatformTheme::standardButtonText(button);
+ return QPlatformTheme::standardButtonText(button);
}
QT_END_NAMESPACE
diff --git a/src/controls/qquickproxytheme_p.h b/src/controls/qquickproxytheme_p.h
index 5f4b42b5..69446669 100644
--- a/src/controls/qquickproxytheme_p.h
+++ b/src/controls/qquickproxytheme_p.h
@@ -34,8 +34,8 @@
**
****************************************************************************/
-#ifndef QQUICKPROXYTHEME_H
-#define QQUICKPROXYTHEME_H
+#ifndef QQUICKPROXYTHEME_P_H
+#define QQUICKPROXYTHEME_P_H
//
// W A R N I N G
@@ -56,8 +56,7 @@ QT_BEGIN_NAMESPACE
class Q_QUICKCONTROLS_PRIVATE_EXPORT QQuickProxyTheme : public QPlatformTheme
{
public:
- QQuickProxyTheme(QPlatformTheme *theme);
-
+ explicit QQuickProxyTheme(QPlatformTheme *theme = nullptr);
~QQuickProxyTheme();
QPlatformTheme* theme() const;
@@ -96,4 +95,4 @@ private:
QT_END_NAMESPACE
-#endif // QQUICKPROXYTHEME_H
+#endif // QQUICKPROXYTHEME_P_H
diff --git a/src/imports/controls/material/qquickmaterialtheme.cpp b/src/imports/controls/material/qquickmaterialtheme.cpp
index 5c89d382..afe6bf65 100644
--- a/src/imports/controls/material/qquickmaterialtheme.cpp
+++ b/src/imports/controls/material/qquickmaterialtheme.cpp
@@ -67,10 +67,6 @@ QQuickMaterialTheme::QQuickMaterialTheme(QPlatformTheme *theme)
menuItemFont.setPixelSize(16);
}
-QQuickMaterialTheme::~QQuickMaterialTheme()
-{
-}
-
const QFont *QQuickMaterialTheme::font(QPlatformTheme::Font type) const
{
switch (type) {
diff --git a/src/imports/controls/material/qquickmaterialtheme_p.h b/src/imports/controls/material/qquickmaterialtheme_p.h
index 9fd74bcc..55533ee5 100644
--- a/src/imports/controls/material/qquickmaterialtheme_p.h
+++ b/src/imports/controls/material/qquickmaterialtheme_p.h
@@ -34,8 +34,8 @@
**
****************************************************************************/
-#ifndef QQUICKMATERIALTHEME_H
-#define QQUICKMATERIALTHEME_H
+#ifndef QQUICKMATERIALTHEME_P_H
+#define QQUICKMATERIALTHEME_P_H
//
// W A R N I N G
@@ -48,7 +48,6 @@
// We mean it.
//
-#include <QtGui/qpa/qplatformtheme.h>
#include <QtGui/qfont.h>
#include <QtQuickControls/private/qquickproxytheme_p.h>
@@ -57,9 +56,7 @@ QT_BEGIN_NAMESPACE
class QQuickMaterialTheme : public QQuickProxyTheme
{
public:
- QQuickMaterialTheme(QPlatformTheme *theme);
-
- ~QQuickMaterialTheme();
+ explicit QQuickMaterialTheme(QPlatformTheme *theme = nullptr);
const QFont *font(Font type = SystemFont) const override;
@@ -72,4 +69,4 @@ private:
QT_END_NAMESPACE
-#endif // QQUICKMATERIALTHEME_H
+#endif // QQUICKMATERIALTHEME_P_H
diff --git a/src/imports/controls/material/qtlabsmaterialstyleplugin.cpp b/src/imports/controls/material/qtlabsmaterialstyleplugin.cpp
index a42424ea..ee9940f2 100644
--- a/src/imports/controls/material/qtlabsmaterialstyleplugin.cpp
+++ b/src/imports/controls/material/qtlabsmaterialstyleplugin.cpp
@@ -93,13 +93,8 @@ void QtLabsMaterialStylePlugin::initializeEngine(QQmlEngine *engine, const char
{
Q_UNUSED(engine);
- if (QQuickStyle::name().compare(QLatin1String("material"), Qt::CaseInsensitive) == 0) {
- QPlatformTheme *old = QGuiApplicationPrivate::platform_theme;
- if (old) {
- QQuickProxyTheme *theme = new QQuickMaterialTheme(old);
- QGuiApplicationPrivate::platform_theme = theme;
- }
- }
+ if (QQuickStyle::name().compare(QLatin1String("material"), Qt::CaseInsensitive) == 0)
+ QGuiApplicationPrivate::platform_theme = new QQuickMaterialTheme;
QByteArray import = QByteArray(uri) + ".impl";
qmlRegisterType<QQuickMaterialProgressRing>(import, 1, 0, "ProgressRing");
diff --git a/src/imports/controls/universal/qquickuniversaltheme.cpp b/src/imports/controls/universal/qquickuniversaltheme.cpp
index 290faa5d..066d1194 100644
--- a/src/imports/controls/universal/qquickuniversaltheme.cpp
+++ b/src/imports/controls/universal/qquickuniversaltheme.cpp
@@ -59,10 +59,6 @@ QQuickUniversalTheme::QQuickUniversalTheme(QPlatformTheme *theme)
tabButtonFont.setWeight(QFont::Light);
}
-QQuickUniversalTheme::~QQuickUniversalTheme()
-{
-}
-
const QFont *QQuickUniversalTheme::font(QPlatformTheme::Font type) const
{
switch (type) {
diff --git a/src/imports/controls/universal/qquickuniversaltheme_p.h b/src/imports/controls/universal/qquickuniversaltheme_p.h
index 07e4905d..0435d46c 100644
--- a/src/imports/controls/universal/qquickuniversaltheme_p.h
+++ b/src/imports/controls/universal/qquickuniversaltheme_p.h
@@ -34,8 +34,8 @@
**
****************************************************************************/
-#ifndef QQUICKUNIVERSALTHEME_H
-#define QQUICKUNIVERSALTHEME_H
+#ifndef QQUICKUNIVERSALTHEME_P_H
+#define QQUICKUNIVERSALTHEME_P_H
//
// W A R N I N G
@@ -48,7 +48,6 @@
// We mean it.
//
-#include <QtGui/qpa/qplatformtheme.h>
#include <QtGui/qfont.h>
#include <QtQuickControls/private/qquickproxytheme_p.h>
@@ -57,9 +56,7 @@ QT_BEGIN_NAMESPACE
class QQuickUniversalTheme : public QQuickProxyTheme
{
public:
- QQuickUniversalTheme(QPlatformTheme *theme);
-
- ~QQuickUniversalTheme();
+ explicit QQuickUniversalTheme(QPlatformTheme *theme = nullptr);
const QFont *font(Font type = SystemFont) const override;
@@ -71,4 +68,4 @@ private:
QT_END_NAMESPACE
-#endif // QQUICKUNIVERSALTHEME_H
+#endif // QQUICKUNIVERSALTHEME_P_H
diff --git a/src/imports/controls/universal/qtlabsuniversalstyleplugin.cpp b/src/imports/controls/universal/qtlabsuniversalstyleplugin.cpp
index 15857f67..7fe69493 100644
--- a/src/imports/controls/universal/qtlabsuniversalstyleplugin.cpp
+++ b/src/imports/controls/universal/qtlabsuniversalstyleplugin.cpp
@@ -91,13 +91,8 @@ void QtLabsUniversalStylePlugin::registerTypes(const char *uri)
void QtLabsUniversalStylePlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
- if (QQuickStyle::name().compare(QLatin1String("universal"), Qt::CaseInsensitive) == 0) {
- QPlatformTheme *old = QGuiApplicationPrivate::platform_theme;
- if (old) {
- QQuickProxyTheme *theme = new QQuickUniversalTheme(old);
- QGuiApplicationPrivate::platform_theme = theme;
- }
- }
+ if (QQuickStyle::name().compare(QLatin1String("universal"), Qt::CaseInsensitive) == 0)
+ QGuiApplicationPrivate::platform_theme = new QQuickUniversalTheme;
engine->addImageProvider(QStringLiteral("universal"), new QQuickColorImageProvider(QStringLiteral(":/qt-project.org/imports/Qt/labs/controls/universal/images")));
diff --git a/tests/auto/applicationwindow/tst_applicationwindow.cpp b/tests/auto/applicationwindow/tst_applicationwindow.cpp
index 24c564ea..67525ef7 100644
--- a/tests/auto/applicationwindow/tst_applicationwindow.cpp
+++ b/tests/auto/applicationwindow/tst_applicationwindow.cpp
@@ -505,7 +505,6 @@ class TestTheme : public QQuickProxyTheme
public:
TestTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme), m_font("Courier")
{ QGuiApplicationPrivate::platform_theme = this; }
- ~TestTheme() { QGuiApplicationPrivate::platform_theme = theme(); }
const QFont *font(Font type = SystemFont) const override
{