Windows: Add dialog helpers for native dialogs.
Implement QPlatformDialogHelper for file dialogs based on IFileDialog. Add prototypical implementation of color dialogs. Change-Id: If3c7470be6c0b8fbf8cfea1b6638bda43afafea7 Reviewed-by: Oliver Wolff <oliver.wolff@nokia.com>
This commit is contained in:
parent
35f56b0cf9
commit
5a67cd2495
@ -61,6 +61,10 @@
|
||||
|
||||
#define CO_E_NOT_SUPPORTED _HRESULT_TYPEDEF_(0x80004021L)
|
||||
|
||||
#define IFMETHOD HRESULT STDMETHODCALLTYPE
|
||||
#define IFACEMETHODIMP STDMETHODIMP
|
||||
#define IFACEMETHODIMP_(type) STDMETHODIMP_(type)
|
||||
|
||||
typedef struct tagUPDATELAYEREDWINDOWINFO {
|
||||
DWORD cbSize;
|
||||
HDC hdcDst;
|
||||
|
@ -75,6 +75,7 @@ int QWindowsContext::verboseFonts = 0;
|
||||
int QWindowsContext::verboseGL = 0;
|
||||
int QWindowsContext::verboseOLE = 0;
|
||||
int QWindowsContext::verboseInputMethods = 0;
|
||||
int QWindowsContext::verboseDialogs = 0;
|
||||
|
||||
// Get verbosity of components from "foo:2,bar:3"
|
||||
static inline int componentVerbose(const char *v, const char *keyWord)
|
||||
@ -144,6 +145,8 @@ static inline bool useRTL_Extensions(QSysInfo::WinVersion ver)
|
||||
In addition, touch-related functions are available only from Windows onwards.
|
||||
These need to resolved dynamically for Q_CC_MSVC as well.
|
||||
|
||||
\sa QWindowsShell32DLL
|
||||
|
||||
\ingroup qt-lighthouse-win
|
||||
*/
|
||||
|
||||
@ -178,7 +181,30 @@ bool QWindowsUser32DLL::initTouch()
|
||||
return registerTouchWindow && getTouchInputInfo && getTouchInputInfo;
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QWindowsShell32DLL
|
||||
\brief Struct that contains dynamically resolved symbols of Shell32.dll.
|
||||
|
||||
The stub libraries shipped with the MinGW compiler miss some of the
|
||||
functions. They need to be retrieved dynamically.
|
||||
|
||||
\sa QWindowsUser32DLL
|
||||
|
||||
\ingroup qt-lighthouse-win
|
||||
*/
|
||||
|
||||
QWindowsShell32DLL::QWindowsShell32DLL() : sHCreateItemFromParsingName(0)
|
||||
{
|
||||
}
|
||||
|
||||
void QWindowsShell32DLL::init()
|
||||
{
|
||||
QSystemLibrary library(QStringLiteral("shell32"));
|
||||
sHCreateItemFromParsingName = (SHCreateItemFromParsingName)(library.resolve("SHCreateItemFromParsingName"));
|
||||
}
|
||||
|
||||
QWindowsUser32DLL QWindowsContext::user32dll;
|
||||
QWindowsShell32DLL QWindowsContext::shell32dll;
|
||||
|
||||
QWindowsContext *QWindowsContext::m_instance = 0;
|
||||
|
||||
@ -214,6 +240,7 @@ QWindowsContextPrivate::QWindowsContextPrivate() :
|
||||
m_oleInitializeResult(OleInitialize(NULL))
|
||||
{
|
||||
QWindowsContext::user32dll.init();
|
||||
QWindowsContext::shell32dll.init();
|
||||
|
||||
const QSysInfo::WinVersion ver = QSysInfo::windowsVersion();
|
||||
|
||||
@ -242,6 +269,7 @@ QWindowsContext::QWindowsContext() :
|
||||
QWindowsContext::verboseGL = componentVerbose(v, "gl");
|
||||
QWindowsContext::verboseOLE = componentVerbose(v, "ole");
|
||||
QWindowsContext::verboseInputMethods = componentVerbose(v, "im");
|
||||
QWindowsContext::verboseDialogs = componentVerbose(v, "dialogs");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,16 @@ struct QWindowsUser32DLL
|
||||
CloseTouchInputHandle closeTouchInputHandle;
|
||||
};
|
||||
|
||||
struct QWindowsShell32DLL
|
||||
{
|
||||
QWindowsShell32DLL();
|
||||
inline void init();
|
||||
|
||||
typedef HRESULT (WINAPI *SHCreateItemFromParsingName)(PCWSTR, IBindCtx *, const GUID&, void **);
|
||||
|
||||
SHCreateItemFromParsingName sHCreateItemFromParsingName;
|
||||
};
|
||||
|
||||
class QWindowsContext
|
||||
{
|
||||
Q_DISABLE_COPY(QWindowsContext)
|
||||
@ -107,6 +117,7 @@ public:
|
||||
static int verboseGL;
|
||||
static int verboseOLE;
|
||||
static int verboseInputMethods;
|
||||
static int verboseDialogs;
|
||||
|
||||
explicit QWindowsContext();
|
||||
~QWindowsContext();
|
||||
@ -153,6 +164,7 @@ public:
|
||||
QWindowsMimeConverter &mimeConverter() const;
|
||||
|
||||
static QWindowsUser32DLL user32dll;
|
||||
static QWindowsShell32DLL shell32dll;
|
||||
|
||||
static QByteArray comErrorString(HRESULT hr);
|
||||
|
||||
|
1343
src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
Normal file
1343
src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
Normal file
File diff suppressed because it is too large
Load Diff
93
src/plugins/platforms/windows/qwindowsdialoghelpers.h
Normal file
93
src/plugins/platforms/windows/qwindowsdialoghelpers.h
Normal file
@ -0,0 +1,93 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
||||
** All rights reserved.
|
||||
** Contact: Nokia Corporation (qt-info@nokia.com)
|
||||
**
|
||||
** This file is part of the plugins of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** GNU Lesser General Public License Usage
|
||||
** 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, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia 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.
|
||||
**
|
||||
** Other Usage
|
||||
** Alternatively, this file may be used in accordance with the terms and
|
||||
** conditions contained in a signed written agreement between you and Nokia.
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QWINDOWSDIALOGHELPER_H
|
||||
#define QWINDOWSDIALOGHELPER_H
|
||||
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
|
||||
#include <QtWidgets/qplatformdialoghelper_qpa.h>
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QFileDialog;
|
||||
class QWindowsNativeDialogBase;
|
||||
|
||||
namespace QWindowsDialogs
|
||||
{
|
||||
enum Type { UnknownType, ColorDialog, FontDialog, FileDialog };
|
||||
|
||||
Type dialogType(const QDialog *dialog);
|
||||
void eatMouseMove();
|
||||
} // namespace QWindowsDialogs
|
||||
|
||||
class QWindowsDialogHelperBase : public QPlatformDialogHelper
|
||||
{
|
||||
public:
|
||||
static bool useHelper(const QDialog *dialog);
|
||||
static QPlatformDialogHelper *create(QDialog *dialog);
|
||||
|
||||
virtual void platformNativeDialogModalHelp();
|
||||
virtual void _q_platformRunNativeAppModalPanel();
|
||||
virtual void deleteNativeDialog_sys();
|
||||
virtual bool setVisible_sys(bool visible);
|
||||
virtual QDialog::DialogCode dialogResultCode_sys();
|
||||
|
||||
virtual bool nonNativeDialog() const = 0;
|
||||
virtual bool supportsNonModalDialog() const { return true; }
|
||||
|
||||
protected:
|
||||
explicit QWindowsDialogHelperBase(QDialog *dialog);
|
||||
QWindowsNativeDialogBase *nativeDialog() const;
|
||||
|
||||
private:
|
||||
virtual QWindowsNativeDialogBase *createNativeDialog() = 0;
|
||||
inline QWindowsNativeDialogBase *ensureNativeDialog();
|
||||
|
||||
QDialog *m_dialog;
|
||||
QWindowsNativeDialogBase *m_nativeDialog;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_WIDGETS_LIB
|
||||
#endif // QWINDOWSDIALOGHELPER_H
|
@ -126,6 +126,7 @@ messageDebugEntries[] = {
|
||||
{WM_MOUSEACTIVATE,"WM_MOUSEACTIVATE", true},
|
||||
{WM_CHILDACTIVATE, "WM_CHILDACTIVATE", true},
|
||||
{WM_PARENTNOTIFY, "WM_PARENTNOTIFY", true},
|
||||
{WM_ENTERIDLE, "WM_ENTERIDLE", false},
|
||||
{WM_GETICON, "WM_GETICON", false},
|
||||
{WM_KEYDOWN, "WM_KEYDOWN", true},
|
||||
{WM_SYSKEYDOWN, "WM_SYSKEYDOWN", true},
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "qwindowsdrag.h"
|
||||
#include "qwindowsinputcontext.h"
|
||||
#include "qwindowsaccessibility.h"
|
||||
#include "qwindowsdialoghelpers.h"
|
||||
|
||||
#include <QtGui/QPlatformNativeInterface>
|
||||
#include <QtGui/QWindowSystemInterface>
|
||||
@ -321,4 +322,17 @@ QAbstractEventDispatcher * QWindowsIntegration::guiThreadEventDispatcher() const
|
||||
return d->m_eventDispatcher;
|
||||
}
|
||||
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
bool QWindowsIntegration::usePlatformNativeDialog(QDialog *dialog) const
|
||||
{
|
||||
return QWindowsDialogHelperBase::useHelper(dialog);
|
||||
}
|
||||
|
||||
QPlatformDialogHelper *QWindowsIntegration::createPlatformDialogHelper(QDialog *dialog) const
|
||||
{
|
||||
return QWindowsDialogHelperBase::create(dialog);
|
||||
}
|
||||
|
||||
#endif // QT_WIDGETS_LIB
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -71,6 +71,11 @@ public:
|
||||
virtual QPlatformFontDatabase *fontDatabase() const;
|
||||
virtual QVariant styleHint(StyleHint hint) const;
|
||||
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
virtual bool usePlatformNativeDialog(QDialog *dialog = 0) const;
|
||||
virtual QPlatformDialogHelper *createPlatformDialogHelper(QDialog *dialog = 0) const;
|
||||
#endif // QT_WIDGETS_LIB
|
||||
|
||||
static QWindowsIntegration *instance();
|
||||
|
||||
private:
|
||||
|
@ -69,6 +69,12 @@ HEADERS += \
|
||||
qwindowsinputcontext.h \
|
||||
qwindowsaccessibility.h
|
||||
|
||||
# Dialog helper: Should be used only if QtWidgets is built
|
||||
QT *= widgets
|
||||
HEADERS += qwindowsdialoghelpers.h
|
||||
SOURCES += qwindowsdialoghelpers.cpp
|
||||
LIBS += -lshlwapi -lShell32
|
||||
|
||||
contains(QT_CONFIG, freetype) {
|
||||
DEFINES *= QT_NO_FONTCONFIG
|
||||
DEFINES *= QT_COMPILES_IN_HARFBUZZ
|
||||
|
Loading…
x
Reference in New Issue
Block a user