From 1a1f26d9e4ab6a4fe51baa78e40c4cdf3f402bcf Mon Sep 17 00:00:00 2001
From: Sine Striker <trueful@163.com>
Date: 摹曛, 07 12月 2023 14:27:00 +0800
Subject: [PATCH] Add context factory

---
 src/core/corewindowagent.cpp |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/core/corewindowagent.cpp b/src/core/corewindowagent.cpp
index bea2239..d5dff5a 100644
--- a/src/core/corewindowagent.cpp
+++ b/src/core/corewindowagent.cpp
@@ -21,15 +21,20 @@
     void CoreWindowAgentPrivate::init() {
     }
 
-    bool CoreWindowAgentPrivate::setup(QObject *host, WindowItemDelegate *delegate) {
-        auto ctx =
+    AbstractWindowContext *CoreWindowAgentPrivate::createContext() const {
+        return
 #ifdef Q_OS_WINDOWS
-            std::make_unique<Win32WindowContext>(host, delegate)
+            new Win32WindowContext()
 #else
-            std::make_unique<QtWindowContext>(host, window, delegate)
+            new QtWindowContext()
 #endif
-            ;
-        if (!ctx->setup()) {
+                ;
+    }
+
+
+    bool CoreWindowAgentPrivate::setup(QObject *host, WindowItemDelegate *delegate) {
+        std::unique_ptr<AbstractWindowContext> ctx(createContext());
+        if (!ctx->setup(host, delegate)) {
             return false;
         }
         context = std::move(ctx);

--
Gitblit v1.9.1