Zhao Yuhang
2023-12-18 44fee9aa1e3087635d1394612c6f6ceab44ba7b0
minor improve quick demo
3个文件已修改
1个文件已添加
75 ■■■■■ 已修改文件
examples/qml/QWKButton.qml 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
examples/qml/main.cpp 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
examples/qml/main.qml 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
examples/qml/qml.qrc 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
examples/qml/QWKButton.qml
New file
@@ -0,0 +1,34 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
Button {
    id: root
    width: height * 1.5
    property alias source: image.source
    contentItem: Item {
        anchors.fill: parent
        Image {
            id: image
            anchors.centerIn: parent
            mipmap: true
            width: 10
            height: 10
        }
    }
    background: Rectangle {
        anchors.fill: parent
        color: {
            if (!root.enabled) {
                return "gray";
            }
            if (root.pressed) {
                return Qt.rgba(0, 0, 0, 0.15);
            }
            if (root.hovered) {
                return Qt.rgba(0, 0, 0, 0.15);
            }
            return "transparent";
        }
    }
}
examples/qml/main.cpp
@@ -6,6 +6,7 @@
int main(int argc, char *argv[]) {
    qputenv("QT_WIN_DEBUG_CONSOLE", "1");
    qputenv("QSG_INFO", "1");
    qputenv("QT_QUICK_CONTROLS_STYLE", "Basic");
#if 1
    qputenv("QSG_RHI_BACKEND", "d3d12");
    qputenv("QSG_RHI_HDR", "scrgb");
examples/qml/main.qml
@@ -22,6 +22,7 @@
        id: titleBar
        anchors {
            top: parent.top
            topMargin: 1
            left: parent.left
            right: parent.right
        }
@@ -37,5 +38,43 @@
            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)
            }
        }
    }
}
examples/qml/qml.qrc
@@ -1,5 +1,6 @@
<RCC>
    <qresource prefix="/">
        <file>main.qml</file>
        <file>QWKButton.qml</file>
    </qresource>
</RCC>