From fb776030fc1673bc22d8e9f8972ee9009438d6a3 Mon Sep 17 00:00:00 2001
From: Sine Striker <trueful@163.com>
Date: 周三, 20 12月 2023 00:10:50 +0800
Subject: [PATCH] Remove redundant API anyway

---
 src/quick/quickwindowagent.h       |    6 ------
 src/widgets/widgetwindowagent.h    |    6 ------
 examples/mainwindow/mainwindow.cpp |    7 ++-----
 README.md                          |   11 +++++++----
 4 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/README.md b/README.md
index 094632f..7178ef6 100644
--- a/README.md
+++ b/README.md
@@ -108,8 +108,8 @@
 
 MyWidget::MyWidget(QWidget *parent) {
     // ...
-    auto agent = new QWK::WidgetWindowAgent(w);
-    agent->setup(w);
+    auto agent = new QWK::WidgetWindowAgent(this);
+    agent->setup(this);
     // ...
 }
 ```
@@ -132,7 +132,7 @@
 agent->setTitleBarWidget(myTitleBar);
 ```
 
-Set system button hints to let `WidgetWindowAgent` know the role of the child widgets, which is important for the Snap Layout to work.
+Next, set system button hints to let `WidgetWindowAgent` know the role of the child widgets, which is important for the Snap Layout to work.
 
 ```c++
 agent->setSystemButton(QWK::WindowAgentBase::WindowIcon, myTitleBar->iconButton());
@@ -140,8 +140,11 @@
 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.
 
-Set hit-test visible hint to let `WidgetWindowAgent` know the widgets that desire to receive mouse events.
+On macOS, this step can be skipped because it is more appropriate 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.
 
 ```c++
 agent->setHitTestVisible(myTitleBar->menuBar(), true);
diff --git a/examples/mainwindow/mainwindow.cpp b/examples/mainwindow/mainwindow.cpp
index c3c133b..e0df17e 100644
--- a/examples/mainwindow/mainwindow.cpp
+++ b/examples/mainwindow/mainwindow.cpp
@@ -107,11 +107,8 @@
 
 void MainWindow::installWindowAgent() {
     // 1. Setup window agent
-    
-    // Equivalent to:
-    // auto agent = new QWK::WidgetWindowAgent(w);
-    // agent->setup(w);
-    QWK::WidgetWindowAgent *agent = QWK::setupWidgetWindow(this);
+    auto agent = new QWK::WidgetWindowAgent(this);
+    agent->setup(this);
 
     // 2. Construct your title bar
     auto menuBar = []() {
diff --git a/src/quick/quickwindowagent.h b/src/quick/quickwindowagent.h
index 95220c0..4d6160b 100644
--- a/src/quick/quickwindowagent.h
+++ b/src/quick/quickwindowagent.h
@@ -38,12 +38,6 @@
         QuickWindowAgent(QuickWindowAgentPrivate &d, QObject *parent = nullptr);
     };
 
-    inline QuickWindowAgent *setupQuickWindow(QQuickWindow *window) {
-        auto agent = new QuickWindowAgent(window);
-        agent->setup(window);
-        return agent;
-    }
-
 }
 
 #endif // QUICKWINDOWAGENT_H
\ No newline at end of file
diff --git a/src/widgets/widgetwindowagent.h b/src/widgets/widgetwindowagent.h
index 9938b1a..ea20025 100644
--- a/src/widgets/widgetwindowagent.h
+++ b/src/widgets/widgetwindowagent.h
@@ -42,12 +42,6 @@
         WidgetWindowAgent(WidgetWindowAgentPrivate &d, QObject *parent = nullptr);
     };
 
-    inline WidgetWindowAgent *setupWidgetWindow(QWidget *w) {
-        auto agent = new WidgetWindowAgent(w);
-        agent->setup(w);
-        return agent;
-    }
-
 }
 
 #endif // WIDGETWINDOWAGENT_H
\ No newline at end of file

--
Gitblit v1.9.1