shift-shell/components/mobileshell/qml/navigationpanel/NavigationPanel.qml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

220 lines
6.6 KiB
QML
Raw Normal View History

2021-10-31 04:11:10 +00:00
/*
* SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
2023-05-13 02:07:48 +00:00
import QtQuick
import QtQuick.Layouts
import QtQuick.Window
import QtQuick.Effects
2021-10-31 04:11:10 +00:00
import org.kde.kirigami 2.20 as Kirigami
2021-10-31 04:11:10 +00:00
import org.kde.taskmanager 0.1 as TaskManager
import org.kde.kquickcontrolsaddons 2.0
import org.kde.plasma.private.mobileshell.state as MobileShellState
2021-10-31 04:11:10 +00:00
Item {
id: root
property bool shadow: false
2021-10-31 04:11:10 +00:00
property color backgroundColor
property var foregroundColorGroup
property NavigationPanelAction leftAction
property NavigationPanelAction middleAction
property NavigationPanelAction rightAction
property NavigationPanelAction leftCornerAction
property NavigationPanelAction rightCornerAction
2023-05-13 02:07:48 +00:00
property bool isVertical: false
2023-05-13 02:07:48 +00:00
// drop shadow for icons
MultiEffect {
anchors.fill: root
visible: shadow
2021-10-31 04:11:10 +00:00
source: icons
2023-05-13 02:07:48 +00:00
blurMax: 16
shadowEnabled: true
shadowVerticalOffset: 1
shadowOpacity: 0.8
2021-10-31 04:11:10 +00:00
}
Item {
id: icons
anchors.fill: parent
2021-10-31 04:11:10 +00:00
property real buttonLength: 0
2021-10-31 04:11:10 +00:00
// background colour
Rectangle {
anchors.fill: parent
color: root.backgroundColor
}
2021-10-31 04:11:10 +00:00
// button row (anchors provided by state)
NavigationPanelButton {
id: leftButton
visible: root.leftAction.visible
Kirigami.Theme.colorSet: root.foregroundColorGroup
Kirigami.Theme.inherit: false
enabled: root.leftAction.enabled
iconSizeFactor: root.leftAction.iconSizeFactor
iconSource: root.leftAction.iconSource
onClicked: {
if (enabled) {
root.leftAction.triggered();
2021-10-31 04:11:10 +00:00
}
}
}
NavigationPanelButton {
id: middleButton
anchors.centerIn: parent
visible: root.middleAction.visible
Kirigami.Theme.colorSet: root.foregroundColorGroup
Kirigami.Theme.inherit: false
enabled: root.middleAction.enabled
iconSizeFactor: root.middleAction.iconSizeFactor
iconSource: root.middleAction.iconSource
onClicked: {
if (enabled) {
root.middleAction.triggered();
2021-10-31 04:11:10 +00:00
}
}
}
2021-10-31 04:11:10 +00:00
NavigationPanelButton {
id: rightButton
visible: root.rightAction.visible
Kirigami.Theme.colorSet: root.foregroundColorGroup
Kirigami.Theme.inherit: false
enabled: root.rightAction.enabled
iconSizeFactor: root.rightAction.iconSizeFactor
iconSource: root.rightAction.iconSource
onClicked: {
if (enabled) {
root.rightAction.triggered();
2021-10-31 04:11:10 +00:00
}
}
}
2021-10-31 04:11:10 +00:00
NavigationPanelButton {
id: rightCornerButton
visible: root.rightCornerAction.visible
Kirigami.Theme.colorSet: root.foregroundColorGroup
Kirigami.Theme.inherit: false
enabled: root.rightCornerAction.enabled
iconSizeFactor: root.rightCornerAction.iconSizeFactor
iconSource: root.rightCornerAction.iconSource
onClicked: {
if (enabled) {
root.rightCornerAction.triggered();
}
}
2021-10-31 04:11:10 +00:00
}
}
states: [
State {
name: "vertical"
when: root.isVertical
2021-10-31 04:11:10 +00:00
PropertyChanges {
target: icons
buttonLength: Math.min(Kirigami.Units.gridUnit * 10, icons.height * 0.7 / 3)
2021-10-31 04:11:10 +00:00
}
AnchorChanges {
target: leftButton
anchors {
horizontalCenter: parent.horizontalCenter
top: middleButton.bottom
2021-10-31 04:11:10 +00:00
}
}
PropertyChanges {
target: leftButton
width: parent.width
height: icons.buttonLength
}
PropertyChanges {
target: middleButton
width: parent.width
height: icons.buttonLength
}
AnchorChanges {
target: rightButton
anchors {
horizontalCenter: parent.horizontalCenter
bottom: middleButton.top
2021-10-31 04:11:10 +00:00
}
}
PropertyChanges {
target: rightButton
height: icons.buttonLength
width: icons.width
}
AnchorChanges {
target: rightCornerButton
anchors {
horizontalCenter: parent.horizontalCenter
top: parent.top
}
}
PropertyChanges {
target: rightCornerButton
height: Kirigami.Units.gridUnit * 2
width: icons.width
}
2021-10-31 04:11:10 +00:00
}, State {
name: "horizontal"
when: !root.isVertical
2021-10-31 04:11:10 +00:00
PropertyChanges {
target: icons
buttonLength: Math.min(Kirigami.Units.gridUnit * 8, icons.width * 0.7 / 3)
2021-10-31 04:11:10 +00:00
}
AnchorChanges {
target: leftButton
anchors {
verticalCenter: parent.verticalCenter
right: middleButton.left
2021-10-31 04:11:10 +00:00
}
}
PropertyChanges {
target: leftButton
height: parent.height
width: icons.buttonLength
}
PropertyChanges {
target: middleButton
height: parent.height
width: icons.buttonLength
}
AnchorChanges {
target: rightButton
anchors {
verticalCenter: parent.verticalCenter
left: middleButton.right
2021-10-31 04:11:10 +00:00
}
}
PropertyChanges {
target: rightButton
height: parent.height
width: icons.buttonLength
}
AnchorChanges {
target: rightCornerButton
anchors {
verticalCenter: parent.verticalCenter
right: parent.right
}
}
PropertyChanges {
target: rightCornerButton
height: parent.height
width: Kirigami.Units.gridUnit * 2
}
2021-10-31 04:11:10 +00:00
}
]
}