From 44fee9aa1e3087635d1394612c6f6ceab44ba7b0 Mon Sep 17 00:00:00 2001 From: Zhao Yuhang <2546789017@qq.com> Date: 周一, 18 12月 2023 20:11:42 +0800 Subject: [PATCH] minor improve quick demo --- examples/qml/main.qml | 80 ++++++++++++++++++++++++++++++++++++++-- 1 files changed, 76 insertions(+), 4 deletions(-) diff --git a/examples/qml/main.qml b/examples/qml/main.qml index e063bc5..8f1f15a 100644 --- a/examples/qml/main.qml +++ b/examples/qml/main.qml @@ -1,8 +1,80 @@ -import QtQuick +import QtQuick 2.15 +import QtQuick.Window 2.15 +import QtQuick.Controls 2.15 +import QWindowKit 1.0 Window { id: window - visible: true - width: 640 - height: 480 + width: 800 + height: 600 + color: "#f0f0f0" + title: qsTr("Hello, world!") + Component.onCompleted: { + windowAgent.setup(window) + window.visible = true + } + + WindowAgent { + id: windowAgent + } + + Rectangle { + id: titleBar + anchors { + top: parent.top + topMargin: 1 + left: parent.left + right: parent.right + } + height: 32 + color: "white" + Component.onCompleted: windowAgent.setTitleBar(titleBar) + + Text { + anchors.centerIn: parent + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + text: window.title + font.pixelSize: 14 + color: window.active ? "black" : "gray" + } + + Row { + anchors { + top: parent.top + right: parent.right + } + height: parent.height + + QWKButton { + id: minButton + height: parent.height + source: "qrc:///window-bar/minimize.svg" + onClicked: window.showMinimized() + Component.onCompleted: windowAgent.setHitTestVisible(minButton) + } + + QWKButton { + id: maxButton + height: parent.height + source: window.visibility === Window.Maximized ? "qrc:///window-bar/restore.svg" : "qrc:///window-bar/maximize.svg" + onClicked: { + if (window.visibility === Window.Maximized) { + window.showNormal() + } else { + window.showMaximized() + } + } + Component.onCompleted: windowAgent.setHitTestVisible(maxButton) + } + + QWKButton { + id: closeButton + height: parent.height + source: "qrc:///window-bar/close.svg" + onClicked: window.close() + Component.onCompleted: windowAgent.setHitTestVisible(closeButton) + } + } + } } \ No newline at end of file -- Gitblit v1.9.1