From 7c279d779b32eb61987fc7d4f1143a1eaa1a1bde Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 7 Jul 2016 12:36:33 +0200 Subject: QWindowsTabletSupport: fix new[]/delete mismatch QScopedPointer deletes with delete, but a pointer returned from new[] needs to be deleted with delete[]. Fix by using QVarLengthArray instead of QScopedPointer(new TCHAR[]). Change-Id: I2f1f252379a9ac1ee919901b5efcec9cec31261e Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowstabletsupport.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp index 222551a86f..87f3eff409 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include @@ -227,7 +227,7 @@ QString QWindowsTabletSupport::description() const const unsigned size = m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_WINTABID, 0); if (!size) return QString(); - QScopedPointer winTabId(new TCHAR[size + 1]); + QVarLengthArray winTabId(size + 1); m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_WINTABID, winTabId.data()); WORD implementationVersion = 0; m_winTab32DLL.wTInfo(WTI_INTERFACE, IFC_IMPLVERSION, &implementationVersion); -- cgit v1.2.3 From 6bb0bc73c809d1defdcedc31c4c464a129d3de4d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 14 Jul 2016 09:35:50 +0200 Subject: QWindowsTheme: Fix the available file icon sizes Previously, QWindowsTheme had a hardcoded list of of available file icon sizes. As the sizes depend on the Windows display scale factor, this can lead to undesired scaling of icons. Maintain an array of the standard sizes against which the sizes are matched; refresh in display change. Task-number: QTBUG-54561 Change-Id: If36de2f30c8a230cc7bd8eeb4dfc9f201aeda5e4 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowscontext.cpp | 3 ++ src/plugins/platforms/windows/qwindowstheme.cpp | 49 +++++++++++++++++------ src/plugins/platforms/windows/qwindowstheme.h | 5 +++ 3 files changed, 45 insertions(+), 12 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 39054b6a64..b6118431d3 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -41,6 +41,7 @@ #include "qwindowsmime.h" #include "qwindowsinputcontext.h" #include "qwindowstabletsupport.h" +#include "qwindowstheme.h" #include #ifndef QT_NO_ACCESSIBILITY # include "accessible/qwindowsaccessibility.h" @@ -1007,6 +1008,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, #endif case QtWindows::DisplayChangedEvent: return d->m_screenManager.handleDisplayChange(wParam, lParam); + if (QWindowsTheme *t = QWindowsTheme::instance()) + t->displayChanged(); case QtWindows::SettingChangedEvent: return d->m_screenManager.handleScreenChanges(); default: diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index f673ce5c25..ce0c69f9ed 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -329,6 +329,7 @@ QWindowsTheme::QWindowsTheme() std::fill(m_fonts, m_fonts + NFonts, static_cast(0)); std::fill(m_palettes, m_palettes + NPalettes, static_cast(0)); refresh(); + refreshIconPixmapSizes(); } QWindowsTheme::~QWindowsTheme() @@ -394,16 +395,8 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const return QVariant(int(WindowsKeyboardScheme)); case UiEffects: return QVariant(uiEffects()); - case IconPixmapSizes: { - QList sizes; - sizes << 16 << 32; -#ifdef USE_IIMAGELIST - sizes << 48; // sHIL_EXTRALARGE - if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) - sizes << 256; // SHIL_JUMBO -#endif // USE_IIMAGELIST - return QVariant::fromValue(sizes); - } + case IconPixmapSizes: + return m_fileIconSizes; case DialogSnapToDefaultButton: return QVariant(booleanSystemParametersInfo(SPI_GETSNAPTODEFBUTTON, false)); case ContextMenuOnMouseRelease: @@ -473,6 +466,15 @@ void QWindowsTheme::refreshFonts() #endif // !Q_OS_WINCE } +enum FileIconSize { + // Standard icons obtainable via shGetFileInfo(), SHGFI_SMALLICON, SHGFI_LARGEICON + SmallFileIcon, LargeFileIcon, + // Larger icons obtainable via SHGetImageList() + ExtraLargeFileIcon, + JumboFileIcon, // Vista onwards + FileIconSizeCount +}; + bool QWindowsTheme::usePlatformNativeDialog(DialogType type) const { return QWindowsDialogs::useHelper(type); @@ -489,6 +491,27 @@ void QWindowsTheme::windowsThemeChanged(QWindow * window) QWindowSystemInterface::handleThemeChange(window); } +static int fileIconSizes[FileIconSizeCount]; + +void QWindowsTheme::refreshIconPixmapSizes() +{ + // Standard sizes: 16, 32, 48, 256 + fileIconSizes[SmallFileIcon] = GetSystemMetrics(SM_CXSMICON); // corresponds to SHGFI_SMALLICON); + fileIconSizes[LargeFileIcon] = GetSystemMetrics(SM_CXICON); // corresponds to SHGFI_LARGEICON + fileIconSizes[ExtraLargeFileIcon] = + fileIconSizes[LargeFileIcon] + fileIconSizes[LargeFileIcon] / 2; + fileIconSizes[JumboFileIcon] = 8 * fileIconSizes[LargeFileIcon]; // empirical, has not been observed to work + QList sizes; + sizes << fileIconSizes[SmallFileIcon] << fileIconSizes[LargeFileIcon]; +#ifdef USE_IIMAGELIST + sizes << fileIconSizes[ExtraLargeFileIcon]; // sHIL_EXTRALARGE + if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA) + sizes << fileIconSizes[JumboFileIcon]; // SHIL_JUMBO +#endif // USE_IIMAGELIST + qCDebug(lcQpaWindows) << __FUNCTION__ << sizes; + m_fileIconSizes = QVariant::fromValue(sizes); +} + // Defined in qpixmap_win.cpp Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon); @@ -706,10 +729,12 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s QPixmap pixmap; const QString filePath = QDir::toNativeSeparators(fileInfo.filePath()); const int width = int(size.width()); - const int iconSize = width > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON; + const int iconSize = width > fileIconSizes[SmallFileIcon] ? SHGFI_LARGEICON : SHGFI_SMALLICON; const int requestedImageListSize = #ifdef USE_IIMAGELIST - width > 48 ? sHIL_JUMBO : (width > 32 ? sHIL_EXTRALARGE : 0); + width > fileIconSizes[ExtraLargeFileIcon] + ? sHIL_JUMBO + : (width > fileIconSizes[LargeFileIcon] ? sHIL_EXTRALARGE : 0); #else 0; #endif // !USE_IIMAGELIST diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h index cacde98601..aafcf320aa 100644 --- a/src/plugins/platforms/windows/qwindowstheme.h +++ b/src/plugins/platforms/windows/qwindowstheme.h @@ -37,6 +37,8 @@ #include "qwindowsthreadpoolrunner.h" #include +#include + QT_BEGIN_NAMESPACE class QWindow; @@ -62,6 +64,7 @@ public: QPlatformTheme::IconOptions iconOptions = 0) const Q_DECL_OVERRIDE; void windowsThemeChanged(QWindow *window); + void displayChanged() { refreshIconPixmapSizes(); } static const char *name; @@ -71,11 +74,13 @@ private: void refreshPalettes(); void clearFonts(); void refreshFonts(); + void refreshIconPixmapSizes(); static QWindowsTheme *m_instance; QPalette *m_palettes[NPalettes]; QFont *m_fonts[NFonts]; mutable QWindowsThreadPoolRunner m_threadPoolRunner; + QVariant m_fileIconSizes; }; QT_END_NAMESPACE -- cgit v1.2.3 From 9a00ae8e24a03b25476cc6200bddf4c8fc510733 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 14 Jul 2016 15:00:23 +0200 Subject: Windows QPA: Add warning to setHasBorderInFullScreen() Emit a warning when the function is called before show() as it does not have any effect in that case. Amends change 69839e55c13000ee9bf8d8e9d74b70096a92ae51. Task-number: QTBUG-41309 Change-Id: I7c2bb21735d8e41d525c5e00213b0e278ae5c774 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 9c6cb53365..e4888d6b87 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2402,9 +2402,10 @@ void QWindowsWindow::aboutToMakeCurrent() void QWindowsWindow::setHasBorderInFullScreenStatic(QWindow *window, bool border) { - if (!window->handle()) - return; - static_cast(window->handle())->setHasBorderInFullScreen(border); + if (QPlatformWindow *handle = window->handle()) + static_cast(handle)->setHasBorderInFullScreen(border); + else + qWarning("%s invoked without window handle; call has no effect.", Q_FUNC_INFO); } void QWindowsWindow::setHasBorderInFullScreen(bool border) -- cgit v1.2.3