110 lines
3.6 KiB
QML
110 lines
3.6 KiB
QML
/*
|
|
* Copyright (C) 2023, KylinSoft Co., Ltd.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
onClicked: viewHide.start();
|
|
}
|
|
|
|
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 && !model.isDisable) ? 0.82 : (itemMouseArea.containsMouse && !model.isDisable) ? 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: !model.isDisable
|
|
onClicked: {
|
|
if (!model.isDisable) {
|
|
viewHide.start();
|
|
root.labelSelected(model.id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|