mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-02 01:34:46 +00:00
kcm: Update to new usage of FormComboBoxDelegate
This commit is contained in:
parent
427fd9127b
commit
643b684d66
2 changed files with 36 additions and 89 deletions
|
|
@ -53,38 +53,24 @@ Kirigami.ScrollablePage {
|
||||||
property string mediumIntensityString: i18nc("Medium intensity", "Medium")
|
property string mediumIntensityString: i18nc("Medium intensity", "Medium")
|
||||||
property string highIntensityString: i18nc("High intensity", "High")
|
property string highIntensityString: i18nc("High intensity", "High")
|
||||||
|
|
||||||
currentValue: {
|
currentIndex: indexOfValue(MobileShell.MobileShellSettings.vibrationIntensity)
|
||||||
let intensity = MobileShell.MobileShellSettings.vibrationIntensity;
|
|
||||||
if (intensity <= 0.2) {
|
|
||||||
return lowIntensityString;
|
|
||||||
} else if (intensity <= 0.5) {
|
|
||||||
return mediumIntensityString;
|
|
||||||
} else {
|
|
||||||
return highIntensityString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
// we can't use i18n with ListElement
|
// we can't use i18n with ListElement
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
append({"name": vibrationIntensityDelegate.highIntensityString, "value": 1.0});
|
append({"name": vibrationIntensityDelegate.highIntensityString, "value": 1.0});
|
||||||
append({"name": vibrationIntensityDelegate.mediumIntensityString, "value": 0.5});
|
append({"name": vibrationIntensityDelegate.mediumIntensityString, "value": 0.5});
|
||||||
append({"name": vibrationIntensityDelegate.lowIntensityString, "value": 0.2});
|
append({"name": vibrationIntensityDelegate.lowIntensityString, "value": 0.2});
|
||||||
|
|
||||||
|
// indexOfValue doesn't bind to model changes unfortunately, set currentIndex manually here
|
||||||
|
vibrationIntensityDelegate.currentIndex = vibrationIntensityDelegate.indexOfValue(MobileShell.MobileShellSettings.vibrationIntensity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textRole: "name"
|
||||||
|
valueRole: "value"
|
||||||
|
|
||||||
Component.onCompleted: dialog.parent = root
|
Component.onCompleted: dialog.parent = root
|
||||||
dialogDelegate: QQC2.RadioDelegate {
|
onCurrentValueChanged: MobileShell.MobileShellSettings.vibrationIntensity = currentValue;
|
||||||
implicitWidth: Kirigami.Units.gridUnit * 16
|
|
||||||
topPadding: Kirigami.Units.smallSpacing * 2
|
|
||||||
bottomPadding: Kirigami.Units.smallSpacing * 2
|
|
||||||
|
|
||||||
text: name
|
|
||||||
checked: vibrationIntensityDelegate.currentValue === name
|
|
||||||
onCheckedChanged: {
|
|
||||||
if (checked) {
|
|
||||||
MobileShell.MobileShellSettings.vibrationIntensity = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MobileForm.FormDelegateSeparator { above: vibrationIntensityDelegate; below: vibrationDurationDelegate }
|
MobileForm.FormDelegateSeparator { above: vibrationIntensityDelegate; below: vibrationDurationDelegate }
|
||||||
|
|
@ -98,38 +84,24 @@ Kirigami.ScrollablePage {
|
||||||
property string mediumString: i18nc("Medium duration", "Medium")
|
property string mediumString: i18nc("Medium duration", "Medium")
|
||||||
property string shortString: i18nc("Short duration", "Short")
|
property string shortString: i18nc("Short duration", "Short")
|
||||||
|
|
||||||
currentValue: {
|
currentIndex: indexOfValue(MobileShell.MobileShellSettings.vibrationDuration)
|
||||||
let duration = MobileShell.MobileShellSettings.vibrationDuration;
|
|
||||||
if (duration >= 100) {
|
|
||||||
return longString;
|
|
||||||
} else if (duration >= 50) {
|
|
||||||
return mediumString;
|
|
||||||
} else {
|
|
||||||
return shortString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
// we can't use i18n with ListElement
|
// we can't use i18n with ListElement
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
append({"name": vibrationDurationDelegate.longString, "value": 100});
|
append({"name": vibrationDurationDelegate.longString, "value": 100});
|
||||||
append({"name": vibrationDurationDelegate.mediumString, "value": 50});
|
append({"name": vibrationDurationDelegate.mediumString, "value": 50});
|
||||||
append({"name": vibrationDurationDelegate.shortString, "value": 15});
|
append({"name": vibrationDurationDelegate.shortString, "value": 15});
|
||||||
|
|
||||||
|
// indexOfValue doesn't bind to model changes unfortunately, set currentIndex manually here
|
||||||
|
vibrationDurationDelegate.currentIndex = vibrationDurationDelegate.indexOfValue(MobileShell.MobileShellSettings.vibrationDuration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textRole: "name"
|
||||||
|
valueRole: "value"
|
||||||
|
|
||||||
Component.onCompleted: dialog.parent = root
|
Component.onCompleted: dialog.parent = root
|
||||||
dialogDelegate: QQC2.RadioDelegate {
|
onCurrentValueChanged: MobileShell.MobileShellSettings.vibrationDuration = currentValue;
|
||||||
implicitWidth: Kirigami.Units.gridUnit * 16
|
|
||||||
topPadding: Kirigami.Units.smallSpacing * 2
|
|
||||||
bottomPadding: Kirigami.Units.smallSpacing * 2
|
|
||||||
|
|
||||||
text: name
|
|
||||||
checked: vibrationDurationDelegate.currentValue === name
|
|
||||||
onCheckedChanged: {
|
|
||||||
if (checked) {
|
|
||||||
MobileShell.MobileShellSettings.vibrationDuration = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -135,37 +135,23 @@ KCM.SimpleKCM {
|
||||||
text: i18n("Top Left Drawer Mode")
|
text: i18n("Top Left Drawer Mode")
|
||||||
description: i18n("Mode when opening from the top left.")
|
description: i18n("Mode when opening from the top left.")
|
||||||
|
|
||||||
currentValue: {
|
currentIndex: indexOfValue(MobileShell.MobileShellSettings.actionDrawerTopLeftMode)
|
||||||
let mode = MobileShell.MobileShellSettings.actionDrawerTopLeftMode;
|
|
||||||
if (mode === MobileShell.MobileShellSettings.Expanded) {
|
|
||||||
return parentCol.expandedString;
|
|
||||||
} else{
|
|
||||||
return parentCol.pinnedString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
// we can't use i18n with ListElement
|
// we can't use i18n with ListElement
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
append({"name": parentCol.pinnedString, "value": MobileShell.MobileShellSettings.Pinned});
|
append({"name": parentCol.pinnedString, "value": MobileShell.MobileShellSettings.Pinned});
|
||||||
append({"name": parentCol.expandedString, "value": MobileShell.MobileShellSettings.Expanded});
|
append({"name": parentCol.expandedString, "value": MobileShell.MobileShellSettings.Expanded});
|
||||||
|
|
||||||
|
// indexOfValue doesn't bind to model changes unfortunately, set currentIndex manually here
|
||||||
|
topLeftActionDrawerModeDelegate.currentIndex = topLeftActionDrawerModeDelegate.indexOfValue(MobileShell.MobileShellSettings.actionDrawerTopLeftMode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
textRole: "name"
|
||||||
|
valueRole: "value"
|
||||||
|
|
||||||
Component.onCompleted: dialog.parent = root
|
Component.onCompleted: dialog.parent = root
|
||||||
|
onCurrentValueChanged: MobileShell.MobileShellSettings.actionDrawerTopLeftMode = currentValue
|
||||||
dialogDelegate: QQC2.RadioDelegate {
|
|
||||||
implicitWidth: Kirigami.Units.gridUnit * 16
|
|
||||||
topPadding: Kirigami.Units.smallSpacing * 2
|
|
||||||
bottomPadding: Kirigami.Units.smallSpacing * 2
|
|
||||||
|
|
||||||
text: name
|
|
||||||
checked: topLeftActionDrawerModeDelegate.currentValue === name
|
|
||||||
onCheckedChanged: {
|
|
||||||
if (checked) {
|
|
||||||
MobileShell.MobileShellSettings.actionDrawerTopLeftMode = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MobileForm.FormDelegateSeparator { above: topLeftActionDrawerModeDelegate; below: topRightActionDrawerModeDelegate }
|
MobileForm.FormDelegateSeparator { above: topLeftActionDrawerModeDelegate; below: topRightActionDrawerModeDelegate }
|
||||||
|
|
@ -175,35 +161,24 @@ KCM.SimpleKCM {
|
||||||
text: i18n("Top Right Drawer Mode")
|
text: i18n("Top Right Drawer Mode")
|
||||||
description: i18n("Mode when opening from from the top right.")
|
description: i18n("Mode when opening from from the top right.")
|
||||||
|
|
||||||
currentValue: {
|
|
||||||
let mode = MobileShell.MobileShellSettings.actionDrawerTopRightMode;
|
|
||||||
if (mode === MobileShell.MobileShellSettings.Expanded) {
|
|
||||||
return parentCol.expandedString;
|
|
||||||
} else {
|
|
||||||
return parentCol.pinnedString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
// we can't use i18n with ListElement
|
// we can't use i18n with ListElement
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
append({"name": parentCol.pinnedString, "value": MobileShell.MobileShellSettings.Pinned});
|
append({"name": parentCol.pinnedString, "value": MobileShell.MobileShellSettings.Pinned});
|
||||||
append({"name": parentCol.expandedString, "value": MobileShell.MobileShellSettings.Expanded});
|
append({"name": parentCol.expandedString, "value": MobileShell.MobileShellSettings.Expanded});
|
||||||
|
|
||||||
|
// indexOfValue doesn't bind to model changes unfortunately, set currentIndex manually here
|
||||||
|
topRightActionDrawerModeDelegate.currentIndex = topRightActionDrawerModeDelegate.indexOfValue(MobileShell.MobileShellSettings.actionDrawerTopRightMode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Component.onCompleted: dialog.parent = root
|
|
||||||
dialogDelegate: QQC2.RadioDelegate {
|
textRole: "name"
|
||||||
implicitWidth: Kirigami.Units.gridUnit * 16
|
valueRole: "value"
|
||||||
topPadding: Kirigami.Units.smallSpacing * 2
|
|
||||||
bottomPadding: Kirigami.Units.smallSpacing * 2
|
Component.onCompleted: {
|
||||||
|
dialog.parent = root
|
||||||
text: name
|
|
||||||
checked: topRightActionDrawerModeDelegate.currentValue === name
|
|
||||||
onCheckedChanged: {
|
|
||||||
if (checked) {
|
|
||||||
MobileShell.MobileShellSettings.actionDrawerTopRightMode = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
onCurrentValueChanged: MobileShell.MobileShellSettings.actionDrawerTopRightMode = currentValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue