From 782a52020a9823bb7dc744ab20849f2558b64652 Mon Sep 17 00:00:00 2001
From: Sine Striker <trueful@163.com>
Date: 周六, 14 12月 2024 17:23:54 +0800
Subject: [PATCH] Update WinRegistry

---
 examples/qml/main.qml |  129 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 127 insertions(+), 2 deletions(-)

diff --git a/examples/qml/main.qml b/examples/qml/main.qml
index b266921..d9ba183 100644
--- a/examples/qml/main.qml
+++ b/examples/qml/main.qml
@@ -1,17 +1,28 @@
 import QtQuick 2.15
 import QtQuick.Window 2.15
 import QtQuick.Controls 2.15
+import Qt.labs.platform 1.1
 import QWindowKit 1.0
 
 Window {
     id: window
     width: 800
     height: 600
-    color: "#1E1E1E"
+    color: darkStyle.windowBackgroundColor
     title: qsTr("Hello, world!")
     Component.onCompleted: {
         windowAgent.setup(window)
+        windowAgent.setWindowAttribute("dark-mode", true)
         window.visible = true
+    }
+
+    QtObject {
+        id: lightStyle
+    }
+
+    QtObject {
+        id: darkStyle
+        readonly property color windowBackgroundColor: "#1E1E1E"
     }
 
     Timer {
@@ -25,11 +36,15 @@
         id: windowAgent
     }
 
+    TapHandler {
+        acceptedButtons: Qt.RightButton
+        onTapped: contextMenu.open()
+    }
+
     Rectangle {
         id: titleBar
         anchors {
             top: parent.top
-            topMargin: 1
             left: parent.left
             right: parent.right
         }
@@ -48,6 +63,8 @@
             height: 18
             mipmap: true
             source: "qrc:///app/example.png"
+            fillMode: Image.PreserveAspectFit
+            Component.onCompleted: windowAgent.setSystemButton(WindowAgent.WindowIcon, iconButton)
         }
 
         Text {
@@ -124,5 +141,113 @@
             bold: true
         }
         color: "#FEFEFE"
+        Component.onCompleted: {
+            if ($curveRenderingAvailable) {
+                timeLabel.renderType = Text.CurveRendering
+            }
+        }
+    }
+
+    Menu {
+        id: contextMenu
+
+        Menu {
+            id: themeMenu
+            title: qsTr("Theme")
+
+            MenuItemGroup {
+                id: themeMenuGroup
+                items: themeMenu.items
+            }
+
+            MenuItem {
+                text: qsTr("Light")
+                checkable: true
+                onTriggered: windowAgent.setWindowAttribute("dark-mode", false)
+            }
+
+            MenuItem {
+                text: qsTr("Dark")
+                checkable: true
+                checked: true
+                onTriggered: windowAgent.setWindowAttribute("dark-mode", true)
+            }
+        }
+
+        Menu {
+            id: specialEffectMenu
+            title: qsTr("Special effect")
+
+            MenuItemGroup {
+                id: specialEffectMenuGroup
+                items: specialEffectMenu.items
+            }
+
+            MenuItem {
+                enabled: Qt.platform.os === "windows"
+                text: qsTr("None")
+                checkable: true
+                checked: true
+                onTriggered: {
+                    window.color = darkStyle.windowBackgroundColor
+                    windowAgent.setWindowAttribute("dwm-blur", false)
+                    windowAgent.setWindowAttribute("acrylic-material", false)
+                    windowAgent.setWindowAttribute("mica", false)
+                    windowAgent.setWindowAttribute("mica-alt", false)
+                }
+            }
+
+            MenuItem {
+                enabled: Qt.platform.os === "windows"
+                text: qsTr("DWM blur")
+                checkable: true
+                onTriggered: {
+                    window.color = "transparent"
+                    windowAgent.setWindowAttribute("acrylic-material", false)
+                    windowAgent.setWindowAttribute("mica", false)
+                    windowAgent.setWindowAttribute("mica-alt", false)
+                    windowAgent.setWindowAttribute("dwm-blur", true)
+                }
+            }
+
+            MenuItem {
+                enabled: Qt.platform.os === "windows"
+                text: qsTr("Acrylic material")
+                checkable: true
+                onTriggered: {
+                    window.color = "transparent"
+                    windowAgent.setWindowAttribute("dwm-blur", false)
+                    windowAgent.setWindowAttribute("mica", false)
+                    windowAgent.setWindowAttribute("mica-alt", false)
+                    windowAgent.setWindowAttribute("acrylic-material", true)
+                }
+            }
+
+            MenuItem {
+                enabled: Qt.platform.os === "windows"
+                text: qsTr("Mica")
+                checkable: true
+                onTriggered: {
+                    window.color = "transparent"
+                    windowAgent.setWindowAttribute("dwm-blur", false)
+                    windowAgent.setWindowAttribute("acrylic-material", false)
+                    windowAgent.setWindowAttribute("mica-alt", false)
+                    windowAgent.setWindowAttribute("mica", true)
+                }
+            }
+
+            MenuItem {
+                enabled: Qt.platform.os === "windows"
+                text: qsTr("Mica Alt")
+                checkable: true
+                onTriggered: {
+                    window.color = "transparent"
+                    windowAgent.setWindowAttribute("dwm-blur", false)
+                    windowAgent.setWindowAttribute("acrylic-material", false)
+                    windowAgent.setWindowAttribute("mica", false)
+                    windowAgent.setWindowAttribute("mica-alt", true)
+                }
+            }
+        }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1