QtQuick demo: work-around a QtQuick bug
See https://bugreports.qt.io/browse/QTBUG-69711 Also some minor tweaks of the constexpr variables. Fixes: #35 Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
ebe7da1a9f
commit
a9256ba4b3
|
@ -79,7 +79,7 @@ Window {
|
|||
|
||||
MinimizeButton {
|
||||
id: minimizeButton
|
||||
onClicked: window.showMinimized()
|
||||
onClicked: framelessHelper.showMinimized()
|
||||
Component.onCompleted: framelessHelper.setHitTestVisible(minimizeButton, true)
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ FRAMELESSHELPER_USE_NAMESPACE
|
|||
static const QColor systemLightColor = QStringLiteral("#f0f0f0");
|
||||
static const QColor systemDarkColor = QColor::fromRgb(32, 32, 32);
|
||||
|
||||
static constexpr char mainStyleSheet[] = R"(
|
||||
static constexpr const char mainStyleSheet[] = R"(
|
||||
#MainWidget {
|
||||
background-color: %1;
|
||||
}
|
||||
|
|
|
@ -105,12 +105,12 @@ Q_NAMESPACE
|
|||
namespace Constants
|
||||
{
|
||||
|
||||
[[maybe_unused]] constexpr char kFramelessModeFlag[] = "_FRAMELESSHELPER_FRAMELESS_MODE";
|
||||
[[maybe_unused]] constexpr char kResizeBorderThicknessFlag[] = "_FRAMELESSHELPER_RESIZE_BORDER_THICKNESS";
|
||||
[[maybe_unused]] constexpr char kCaptionHeightFlag[] = "_FRAMELESSHELPER_CAPTION_HEIGHT";
|
||||
[[maybe_unused]] constexpr char kTitleBarHeightFlag[] = "_FRAMELESSHELPER_TITLE_BAR_HEIGHT";
|
||||
[[maybe_unused]] constexpr char kHitTestVisibleFlag[] = "_FRAMELESSHELPER_HIT_TEST_VISIBLE";
|
||||
[[maybe_unused]] constexpr char kWindowFixedSizeFlag[] = "_FRAMELESSHELPER_WINDOW_FIXED_SIZE";
|
||||
[[maybe_unused]] static constexpr const char kFramelessModeFlag[] = "_FRAMELESSHELPER_FRAMELESS_MODE";
|
||||
[[maybe_unused]] static constexpr const char kResizeBorderThicknessFlag[] = "_FRAMELESSHELPER_RESIZE_BORDER_THICKNESS";
|
||||
[[maybe_unused]] static constexpr const char kCaptionHeightFlag[] = "_FRAMELESSHELPER_CAPTION_HEIGHT";
|
||||
[[maybe_unused]] static constexpr const char kTitleBarHeightFlag[] = "_FRAMELESSHELPER_TITLE_BAR_HEIGHT";
|
||||
[[maybe_unused]] static constexpr const char kHitTestVisibleFlag[] = "_FRAMELESSHELPER_HIT_TEST_VISIBLE";
|
||||
[[maybe_unused]] static constexpr const char kWindowFixedSizeFlag[] = "_FRAMELESSHELPER_WINDOW_FIXED_SIZE";
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@ FRAMELESSHELPER_BEGIN_NAMESPACE
|
|||
|
||||
struct FramelessHelperWinData
|
||||
{
|
||||
explicit FramelessHelperWinData() = default;
|
||||
~FramelessHelperWinData() = default;
|
||||
|
||||
[[nodiscard]] bool create() {
|
||||
if (!m_instance.isNull()) {
|
||||
return false;
|
||||
|
@ -85,6 +88,7 @@ struct FramelessHelperWinData
|
|||
}
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(FramelessHelperWinData)
|
||||
QScopedPointer<FramelessHelperWin> m_instance;
|
||||
bool m_installed = false;
|
||||
};
|
||||
|
|
|
@ -124,13 +124,13 @@ using flh_PTIMECAPS = flh_timecaps_tag *;
|
|||
using flh_NPTIMECAPS = flh_timecaps_tag * NEAR;
|
||||
using flh_LPTIMECAPS = flh_timecaps_tag * FAR;
|
||||
|
||||
[[maybe_unused]] static constexpr UINT kAutoHideTaskbarThickness = 2; // The thickness of an auto-hide taskbar in pixels
|
||||
[[maybe_unused]] static constexpr const UINT kAutoHideTaskbarThickness = 2; // The thickness of an auto-hide taskbar in pixels
|
||||
|
||||
[[maybe_unused]] static constexpr char kDwmRegistryKey[] = R"(Software\Microsoft\Windows\DWM)";
|
||||
[[maybe_unused]] static constexpr char kPersonalizeRegistryKey[] = R"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)";
|
||||
[[maybe_unused]] static constexpr const char kDwmRegistryKey[] = R"(Software\Microsoft\Windows\DWM)";
|
||||
[[maybe_unused]] static constexpr const char kPersonalizeRegistryKey[] = R"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)";
|
||||
|
||||
[[maybe_unused]] static constexpr UINT kDefaultResizeBorderThicknessClassic = 4;
|
||||
[[maybe_unused]] static constexpr UINT kDefaultResizeBorderThicknessAero = 8;
|
||||
[[maybe_unused]] static constexpr UINT kDefaultCaptionHeight = 23;
|
||||
[[maybe_unused]] static constexpr const UINT kDefaultResizeBorderThicknessClassic = 4;
|
||||
[[maybe_unused]] static constexpr const UINT kDefaultResizeBorderThicknessAero = 8;
|
||||
[[maybe_unused]] static constexpr const UINT kDefaultCaptionHeight = 23;
|
||||
|
||||
[[maybe_unused]] static constexpr DWORD _DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37;
|
||||
[[maybe_unused]] static constexpr const DWORD _DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37;
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
#include "framelessquickhelper.h"
|
||||
#include "framelesswindowsmanager.h"
|
||||
#include <QtQuick/qquickwindow.h>
|
||||
#ifdef Q_OS_WINDOWS
|
||||
#include "framelesshelper_windows.h"
|
||||
#endif
|
||||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -89,4 +92,14 @@ void FramelessQuickHelper::setHitTestVisible(QQuickItem *item, const bool visibl
|
|||
FramelessWindowsManager::setHitTestVisible(window(), item, visible);
|
||||
}
|
||||
|
||||
void FramelessQuickHelper::showMinimized()
|
||||
{
|
||||
#ifdef Q_OS_WINDOWS
|
||||
// Work-around a QtQuick bug: https://bugreports.qt.io/browse/QTBUG-69711
|
||||
ShowWindow(reinterpret_cast<HWND>(window()->winId()), SW_MINIMIZE);
|
||||
#else
|
||||
window()->showMinimized();
|
||||
#endif
|
||||
}
|
||||
|
||||
FRAMELESSHELPER_END_NAMESPACE
|
||||
|
|
|
@ -53,11 +53,13 @@ public:
|
|||
Q_NODISCARD bool resizable() const;
|
||||
void setResizable(const bool val);
|
||||
|
||||
Q_NODISCARD Q_INVOKABLE bool isWindowFrameless() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void removeWindowFrame();
|
||||
void bringBackWindowFrame();
|
||||
Q_NODISCARD bool isWindowFrameless() const;
|
||||
void setHitTestVisible(QQuickItem *item, const bool visible);
|
||||
void showMinimized();
|
||||
|
||||
Q_SIGNALS:
|
||||
void resizeBorderThicknessChanged(qreal);
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
|
||||
FRAMELESSHELPER_BEGIN_NAMESPACE
|
||||
|
||||
static constexpr int kDefaultResizeBorderThickness = 8;
|
||||
static constexpr int kDefaultCaptionHeight = 23;
|
||||
static constexpr const int kDefaultResizeBorderThickness = 8;
|
||||
static constexpr const int kDefaultCaptionHeight = 23;
|
||||
|
||||
int Utilities::getSystemMetric(const QWindow *window, const SystemMetric metric, const bool dpiScale, const bool forceSystemValue)
|
||||
{
|
||||
|
|
|
@ -266,7 +266,7 @@ void Utilities::triggerFrameChange(const WId winId)
|
|||
return;
|
||||
}
|
||||
const auto hwnd = reinterpret_cast<HWND>(winId);
|
||||
constexpr UINT flags = (SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER);
|
||||
static constexpr const UINT flags = (SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER);
|
||||
if (SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, flags) == FALSE) {
|
||||
qWarning() << getSystemErrorMessage(QStringLiteral("SetWindowPos"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue