ukui-menu/qml/AppUI/SelectionPage.qml

86 lines
2.7 KiB
QML
Raw Normal View History

import QtQuick 2.12
import QtQuick.Layouts 1.2
import org.ukui.menu.core 1.0
import AppControls2 1.0 as AppControls2
Item {
id: root
signal viewHideFinished()
signal labelSelected(string labelId)
function viewShowStart() {
viewShow.start();
}
ParallelAnimation {
id: viewShow
NumberAnimation { target: selectionArea; property: "scale"; easing.type: Easing.InOutCubic; from: 1.5; to: 1.0; duration: 300}
NumberAnimation { target: selectionArea; property: "opacity"; easing.type: Easing.InOutCubic; from: 0; to: 1.0; duration: 300}
}
ParallelAnimation {
id: viewHide
NumberAnimation { target: selectionArea; property: "scale"; easing.type: Easing.InOutCubic; from: 1.0; to: 1.5 ;duration: 300}
NumberAnimation { target: selectionArea; property: "opacity"; easing.type: Easing.InOutCubic; from: 1.0; to: 0 ;duration: 300}
onFinished: {
viewHideFinished();
}
}
GridView {
id: selectionArea
anchors.centerIn: parent
interactive: false
property int itemWidth: 0
property int itemHeight: 40
cellWidth: itemWidth; cellHeight: itemHeight
state: count < 20 ? "functionArea" : "AlphabetArea"
states: [
State {
name: "functionArea"
PropertyChanges { target: selectionArea; itemWidth: 80; width: itemWidth * 2; height: itemHeight * 7 }
},
State {
name: "AlphabetArea"
PropertyChanges { target: selectionArea; itemWidth: 40; width: itemWidth * 5; height: itemHeight * 6 }
}
]
model: modelManager.getLabelModel()
onCountChanged: {
if (count === 0) {
viewHide.start();
}
}
delegate: AppControls2.StyleBackground {
height: selectionArea.itemHeight; width: selectionArea.itemWidth
alpha: itemMouseArea.containsPress ? 0.82 : itemMouseArea.containsMouse ? 0.55 : 0.00
useStyleTransparent: false
radius: 8
AppControls2.StyleText {
anchors.fill: parent
text: model.displayName
alpha: model.isDisable ? 0.2 : 0.9
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
MouseArea {
id: itemMouseArea
anchors.fill: parent
hoverEnabled: true
visible: !model.isDisable
onClicked: {
viewHide.start();
root.labelSelected(model.id);
}
}
}
}
}