summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2014-07-04 15:16:06 +0300
committerAndrew Knight <andrew.knight@digia.com>2014-07-10 21:37:05 +0200
commitbb5b25e40d7d886961b423f0c3757684e1f47032 (patch)
treebc5cc6a33da6ebe686ae79c0559f794481ee137e /src/plugins
parent4a1120a2f1959ca8bcb61062a2f7c33a46e57c59 (diff)
winrt: Clean up platform theme
- Drop "Platform" from class name for consistency - Move styleHint() into theme class for better code reuse - Use ComPtr and result checking - Remove obsolete WinRT ifdefs Change-Id: Id26bd75739a9665f61ee2e70eb3fb36747b75410 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/winrt/qwinrtintegration.cpp37
-rw-r--r--src/plugins/platforms/winrt/qwinrtplatformtheme.cpp76
-rw-r--r--src/plugins/platforms/winrt/qwinrttheme.cpp138
-rw-r--r--src/plugins/platforms/winrt/qwinrttheme.h (renamed from src/plugins/platforms/winrt/qwinrtplatformtheme.h)13
-rw-r--r--src/plugins/platforms/winrt/winrt.pro4
5 files changed, 151 insertions, 117 deletions
diff --git a/src/plugins/platforms/winrt/qwinrtintegration.cpp b/src/plugins/platforms/winrt/qwinrtintegration.cpp
index 806b8f99bb..53d52a430c 100644
--- a/src/plugins/platforms/winrt/qwinrtintegration.cpp
+++ b/src/plugins/platforms/winrt/qwinrtintegration.cpp
@@ -48,7 +48,7 @@
#include "qwinrtservices.h"
#include "qwinrteglcontext.h"
#include "qwinrtfontdatabase.h"
-#include "qwinrtplatformtheme.h"
+#include "qwinrttheme.h"
#include <QtGui/QOpenGLContext>
@@ -63,18 +63,6 @@ using namespace ABI::Windows::UI::Core;
using namespace ABI::Windows::UI::ViewManagement;
using namespace ABI::Windows::ApplicationModel::Core;
-static IUISettings *getSettings()
-{
- static IUISettings *settings = 0;
- if (!settings) {
- if (FAILED(RoActivateInstance(Wrappers::HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_UISettings).Get(),
- reinterpret_cast<IInspectable **>(&settings)))) {
- qWarning("Could not activate UISettings.");
- }
- }
- return settings;
-}
-
QT_BEGIN_NAMESPACE
QWinRTIntegration::QWinRTIntegration()
@@ -114,26 +102,7 @@ bool QWinRTIntegration::hasCapability(QPlatformIntegration::Capability cap) cons
QVariant QWinRTIntegration::styleHint(StyleHint hint) const
{
- switch (hint) {
- case CursorFlashTime:
- if (IUISettings *settings = getSettings()) {
- quint32 blinkRate;
- settings->get_CaretBlinkRate(&blinkRate);
- return blinkRate;
- }
- break;
- case MouseDoubleClickInterval:
- if (IUISettings *settings = getSettings()) {
- quint32 doubleClickTime;
- settings->get_DoubleClickTime(&doubleClickTime);
- return doubleClickTime;
- }
- case ShowIsFullScreen:
- return true;
- default:
- break;
- }
- return QPlatformIntegration::styleHint(hint);
+ return QWinRTTheme::styleHint(hint);
}
QPlatformWindow *QWinRTIntegration::createPlatformWindow(QWindow *window) const
@@ -181,7 +150,7 @@ QPlatformTheme *QWinRTIntegration::createPlatformTheme(const QString &
name) const
{
if (name == QLatin1String("winrt"))
- return new QWinRTPlatformTheme();
+ return new QWinRTTheme();
return 0;
}
diff --git a/src/plugins/platforms/winrt/qwinrtplatformtheme.cpp b/src/plugins/platforms/winrt/qwinrtplatformtheme.cpp
deleted file mode 100644
index d4034ec571..0000000000
--- a/src/plugins/platforms/winrt/qwinrtplatformtheme.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwinrtplatformtheme.h"
-#include "qwinrtplatformmessagedialoghelper.h"
-
-QT_BEGIN_NAMESPACE
-
-QWinRTPlatformTheme::QWinRTPlatformTheme()
-{
-}
-
-bool QWinRTPlatformTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const
-{
-#if !(defined(Q_OS_WINPHONE) && _MSC_VER<=1700)
- if (type == QPlatformTheme::MessageDialog)
- return true;
-#else
- Q_UNUSED(type)
-#endif // !(Q_OS_WINPHONE && _MSC_VER<=1700)
- return false;
-}
-
-QPlatformDialogHelper *QWinRTPlatformTheme::createPlatformDialogHelper(QPlatformTheme::DialogType type) const
-{
-#if !(defined(Q_OS_WINPHONE) && _MSC_VER<=1700)
- switch (type) {
- case QPlatformTheme::MessageDialog:
- return new QWinRTPlatformMessageDialogHelper();
- default:
- return QPlatformTheme::createPlatformDialogHelper(type);
- }
-#else // !(Q_OS_WINPHONE && _MSC_VER<=1700)
- return QPlatformTheme::createPlatformDialogHelper(type);
-#endif // Q_OS_WINPHONE && _MSC_VER<=1700
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp
new file mode 100644
index 0000000000..041c15fbf4
--- /dev/null
+++ b/src/plugins/platforms/winrt/qwinrttheme.cpp
@@ -0,0 +1,138 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwinrttheme.h"
+#include "qwinrtplatformmessagedialoghelper.h"
+
+#include <QtCore/qfunctions_winrt.h>
+
+#include <wrl.h>
+#include <windows.ui.viewmanagement.h>
+using namespace Microsoft::WRL;
+using namespace ABI::Windows::UI::ViewManagement;
+
+QT_BEGIN_NAMESPACE
+
+static IUISettings *uiSettings()
+{
+ static ComPtr<IUISettings> settings;
+ if (!settings) {
+ HRESULT hr;
+ hr = RoActivateInstance(Wrappers::HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_UISettings).Get(),
+ &settings);
+ Q_ASSERT_SUCCEEDED(hr);
+ }
+ return settings.Get();
+}
+
+QWinRTTheme::QWinRTTheme()
+{
+}
+
+bool QWinRTTheme::usePlatformNativeDialog(DialogType type) const
+{
+ if (type == MessageDialog)
+ return true;
+ return false;
+}
+
+QPlatformDialogHelper *QWinRTTheme::createPlatformDialogHelper(DialogType type) const
+{
+ switch (type) {
+ case MessageDialog:
+ return new QWinRTPlatformMessageDialogHelper;
+ default:
+ break;
+ }
+ return QPlatformTheme::createPlatformDialogHelper(type);
+}
+
+QVariant QWinRTTheme::styleHint(QPlatformIntegration::StyleHint hint)
+{
+ HRESULT hr;
+ switch (hint) {
+ case QPlatformIntegration::CursorFlashTime: {
+ quint32 blinkRate;
+ hr = uiSettings()->get_CaretBlinkRate(&blinkRate);
+ RETURN_IF_FAILED("Failed to get caret blink rate", return defaultThemeHint(CursorFlashTime));
+ return blinkRate;
+ }
+ case QPlatformIntegration::KeyboardInputInterval:
+ return defaultThemeHint(KeyboardInputInterval);
+ case QPlatformIntegration::MouseDoubleClickInterval: {
+ quint32 doubleClickTime;
+ hr = uiSettings()->get_DoubleClickTime(&doubleClickTime);
+ RETURN_IF_FAILED("Failed to get double click time", return defaultThemeHint(MouseDoubleClickInterval));
+ return doubleClickTime;
+ }
+ case QPlatformIntegration::StartDragDistance:
+ return defaultThemeHint(StartDragDistance);
+ case QPlatformIntegration::StartDragTime:
+ return defaultThemeHint(StartDragTime);
+ case QPlatformIntegration::KeyboardAutoRepeatRate:
+ return defaultThemeHint(KeyboardAutoRepeatRate);
+ case QPlatformIntegration::ShowIsFullScreen:
+ return true;
+ case QPlatformIntegration::PasswordMaskDelay:
+ return defaultThemeHint(PasswordMaskDelay);
+ case QPlatformIntegration::FontSmoothingGamma:
+ return qreal(1.7);
+ case QPlatformIntegration::StartDragVelocity:
+ return defaultThemeHint(StartDragVelocity);
+ case QPlatformIntegration::UseRtlExtensions:
+ return false;
+ case QPlatformIntegration::SynthesizeMouseFromTouchEvents:
+ return true;
+ case QPlatformIntegration::PasswordMaskCharacter:
+ return defaultThemeHint(PasswordMaskCharacter);
+ case QPlatformIntegration::SetFocusOnTouchRelease:
+ return false;
+ case QPlatformIntegration::ShowIsMaximized:
+ return false;
+ case MousePressAndHoldInterval:
+ return defaultThemeHint(MousePressAndHoldInterval);
+ default:
+ break;
+ }
+ return QVariant();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/winrt/qwinrtplatformtheme.h b/src/plugins/platforms/winrt/qwinrttheme.h
index f4a61982b2..95bb736cd3 100644
--- a/src/plugins/platforms/winrt/qwinrtplatformtheme.h
+++ b/src/plugins/platforms/winrt/qwinrttheme.h
@@ -39,22 +39,25 @@
**
****************************************************************************/
-#ifndef QWINRTPLATFORMTHEME_H
-#define QWINRTPLATFORMTHEME_H
+#ifndef QWINRTTHEME_H
+#define QWINRTTHEME_H
#include <qpa/qplatformtheme.h>
+#include <qpa/qplatformintegration.h>
QT_BEGIN_NAMESPACE
-class QWinRTPlatformTheme : public QPlatformTheme
+class QWinRTTheme : public QPlatformTheme
{
public:
- QWinRTPlatformTheme();
+ QWinRTTheme();
bool usePlatformNativeDialog(DialogType type) const;
QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const;
+
+ static QVariant styleHint(QPlatformIntegration::StyleHint hint);
};
QT_END_NAMESPACE
-#endif // QWINRTPLATFORMTHEME_H
+#endif // QWINRTTHEME_H
diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro
index 349cdf11c9..5460a7b18c 100644
--- a/src/plugins/platforms/winrt/winrt.pro
+++ b/src/plugins/platforms/winrt/winrt.pro
@@ -36,9 +36,9 @@ SOURCES = \
qwinrtinputcontext.cpp \
qwinrtintegration.cpp \
qwinrtplatformmessagedialoghelper.cpp \
- qwinrtplatformtheme.cpp \
qwinrtscreen.cpp \
qwinrtservices.cpp \
+ qwinrttheme.cpp \
qwinrtwindow.cpp
HEADERS = \
@@ -50,9 +50,9 @@ HEADERS = \
qwinrtinputcontext.h \
qwinrtintegration.h \
qwinrtplatformmessagedialoghelper.h \
- qwinrtplatformtheme.h \
qwinrtscreen.h \
qwinrtservices.h \
+ qwinrttheme.h \
qwinrtwindow.h
BLIT_INPUT = $$PWD/blit.hlsl