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>
This commit is contained in:
parent
4a1120a2f1
commit
bb5b25e40d
@ -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;
|
||||
}
|
||||
|
@ -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
|
138
src/plugins/platforms/winrt/qwinrttheme.cpp
Normal file
138
src/plugins/platforms/winrt/qwinrttheme.cpp
Normal file
@ -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
|
@ -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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user