diff --git a/kcms/nightcolor/package/contents/ui/main.qml b/kcms/nightcolor/package/contents/ui/main.qml index 889283ad3..905eb4548 100644 --- a/kcms/nightcolor/package/contents/ui/main.qml +++ b/kcms/nightcolor/package/contents/ui/main.qml @@ -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 } diff --git a/libcolorcorrect/compositorcoloradaptor.cpp b/libcolorcorrect/compositorcoloradaptor.cpp index 6281f5994..19b7dace4 100644 --- a/libcolorcorrect/compositorcoloradaptor.cpp +++ b/libcolorcorrect/compositorcoloradaptor.cpp @@ -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"); +} } diff --git a/libcolorcorrect/compositorcoloradaptor.h b/libcolorcorrect/compositorcoloradaptor.h index 68cd84143..1bb5f099a 100644 --- a/libcolorcorrect/compositorcoloradaptor.h +++ b/libcolorcorrect/compositorcoloradaptor.h @@ -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();