diff options
Diffstat (limited to 'src/plugins/platforms')
42 files changed, 224 insertions, 155 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp b/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp index ced35c4cfa..9218afa7f5 100644 --- a/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp +++ b/src/plugins/platforms/android/qandroidplatformdialoghelpers.cpp @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2018 The Qt Company Ltd. ** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org> ** Contact: https://www.qt.io/licensing/ ** @@ -117,6 +118,15 @@ bool QAndroidPlatformMessageDialogHelper::show(Qt::WindowFlags windowFlags void QAndroidPlatformMessageDialogHelper::addButtons(QSharedPointer<QMessageDialogOptions> opt, ButtonRole role) { + for (const QMessageDialogOptions::CustomButton &b : opt->customButtons()) { + if (b.role == role) { + QString label = b.label; + label.remove(QChar('&')); + m_javaMessageDialog.callMethod<void>("addButton", "(ILjava/lang/String;)V", b.id, + QJNIObjectPrivate::fromString(label).object()); + } + } + for (int i = QPlatformDialogHelper::FirstButton; i < QPlatformDialogHelper::LastButton; i<<=1) { StandardButton b = static_cast<StandardButton>(i); if (buttonRole(b) == role && (opt->standardButtons() & i)) { @@ -144,6 +154,12 @@ void QAndroidPlatformMessageDialogHelper::dialogResult(int buttonID) QPlatformDialogHelper::StandardButton standardButton = static_cast<QPlatformDialogHelper::StandardButton>(buttonID); QPlatformDialogHelper::ButtonRole role = QPlatformDialogHelper::buttonRole(standardButton); + if (buttonID > QPlatformDialogHelper::LastButton) { + const QMessageDialogOptions::CustomButton *custom = options()->customButton(buttonID); + Q_ASSERT(custom); + role = custom->role; + } + emit clicked(standardButton, role); } diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm index 60eb8cdf68..c1711e7cd4 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm @@ -225,6 +225,9 @@ QHash<QPlatformTheme::Palette, QPalette*> qt_mac_createRolePalettes() pal.setBrush(QPalette::Active, QPalette::Base, qt_mac_toQColor([NSColor textBackgroundColor])); pal.setBrush(QPalette::Disabled, QPalette::Base, pal.brush(QPalette::Active, QPalette::Base)); + } else if (mac_widget_colors[i].paletteRole == QPlatformTheme::LabelPalette) { + qc = qt_mac_toQColor([NSColor labelColor]); + pal.setBrush(QPalette::Inactive, QPalette::ToolTipText, qc); } palettes.insert(mac_widget_colors[i].paletteRole, &pal); } diff --git a/src/plugins/platforms/wasm/qwasmcompositor.cpp b/src/plugins/platforms/wasm/qwasmcompositor.cpp index f3ea013325..3dc6b7d2f3 100644 --- a/src/plugins/platforms/wasm/qwasmcompositor.cpp +++ b/src/plugins/platforms/wasm/qwasmcompositor.cpp @@ -642,7 +642,7 @@ void QWasmCompositor::drawShadePanel(QWasmTitleBarOptions options, QPainter *pai void QWasmCompositor::drawWindow(QOpenGLTextureBlitter *blitter, QWasmScreen *screen, QWasmWindow *window) { - if (window->window()->type() != Qt::Popup) + if (window->window()->type() != Qt::Popup && !(window->m_windowState & Qt::WindowFullScreen)) drawWindowDecorations(blitter, screen, window); drawWindowContent(blitter, screen, window); } diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index 6545eda4e3..95bedf701c 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -362,13 +362,15 @@ void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEven if (mouseEvent->button == 0) { pressedWindow = window2; buttonEventType = QEvent::MouseButtonPress; - if (htmlWindow && window2->flags().testFlag(Qt::WindowTitleHint) && htmlWindow->isPointOnTitle(point)) - draggedWindow = window2; - else if (htmlWindow && htmlWindow->isPointOnResizeRegion(point)) { - draggedWindow = window2; - resizeMode = htmlWindow->resizeModeAtPoint(point); - resizePoint = point; - resizeStartRect = window2->geometry(); + if (!(htmlWindow->m_windowState & Qt::WindowFullScreen) && !(htmlWindow->m_windowState & Qt::WindowMaximized)) { + if (htmlWindow && window2->flags().testFlag(Qt::WindowTitleHint) && htmlWindow->isPointOnTitle(point)) + draggedWindow = window2; + else if (htmlWindow && htmlWindow->isPointOnResizeRegion(point)) { + draggedWindow = window2; + resizeMode = htmlWindow->resizeModeAtPoint(point); + resizePoint = point; + resizeStartRect = window2->geometry(); + } } } @@ -399,14 +401,16 @@ void QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEven case 8://move //drag event { buttonEventType = QEvent::MouseMove; - if (resizeMode == QWasmWindow::ResizeNone && draggedWindow) { - draggedWindow->setX(draggedWindow->x() + mouseEvent->movementX); - draggedWindow->setY(draggedWindow->y() + mouseEvent->movementY); - } + if (!(htmlWindow->m_windowState & Qt::WindowFullScreen) && !(htmlWindow->m_windowState & Qt::WindowMaximized)) { + if (resizeMode == QWasmWindow::ResizeNone && draggedWindow) { + draggedWindow->setX(draggedWindow->x() + mouseEvent->movementX); + draggedWindow->setY(draggedWindow->y() + mouseEvent->movementY); + } - if (resizeMode != QWasmWindow::ResizeNone) { - QPoint delta = QPoint(mouseEvent->canvasX, mouseEvent->canvasY) - resizePoint; - resizeWindow(draggedWindow, resizeMode, resizeStartRect, delta); + if (resizeMode != QWasmWindow::ResizeNone && !(htmlWindow->m_windowState & Qt::WindowFullScreen)) { + QPoint delta = QPoint(mouseEvent->canvasX, mouseEvent->canvasY) - resizePoint; + resizeWindow(draggedWindow, resizeMode, resizeStartRect, delta); + } } break; } diff --git a/src/plugins/platforms/wasm/qwasmwindow.cpp b/src/plugins/platforms/wasm/qwasmwindow.cpp index 0489813929..c4167be71e 100644 --- a/src/plugins/platforms/wasm/qwasmwindow.cpp +++ b/src/plugins/platforms/wasm/qwasmwindow.cpp @@ -83,8 +83,6 @@ void QWasmWindow::initialize() setWindowState(window()->windowStates()); setWindowFlags(window()->flags()); setWindowTitle(window()->title()); - m_hasTitle = window()->flags().testFlag(Qt::WindowTitleHint) && m_needsCompositor; - if (window()->isTopLevel()) setWindowIcon(window()->icon()); m_normalGeometry = rect; @@ -135,8 +133,8 @@ void QWasmWindow::setVisible(bool visible) QMargins QWasmWindow::frameMargins() const { - int border = m_hasTitle ? 4. * (qreal(qt_defaultDpiX()) / 96.0) : 0; - int titleBarHeight = m_hasTitle ? titleHeight() : 0; + int border = hasTitleBar() ? 4. * (qreal(qt_defaultDpiX()) / 96.0) : 0; + int titleBarHeight = hasTitleBar() ? titleHeight() : 0; QMargins margins; margins.setLeft(border); @@ -177,7 +175,7 @@ void QWasmWindow::injectMousePressed(const QPoint &local, const QPoint &global, Q_UNUSED(local); Q_UNUSED(mods); - if (!m_hasTitle || button != Qt::LeftButton) + if (!hasTitleBar() || button != Qt::LeftButton) return; if (maxButtonRect().contains(global)) @@ -198,7 +196,7 @@ void QWasmWindow::injectMouseReleased(const QPoint &local, const QPoint &global, Q_UNUSED(local); Q_UNUSED(mods); - if (!m_hasTitle || button != Qt::LeftButton) + if (!hasTitleBar() || button != Qt::LeftButton) return; if (closeButtonRect().contains(global) && m_activeControl == QWasmCompositor::SC_TitleBarCloseButton) @@ -395,4 +393,9 @@ void QWasmWindow::requestUpdate() QPlatformWindow::requestUpdate(); } +bool QWasmWindow::hasTitleBar() const +{ + return !(m_windowState & Qt::WindowFullScreen) && (window()->flags().testFlag(Qt::WindowTitleHint) && m_needsCompositor); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/wasm/qwasmwindow.h b/src/plugins/platforms/wasm/qwasmwindow.h index a0c463e796..cbbce99aeb 100644 --- a/src/plugins/platforms/wasm/qwasmwindow.h +++ b/src/plugins/platforms/wasm/qwasmwindow.h @@ -105,6 +105,7 @@ public: protected: void invalidate(); + bool hasTitleBar() const; protected: friend class QWasmScreen; @@ -119,6 +120,8 @@ protected: WId m_winid = 0; bool m_hasTitle = false; bool m_needsCompositor = false; + friend class QWasmCompositor; + friend class QWasmEventTranslator; }; QT_END_NAMESPACE #endif // QWASMWINDOW_H diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp index 53f329422c..8b386da9f7 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.cpp +++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp @@ -50,6 +50,7 @@ #include <QtCore/qdebug.h> #include <QtCore/qmimedata.h> #include <QtCore/qstringlist.h> +#include <QtCore/qthread.h> #include <QtCore/qvariant.h> #include <QtCore/qurl.h> @@ -318,7 +319,15 @@ void QWindowsClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode) m_data = new QWindowsOleDataObject(mimeData); } - const HRESULT src = OleSetClipboard(m_data); + HRESULT src = S_FALSE; + int attempts = 0; + for (; attempts < 3; ++attempts) { + src = OleSetClipboard(m_data); + if (src != CLIPBRD_E_CANT_OPEN || QWindowsContext::isSessionLocked()) + break; + QThread::msleep(100); + } + if (src != S_OK) { QString mimeDataFormats = mimeData ? mimeData->formats().join(QLatin1String(", ")) : QString(QStringLiteral("NULL")); diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 373758b49e..9bce72d853 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -86,6 +86,7 @@ #include <windowsx.h> #include <comdef.h> #include <dbt.h> +#include <wtsapi32.h> QT_BEGIN_NAMESPACE @@ -754,6 +755,37 @@ QWindowsWindow *QWindowsContext::findPlatformWindowAt(HWND parent, return result; } +bool QWindowsContext::isSessionLocked() +{ + bool result = false; + const DWORD sessionId = WTSGetActiveConsoleSessionId(); + if (sessionId != 0xFFFFFFFF) { + LPTSTR buffer = nullptr; + DWORD size = 0; +#if !defined(Q_CC_MINGW) + if (WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, sessionId, + WTSSessionInfoEx, &buffer, &size) == TRUE + && size > 0) { + const WTSINFOEXW *info = reinterpret_cast<WTSINFOEXW *>(buffer); + result = info->Level == 1 && info->Data.WTSInfoExLevel1.SessionFlags == WTS_SESSIONSTATE_LOCK; + WTSFreeMemory(buffer); + } +#else // MinGW as of 7.3 does not have WTSINFOEXW in wtsapi32.h + // Retrieve the flags which are at offset 16 due to padding for 32/64bit alike. + if (WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, sessionId, + WTS_INFO_CLASS(25), &buffer, &size) == TRUE + && size >= 20) { + const DWORD *p = reinterpret_cast<DWORD *>(buffer); + const DWORD level = *p; + const DWORD sessionFlags = *(p + 4); + result = level == 1 && sessionFlags == 1; + WTSFreeMemory(buffer); + } +#endif // Q_CC_MINGW + } + return result; +} + QWindowsMimeConverter &QWindowsContext::mimeConverter() const { return d->m_mimeConverter; diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h index 622c729a10..19e9c26130 100644 --- a/src/plugins/platforms/windows/qwindowscontext.h +++ b/src/plugins/platforms/windows/qwindowscontext.h @@ -224,6 +224,8 @@ public: bool useRTLExtensions() const; QList<int> possibleKeys(const QKeyEvent *e) const; + static bool isSessionLocked(); + QWindowsMimeConverter &mimeConverter() const; QWindowsScreenManager &screenManager(); QWindowsTabletSupport *tabletSupport() const; diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp index 825602e7dc..4f669a5509 100644 --- a/src/plugins/platforms/windows/qwindowscursor.cpp +++ b/src/plugins/platforms/windows/qwindowscursor.cpp @@ -660,18 +660,18 @@ QPoint QWindowsCursor::mousePosition() return QPoint(p.x, p.y); } -QWindowsCursor::CursorState QWindowsCursor::cursorState() +QWindowsCursor::State QWindowsCursor::cursorState() { enum { cursorShowing = 0x1, cursorSuppressed = 0x2 }; // Windows 8: CURSOR_SUPPRESSED CURSORINFO cursorInfo; cursorInfo.cbSize = sizeof(CURSORINFO); if (GetCursorInfo(&cursorInfo)) { - if (cursorInfo.flags & CursorShowing) - return CursorShowing; + if (cursorInfo.flags & cursorShowing) + return State::Showing; if (cursorInfo.flags & cursorSuppressed) - return CursorSuppressed; + return State::Suppressed; } - return CursorHidden; + return State::Hidden; } QPoint QWindowsCursor::pos() const diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h index 1816732594..8495b51a5a 100644 --- a/src/plugins/platforms/windows/qwindowscursor.h +++ b/src/plugins/platforms/windows/qwindowscursor.h @@ -89,10 +89,10 @@ typedef QSharedPointer<CursorHandle> CursorHandlePtr; class QWindowsCursor : public QPlatformCursor { public: - enum CursorState { - CursorShowing, - CursorHidden, - CursorSuppressed // Cursor suppressed by touch interaction (Windows 8). + enum class State { + Showing, + Hidden, + Suppressed // Cursor suppressed by touch interaction (Windows 8). }; struct PixmapCursor { @@ -119,7 +119,7 @@ public: static HCURSOR createCursorFromShape(Qt::CursorShape cursorShape, const QPlatformScreen *screen = nullptr); static QPoint mousePosition(); - static CursorState cursorState(); + static State cursorState(); CursorHandlePtr standardWindowCursor(Qt::CursorShape s = Qt::ArrowCursor); CursorHandlePtr pixmapWindowCursor(const QCursor &c); diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp index 8d4e4dc611..b7d225cb00 100644 --- a/src/plugins/platforms/windows/qwindowsdrag.cpp +++ b/src/plugins/platforms/windows/qwindowsdrag.cpp @@ -260,7 +260,7 @@ private: }; QWindowsOleDropSource::QWindowsOleDropSource(QWindowsDrag *drag) - : m_mode(QWindowsCursor::cursorState() != QWindowsCursor::CursorSuppressed ? MouseDrag : TouchDrag) + : m_mode(QWindowsCursor::cursorState() != QWindowsCursor::State::Suppressed ? MouseDrag : TouchDrag) , m_drag(drag) , m_windowUnderMouse(QWindowsContext::instance()->windowUnderMouse()) , m_currentButtons(Qt::NoButton) @@ -455,7 +455,7 @@ QWindowsOleDropSource::GiveFeedback(DWORD dwEffect) break; case TouchDrag: // "Touch drag" with an unsuppressed cursor may happen with RDP (see createCursors()) - if (QWindowsCursor::cursorState() != QWindowsCursor::CursorSuppressed) + if (QWindowsCursor::cursorState() != QWindowsCursor::State::Suppressed) SetCursor(nullptr); if (!m_touchDragWindow) m_touchDragWindow = new QWindowsDragCursorWindow; diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 7d621126b9..9e03d09607 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -393,7 +393,7 @@ QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate() switch (requestedRenderer) { case QWindowsOpenGLTester::DesktopGl: if (QWindowsStaticOpenGLContext *glCtx = QOpenGLStaticContext::create()) { - if ((QWindowsOpenGLTester::supportedRenderers() & QWindowsOpenGLTester::DisableRotationFlag) + if ((QWindowsOpenGLTester::supportedRenderers(requestedRenderer) & QWindowsOpenGLTester::DisableRotationFlag) && !QWindowsScreen::setOrientationPreference(Qt::LandscapeOrientation)) { qCWarning(lcQpaGl, "Unable to disable rotation."); } @@ -407,19 +407,19 @@ QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate() case QWindowsOpenGLTester::AngleRendererD3d11Warp: return QWindowsEGLStaticContext::create(requestedRenderer); case QWindowsOpenGLTester::Gles: - return QWindowsEGLStaticContext::create(QWindowsOpenGLTester::supportedGlesRenderers()); + return QWindowsEGLStaticContext::create(requestedRenderer); case QWindowsOpenGLTester::SoftwareRasterizer: if (QWindowsStaticOpenGLContext *swCtx = QOpenGLStaticContext::create(true)) return swCtx; qCWarning(lcQpaGl, "Software OpenGL failed. Falling back to system OpenGL."); - if (QWindowsOpenGLTester::supportedRenderers() & QWindowsOpenGLTester::DesktopGl) + if (QWindowsOpenGLTester::supportedRenderers(requestedRenderer) & QWindowsOpenGLTester::DesktopGl) return QOpenGLStaticContext::create(); return nullptr; default: break; } - const QWindowsOpenGLTester::Renderers supportedRenderers = QWindowsOpenGLTester::supportedRenderers(); + const QWindowsOpenGLTester::Renderers supportedRenderers = QWindowsOpenGLTester::supportedRenderers(requestedRenderer); if (supportedRenderers.testFlag(QWindowsOpenGLTester::DisableProgramCacheFlag) && !QCoreApplication::testAttribute(Qt::AA_DisableShaderDiskCache)) { QCoreApplication::setAttribute(Qt::AA_DisableShaderDiskCache); @@ -441,7 +441,7 @@ QWindowsStaticOpenGLContext *QWindowsStaticOpenGLContext::doCreate() #elif defined(QT_OPENGL_ES_2) QWindowsOpenGLTester::Renderers glesRenderers = QWindowsOpenGLTester::requestedGlesRenderer(); if (glesRenderers == QWindowsOpenGLTester::InvalidRenderer) - glesRenderers = QWindowsOpenGLTester::supportedGlesRenderers(); + glesRenderers = QWindowsOpenGLTester::supportedRenderers(QWindowsOpenGLTester::AngleRendererD3d11); return QWindowsEGLStaticContext::create(glesRenderers); #elif !defined(QT_NO_OPENGL) return QOpenGLStaticContext::create(); diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 1209b6c4b4..9e6101b758 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -877,10 +877,26 @@ bool QWindowsKeyMapper::translateKeyEvent(QWindow *widget, HWND hwnd, bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, const MSG &msg) { #if defined(WM_APPCOMMAND) + const int cmd = GET_APPCOMMAND_LPARAM(msg.lParam); // QTBUG-57198, do not send mouse-synthesized commands as key events in addition - if (GET_DEVICE_LPARAM(msg.lParam) == FAPPCOMMAND_MOUSE) + switch (GET_DEVICE_LPARAM(msg.lParam)) { + case FAPPCOMMAND_MOUSE: return false; - const int cmd = GET_APPCOMMAND_LPARAM(msg.lParam); + case FAPPCOMMAND_KEY: + // QTBUG-62838, swallow WM_KEYDOWN, WM_KEYUP for commands that are + // reflected in VK(s) like VK_MEDIA_NEXT_TRACK. Don't do that for + // APPCOMMAND_BROWSER_HOME as that one does not trigger two events + if (cmd != APPCOMMAND_BROWSER_HOME) { + MSG peekedMsg; + if (PeekMessage(&peekedMsg, msg.hwnd, 0, 0, PM_NOREMOVE) + && peekedMsg.message == WM_KEYDOWN) { + PeekMessage(&peekedMsg, msg.hwnd, 0, 0, PM_REMOVE); + PeekMessage(&peekedMsg, msg.hwnd, 0, 0, PM_REMOVE); + } + } + break; + } + const int dwKeys = GET_KEYSTATE_LPARAM(msg.lParam); int state = 0; state |= (dwKeys & MK_SHIFT ? int(Qt::ShiftModifier) : 0); diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index 9a630aff4f..3efccf0f32 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -247,11 +247,12 @@ typedef QHash<QOpenGLConfig::Gpu, QWindowsOpenGLTester::Renderers> SupportedRend Q_GLOBAL_STATIC(SupportedRenderersCache, supportedRenderersCache) #endif -QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(const GpuDescription &gpu, bool glesOnly) +QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(const GpuDescription &gpu, + Renderer requested) { - Q_UNUSED(gpu) - Q_UNUSED(glesOnly) #if defined(QT_NO_OPENGL) + Q_UNUSED(gpu) + Q_UNUSED(requested) return 0; #else QOpenGLConfig::Gpu qgpu = QOpenGLConfig::Gpu::fromDevice(gpu.vendorId, gpu.deviceId, gpu.driverVersion, gpu.description); @@ -265,8 +266,11 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(c | QWindowsOpenGLTester::AngleRendererD3d11Warp | QWindowsOpenGLTester::SoftwareRasterizer); - if (!glesOnly && testDesktopGL()) - result |= QWindowsOpenGLTester::DesktopGl; + // Don't test for GL if explicitly requested or GLES only is requested + if (requested == DesktopGl + || ((requested & GlesMask) == 0 && testDesktopGL())) { + result |= QWindowsOpenGLTester::DesktopGl; + } const char bugListFileVar[] = "QT_OPENGL_BUGLIST"; QString buglistFileName = QStringLiteral(":/qt-project.org/windows/openglblacklists/default.json"); @@ -310,19 +314,11 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(c #endif // !QT_NO_OPENGL } -QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedGlesRenderers() -{ - const GpuDescription gpu = GpuDescription::detect(); - const QWindowsOpenGLTester::Renderers result = detectSupportedRenderers(gpu, true); - qCDebug(lcQpaGl) << __FUNCTION__ << gpu << "renderer: " << result; - return result; -} - -QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedRenderers() +QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedRenderers(Renderer requested) { const GpuDescription gpu = GpuDescription::detect(); - const QWindowsOpenGLTester::Renderers result = detectSupportedRenderers(gpu, false); - qCDebug(lcQpaGl) << __FUNCTION__ << gpu << "renderer: " << result; + const QWindowsOpenGLTester::Renderers result = detectSupportedRenderers(gpu, requested); + qCDebug(lcQpaGl) << __FUNCTION__ << gpu << requested << "renderer: " << result; return result; } diff --git a/src/plugins/platforms/windows/qwindowsopengltester.h b/src/plugins/platforms/windows/qwindowsopengltester.h index bec87c1f86..08628c2586 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.h +++ b/src/plugins/platforms/windows/qwindowsopengltester.h @@ -91,11 +91,10 @@ public: static Renderer requestedGlesRenderer(); static Renderer requestedRenderer(); - static Renderers supportedGlesRenderers(); - static Renderers supportedRenderers(); + static QWindowsOpenGLTester::Renderers supportedRenderers(Renderer requested); private: - static QWindowsOpenGLTester::Renderers detectSupportedRenderers(const GpuDescription &gpu, bool glesOnly); + static Renderers detectSupportedRenderers(const GpuDescription &gpu, Renderer requested); static bool testDesktopGL(); }; diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.h b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.h index 11684de721..325d5b3de4 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.h +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.h @@ -86,7 +86,7 @@ public: HRESULT STDMETHODCALLTYPE GetRuntimeId(SAFEARRAY **pRetVal) override; HRESULT STDMETHODCALLTYPE get_BoundingRectangle(UiaRect *pRetVal) override; HRESULT STDMETHODCALLTYPE GetEmbeddedFragmentRoots(SAFEARRAY **pRetVal) override; - HRESULT STDMETHODCALLTYPE SetFocus(); + HRESULT STDMETHODCALLTYPE SetFocus() override; HRESULT STDMETHODCALLTYPE get_FragmentRoot(IRawElementProviderFragmentRoot **pRetVal) override; // IRawElementProviderFragmentRoot methods diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri index c1d4e907d9..db06a6a2a3 100644 --- a/src/plugins/platforms/windows/windows.pri +++ b/src/plugins/platforms/windows/windows.pri @@ -7,7 +7,7 @@ qtConfig(opengl):!qtConfig(opengles2):!qtConfig(dynamicgl): LIBS *= -lopengl32 mingw: LIBS *= -luuid # For the dialog helpers: -LIBS += -lshlwapi -lshell32 -ladvapi32 +LIBS += -lshlwapi -lshell32 -ladvapi32 -lwtsapi32 DEFINES *= QT_NO_CAST_FROM_ASCII QT_NO_FOREACH diff --git a/src/plugins/platforms/winrt/main.cpp b/src/plugins/platforms/winrt/main.cpp index 222287b3ef..a37bd1e3d8 100644 --- a/src/plugins/platforms/winrt/main.cpp +++ b/src/plugins/platforms/winrt/main.cpp @@ -58,7 +58,7 @@ QPlatformIntegration *QWinRTIntegrationPlugin::create(const QString& system, con if (!system.compare(QLatin1String("winrt"), Qt::CaseInsensitive)) return QWinRTIntegration::create(); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/winrt/qwinrtbackingstore.h b/src/plugins/platforms/winrt/qwinrtbackingstore.h index 51fa13845e..b62d340b82 100644 --- a/src/plugins/platforms/winrt/qwinrtbackingstore.h +++ b/src/plugins/platforms/winrt/qwinrtbackingstore.h @@ -54,7 +54,7 @@ class QWinRTBackingStore : public QPlatformBackingStore { public: explicit QWinRTBackingStore(QWindow *window); - ~QWinRTBackingStore(); + ~QWinRTBackingStore() override; QPaintDevice *paintDevice() override; void beginPaint(const QRegion &) override; void endPaint() override; diff --git a/src/plugins/platforms/winrt/qwinrtcanvas.cpp b/src/plugins/platforms/winrt/qwinrtcanvas.cpp index ad77d811e6..dd6b52d9cd 100644 --- a/src/plugins/platforms/winrt/qwinrtcanvas.cpp +++ b/src/plugins/platforms/winrt/qwinrtcanvas.cpp @@ -70,10 +70,6 @@ QWinRTCanvas::QWinRTCanvas(const std::function<QWindow*()> &delegateWindow) delegate = delegateWindow; } -QWinRTCanvas::~QWinRTCanvas() -{ -} - HRESULT STDMETHODCALLTYPE QWinRTCanvas::QueryInterface(REFIID iid, LPVOID *iface) { if (!iface) diff --git a/src/plugins/platforms/winrt/qwinrtcanvas.h b/src/plugins/platforms/winrt/qwinrtcanvas.h index 68c15c7602..bc3b708ac2 100644 --- a/src/plugins/platforms/winrt/qwinrtcanvas.h +++ b/src/plugins/platforms/winrt/qwinrtcanvas.h @@ -54,7 +54,7 @@ class QWinRTCanvas: { public: QWinRTCanvas(const std::function<QWindow*()> &delegateWindow); - virtual ~QWinRTCanvas(); + ~QWinRTCanvas() override = default; HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, LPVOID *iface) override; HRESULT STDMETHODCALLTYPE GetIids(ULONG *iidCount, IID **iids) override; diff --git a/src/plugins/platforms/winrt/qwinrtclipboard.cpp b/src/plugins/platforms/winrt/qwinrtclipboard.cpp index 05c34b82f8..fd0ed8aed2 100644 --- a/src/plugins/platforms/winrt/qwinrtclipboard.cpp +++ b/src/plugins/platforms/winrt/qwinrtclipboard.cpp @@ -99,7 +99,7 @@ QMimeData *QWinRTClipboard::mimeData(QClipboard::Mode mode) quint32 size; const wchar_t *textStr = result.GetRawBuffer(&size); - QString text = QString::fromWCharArray(textStr, size); + QString text = QString::fromWCharArray(textStr, int(size)); text.replace(QLatin1String("\r\n"), QLatin1String("\n")); if (m_mimeData) { @@ -161,7 +161,8 @@ void QWinRTClipboard::setMimeData(QMimeData *data, QClipboard::Mode mode) &package); const QString nativeString = convertToWindowsLineEnding(text); - HStringReference textRef(reinterpret_cast<LPCWSTR>(nativeString.utf16()), nativeString.length()); + HStringReference textRef(reinterpret_cast<LPCWSTR>(nativeString.utf16()), + uint(nativeString.length())); hr = package->SetText(textRef.Get()); RETURN_HR_IF_FAILED("Could not set text to clipboard data package."); diff --git a/src/plugins/platforms/winrt/qwinrtcursor.cpp b/src/plugins/platforms/winrt/qwinrtcursor.cpp index f22b9a435a..180905945b 100644 --- a/src/plugins/platforms/winrt/qwinrtcursor.cpp +++ b/src/plugins/platforms/winrt/qwinrtcursor.cpp @@ -78,10 +78,6 @@ QWinRTCursor::QWinRTCursor() Q_ASSERT_SUCCEEDED(hr); } -QWinRTCursor::~QWinRTCursor() -{ -} - #ifndef QT_NO_CURSOR void QWinRTCursor::changeCursor(QCursor *windowCursor, QWindow *window) { @@ -183,14 +179,15 @@ QPoint QWinRTCursor::pos() const return hr; }); Q_ASSERT_SUCCEEDED(hr); - QPoint position = QPoint(point.X, point.Y); + QPointF position(qreal(point.X), qreal(point.Y)); // If no cursor get_PointerPosition returns SHRT_MIN for x and y - if (position.x() == SHRT_MIN && position.y() == SHRT_MIN || FAILED(hr)) + if ((int(position.x()) == SHRT_MIN && int(position.y()) == SHRT_MIN) + || FAILED(hr)) return QPointF(Q_INFINITY, Q_INFINITY).toPoint(); - position.rx() -= bounds.X; - position.ry() -= bounds.Y; + position.rx() -= qreal(bounds.X); + position.ry() -= qreal(bounds.Y); position *= screen->scaleFactor(); - return position; + return position.toPoint(); } void QWinRTCursor::setPos(const QPoint &pos) @@ -199,7 +196,7 @@ void QWinRTCursor::setPos(const QPoint &pos) Q_ASSERT(screen); ComPtr<ICoreWindow> coreWindow = screen->coreWindow(); Q_ASSERT(coreWindow); - const QPointF scaledPos = pos / screen->scaleFactor(); + const QPointF scaledPos = QPointF(pos) / screen->scaleFactor(); QWinRTScreen::MousePositionTransition t; HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([coreWindow, scaledPos, &t]() { ComPtr<ICoreWindow2> coreWindow2; @@ -211,7 +208,8 @@ void QWinRTCursor::setPos(const QPoint &pos) Point mousePos; hr = coreWindow->get_PointerPosition(&mousePos); RETURN_HR_IF_FAILED("Failed to obtain mouse position."); - const Point p = {FLOAT(scaledPos.x() + bounds.X), FLOAT(scaledPos.y() + bounds.Y)}; + const Point p = { FLOAT(scaledPos.x()) + bounds.X, + FLOAT(scaledPos.y()) + bounds.Y }; const bool wasInWindow = qIsPointInRect(mousePos, bounds); const bool willBeInWindow = qIsPointInRect(p, bounds); if (wasInWindow && willBeInWindow) diff --git a/src/plugins/platforms/winrt/qwinrtcursor.h b/src/plugins/platforms/winrt/qwinrtcursor.h index 253827f38f..eca3d8c7ca 100644 --- a/src/plugins/platforms/winrt/qwinrtcursor.h +++ b/src/plugins/platforms/winrt/qwinrtcursor.h @@ -49,7 +49,7 @@ class QWinRTCursor : public QPlatformCursor { public: explicit QWinRTCursor(); - ~QWinRTCursor(); + ~QWinRTCursor() override = default; #ifndef QT_NO_CURSOR void changeCursor(QCursor * windowCursor, QWindow *window) override; #endif diff --git a/src/plugins/platforms/winrt/qwinrtdrag.cpp b/src/plugins/platforms/winrt/qwinrtdrag.cpp index 0c918230b3..3ed4cd692d 100644 --- a/src/plugins/platforms/winrt/qwinrtdrag.cpp +++ b/src/plugins/platforms/winrt/qwinrtdrag.cpp @@ -81,7 +81,7 @@ ComPtr<IBuffer> createIBufferFromData(const char *data, qint32 size) } ComPtr<IBuffer> buffer; - const UINT32 length = size; + const UINT32 length = UINT32(size); hr = bufferFactory->Create(length, &buffer); Q_ASSERT_SUCCEEDED(hr); hr = buffer->put_Length(length); @@ -118,13 +118,13 @@ inline QString hStringToQString(const HString &hString) { quint32 l; const wchar_t *raw = hString.GetRawBuffer(&l); - return (QString::fromWCharArray(raw, l)); + return (QString::fromWCharArray(raw, int(l))); } inline HString qStringToHString(const QString &qString) { HString h; - h.Set(reinterpret_cast<const wchar_t*>(qString.utf16()), qString.size()); + h.Set(reinterpret_cast<const wchar_t*>(qString.utf16()), uint(qString.size())); return h; } @@ -184,10 +184,6 @@ QWinRTInternalMimeData::QWinRTInternalMimeData() } } -QWinRTInternalMimeData::~QWinRTInternalMimeData() -{ -} - bool QWinRTInternalMimeData::hasFormat_sys(const QString &mimetype) const { qCDebug(lcQpaMime) << __FUNCTION__ << mimetype; @@ -311,7 +307,7 @@ QVariant QWinRTInternalMimeData::retrieveData_sys(const QString &mimetype, QVari ComPtr<IAsyncOperation<IInspectable*>> op; ComPtr<IInspectable> res; HString type; - type.Set(reinterpret_cast<const wchar_t*>(mimetype.utf16()), mimetype.size()); + type.Set(reinterpret_cast<const wchar_t*>(mimetype.utf16()), uint(mimetype.size())); hr = dataView->GetDataAsync(type.Get(), &op); RETURN_OK_IF_FAILED("Could not query custom drag data."); hr = QWinRTFunctions::await(op, res.GetAddressOf()); @@ -434,7 +430,7 @@ QVariant QWinRTInternalMimeData::retrieveData_sys(const QString &mimetype, QVari IID_PPV_ARGS(&bufferFactory)); Q_ASSERT_SUCCEEDED(hr); - UINT32 length = qBound(quint64(0), quint64(size), quint64(UINT_MAX)); + UINT32 length = UINT32(qBound(quint64(0), quint64(size), quint64(UINT_MAX))); ComPtr<IBuffer> buffer; hr = bufferFactory->Create(length, &buffer); Q_ASSERT_SUCCEEDED(hr); @@ -452,7 +448,7 @@ QVariant QWinRTInternalMimeData::retrieveData_sys(const QString &mimetype, QVari byte *bytes; hr = byteArrayAccess->Buffer(&bytes); - QByteArray array((char *)bytes, length); + QByteArray array((char *)bytes, int(length)); result.setValue(array); return S_OK; } @@ -559,7 +555,7 @@ extern ComPtr<ABI::Windows::UI::Input::IPointerPoint> qt_winrt_lastPointerPoint; QWinRTDrag::QWinRTDrag() : QPlatformDrag() - , m_dragTarget(0) + , m_dragTarget(nullptr) { qCDebug(lcQpaMime) << __FUNCTION__; m_enter = new Q_INST_DRAGHANDLER(Enter); @@ -612,7 +608,7 @@ Qt::DropAction QWinRTDrag::drag(QDrag *drag) ComPtr<IAsyncOperation<ABI::Windows::ApplicationModel::DataTransfer::DataPackageOperation>> op; EventRegistrationToken startingToken; - hr = QEventDispatcherWinRT::runOnXamlThread([drag, &op, &hr, elem3, &startingToken, this]() { + hr = QEventDispatcherWinRT::runOnXamlThread([drag, &op, &hr, elem3, &startingToken]() { hr = elem3->put_CanDrag(true); Q_ASSERT_SUCCEEDED(hr); @@ -660,7 +656,8 @@ Qt::DropAction QWinRTDrag::drag(QDrag *drag) const QImage image = image2.convertToFormat(QImage::Format_ARGB32); if (!image.isNull()) { // Create IBuffer containing image - ComPtr<IBuffer> imageBuffer = createIBufferFromData(reinterpret_cast<const char*>(image.bits()), image.byteCount()); + ComPtr<IBuffer> imageBuffer + = createIBufferFromData(reinterpret_cast<const char*>(image.bits()), int(image.sizeInBytes())); ComPtr<ISoftwareBitmapFactory> bitmapFactory; hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Graphics_Imaging_SoftwareBitmap).Get(), @@ -697,7 +694,7 @@ Qt::DropAction QWinRTDrag::drag(QDrag *drag) hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Storage_Streams_InMemoryRandomAccessStream).Get(), &ras); Q_ASSERT_SUCCEEDED(hr); - hr = ras->put_Size(data.size()); + hr = ras->put_Size(UINT64(data.size())); ComPtr<IOutputStream> outputStream; hr = ras->GetOutputStreamAt(0, &outputStream); Q_ASSERT_SUCCEEDED(hr); @@ -802,7 +799,7 @@ void QWinRTDrag::handleNativeDragEvent(IInspectable *sender, ABI::Windows::UI::X Point relativePoint; hr = e->GetPosition(m_ui.Get(), &relativePoint); RETURN_VOID_IF_FAILED("Could not query drag position."); - const QPoint p(relativePoint.X, relativePoint.Y); + const QPoint p(int(relativePoint.X), int(relativePoint.Y)); ComPtr<IDragEventArgs2> e2; hr = e->QueryInterface(IID_PPV_ARGS(&e2)); diff --git a/src/plugins/platforms/winrt/qwinrtdrag.h b/src/plugins/platforms/winrt/qwinrtdrag.h index 3868c9f015..ab57999bba 100644 --- a/src/plugins/platforms/winrt/qwinrtdrag.h +++ b/src/plugins/platforms/winrt/qwinrtdrag.h @@ -77,7 +77,7 @@ class QWinRTInternalMimeData; class QWinRTInternalMimeData : public QInternalMimeData { public: QWinRTInternalMimeData(); - virtual ~QWinRTInternalMimeData(); + ~QWinRTInternalMimeData() override = default; bool hasFormat_sys(const QString &mimetype) const override; QStringList formats_sys() const override; @@ -92,7 +92,7 @@ private: class QWinRTDrag : public QPlatformDrag { public: QWinRTDrag(); - virtual ~QWinRTDrag(); + ~QWinRTDrag() override; static QWinRTDrag *instance(); Qt::DropAction drag(QDrag *) override; diff --git a/src/plugins/platforms/winrt/qwinrteglcontext.h b/src/plugins/platforms/winrt/qwinrteglcontext.h index 325dc82c40..8dbd0fc7d0 100644 --- a/src/plugins/platforms/winrt/qwinrteglcontext.h +++ b/src/plugins/platforms/winrt/qwinrteglcontext.h @@ -50,7 +50,7 @@ class QWinRTEGLContext : public QPlatformOpenGLContext { public: explicit QWinRTEGLContext(QOpenGLContext *context); - ~QWinRTEGLContext(); + ~QWinRTEGLContext() override; void initialize() override; diff --git a/src/plugins/platforms/winrt/qwinrteventdispatcher.h b/src/plugins/platforms/winrt/qwinrteventdispatcher.h index 4c5c19c6b0..61c824f0a9 100644 --- a/src/plugins/platforms/winrt/qwinrteventdispatcher.h +++ b/src/plugins/platforms/winrt/qwinrteventdispatcher.h @@ -48,7 +48,7 @@ class QWinRTEventDispatcher : public QEventDispatcherWinRT { Q_OBJECT public: - explicit QWinRTEventDispatcher(QObject *parent = 0); + explicit QWinRTEventDispatcher(QObject *parent = nullptr); protected: bool hasPendingEvents() override; diff --git a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp index 3c90334c8c..114d6dacd8 100644 --- a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp +++ b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp @@ -51,7 +51,7 @@ #include <wrl.h> #include <windows.foundation.h> #include <windows.storage.pickers.h> -#include <Windows.ApplicationModel.activation.h> +#include <Windows.Applicationmodel.Activation.h> using namespace Microsoft::WRL; using namespace Microsoft::WRL::Wrappers; @@ -73,12 +73,12 @@ class WindowsStringVector : public RuntimeClass<IVector<HSTRING>> public: HRESULT __stdcall GetAt(quint32 index, HSTRING *item) { - *item = impl.at(index); + *item = impl.at(int(index)); return S_OK; } HRESULT __stdcall get_Size(quint32 *size) { - *size = impl.size(); + *size = quint32(impl.size()); return S_OK; } HRESULT __stdcall GetView(IVectorView<HSTRING> **view) @@ -108,7 +108,7 @@ public: HRESULT hr = WindowsDuplicateString(item, &newItem); if (FAILED(hr)) return hr; - impl[index] = newItem; + impl[int(index)] = newItem; return S_OK; } HRESULT __stdcall InsertAt(quint32 index, HSTRING item) @@ -117,12 +117,12 @@ public: HRESULT hr = WindowsDuplicateString(item, &newItem); if (FAILED(hr)) return hr; - impl.insert(index, newItem); + impl.insert(int(index), newItem); return S_OK; } HRESULT __stdcall RemoveAt(quint32 index) { - WindowsDeleteString(impl.takeAt(index)); + WindowsDeleteString(impl.takeAt(int(index))); return S_OK; } HRESULT __stdcall Append(HSTRING item) @@ -164,7 +164,7 @@ static bool initializePicker(HSTRING runtimeId, T **picker, const QSharedPointer if (options->isLabelExplicitlySet(QFileDialogOptions::Accept)) { const QString labelText = options->labelText(QFileDialogOptions::Accept); HStringReference labelTextRef(reinterpret_cast<const wchar_t *>(labelText.utf16()), - labelText.length()); + uint(labelText.length())); hr = (*picker)->put_CommitButtonText(labelTextRef.Get()); RETURN_FALSE_IF_FAILED("Failed to set commit button text"); } @@ -188,7 +188,7 @@ static bool initializeOpenPickerOptions(T *picker, const QSharedPointer<QFileDia // Remove leading star const int offset = (filter.length() > 1 && filter.startsWith(QLatin1Char('*'))) ? 1 : 0; HStringReference filterRef(reinterpret_cast<const wchar_t *>(filter.utf16() + offset), - filter.length() - offset); + uint(filter.length() - offset)); hr = filters->Append(filterRef.Get()); if (FAILED(hr)) { qWarning("Failed to add named file filter \"%s\": %s", @@ -290,16 +290,12 @@ QWinRTFileDialogHelper::QWinRTFileDialogHelper() d->shown = false; } -QWinRTFileDialogHelper::~QWinRTFileDialogHelper() -{ -} - void QWinRTFileDialogHelper::exec() { Q_D(QWinRTFileDialogHelper); if (!d->shown) - show(Qt::Dialog, Qt::ApplicationModal, 0); + show(Qt::Dialog, Qt::ApplicationModal, nullptr); d->loop.exec(); } @@ -369,7 +365,7 @@ bool QWinRTFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit // Remove leading star const int starOffset = (filter.length() > 1 && filter.startsWith(QLatin1Char('*'))) ? 1 : 0; HStringReference filterRef(reinterpret_cast<const wchar_t *>(filter.utf16() + starOffset), - filter.length() - starOffset); + uint(filter.length() - starOffset)); hr = entry->Append(filterRef.Get()); if (FAILED(hr)) { qWarning("Failed to add named file filter \"%s\": %s", @@ -379,7 +375,7 @@ bool QWinRTFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit const int offset = namedFilter.indexOf(QLatin1String(" (")); const QString filterTitle = namedFilter.mid(0, offset); HStringReference namedFilterRef(reinterpret_cast<const wchar_t *>(filterTitle.utf16()), - filterTitle.length()); + uint(filterTitle.length())); boolean replaced; hr = choices->Insert(namedFilterRef.Get(), entry.Get(), &replaced); // Only print a warning as * or *.* is not a valid choice on Windows 10 @@ -396,7 +392,7 @@ bool QWinRTFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit if (!suffix.startsWith(QLatin1Char('.'))) suffix.prepend(QLatin1Char('.')); HStringReference nativeSuffix(reinterpret_cast<const wchar_t *>(suffix.utf16()), - suffix.length()); + uint(suffix.length())); hr = picker->put_DefaultFileExtension(nativeSuffix.Get()); RETURN_FALSE_IF_FAILED_WITH_ARGS("Failed to set default file extension \"%s\"", qPrintable(suffix)); } @@ -404,7 +400,7 @@ bool QWinRTFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit const QString suggestedName = QFileInfo(d->saveFileName.toLocalFile()).fileName(); if (!suggestedName.isEmpty()) { HStringReference nativeSuggestedName(reinterpret_cast<const wchar_t *>(suggestedName.utf16()), - suggestedName.length()); + uint(suggestedName.length())); hr = picker->put_SuggestedFileName(nativeSuggestedName.Get()); RETURN_FALSE_IF_FAILED("Failed to set suggested file name"); } diff --git a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.h b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.h index 99239aad3a..994d099dcf 100644 --- a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.h +++ b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.h @@ -70,7 +70,7 @@ class QWinRTFileDialogHelper : public QPlatformFileDialogHelper Q_OBJECT public: explicit QWinRTFileDialogHelper(); - ~QWinRTFileDialogHelper(); + ~QWinRTFileDialogHelper() override = default; void exec() override; bool show(Qt::WindowFlags, Qt::WindowModality, QWindow *) override; diff --git a/src/plugins/platforms/winrt/qwinrtfileengine.cpp b/src/plugins/platforms/winrt/qwinrtfileengine.cpp index 76efdf6cc8..3014b30c38 100644 --- a/src/plugins/platforms/winrt/qwinrtfileengine.cpp +++ b/src/plugins/platforms/winrt/qwinrtfileengine.cpp @@ -122,10 +122,6 @@ QWinRTFileEngineHandler::QWinRTFileEngineHandler() { } -QWinRTFileEngineHandler::~QWinRTFileEngineHandler() -{ -} - void QWinRTFileEngineHandler::registerFile(const QString &fileName, IStorageItem *file) { handlerInstance->d_func()->files.insert(QDir::cleanPath(fileName), file); @@ -168,7 +164,7 @@ static HRESULT getDestinationFolder(const QString &fileName, const QString &newF const QString newFilePath = QDir::toNativeSeparators(newFileInfo.absolutePath()); HStringReference nativeNewFilePath(reinterpret_cast<LPCWSTR>(newFilePath.utf16()), - newFilePath.length()); + uint(newFilePath.length())); hr = folderFactory->GetFolderFromPathAsync(nativeNewFilePath.Get(), &op); } if (FAILED(hr)) @@ -181,10 +177,6 @@ QWinRTFileEngine::QWinRTFileEngine(const QString &fileName, IStorageItem *file) { } -QWinRTFileEngine::~QWinRTFileEngine() -{ -} - bool QWinRTFileEngine::open(QIODevice::OpenMode openMode) { Q_D(QWinRTFileEngine); @@ -278,7 +270,7 @@ bool QWinRTFileEngine::seek(qint64 pos) if (!d->stream) return false; - HRESULT hr = d->stream->Seek(pos); + HRESULT hr = d->stream->Seek(UINT64(pos)); RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::PositionError, false); d->pos = pos; return SUCCEEDED(hr); @@ -311,7 +303,8 @@ bool QWinRTFileEngine::copy(const QString &newName) RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::CopyError, false); const QString destinationName = QFileInfo(newName).fileName(); - HStringReference nativeDestinationName(reinterpret_cast<LPCWSTR>(destinationName.utf16()), destinationName.length()); + HStringReference nativeDestinationName(reinterpret_cast<LPCWSTR>(destinationName.utf16()), + uint(destinationName.length())); ComPtr<IAsyncOperation<StorageFile *>> op; hr = file->CopyOverloadDefaultOptions(destinationFolder.Get(), nativeDestinationName.Get(), &op); RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::CopyError, false); @@ -332,7 +325,8 @@ bool QWinRTFileEngine::rename(const QString &newName) RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::RenameError, false); const QString destinationName = QFileInfo(newName).fileName(); - HStringReference nativeDestinationName(reinterpret_cast<LPCWSTR>(destinationName.utf16()), destinationName.length()); + HStringReference nativeDestinationName(reinterpret_cast<LPCWSTR>(destinationName.utf16()), + uint(destinationName.length())); ComPtr<IAsyncAction> op; hr = d->file->RenameAsyncOverloadDefaultOptions(nativeDestinationName.Get(), &op); RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::RenameError, false); @@ -349,7 +343,8 @@ bool QWinRTFileEngine::renameOverwrite(const QString &newName) RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::RenameError, false); const QString destinationName = QFileInfo(newName).fileName(); - HStringReference nativeDestinationName(reinterpret_cast<LPCWSTR>(destinationName.utf16()), destinationName.length()); + HStringReference nativeDestinationName(reinterpret_cast<LPCWSTR>(destinationName.utf16()), + uint(destinationName.length())); ComPtr<IAsyncAction> op; hr = d->file->RenameAsync(nativeDestinationName.Get(), NameCollisionOption_ReplaceExisting, &op); RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::RenameError, false); @@ -451,7 +446,7 @@ qint64 QWinRTFileEngine::read(char *data, qint64 maxlen) HRESULT hr = d->stream.As(&stream); RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::ReadError, -1); - UINT32 length = qBound(quint64(0), quint64(maxlen), quint64(UINT_MAX)); + UINT32 length = UINT32(qBound(quint64(0), quint64(maxlen), quint64(UINT32_MAX))); ComPtr<IBuffer> buffer; hr = d->bufferFactory->Create(length, &buffer); RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::ReadError, -1); @@ -494,7 +489,7 @@ qint64 QWinRTFileEngine::write(const char *data, qint64 maxlen) HRESULT hr = d->stream.As(&stream); RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::WriteError, -1); - UINT32 length = qBound(quint64(0), quint64(maxlen), quint64(UINT_MAX)); + UINT32 length = UINT32(qBound(quint64(0), quint64(maxlen), quint64(UINT_MAX))); ComPtr<IBuffer> buffer; hr = d->bufferFactory->Create(length, &buffer); RETURN_AND_SET_ERROR_IF_FAILED(QFileDevice::WriteError, -1); diff --git a/src/plugins/platforms/winrt/qwinrtfileengine.h b/src/plugins/platforms/winrt/qwinrtfileengine.h index 73ff54b0c8..4485917c9e 100644 --- a/src/plugins/platforms/winrt/qwinrtfileengine.h +++ b/src/plugins/platforms/winrt/qwinrtfileengine.h @@ -57,7 +57,7 @@ class QWinRTFileEngineHandler : public QAbstractFileEngineHandler { public: QWinRTFileEngineHandler(); - ~QWinRTFileEngineHandler(); + ~QWinRTFileEngineHandler() override = default; QAbstractFileEngine *create(const QString &fileName) const override; static void registerFile(const QString &fileName, ABI::Windows::Storage::IStorageItem *file); @@ -73,7 +73,7 @@ class QWinRTFileEngine : public QAbstractFileEngine { public: QWinRTFileEngine(const QString &fileName, ABI::Windows::Storage::IStorageItem *file); - ~QWinRTFileEngine(); + ~QWinRTFileEngine() override = default; bool open(QIODevice::OpenMode openMode) override; bool close() override; diff --git a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp index 63e5b0cf27..f7e91bb047 100644 --- a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp +++ b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp @@ -64,8 +64,8 @@ inline QRectF getInputPaneRect(ComPtr<IInputPane> pane, qreal scaleFactor) { Rect rect; pane->get_OccludedRect(&rect); - return QRectF(qRound(rect.X * scaleFactor), qRound(rect.Y * scaleFactor), - qRound(rect.Width * scaleFactor), qRound(rect.Height * scaleFactor)); + return QRectF(qRound(qreal(rect.X) * scaleFactor), qRound(qreal(rect.Y) * scaleFactor), + qRound(qreal(rect.Width) * scaleFactor), qRound(qreal(rect.Height) * scaleFactor)); } /*! @@ -205,6 +205,8 @@ void QWinRTInputContext::showInputPanel() void QWinRTInputContext::hideInputPanel() { qCDebug(lcQpaInputMethods) << __FUNCTION__; + if (!m_isInputPanelVisible) + return; QEventDispatcherWinRT::runOnXamlThread([&]() { ComPtr<IInputPane2> inputPane; diff --git a/src/plugins/platforms/winrt/qwinrtintegration.h b/src/plugins/platforms/winrt/qwinrtintegration.h index 7c83e27c26..636e594b4b 100644 --- a/src/plugins/platforms/winrt/qwinrtintegration.h +++ b/src/plugins/platforms/winrt/qwinrtintegration.h @@ -75,7 +75,7 @@ class QWinRTIntegration : public QPlatformIntegration private: explicit QWinRTIntegration(); public: - ~QWinRTIntegration(); + ~QWinRTIntegration() override; static QWinRTIntegration *create() { diff --git a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp index d69c63e9a4..7016b47f7e 100644 --- a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp +++ b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp @@ -99,7 +99,7 @@ void QWinRTMessageDialogHelper::exec() Q_D(QWinRTMessageDialogHelper); if (!d->shown) - show(Qt::Dialog, Qt::ApplicationModal, 0); + show(Qt::Dialog, Qt::ApplicationModal, nullptr); d->loop.exec(); } @@ -134,9 +134,11 @@ bool QWinRTMessageDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModa RETURN_FALSE_IF_FAILED("Failed to create command factory"); ComPtr<IMessageDialog> dialog; - HStringReference nativeText(reinterpret_cast<LPCWSTR>(text.utf16()), text.size()); + HStringReference nativeText(reinterpret_cast<LPCWSTR>(text.utf16()), + uint(text.size())); if (!title.isEmpty()) { - HStringReference nativeTitle(reinterpret_cast<LPCWSTR>(title.utf16()), title.size()); + HStringReference nativeTitle(reinterpret_cast<LPCWSTR>(title.utf16()), + uint(title.size())); hr = dialogFactory->CreateWithTitle(nativeText.Get(), nativeTitle.Get(), &dialog); RETURN_FALSE_IF_FAILED("Failed to create dialog with title"); } else { @@ -162,7 +164,8 @@ bool QWinRTMessageDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModa continue; // Add native command const QString label = d->theme->standardButtonText(i); - HStringReference nativeLabel(reinterpret_cast<LPCWSTR>(label.utf16()), label.size()); + HStringReference nativeLabel(reinterpret_cast<LPCWSTR>(label.utf16()), + uint(label.size())); ComPtr<IUICommand> command; hr = commandFactory->Create(nativeLabel.Get(), &command); RETURN_HR_IF_FAILED("Failed to create message box command"); diff --git a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.h b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.h index 14b6d4b715..ab704b1c7d 100644 --- a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.h +++ b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.h @@ -67,7 +67,7 @@ class QWinRTMessageDialogHelper : public QPlatformMessageDialogHelper Q_OBJECT public: explicit QWinRTMessageDialogHelper(const QWinRTTheme *theme); - ~QWinRTMessageDialogHelper(); + ~QWinRTMessageDialogHelper() override; void exec() override; bool show(Qt::WindowFlags windowFlags, diff --git a/src/plugins/platforms/winrt/qwinrtscreen.h b/src/plugins/platforms/winrt/qwinrtscreen.h index 6d0d3cdf52..cde148a638 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.h +++ b/src/plugins/platforms/winrt/qwinrtscreen.h @@ -89,7 +89,7 @@ class QWinRTScreen : public QPlatformScreen { public: explicit QWinRTScreen(); - ~QWinRTScreen(); + ~QWinRTScreen() override; QRect geometry() const override; QRect availableGeometry() const override; diff --git a/src/plugins/platforms/winrt/qwinrtservices.cpp b/src/plugins/platforms/winrt/qwinrtservices.cpp index 05620ca4c8..b27c408f40 100644 --- a/src/plugins/platforms/winrt/qwinrtservices.cpp +++ b/src/plugins/platforms/winrt/qwinrtservices.cpp @@ -83,17 +83,14 @@ QWinRTServices::QWinRTServices() Q_ASSERT_X(SUCCEEDED(hr), Q_FUNC_INFO, qPrintable(qt_error_string(hr))); } -QWinRTServices::~QWinRTServices() -{ -} - bool QWinRTServices::openUrl(const QUrl &url) { Q_D(QWinRTServices); ComPtr<IUriRuntimeClass> uri; QString urlString = url.toString(); - HStringReference uriString(reinterpret_cast<LPCWSTR>(urlString.utf16()), urlString.length()); + HStringReference uriString(reinterpret_cast<LPCWSTR>(urlString.utf16()), + uint(urlString.length())); HRESULT hr = d->uriFactory->CreateUri(uriString.Get(), &uri); RETURN_FALSE_IF_FAILED("Failed to create URI from QUrl."); @@ -122,7 +119,8 @@ bool QWinRTServices::openDocument(const QUrl &url) } if (!file) { const QString pathString = QDir::toNativeSeparators(url.toLocalFile()); - HStringReference path(reinterpret_cast<LPCWSTR>(pathString.utf16()), pathString.length()); + HStringReference path(reinterpret_cast<LPCWSTR>(pathString.utf16()), + uint(pathString.length())); ComPtr<IAsyncOperation<StorageFile *>> op; hr = d->fileFactory->GetFileFromPathAsync(path.Get(), &op); RETURN_FALSE_IF_FAILED("Failed to initialize file URI."); diff --git a/src/plugins/platforms/winrt/qwinrtservices.h b/src/plugins/platforms/winrt/qwinrtservices.h index 80b9a6c92a..202ce722cf 100644 --- a/src/plugins/platforms/winrt/qwinrtservices.h +++ b/src/plugins/platforms/winrt/qwinrtservices.h @@ -50,7 +50,7 @@ class QWinRTServices : public QPlatformServices { public: explicit QWinRTServices(); - ~QWinRTServices(); + ~QWinRTServices() override = default; bool openUrl(const QUrl &url) override; bool openDocument(const QUrl &url) override; diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp index cbf0ba36c9..29d234d276 100644 --- a/src/plugins/platforms/winrt/qwinrtwindow.cpp +++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp @@ -126,7 +126,7 @@ QWinRTWindow::QWinRTWindow(QWindow *window) hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_Xaml_Controls_Canvas).Get(), IID_PPV_ARGS(&d->canvas)); Q_ASSERT_SUCCEEDED(hr); - hr = QEventDispatcherWinRT::runOnXamlThread([this, d]() { + hr = QEventDispatcherWinRT::runOnXamlThread([d]() { // Create a new swapchain and place it inside the canvas HRESULT hr; hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_UI_Xaml_Controls_SwapChainPanel).Get(), diff --git a/src/plugins/platforms/winrt/qwinrtwindow.h b/src/plugins/platforms/winrt/qwinrtwindow.h index 9604b4bbaa..0445e6bf54 100644 --- a/src/plugins/platforms/winrt/qwinrtwindow.h +++ b/src/plugins/platforms/winrt/qwinrtwindow.h @@ -54,7 +54,7 @@ class QWinRTWindow : public QPlatformWindow { public: QWinRTWindow(QWindow *window); - ~QWinRTWindow(); + ~QWinRTWindow() override; QSurfaceFormat format() const override; bool isActive() const override; |