Skip to content

Commit

Permalink
feat(plasmoid): use Switch for instant-apply "presentation mode" setting
Browse files Browse the repository at this point in the history
  • Loading branch information
romangg committed Feb 26, 2024
1 parent 793cdfe commit f9748c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
Expand Up @@ -32,8 +32,8 @@ import org.kde.kirigami 2.20 as Kirigami
ColumnLayout {
spacing: Kirigami.Units.smallSpacing

PlasmaComponents3.CheckBox {
id: checkBox
PlasmaComponents3.Switch {
id: presentationModeSwitch
Layout.fillWidth: true
// Remove spacing between checkbox and the explanatory label below
Layout.bottomMargin: -parent.spacing
Expand All @@ -44,8 +44,8 @@ ColumnLayout {
return;
}

// disable CheckBox while job is running
checkBox.enabled = false;
// disable Switch while job is running
presentationModeSwitch.enabled = false;

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

Expand All @@ -56,7 +56,7 @@ ColumnLayout {
var job = service.startOperationCall(op);
job.finished.connect(function (job) {
presentationModeCookie = job.result;
checkBox.enabled = true;
presentationModeSwitch.enabled = true;
});
} else {
var op = service.operationDescription("stopSuppressingScreenPowerManagement");
Expand All @@ -65,29 +65,23 @@ ColumnLayout {
var job = service.startOperationCall(op);
job.finished.connect(function (job) {
presentationModeCookie = -1;
checkBox.enabled = true;
presentationModeSwitch.enabled = true;
});
}
}
}

// so we can align the labels below with the checkbox
PlasmaComponents3.CheckBox {
id: checkBoxMetrics
visible: false
}

PlasmaExtras.DescriptiveLabel {
Layout.fillWidth: true
Layout.leftMargin: checkBoxMetrics.width
Layout.leftMargin: presentationModeSwitch.indicator.width + presentationModeSwitch.spacing
font.pointSize: theme.smallestFont.pointSize
text: i18n("This will prevent your display and computer from turning off automatically.")
wrapMode: Text.WordWrap
}

RowLayout {
Layout.fillWidth: true
Layout.leftMargin: checkBoxMetrics.width
Layout.leftMargin: presentationModeSwitch.indicator.width + presentationModeSwitch.spacing
spacing: Kirigami.Units.smallSpacing

PlasmaCore.IconItem {
Expand Down
8 changes: 4 additions & 4 deletions plasma-integration/po/plasma_applet_org.kwinft.kdisplay.pot
Expand Up @@ -63,27 +63,27 @@ msgstr ""
msgid "User enabled presentation mode"
msgstr ""

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

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

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

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

0 comments on commit f9748c9

Please sign in to comment.