From a5372ac566469efb59e6cfb29a695021c7c3528d Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: 周三, 20 12月 2023 00:53:42 +0800 Subject: [PATCH] Add TODO --- src/core/kernel/systemwindow_p.h | 6 +++--- src/core/contexts/cocoawindowcontext.mm | 26 +++++++++++++++++++++++--- README.md | 8 ++++---- src/core/contexts/win32windowcontext.cpp | 2 +- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 7178ef6..f4aff2a 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ | Component | Requirement | Details | |:---------:|:-----------:|:-------------------------:| -| Qt | \>=5.15 | Core, Gui, Widgets, Quick | +| Qt | \>=5.12 | Core, Gui, Widgets, Quick | | Compiler | \>=C++17 | MSVC 2019, GCC, Clang | | CMake | \>=3.17 | >=3.20 is recommended | @@ -140,9 +140,9 @@ agent->setSystemButton(QWK::WindowAgentBase::Maximize, myTitleBar->maxButton()); agent->setSystemButton(QWK::WindowAgentBase::Close, myTitleBar->closeButton()); ``` -Doing this does not mean that these buttons' click events are automatically associated with window events, you still need to manually connect the signals and slots to emulate the native window's behaviors. +Doing this does not mean that these buttons' click events are automatically associated with window actions, you still need to manually connect the signals and slots to emulate the native window behaviors. -On macOS, this step can be skipped because it is more appropriate to use the buttons provided by the system. +On macOS, this step can be skipped because it is better to use the buttons provided by the system. Last but not least, set hit-test visible hint to let `WidgetWindowAgent` know other widgets that desire to receive mouse events. @@ -156,7 +156,7 @@ ### Qt Quick Application -Make sure you have registered QWK into QtQuick: +Make sure you have registered `QWindowKit` into QtQuick: ```cpp #include <QWKQuick/qwkquickglobal.h> diff --git a/src/core/contexts/cocoawindowcontext.mm b/src/core/contexts/cocoawindowcontext.mm index 9add515..9723d5a 100644 --- a/src/core/contexts/cocoawindowcontext.mm +++ b/src/core/contexts/cocoawindowcontext.mm @@ -369,12 +369,32 @@ void CocoaWindowContext::virtual_hook(int id, void *data) { switch (id) { - case ShowSystemMenuHook: + case ShowSystemMenuHook: { // TODO: mac system menu return; - case SystemButtonAreaChangedHook: + } + + case SystemButtonAreaChangedHook: { // TODO: mac system button rect updated return; + } + + case WindowAttributeChangedHook: { + auto args = static_cast<void **>(data); + const auto &key = *static_cast<const QString *>(args[0]); + const auto &newVar = *static_cast<const QVariant *>(args[1]); + const auto &oldVar = *static_cast<const QVariant *>(args[2]); + + if (key == QStringLiteral("no-system-buttons")) { + if (newVar.toBool()) { + // TODO: set off + } else { + // TODO: set on + } + } + break; + } + default: break; } @@ -386,7 +406,7 @@ if (!m_windowHandle) { return; } - + windowId = m_windowHandle->winId(); ensureWindowProxy(windowId)->setSystemTitleBarVisible(false); cocoaWindowEventFilter = std::make_unique<CocoaWindowEventFilter>(this, this); diff --git a/src/core/contexts/win32windowcontext.cpp b/src/core/contexts/win32windowcontext.cpp index cd1ab62..230bf5d 100644 --- a/src/core/contexts/win32windowcontext.cpp +++ b/src/core/contexts/win32windowcontext.cpp @@ -902,7 +902,7 @@ const auto &key = *static_cast<const QString *>(args[0]); const auto &newVar = *static_cast<const QVariant *>(args[1]); const auto &oldVar = *static_cast<const QVariant *>(args[2]); - + if (key == QStringLiteral("no-frame-shadow")) { if (newVar.toBool()) { // TODO: set off diff --git a/src/core/kernel/systemwindow_p.h b/src/core/kernel/systemwindow_p.h index 567b993..51e12c2 100644 --- a/src/core/kernel/systemwindow_p.h +++ b/src/core/kernel/systemwindow_p.h @@ -45,7 +45,7 @@ target->setPosition(target->x(), 0); } target->removeEventFilter(this); - this->deleteLater(); + deleteLater(); } default: @@ -99,7 +99,7 @@ case QEvent::MouseButtonRelease: { target->removeEventFilter(this); - this->deleteLater(); + deleteLater(); } default: @@ -120,7 +120,7 @@ // QWindow::startSystemMove() and QWindow::startSystemResize() is first supported at Qt 5.15 // QWindow::startSystemResize() returns false on macOS // QWindow::startSystemMove() and QWindow::startSystemResize() returns false on Linux Unity DE - + // When the new API fails, we emulate the window actions using the classical API. static inline void startSystemMove(QWindow *window) { -- Gitblit v1.9.1