mirror of
https://github.com/danbulant/dots-hyprland
synced 2026-05-24 12:22:09 +00:00
130 lines
4 KiB
QML
130 lines
4 KiB
QML
import "root:/modules/common"
|
|
import "root:/modules/common/widgets"
|
|
import "root:/services"
|
|
import "root:/"
|
|
import Qt5Compat.GraphicalEffects
|
|
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
import Quickshell
|
|
|
|
Item {
|
|
id: root
|
|
property real dialogPadding: 15
|
|
property real dialogMargin: 30
|
|
property string titleText: "Selection Dialog"
|
|
property alias items: choiceModel.values
|
|
property int selectedId: choiceListView.currentIndex
|
|
property var defaultChoice
|
|
|
|
signal canceled();
|
|
signal selected(var result);
|
|
|
|
Rectangle { // Scrim
|
|
id: scrimOverlay
|
|
anchors.fill: parent
|
|
radius: Appearance.rounding.small
|
|
color: Appearance.colors.colScrim
|
|
MouseArea {
|
|
hoverEnabled: true
|
|
anchors.fill: parent
|
|
preventStealing: true
|
|
propagateComposedEvents: false
|
|
}
|
|
}
|
|
|
|
Rectangle { // The dialog
|
|
id: dialog
|
|
color: Appearance.colors.colSurfaceContainerHigh
|
|
radius: Appearance.rounding.normal
|
|
anchors.fill: parent
|
|
anchors.margins: dialogMargin
|
|
implicitHeight: dialogColumnLayout.implicitHeight
|
|
|
|
ColumnLayout {
|
|
id: dialogColumnLayout
|
|
anchors.fill: parent
|
|
spacing: 16
|
|
|
|
StyledText {
|
|
id: dialogTitle
|
|
Layout.topMargin: dialogPadding
|
|
Layout.leftMargin: dialogPadding
|
|
Layout.rightMargin: dialogPadding
|
|
Layout.alignment: Qt.AlignLeft
|
|
color: Appearance.m3colors.m3onSurface
|
|
font.pixelSize: Appearance.font.pixelSize.larger
|
|
text: root.titleText
|
|
}
|
|
|
|
Rectangle {
|
|
color: Appearance.m3colors.m3outline
|
|
implicitHeight: 1
|
|
Layout.fillWidth: true
|
|
Layout.leftMargin: dialogPadding
|
|
Layout.rightMargin: dialogPadding
|
|
}
|
|
|
|
ListView {
|
|
id: choiceListView
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
clip: true
|
|
currentIndex: root.defaultChoice !== undefined ? root.items.indexOf(root.defaultChoice) : -1
|
|
|
|
model: ScriptModel {
|
|
id: choiceModel
|
|
}
|
|
|
|
delegate: StyledRadioButton {
|
|
id: radioButton
|
|
required property var modelData
|
|
required property int index
|
|
anchors {
|
|
left: parent?.left
|
|
right: parent?.right
|
|
leftMargin: root.dialogPadding
|
|
rightMargin: root.dialogPadding
|
|
}
|
|
|
|
description: modelData.toString()
|
|
checked: index === choiceListView.currentIndex
|
|
|
|
onCheckedChanged: {
|
|
if (checked) {
|
|
choiceListView.currentIndex = index;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
color: Appearance.m3colors.m3outline
|
|
implicitHeight: 1
|
|
Layout.fillWidth: true
|
|
Layout.leftMargin: dialogPadding
|
|
Layout.rightMargin: dialogPadding
|
|
}
|
|
|
|
RowLayout {
|
|
id: dialogButtonsRowLayout
|
|
Layout.bottomMargin: dialogPadding
|
|
Layout.leftMargin: dialogPadding
|
|
Layout.rightMargin: dialogPadding
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
DialogButton {
|
|
buttonText: Translation.tr("Cancel")
|
|
onClicked: root.canceled()
|
|
}
|
|
DialogButton {
|
|
buttonText: Translation.tr("OK")
|
|
onClicked: root.selected(
|
|
root.selectedId === -1 ? null :
|
|
root.items[root.selectedId]
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|