119 lines
2.8 KiB
QML
119 lines
2.8 KiB
QML
|
// SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu>
|
||
|
// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
|
||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||
|
|
||
|
import QtQuick
|
||
|
import QtQml.Models
|
||
|
import QtQuick.Layouts
|
||
|
import QtQuick.Controls as QQC2
|
||
|
|
||
|
import org.kde.kirigami as Kirigami
|
||
|
|
||
|
import com.redstrate.sukai
|
||
|
|
||
|
Kirigami.OverlayDrawer {
|
||
|
id: drawer
|
||
|
|
||
|
property alias actions: actionsRepeater.model
|
||
|
property alias bottomActions: bottomActionsRepeater.model
|
||
|
|
||
|
edge: Qt.application.layoutDirection === Qt.RightToLeft ? Qt.RightEdge : Qt.LeftEdge
|
||
|
modal: !enabled
|
||
|
width: Kirigami.Units.gridUnit * 14
|
||
|
Behavior on width {
|
||
|
NumberAnimation {
|
||
|
duration: Kirigami.Units.longDuration
|
||
|
easing.type: Easing.InOutQuad
|
||
|
}
|
||
|
}
|
||
|
Kirigami.Theme.colorSet: Kirigami.Theme.Window
|
||
|
Kirigami.Theme.inherit: false
|
||
|
|
||
|
handleVisible: modal && enabled
|
||
|
onModalChanged: drawerOpen = !modal
|
||
|
|
||
|
leftPadding: 0
|
||
|
rightPadding: 0
|
||
|
topPadding: 0
|
||
|
bottomPadding: 0
|
||
|
|
||
|
component ActionDelegate: QQC2.ItemDelegate {
|
||
|
id: delegate
|
||
|
|
||
|
property int alertCount
|
||
|
|
||
|
QQC2.ButtonGroup.group: pageButtonGroup
|
||
|
|
||
|
padding: Kirigami.Units.largeSpacing
|
||
|
Layout.fillWidth: true
|
||
|
activeFocusOnTab: true
|
||
|
|
||
|
onClicked: {
|
||
|
if (drawer.modal) {
|
||
|
drawer.close();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Notification indicator
|
||
|
Rectangle {
|
||
|
anchors {
|
||
|
verticalCenter: parent.verticalCenter
|
||
|
right: parent.right
|
||
|
rightMargin: Kirigami.Units.largeSpacing
|
||
|
}
|
||
|
|
||
|
color: Kirigami.Theme.highlightColor
|
||
|
|
||
|
width: 20
|
||
|
height: width
|
||
|
radius: width
|
||
|
visible: delegate.alertCount > 0
|
||
|
|
||
|
QQC2.Label {
|
||
|
anchors {
|
||
|
centerIn: parent
|
||
|
}
|
||
|
|
||
|
text: delegate.alertCount
|
||
|
horizontalAlignment: Text.AlignHCenter
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
contentItem: ColumnLayout {
|
||
|
spacing: 0
|
||
|
|
||
|
QQC2.ButtonGroup {
|
||
|
id: pageButtonGroup
|
||
|
}
|
||
|
|
||
|
Repeater {
|
||
|
id: actionsRepeater
|
||
|
|
||
|
delegate: ActionDelegate {
|
||
|
required property var modelData
|
||
|
|
||
|
action: modelData
|
||
|
visible: modelData.visible
|
||
|
enabled: !AccountManager.selectedAccountHasIssue
|
||
|
alertCount: modelData.alertCount ?? 0
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Item {
|
||
|
Layout.fillHeight: true
|
||
|
}
|
||
|
|
||
|
Repeater {
|
||
|
id: bottomActionsRepeater
|
||
|
|
||
|
delegate: ActionDelegate {
|
||
|
required property var modelData
|
||
|
|
||
|
action: modelData
|
||
|
visible: modelData.visible
|
||
|
alertCount: modelData.alertCount ?? 0
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|