2022-12-21 10:22:48 +08:00
|
|
|
|
import QtQuick 2.0
|
|
|
|
|
import org.ukui.menu.core 1.0
|
2024-01-08 17:25:27 +08:00
|
|
|
|
import org.ukui.quick.items 1.0 as UkuiItems
|
2024-01-18 03:24:01 +08:00
|
|
|
|
import org.ukui.quick.platform 1.0 as Platform
|
2022-12-21 10:22:48 +08:00
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
property int display: Display.TextUnderIcon
|
|
|
|
|
// 上下布局icon大小为48*48 左右布局icon大小为32*32
|
|
|
|
|
property int iconHeight: 48
|
|
|
|
|
property int iconWidth: 48
|
|
|
|
|
property string appName: ""
|
|
|
|
|
property string appIcon: ""
|
|
|
|
|
// 上下布局spacing:0 左右布局spacing:12
|
|
|
|
|
property int spacing: 2
|
2023-02-20 17:23:08 +08:00
|
|
|
|
property bool textTruncated: iconText.truncated
|
2023-03-30 16:44:53 +08:00
|
|
|
|
property bool textHighLight: false
|
|
|
|
|
|
2022-12-21 10:22:48 +08:00
|
|
|
|
state: root.display
|
|
|
|
|
|
|
|
|
|
states: [
|
|
|
|
|
State {
|
|
|
|
|
name: Display.TextBesideIcon
|
2023-02-20 17:23:08 +08:00
|
|
|
|
PropertyChanges {
|
2022-12-21 10:22:48 +08:00
|
|
|
|
target: iconImage
|
|
|
|
|
anchors.verticalCenter: root.verticalCenter
|
2023-02-20 17:23:08 +08:00
|
|
|
|
anchors.left: root.left
|
|
|
|
|
anchors.leftMargin: root.spacing
|
2022-12-21 10:22:48 +08:00
|
|
|
|
}
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: iconText
|
2023-03-30 16:44:53 +08:00
|
|
|
|
width: root.width - iconImage.width - root.spacing * 2
|
2022-12-21 10:22:48 +08:00
|
|
|
|
|
2023-03-30 16:44:53 +08:00
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
2022-12-21 10:22:48 +08:00
|
|
|
|
anchors.left: iconImage.right
|
|
|
|
|
anchors.leftMargin: root.spacing
|
|
|
|
|
anchors.verticalCenter: root.verticalCenter
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
State {
|
|
|
|
|
name: Display.TextUnderIcon
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: iconImage
|
|
|
|
|
anchors.top: root.top
|
2023-03-30 16:44:53 +08:00
|
|
|
|
anchors.topMargin: (root.height - root.spacing - iconImage.height - iconText.height) / 2
|
2022-12-21 10:22:48 +08:00
|
|
|
|
anchors.horizontalCenter: root.horizontalCenter
|
|
|
|
|
}
|
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: iconText
|
2023-03-30 16:44:53 +08:00
|
|
|
|
width: root.width
|
2022-12-21 10:22:48 +08:00
|
|
|
|
|
2023-03-30 16:44:53 +08:00
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
2022-12-21 10:22:48 +08:00
|
|
|
|
anchors.top: iconImage.bottom
|
|
|
|
|
anchors.topMargin: root.spacing
|
|
|
|
|
anchors.horizontalCenter: root.horizontalCenter
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
2024-02-02 16:10:09 +08:00
|
|
|
|
UkuiItems.Icon {
|
2022-12-21 10:22:48 +08:00
|
|
|
|
id: iconImage
|
|
|
|
|
height: root.iconHeight
|
|
|
|
|
width: root.iconWidth
|
|
|
|
|
source: root.appIcon
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-08 17:25:27 +08:00
|
|
|
|
UkuiItems.StyleText {
|
2022-12-21 10:22:48 +08:00
|
|
|
|
id: iconText
|
|
|
|
|
text: root.appName
|
|
|
|
|
elide: Text.ElideRight
|
2024-01-08 17:25:27 +08:00
|
|
|
|
paletteRole: root.textHighLight ? Platform.Theme.HighlightedText : Platform.Theme.Text
|
2022-12-21 10:22:48 +08:00
|
|
|
|
}
|
|
|
|
|
}
|