Support Windows Phone 8.1 in WinRT QPA
- Unsupported code paths for WP8.0 are avoided, and new APIs are used where appropriate (virtual keyboard) - DirectWrite fonts are loaded on WP8.1 - Platform dialogs are used on WP8.1 Change-Id: I721006ac943ad4e248f0f1590ce247a03e40fbc0 Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>bb10
parent
9d3b169bda
commit
4c9eb38390
|
|
@ -44,13 +44,13 @@
|
|||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QFile>
|
||||
|
||||
#ifndef Q_OS_WINPHONE
|
||||
#ifdef QT_WINRT_USE_DWRITE
|
||||
#include <QtCore/QUuid>
|
||||
#include <QtGui/private/qfontengine_ft_p.h>
|
||||
#include <dwrite_1.h>
|
||||
#include <wrl.h>
|
||||
using namespace Microsoft::WRL;
|
||||
#endif // !Q_OS_WINPHONE
|
||||
#endif // QT_WINRT_USE_DWRITE
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ QString QWinRTFontDatabase::fontDir() const
|
|||
const QString applicationDirPath = QCoreApplication::applicationDirPath();
|
||||
fontDirectory = applicationDirPath + QLatin1String("/fonts");
|
||||
if (!QFile::exists(fontDirectory)) {
|
||||
#ifndef Q_OS_WINPHONE
|
||||
#ifdef QT_WINRT_USE_DWRITE
|
||||
if (m_fontFamilies.isEmpty())
|
||||
#endif
|
||||
qWarning("No fonts directory found in application package.");
|
||||
|
|
@ -72,7 +72,7 @@ QString QWinRTFontDatabase::fontDir() const
|
|||
return fontDirectory;
|
||||
}
|
||||
|
||||
#ifndef Q_OS_WINPHONE
|
||||
#ifdef QT_WINRT_USE_DWRITE
|
||||
|
||||
QWinRTFontDatabase::~QWinRTFontDatabase()
|
||||
{
|
||||
|
|
@ -398,6 +398,6 @@ void QWinRTFontDatabase::releaseHandle(void *handle)
|
|||
QBasicFontDatabase::releaseHandle(handle);
|
||||
}
|
||||
|
||||
#endif // !Q_OS_WINPHONE
|
||||
#endif // QT_WINRT_USE_DWRITE
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef Q_OS_WINPHONE
|
||||
#ifdef QT_WINRT_USE_DWRITE
|
||||
struct IDWriteFontFile;
|
||||
struct IDWriteFontFamily;
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ class QWinRTFontDatabase : public QBasicFontDatabase
|
|||
{
|
||||
public:
|
||||
QString fontDir() const;
|
||||
#ifndef Q_OS_WINPHONE
|
||||
#ifdef QT_WINRT_USE_DWRITE
|
||||
~QWinRTFontDatabase();
|
||||
QFont defaultFont() const Q_DECL_OVERRIDE;
|
||||
void populateFontDatabase() Q_DECL_OVERRIDE;
|
||||
|
|
@ -71,7 +71,7 @@ public:
|
|||
private:
|
||||
QHash<IDWriteFontFile *, FontDescription> m_fonts;
|
||||
QHash<QString, IDWriteFontFamily *> m_fontFamilies;
|
||||
#endif // !Q_OS_WINPHONE
|
||||
#endif // QT_WINRT_USE_DWRITE
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ using namespace ABI::Windows::Foundation;
|
|||
using namespace ABI::Windows::UI::ViewManagement;
|
||||
using namespace ABI::Windows::UI::Core;
|
||||
|
||||
#ifdef Q_OS_WINPHONE
|
||||
#if defined(Q_OS_WINPHONE) && _MSC_VER==1700
|
||||
#include <windows.phone.ui.core.h>
|
||||
using namespace ABI::Windows::Phone::UI::Core;
|
||||
#endif
|
||||
|
|
@ -148,22 +148,73 @@ void QWinRTInputContext::setKeyboardRect(const QRectF rect)
|
|||
|
||||
#ifdef Q_OS_WINPHONE
|
||||
|
||||
#if _MSC_VER>1700 // Windows Phone 8.1+
|
||||
static HRESULT getInputPane(ComPtr<IInputPane2> *inputPane2)
|
||||
{
|
||||
ComPtr<IInputPaneStatics> factory;
|
||||
HRESULT hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_InputPane).Get(),
|
||||
&factory);
|
||||
if (FAILED(hr)) {
|
||||
qErrnoWarning(hr, "Failed to get input pane factory.");
|
||||
return hr;
|
||||
}
|
||||
|
||||
ComPtr<IInputPane> inputPane;
|
||||
hr = factory->GetForCurrentView(&inputPane);
|
||||
if (FAILED(hr)) {
|
||||
qErrnoWarning(hr, "Failed to get input pane.");
|
||||
return hr;
|
||||
}
|
||||
|
||||
hr = inputPane.As(inputPane2);
|
||||
if (FAILED(hr)) {
|
||||
qErrnoWarning(hr, "Failed to get extended input pane.");
|
||||
return hr;
|
||||
}
|
||||
return hr;
|
||||
}
|
||||
#endif // _MSC_VER>1700
|
||||
|
||||
void QWinRTInputContext::showInputPanel()
|
||||
{
|
||||
#if _MSC_VER<=1700 // Windows Phone 8.0
|
||||
ICoreWindowKeyboardInput *input;
|
||||
if (SUCCEEDED(m_window->QueryInterface(IID_PPV_ARGS(&input)))) {
|
||||
input->put_IsKeyboardInputEnabled(true);
|
||||
input->Release();
|
||||
}
|
||||
#else // _MSC_VER<=1700
|
||||
ComPtr<IInputPane2> inputPane;
|
||||
HRESULT hr = getInputPane(&inputPane);
|
||||
if (FAILED(hr))
|
||||
return;
|
||||
|
||||
boolean success;
|
||||
hr = inputPane->TryShow(&success);
|
||||
if (FAILED(hr))
|
||||
qErrnoWarning(hr, "Failed to show input panel.");
|
||||
#endif // _MSC_VER>1700
|
||||
}
|
||||
|
||||
void QWinRTInputContext::hideInputPanel()
|
||||
{
|
||||
#if _MSC_VER<=1700 // Windows Phone 8.0
|
||||
ICoreWindowKeyboardInput *input;
|
||||
if (SUCCEEDED(m_window->QueryInterface(IID_PPV_ARGS(&input)))) {
|
||||
input->put_IsKeyboardInputEnabled(false);
|
||||
input->Release();
|
||||
}
|
||||
#else // _MSC_VER<=1700
|
||||
ComPtr<IInputPane2> inputPane;
|
||||
HRESULT hr = getInputPane(&inputPane);
|
||||
if (FAILED(hr))
|
||||
return;
|
||||
|
||||
boolean success;
|
||||
hr = inputPane->TryHide(&success);
|
||||
if (FAILED(hr))
|
||||
qErrnoWarning(hr, "Failed to hide input panel.");
|
||||
#endif // _MSC_VER>1700
|
||||
}
|
||||
|
||||
#else // Q_OS_WINPHONE
|
||||
|
|
|
|||
|
|
@ -50,25 +50,25 @@ QWinRTPlatformTheme::QWinRTPlatformTheme()
|
|||
|
||||
bool QWinRTPlatformTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const
|
||||
{
|
||||
#ifndef Q_OS_WINPHONE
|
||||
#if !(defined(Q_OS_WINPHONE) && _MSC_VER<=1700)
|
||||
if (type == QPlatformTheme::MessageDialog)
|
||||
return true;
|
||||
#endif // Q_OS_WINPHONE
|
||||
#endif // !(Q_OS_WINPHONE && _MSC_VER<=1700)
|
||||
return false;
|
||||
}
|
||||
|
||||
QPlatformDialogHelper *QWinRTPlatformTheme::createPlatformDialogHelper(QPlatformTheme::DialogType type) const
|
||||
{
|
||||
#ifndef Q_OS_WINPHONE
|
||||
#if !(defined(Q_OS_WINPHONE) && _MSC_VER<=1700)
|
||||
switch (type) {
|
||||
case QPlatformTheme::MessageDialog:
|
||||
return new QWinRTPlatformMessageDialogHelper();
|
||||
default:
|
||||
return QPlatformTheme::createPlatformDialogHelper(type);
|
||||
}
|
||||
#else
|
||||
#else // !(Q_OS_WINPHONE && _MSC_VER<=1700)
|
||||
return QPlatformTheme::createPlatformDialogHelper(type);
|
||||
#endif // Q_OS_WINPHONE
|
||||
#endif // Q_OS_WINPHONE && _MSC_VER<=1700
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ CONFIG -= precompile_header
|
|||
|
||||
# For Windows Phone 8 we have to deploy fonts together with the application as DirectWrite
|
||||
# is not supported here.
|
||||
# TODO: Add a condition/remove this block if Windows Phone 8.1 supports DirectWrite
|
||||
winphone {
|
||||
winphone:equals(WINSDK_VER, 8.0): {
|
||||
fonts.path = $$[QT_INSTALL_LIBS]/fonts
|
||||
fonts.files = $$QT_SOURCE_TREE/lib/fonts/DejaVu*.ttf
|
||||
INSTALLS += fonts
|
||||
|
|
@ -21,9 +20,10 @@ DEFINES *= QT_NO_CAST_FROM_ASCII __WRL_NO_DEFAULT_LIB__ GL_GLEXT_PROTOTYPES
|
|||
|
||||
LIBS += $$QMAKE_LIBS_CORE
|
||||
|
||||
!winphone {
|
||||
!if(winphone:equals(WINSDK_VER, 8.0)) {
|
||||
LIBS += -ldwrite
|
||||
INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/freetype/include
|
||||
DEFINES += QT_WINRT_USE_DWRITE
|
||||
}
|
||||
|
||||
SOURCES = \
|
||||
|
|
@ -70,7 +70,7 @@ fxc_blitvs.variable_out = HEADERS
|
|||
fxc_blitvs.CONFIG += target_predeps
|
||||
QMAKE_EXTRA_COMPILERS += fxc_blitps fxc_blitvs
|
||||
|
||||
winphone {
|
||||
winphone:equals(WINSDK_VER, 8.0): {
|
||||
SOURCES -= qwinrtplatformmessagedialoghelper.cpp
|
||||
HEADERS -= qwinrtplatformmessagedialoghelper.h
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue