FluentUI/Gallery/res/qml/component/base/IconDropdownButton.qml
yxdy ff15075c79
Some checks are pending
Gallery App Build / macOS (push) Waiting to run
Gallery App Build / Windows (push) Waiting to run
Gallery App Build / Ubuntu (push) Waiting to run
修改样式
2025-03-07 16:23:09 +08:00

147 lines
4.0 KiB
QML

import QtQuick 2.15
import QtQuick.Layouts
import QtQuick.Controls
import FluentUI.Controls
import FluentUI.impl
Rectangle {
id: control
color: "transparent"
radius: 5
property var p_img: "qrc:/qt/qml/Gallery/res/image/components/rect.png"
property var p_menu
property var p_others: []
signal clickItem(var type)
Image{
width: 15
height: 15
source: p_img
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
}
Image{
width: 5
height: 5
source: "qrc:/qt/qml/Gallery/res/image/components/down.png"
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.rightMargin: 3
anchors.bottomMargin: 3
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: parent.color = "#424242"
onExited: parent.color = "transparent"
}
Menu {
id:menu
width: 140
BaseMenuItem{
m_icon: "qrc:/qt/qml/Gallery/res/image/icons/point.png"
m_text: "点"
m_key: "P"
m_width: 16
m_height: 16
onClickItem: {
control.clickItem("StartAddPoint")
}
}
BaseMenuItem{
m_icon: "qrc:/qt/qml/Gallery/res/image/icons/curve.png"
m_text: "曲线"
m_key: "Q"
onClickItem: {
control.clickItem("StartCurve")
}
}
BaseMenuItem{
m_icon: "qrc:/qt/qml/Gallery/res/image/icons/polygon.png"
m_text: "多边形"
m_key: "D"
onClickItem: {
control.clickItem("StartAddPoly")
}
}
BaseMenuItem{
m_icon: "qrc:/qt/qml/Gallery/res/image/icons/triangle.png"
m_text: "三角形"
m_key: "T"
onClickItem: {
control.clickItem("StartTriangle")
}
}
BaseMenuItem{
m_icon: "qrc:/qt/qml/Gallery/res/image/icons/circle.png"
m_text: "圆"
m_key: "C"
onClickItem: {
control.clickItem("StartCircle")
}
}
BaseMenuItem{
m_icon: "qrc:/qt/qml/Gallery/res/image/icons/ellipse.png"
m_text: "椭圆"
m_key: "E"
onClickItem: {
control.clickItem("StartEllipse")
}
}
BaseMenuItem{
m_icon: "qrc:/qt/qml/Gallery/res/image/icons/free_line.png"
m_text: "自由线"
m_key: "L"
onClickItem: {
control.clickItem("StartFreeLine")
}
}
BaseMenuItem{
m_icon: "qrc:/qt/qml/Gallery/res/image/icons/free_area.png"
m_text: "自由面"
m_key: "A"
onClickItem: {
control.clickItem("StartFreeSurface")
}
}
}
Rectangle{
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.rightMargin: 4
anchors.bottomMargin: 4
width: 8
height: 8
color: "transparent"
MouseArea {
anchors.fill: parent
hoverEnabled: true
onExited: {
}
onEntered: {
if (!p_menu) {
for (var d of p_others) {
d.close()
}
menu.popup(control)
menu.x = -50
menu.y = 30
} else {
for (var d of p_others) {
d.close()
}
p_menu.popup(control)
p_menu.x = -50
p_menu.y = 30
}
}
}
}
}