Commit f1943a1e authored by Méven Car's avatar Méven Car
Browse files

[KCM/NightColor] Allow the user to know the default settings are selected

Test Plan:
kcmshell5 kcm_nightcolor
Checked all settings reacts correctly to the restore defaults button

Reviewers: #kwin, crossi, ervin, romangg, davidedmundson

Reviewed By: #kwin, romangg, davidedmundson

Subscribers: davidedmundson, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26049
parent 35e8cb70
...@@ -25,6 +25,10 @@ Kirigami.FormLayout { ...@@ -25,6 +25,10 @@ Kirigami.FormLayout {
Connections { Connections {
target: root target: root
onReset: reset() onReset: reset()
onDefaults: {
latitudeFixedField.backend = cA.latitudeFixedDefault;
longitudeFixedField.backend = cA.longitudeFixedDefault;
}
} }
function reset() { function reset() {
......
...@@ -48,12 +48,30 @@ KCM.SimpleKCM { ...@@ -48,12 +48,30 @@ KCM.SimpleKCM {
// Default was triggered, only allow a normal // Default was triggered, only allow a normal
// configuration change again: // configuration change again:
defaultRequested = false; defaultRequested = false;
calcRepresentsDefault();
}
function calcRepresentsDefault() {
if (cA.nightColorAvailable) {
kcm.representsDefaults = activator.checked === cA.activeDefault &&
tempSlider.value === cA.nightTemperatureDefault &&
modeSwitcher.currentIndex === cA.modeDefault &&
cA.latitudeFixedStaged === cA.latitudeFixedDefault &&
cA.longitudeFixedStaged === cA.longitudeFixedDefault &&
cA.morningBeginFixedStaged.toString() === cA.morningBeginFixedDefault.toString() &&
cA.eveningBeginFixedStaged.toString() === cA.eveningBeginFixedDefault.toString() &&
cA.transitionTimeStaged === cA.transitionTimeDefault;
} else {
kcm.representsDefaults = true;
}
} }
Connections { Connections {
target: kcm target: kcm
onLoadRelay: cA.reloadData() onLoadRelay: cA.reloadData()
onSaveRelay: defaultRequested ? cA.sendConfigurationAll() : cA.sendConfiguration(); onSaveRelay: {
defaultRequested ? cA.sendConfigurationAll() : cA.sendConfiguration();
}
onDefaultsRelay: { onDefaultsRelay: {
if (!cA.nightColorAvailable) { if (!cA.nightColorAvailable) {
return; return;
...@@ -63,17 +81,20 @@ KCM.SimpleKCM { ...@@ -63,17 +81,20 @@ KCM.SimpleKCM {
modeSwitcher.currentIndex = cA.modeDefault; modeSwitcher.currentIndex = cA.modeDefault;
// set everything else to default as well // set everything else to default as well
cA.latitudeFixedStaged = cA.latitudeFixedDefault; defaults()
cA.longitudeFixedStaged = cA.longitudeFixedDefault;
cA.morningBeginFixedStaged = cA.morningBeginFixedDefault; mornBeginManField.backend = cA.morningBeginFixedDefault;
cA.eveningBeginFixedStaged = cA.eveningBeginFixedDefault; evenBeginManField.backend = cA.eveningBeginFixedDefault;
cA.transitionTimeStaged = cA.transitionTimeDefault; transTimeField.value = cA.transitionTimeDefault;
cA.transitionTimeStaged = transTimeField.value;
kcm.needsSave = cA.checkStagedAll(); kcm.needsSave = cA.checkStagedAll();
defaultRequested = true; defaultRequested = true;
calcRepresentsDefault();
} }
} }
signal defaults()
Connections { Connections {
target: cA target: cA
...@@ -220,7 +241,8 @@ KCM.SimpleKCM { ...@@ -220,7 +241,8 @@ KCM.SimpleKCM {
visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeTimings visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeTimings
Kirigami.FormData.label: i18n("Turn on at:") Kirigami.FormData.label: i18n("Turn on at:")
backend: cA.eveningBeginFixedStaged backend: cA.eveningBeginFixedStaged
onBackendChanged: {cA.eveningBeginFixedStaged = backend; onBackendChanged: {
cA.eveningBeginFixedStaged = backend;
calcNeedsSave(); calcNeedsSave();
} }
...@@ -236,7 +258,8 @@ KCM.SimpleKCM { ...@@ -236,7 +258,8 @@ KCM.SimpleKCM {
visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeTimings visible: modeSwitcher.currentIndex === CC.CompositorAdaptor.ModeTimings
Kirigami.FormData.label: i18n("Turn off at:") Kirigami.FormData.label: i18n("Turn off at:")
backend: cA.morningBeginFixedStaged backend: cA.morningBeginFixedStaged
onBackendChanged: {cA.morningBeginFixedStaged = backend; onBackendChanged: {
cA.morningBeginFixedStaged = backend;
calcNeedsSave(); calcNeedsSave();
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment