ui: 使用UkuiItems.Button实现按钮

This commit is contained in:
hewenfei 2023-11-29 15:50:17 +08:00
parent 26b436d98a
commit 5f879bab40
1 changed files with 13 additions and 43 deletions

View File

@ -35,8 +35,9 @@ Item {
anchors.bottomMargin: 12 anchors.bottomMargin: 12
spacing: 0 spacing: 0
MouseArea { UkuiItems.Button {
id: fullScreenbutton id: fullScreenbutton
visible: !isLiteMode
Layout.preferredWidth: 36 Layout.preferredWidth: 36
Layout.preferredHeight: 36 Layout.preferredHeight: 36
@ -46,10 +47,6 @@ Item {
ToolTip.text: qsTr("Expand") ToolTip.text: qsTr("Expand")
ToolTip.visible: containsMouse ToolTip.visible: containsMouse
visible: !isLiteMode
hoverEnabled: true
activeFocusOnTab: true
onClicked: mainWindow.isFullScreen = true onClicked: mainWindow.isFullScreen = true
Keys.onPressed: { Keys.onPressed: {
if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) { if (event.key === Qt.Key_Enter || event.key === Qt.Key_Return) {
@ -57,24 +54,12 @@ Item {
} }
} }
UkuiItems.StyleBackground { background.radius: 4
anchors.fill: parent icon.mode: UkuiItems.Icon.AutoHighlight
radius: 4 icon.source: "view-fullscreen-symbolic"
useStyleTransparency: false
paletteRole: UkuiItems.Theme.Button
alpha: parent.containsPress ? 1 : parent.containsMouse ? 0.7 : 0
borderColor: UkuiItems.Theme.Highlight
border.width: parent.activeFocus ? 2 : 0
ThemeIcon {
anchors.centerIn: parent
width: 16; height: 16
source: "view-fullscreen-symbolic"
}
}
} }
MouseArea { UkuiItems.Button {
id: powerButton id: powerButton
Layout.preferredWidth: 36 Layout.preferredWidth: 36
Layout.preferredHeight: 36 Layout.preferredHeight: 36
@ -84,8 +69,10 @@ Item {
ToolTip.visible: containsMouse ToolTip.visible: containsMouse
ToolTip.text: powerButtonBase.toolTip ToolTip.text: powerButtonBase.toolTip
hoverEnabled: true PowerButton {
activeFocusOnTab: true id: powerButtonBase
}
acceptedButtons: Qt.LeftButton | Qt.RightButton acceptedButtons: Qt.LeftButton | Qt.RightButton
property int spacingFromMenu: 16 property int spacingFromMenu: 16
@ -100,26 +87,9 @@ Item {
powerButtonBase.clicked(mouse.button === Qt.LeftButton, buttonPosition.x + spacingFromMenu, buttonPosition.y + spacingFromMenu, mainWindow.isFullScreen); powerButtonBase.clicked(mouse.button === Qt.LeftButton, buttonPosition.x + spacingFromMenu, buttonPosition.y + spacingFromMenu, mainWindow.isFullScreen);
} }
UkuiItems.StyleBackground { background.radius: 4
anchors.fill: parent icon.mode: UkuiItems.Icon.AutoHighlight
paletteRole: UkuiItems.Theme.Button icon.source: powerButtonBase.icon
useStyleTransparency: false
alpha: parent.containsPress ? 1 : parent.containsMouse ? 0.7 : 0
radius: 4
borderColor: UkuiItems.Theme.Highlight
border.width: parent.activeFocus ? 2 : 0
PowerButton {
id: powerButtonBase
}
ThemeIcon {
anchors.centerIn: parent
width: 16
height: 16
source: powerButtonBase.icon
}
}
} }
} }
} }