From 6500aae0d32383a988aff9fb680d58a851012a14 Mon Sep 17 00:00:00 2001 From: Zhao Yuhang <2546789017@qq.com> Date: 周一, 18 12月 2023 20:59:09 +0800 Subject: [PATCH] finish quick demo --- examples/qml/main.qml | 62 +++++++++++++++++++++++++++--- examples/qml/main.cpp | 6 ++ examples/qml/QWKButton.qml | 15 +++++-- 3 files changed, 70 insertions(+), 13 deletions(-) diff --git a/examples/qml/QWKButton.qml b/examples/qml/QWKButton.qml index 9068242..91569f7 100644 --- a/examples/qml/QWKButton.qml +++ b/examples/qml/QWKButton.qml @@ -4,20 +4,25 @@ Button { id: root width: height * 1.5 + leftPadding: 0 + topPadding: 0 + rightPadding: 0 + bottomPadding: 0 + leftInset: 0 + topInset: 0 + rightInset: 0 + bottomInset: 0 property alias source: image.source contentItem: Item { - anchors.fill: parent - Image { id: image anchors.centerIn: parent mipmap: true - width: 10 - height: 10 + width: 12 + height: 12 } } background: Rectangle { - anchors.fill: parent color: { if (!root.enabled) { return "gray"; diff --git a/examples/qml/main.cpp b/examples/qml/main.cpp index dba5d17..75ca6e2 100644 --- a/examples/qml/main.cpp +++ b/examples/qml/main.cpp @@ -6,8 +6,12 @@ int main(int argc, char *argv[]) { qputenv("QT_WIN_DEBUG_CONSOLE", "1"); qputenv("QSG_INFO", "1"); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) qputenv("QT_QUICK_CONTROLS_STYLE", "Basic"); -#if 1 +#else + qputenv("QT_QUICK_CONTROLS_STYLE", "Default"); +#endif +#if 0 qputenv("QSG_RHI_BACKEND", "d3d12"); qputenv("QSG_RHI_HDR", "scrgb"); qputenv("QT_QPA_DISABLE_REDIRECTION_SURFACE", "1"); diff --git a/examples/qml/main.qml b/examples/qml/main.qml index 8f1f15a..b266921 100644 --- a/examples/qml/main.qml +++ b/examples/qml/main.qml @@ -7,11 +7,18 @@ id: window width: 800 height: 600 - color: "#f0f0f0" + color: "#1E1E1E" title: qsTr("Hello, world!") Component.onCompleted: { windowAgent.setup(window) window.visible = true + } + + Timer { + interval: 100 + running: true + repeat: true + onTriggered: timeLabel.text = Qt.formatTime(new Date(), "hh:mm:ss") } WindowAgent { @@ -27,16 +34,33 @@ right: parent.right } height: 32 - color: "white" + color: window.active ? "#3C3C3C" : "#505050" Component.onCompleted: windowAgent.setTitleBar(titleBar) + Image { + id: iconButton + anchors { + verticalCenter: parent.verticalCenter + left: parent.left + leftMargin: 10 + } + width: 18 + height: 18 + mipmap: true + source: "qrc:///app/example.png" + } + Text { - anchors.centerIn: parent + anchors { + verticalCenter: parent.verticalCenter + left: iconButton.right + leftMargin: 10 + } horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter text: window.title font.pixelSize: 14 - color: window.active ? "black" : "gray" + color: "#ECECEC" } Row { @@ -51,7 +75,7 @@ height: parent.height source: "qrc:///window-bar/minimize.svg" onClicked: window.showMinimized() - Component.onCompleted: windowAgent.setHitTestVisible(minButton) + Component.onCompleted: windowAgent.setSystemButton(WindowAgent.Minimize, minButton) } QWKButton { @@ -65,16 +89,40 @@ window.showMaximized() } } - Component.onCompleted: windowAgent.setHitTestVisible(maxButton) + Component.onCompleted: windowAgent.setSystemButton(WindowAgent.Maximize, maxButton) } QWKButton { id: closeButton height: parent.height source: "qrc:///window-bar/close.svg" + background: Rectangle { + color: { + if (!closeButton.enabled) { + return "gray"; + } + if (closeButton.pressed) { + return "#e81123"; + } + if (closeButton.hovered) { + return "#e81123"; + } + return "transparent"; + } + } onClicked: window.close() - Component.onCompleted: windowAgent.setHitTestVisible(closeButton) + Component.onCompleted: windowAgent.setSystemButton(WindowAgent.Close, closeButton) } } } + + Label { + id: timeLabel + anchors.centerIn: parent + font { + pointSize: 75 + bold: true + } + color: "#FEFEFE" + } } \ No newline at end of file -- Gitblit v1.9.1