Archived
1
Fork 0
This repository has been archived on 2025-04-27. You can view files and clone it, but cannot push or open issues or pull requests.
sukai/ui/Sidebar.qml

119 lines
2.8 KiB
QML
Raw Permalink Normal View History

// 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
}
}
}
}