Windows QPA: Move window properties to the new interfaces
Affects the custom margin used by QWizard. Task-number: QTBUG-83252 Change-Id: Iffda043f106282f682e119ec955fa2b2eb0f259e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>bb10
parent
c692f41ae5
commit
ff97e083ed
|
|
@ -57,6 +57,8 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QMargins;
|
||||
|
||||
class QPlatformWindowPrivate
|
||||
{
|
||||
public:
|
||||
|
|
@ -116,6 +118,9 @@ struct Q_GUI_EXPORT QWindowsWindow
|
|||
|
||||
virtual void setHasBorderInFullScreen(bool border) = 0;
|
||||
virtual bool hasBorderInFullScreen() const = 0;
|
||||
|
||||
virtual QMargins customMargins() const = 0;
|
||||
virtual void setCustomMargins(const QMargins &margins) = 0;
|
||||
};
|
||||
#endif // Q_OS_WIN
|
||||
|
||||
|
|
|
|||
|
|
@ -144,37 +144,6 @@ void *QWindowsNativeInterface::nativeResourceForCursor(const QByteArray &resourc
|
|||
}
|
||||
#endif // !QT_NO_CURSOR
|
||||
|
||||
static const char customMarginPropertyC[] = "WindowsCustomMargins";
|
||||
|
||||
QVariant QWindowsNativeInterface::windowProperty(QPlatformWindow *window, const QString &name) const
|
||||
{
|
||||
auto *platformWindow = static_cast<QWindowsWindow *>(window);
|
||||
if (name == QLatin1String(customMarginPropertyC))
|
||||
return QVariant::fromValue(platformWindow->customMargins());
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant QWindowsNativeInterface::windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const
|
||||
{
|
||||
const QVariant result = windowProperty(window, name);
|
||||
return result.isValid() ? result : defaultValue;
|
||||
}
|
||||
|
||||
void QWindowsNativeInterface::setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value)
|
||||
{
|
||||
auto *platformWindow = static_cast<QWindowsWindow *>(window);
|
||||
if (name == QLatin1String(customMarginPropertyC))
|
||||
platformWindow->setCustomMargins(qvariant_cast<QMargins>(value));
|
||||
}
|
||||
|
||||
QVariantMap QWindowsNativeInterface::windowProperties(QPlatformWindow *window) const
|
||||
{
|
||||
QVariantMap result;
|
||||
const QString customMarginProperty = QLatin1String(customMarginPropertyC);
|
||||
result.insert(customMarginProperty, windowProperty(window, customMarginProperty));
|
||||
return result;
|
||||
}
|
||||
|
||||
void *QWindowsNativeInterface::nativeResourceForIntegration(const QByteArray &resource)
|
||||
{
|
||||
#ifdef QT_NO_OPENGL
|
||||
|
|
|
|||
|
|
@ -98,11 +98,6 @@ public:
|
|||
QVariant gpu() const;
|
||||
QVariant gpuList() const;
|
||||
|
||||
QVariantMap windowProperties(QPlatformWindow *window) const override;
|
||||
QVariant windowProperty(QPlatformWindow *window, const QString &name) const override;
|
||||
QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const override;
|
||||
void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void darkModeChanged(bool);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1193,6 +1193,16 @@ bool QWindowsBaseWindow::hasBorderInFullScreen() const
|
|||
return false;
|
||||
}
|
||||
|
||||
QMargins QWindowsBaseWindow::customMargins() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void QWindowsBaseWindow::setCustomMargins(const QMargins &)
|
||||
{
|
||||
Q_UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QWindowsDesktopWindow
|
||||
\brief Window wrapping GetDesktopWindow not allowing any manipulation.
|
||||
|
|
|
|||
|
|
@ -144,6 +144,9 @@ public:
|
|||
void setHasBorderInFullScreen(bool border) override;
|
||||
bool hasBorderInFullScreen() const override;
|
||||
|
||||
QMargins customMargins() const override;
|
||||
void setCustomMargins(const QMargins &margins) override;
|
||||
|
||||
using QPlatformWindow::screenForGeometry;
|
||||
|
||||
virtual HWND handle() const = 0;
|
||||
|
|
@ -304,8 +307,8 @@ public:
|
|||
QWindowsMenuBar *menuBar() const;
|
||||
void setMenuBar(QWindowsMenuBar *mb);
|
||||
|
||||
QMargins customMargins() const { return m_data.customMargins; }
|
||||
void setCustomMargins(const QMargins &m);
|
||||
QMargins customMargins() const override { return m_data.customMargins; }
|
||||
void setCustomMargins(const QMargins &m) override;
|
||||
|
||||
void setStyle(unsigned s) const;
|
||||
void setExStyle(unsigned s) const;
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@
|
|||
|
||||
#include "qwizard_win_p.h"
|
||||
#include <private/qapplication_p.h>
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <qpa/qplatformwindow.h>
|
||||
#include <qpa/qplatformwindow_p.h>
|
||||
#include "qwizard.h"
|
||||
#include "qpaintengine.h"
|
||||
#include "qapplication.h"
|
||||
|
|
@ -166,6 +167,8 @@ QVistaHelper::~QVistaHelper()
|
|||
|
||||
void QVistaHelper::updateCustomMargins(bool vistaMargins)
|
||||
{
|
||||
using namespace QPlatformInterface::Private;
|
||||
|
||||
if (QWindow *window = wizard->windowHandle()) {
|
||||
// Reduce top frame to zero since we paint it ourselves. Use
|
||||
// device pixel to avoid rounding errors.
|
||||
|
|
@ -176,11 +179,8 @@ void QVistaHelper::updateCustomMargins(bool vistaMargins)
|
|||
// The dynamic property takes effect when creating the platform window.
|
||||
window->setProperty("_q_windowsCustomMargins", customMarginsV);
|
||||
// If a platform window exists, change via native interface.
|
||||
if (QPlatformWindow *platformWindow = window->handle()) {
|
||||
QGuiApplication::platformNativeInterface()->
|
||||
setWindowProperty(platformWindow, QStringLiteral("WindowsCustomMargins"),
|
||||
customMarginsV);
|
||||
}
|
||||
if (auto platformWindow = dynamic_cast<QWindowsWindow *>(window->handle()))
|
||||
platformWindow->setCustomMargins(customMarginsDp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue