Commit 3d47a5f2 authored by Bharadwaj Raju's avatar Bharadwaj Raju Committed by Nate Graham
Browse files

kcms/nightcolor: Show live temperature preview

Allows live preview of what Night Color will look like when active. Now
users don't have to find a temperature they like by trial-and-error.

Requires kwin!1931
parent 8b054656
Pipeline #162832 passed with stage
in 7 minutes and 58 seconds
......@@ -118,10 +118,20 @@ KCM.SimpleKCM {
from: 1000 // TODO get min/max fron kcfg
to: 6500
stepSize: 100
live: true
value: kcm.nightColorSettings.nightTemperature
onMoved: kcm.nightColorSettings.nightTemperature = value
onMoved: {
kcm.nightColorSettings.nightTemperature = value
previewMessage.state = "visible"
cA.preview(value)
}
onPressedChanged: {
previewMessage.state = "invisible"
cA.stopPreview()
}
Layout.columnSpan: 3
......@@ -147,6 +157,35 @@ KCM.SimpleKCM {
Item {}
}
QQC2.Label {
id: previewMessage
text: i18n("This is what Night Color will look like when active.")
opacity: 0
state: "invisible"
states: [
State {
name: "invisible"
PropertyChanges { target: previewMessage; opacity: 0 }
},
State {
name: "visible"
PropertyChanges { target: previewMessage; opacity: 1 }
}
]
transitions: [
Transition {
from: "invisible"
to: "visible"
NumberAnimation { properties: "opacity"; easing.type: Easing.OutCubic; duration: Kirigami.Units.shortDuration }
},
Transition {
from: "visible"
to: "invisible"
NumberAnimation { properties: "opacity"; easing.type: Easing.InCubic; duration: Kirigami.Units.shortDuration }
}
]
}
Item {
Kirigami.FormData.isSection: true
}
......
......@@ -108,4 +108,13 @@ void CompositorAdaptor::sendAutoLocationUpdate(double latitude, double longitude
m_iface->call(QStringLiteral("nightColorAutoLocationUpdate"), latitude, longitude);
}
void CompositorAdaptor::preview(int temperature)
{
m_iface->call("preview", (uint)temperature);
}
void CompositorAdaptor::stopPreview()
{
m_iface->call("stopPreview");
}
}
......@@ -72,6 +72,22 @@ public:
**/
Q_INVOKABLE void sendAutoLocationUpdate(double latitude, double longitude);
/**
* @brief Preview a color temperature for 15s.
*
* @return void
* @since 5.25
**/
Q_INVOKABLE void preview(int temperature);
/**
* @brief Stop an ongoing preview.
*
* @return void
* @since 5.25
**/
Q_INVOKABLE void stopPreview();
Q_SIGNALS:
void errorChanged();
void errorTextChanged();
......
Supports Markdown
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