Skip to content

Commit f9748c9

Browse files
committed
feat(plasmoid): use Switch for instant-apply "presentation mode" setting
Similar to [1]. [1] https://invent.kde.org/plasma/kscreen/-/commit/b2878494
1 parent 793cdfe commit f9748c9

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

plasma-integration/plasmoid/package/contents/ui/PresentationModeItem.qml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ import org.kde.kirigami 2.20 as Kirigami
3232
ColumnLayout {
3333
spacing: Kirigami.Units.smallSpacing
3434

35-
PlasmaComponents3.CheckBox {
36-
id: checkBox
35+
PlasmaComponents3.Switch {
36+
id: presentationModeSwitch
3737
Layout.fillWidth: true
3838
// Remove spacing between checkbox and the explanatory label below
3939
Layout.bottomMargin: -parent.spacing
@@ -44,8 +44,8 @@ ColumnLayout {
4444
return;
4545
}
4646

47-
// disable CheckBox while job is running
48-
checkBox.enabled = false;
47+
// disable Switch while job is running
48+
presentationModeSwitch.enabled = false;
4949

5050
var service = pmSource.serviceForSource("PowerDevil");
5151

@@ -56,7 +56,7 @@ ColumnLayout {
5656
var job = service.startOperationCall(op);
5757
job.finished.connect(function (job) {
5858
presentationModeCookie = job.result;
59-
checkBox.enabled = true;
59+
presentationModeSwitch.enabled = true;
6060
});
6161
} else {
6262
var op = service.operationDescription("stopSuppressingScreenPowerManagement");
@@ -65,29 +65,23 @@ ColumnLayout {
6565
var job = service.startOperationCall(op);
6666
job.finished.connect(function (job) {
6767
presentationModeCookie = -1;
68-
checkBox.enabled = true;
68+
presentationModeSwitch.enabled = true;
6969
});
7070
}
7171
}
7272
}
7373

74-
// so we can align the labels below with the checkbox
75-
PlasmaComponents3.CheckBox {
76-
id: checkBoxMetrics
77-
visible: false
78-
}
79-
8074
PlasmaExtras.DescriptiveLabel {
8175
Layout.fillWidth: true
82-
Layout.leftMargin: checkBoxMetrics.width
76+
Layout.leftMargin: presentationModeSwitch.indicator.width + presentationModeSwitch.spacing
8377
font.pointSize: theme.smallestFont.pointSize
8478
text: i18n("This will prevent your display and computer from turning off automatically.")
8579
wrapMode: Text.WordWrap
8680
}
8781

8882
RowLayout {
8983
Layout.fillWidth: true
90-
Layout.leftMargin: checkBoxMetrics.width
84+
Layout.leftMargin: presentationModeSwitch.indicator.width + presentationModeSwitch.spacing
9185
spacing: Kirigami.Units.smallSpacing
9286

9387
PlasmaCore.IconItem {

plasma-integration/po/plasma_applet_org.kwinft.kdisplay.pot

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,27 @@ msgstr ""
6363
msgid "User enabled presentation mode"
6464
msgstr ""
6565

66-
#: plasma-integration/plasmoid/package/contents/ui/PresentationModeItem.qml:84
66+
#: plasma-integration/plasmoid/package/contents/ui/PresentationModeItem.qml:78
6767
#, kde-format
6868
msgid ""
6969
"This will prevent your display and computer from turning off automatically."
7070
msgstr ""
7171

72-
#: plasma-integration/plasmoid/package/contents/ui/PresentationModeItem.qml:111
72+
#: plasma-integration/plasmoid/package/contents/ui/PresentationModeItem.qml:105
7373
#, kde-format
7474
msgctxt "Some Application and n others enforce presentation mode"
7575
msgid "%2 and %1 other application are enforcing presentation mode."
7676
msgid_plural "%2 and %1 other applications are enforcing presentation mode."
7777
msgstr[0] ""
7878
msgstr[1] ""
7979

80-
#: plasma-integration/plasmoid/package/contents/ui/PresentationModeItem.qml:117
80+
#: plasma-integration/plasmoid/package/contents/ui/PresentationModeItem.qml:111
8181
#, kde-format
8282
msgctxt "Some Application enforce presentation mode"
8383
msgid "%1 is enforcing presentation mode."
8484
msgstr ""
8585

86-
#: plasma-integration/plasmoid/package/contents/ui/PresentationModeItem.qml:120
86+
#: plasma-integration/plasmoid/package/contents/ui/PresentationModeItem.qml:114
8787
#, kde-format
8888
msgctxt ""
8989
"Some Application enforce presentation mode: Reason provided by the app"

0 commit comments

Comments
 (0)