summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeinterface.h2
-rw-r--r--src/widgets/dialogs/qwizard_win.cpp50
-rw-r--r--src/widgets/dialogs/qwizard_win_p.h1
4 files changed, 43 insertions, 16 deletions
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
index 9691156403..6e58c55bbe 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
@@ -34,6 +34,7 @@
#include "qwindowsnativeinterface.h"
#include "qwindowswindow.h"
#include "qwindowscontext.h"
+#include "qwindowsfontdatabase.h"
#include "qwindowsopenglcontext.h"
#include "qwindowsopengltester.h"
#include "qwindowsintegration.h"
@@ -222,6 +223,11 @@ int QWindowsNativeInterface::registerMimeType(const QString &mimeType)
return QWindowsMime::registerMimeType(mimeType);
}
+QFont QWindowsNativeInterface::logFontToQFont(const void *logFont, int verticalDpi)
+{
+ return QWindowsFontDatabase::LOGFONT_to_QFont(*reinterpret_cast<const LOGFONT *>(logFont), verticalDpi);
+}
+
QFunctionPointer QWindowsNativeInterface::platformFunction(const QByteArray &function) const
{
if (function == QWindowsWindowFunctions::setTouchWindowTouchTypeIdentifier())
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.h b/src/plugins/platforms/windows/qwindowsnativeinterface.h
index be8418b769..97839ae1ae 100644
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.h
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.h
@@ -34,6 +34,7 @@
#ifndef QWINDOWSNATIVEINTERFACE_H
#define QWINDOWSNATIVEINTERFACE_H
+#include <QtGui/qfont.h>
#include <QtGui/qpa/qplatformnativeinterface.h>
QT_BEGIN_NAMESPACE
@@ -77,6 +78,7 @@ public:
Q_INVOKABLE void registerWindowsMime(void *mimeIn);
Q_INVOKABLE void unregisterWindowsMime(void *mime);
Q_INVOKABLE int registerMimeType(const QString &mimeType);
+ Q_INVOKABLE QFont logFontToQFont(const void *logFont, int verticalDpi);
bool asyncExpose() const;
void setAsyncExpose(bool value);
diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp
index 701fea1c03..a4b37f360b 100644
--- a/src/widgets/dialogs/qwizard_win.cpp
+++ b/src/widgets/dialogs/qwizard_win.cpp
@@ -361,6 +361,36 @@ bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type)
Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &);
+static LOGFONT getCaptionLogFont(HANDLE hTheme)
+{
+ LOGFONT result = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 } };
+
+ if (!hTheme || FAILED(pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &result))) {
+ NONCLIENTMETRICS ncm;
+ ncm.cbSize = sizeof(NONCLIENTMETRICS);
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, false);
+ result = ncm.lfMessageFont;
+ }
+ return result;
+}
+
+static bool getCaptionQFont(int dpi, QFont *result)
+{
+ if (!pOpenThemeData)
+ return false;
+ const HANDLE hTheme =
+ pOpenThemeData(QApplicationPrivate::getHWNDForWidget(QApplication::desktop()), L"WINDOW");
+ if (!hTheme)
+ return false;
+ // Call into QWindowsNativeInterface to convert the LOGFONT into a QFont.
+ const LOGFONT logFont = getCaptionLogFont(hTheme);
+ QPlatformNativeInterface *ni = QGuiApplication::platformNativeInterface();
+ return ni && QMetaObject::invokeMethod(ni, "logFontToQFont", Qt::DirectConnection,
+ Q_RETURN_ARG(QFont, *result),
+ Q_ARG(const void *, &logFont),
+ Q_ARG(int, dpi));
+}
+
void QVistaHelper::drawTitleBar(QPainter *painter)
{
Q_ASSERT(backButton_);
@@ -378,7 +408,9 @@ void QVistaHelper::drawTitleBar(QPainter *painter)
const int verticalCenter = (btnTop + btnHeight / 2) - 1;
const QString text = wizard->window()->windowTitle();
- const QFont font = QApplication::font("QMdiSubWindowTitleBar");
+ QFont font;
+ if (!isWindow || !getCaptionQFont(wizard->logicalDpiY() * wizard->devicePixelRatio(), &font))
+ font = QApplication::font("QMdiSubWindowTitleBar");
const QFontMetrics fontMetrics(font);
const QRect brect = fontMetrics.boundingRect(text);
int textHeight = brect.height();
@@ -649,19 +681,6 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event)
return false;
}
-HFONT QVistaHelper::getCaptionFont(HANDLE hTheme)
-{
- LOGFONT lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 } };
-
- if (!hTheme || FAILED(pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &lf))) {
- NONCLIENTMETRICS ncm;
- ncm.cbSize = sizeof(NONCLIENTMETRICS);
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, false);
- lf = ncm.lfMessageFont;
- }
- return CreateFontIndirect(&lf);
-}
-
// Return a HDC for the wizard along with the transformation if the
// wizard is a child window.
HDC QVistaHelper::backingStoreDC(const QWidget *wizard, QPoint *offset)
@@ -713,7 +732,8 @@ bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const Q
bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
// Set up the DC
- HFONT hCaptionFont = getCaptionFont(hTheme);
+ const LOGFONT captionLogFont = getCaptionLogFont(hTheme);
+ const HFONT hCaptionFont = CreateFontIndirect(&captionLogFont);
HBITMAP hOldBmp = (HBITMAP)SelectObject(dcMem, (HGDIOBJ) bmp);
HFONT hOldFont = (HFONT)SelectObject(dcMem, (HGDIOBJ) hCaptionFont);
diff --git a/src/widgets/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h
index 8c36472bee..84b795d506 100644
--- a/src/widgets/dialogs/qwizard_win_p.h
+++ b/src/widgets/dialogs/qwizard_win_p.h
@@ -105,7 +105,6 @@ public:
static HDC backingStoreDC(const QWidget *wizard, QPoint *offset);
private:
- static HFONT getCaptionFont(HANDLE hTheme);
HWND wizardHWND() const;
bool drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc);
static bool drawBlackRect(const QRect &rect, HDC hdc);