From 6eb2efea00eb07ce3a6b089b984885ce4a08c9ca Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: 周五, 29 12月 2023 20:55:09 +0800 Subject: [PATCH] Add WinRegKey support --- src/widgets/widgetwindowagent_mac.cpp | 30 +++++++++++++++++++++++++++--- 1 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/widgets/widgetwindowagent_mac.cpp b/src/widgets/widgetwindowagent_mac.cpp index 1d4f320..d3cb1ba 100644 --- a/src/widgets/widgetwindowagent_mac.cpp +++ b/src/widgets/widgetwindowagent_mac.cpp @@ -14,6 +14,9 @@ QObject *parent = nullptr) : QObject(parent), widget(widget), ctx(ctx) { widget->installEventFilter(this); + ctx->setSystemButtonAreaCallback([widget](const QSize &) { + return getWidgetSceneRect(widget); // + }); } ~SystemButtonAreaWidgetEventFilter() override = default; @@ -23,7 +26,7 @@ switch (event->type()) { case QEvent::Move: case QEvent::Resize: { - ctx->setSystemButtonArea(getWidgetSceneRect(widget)); + ctx->virtual_hook(AbstractWindowContext::SystemButtonAreaChangedHook, nullptr); break; } @@ -49,6 +52,8 @@ /*! Sets the widget that acts as the system button area. The system button will be centered in its area, it is recommended to place the widget in a layout and set a fixed size policy. + + The system button will be visible in the system title bar area. */ void WidgetWindowAgent::setSystemButtonArea(QWidget *widget) { Q_D(WidgetWindowAgent); @@ -58,13 +63,32 @@ auto ctx = d->context.get(); d->systemButtonAreaWidget = widget; if (!widget) { + d->context->setSystemButtonAreaCallback({}); d->systemButtonAreaWidgetEventFilter.reset(); - ctx->setSystemButtonArea({}); return; } d->systemButtonAreaWidgetEventFilter = std::make_unique<SystemButtonAreaWidgetEventFilter>(widget, ctx); - ctx->setSystemButtonArea(getWidgetSceneRect(widget)); + } + + /*! + Returns the the system button area callback. + */ + ScreenRectCallback WidgetWindowAgent::systemButtonAreaCallback() const { + Q_D(const WidgetWindowAgent); + return d->systemButtonAreaWidget ? nullptr : d->context->systemButtonAreaCallback(); + } + + /*! + Sets the the system button area callback, the \c size of the callback is the native title + bar size. + + The system button position will be updated when the window resizes. + */ + void WidgetWindowAgent::setSystemButtonAreaCallback(const ScreenRectCallback &callback) { + Q_D(WidgetWindowAgent); + setSystemButtonArea(nullptr); + d->context->setSystemButtonAreaCallback(callback); } } \ No newline at end of file -- Gitblit v1.9.1