diff --git a/kcms/nightcolor/package/contents/ui/LocationsAutoView.qml b/kcms/nightcolor/package/contents/ui/LocationsAutoView.qml
--- a/kcms/nightcolor/package/contents/ui/LocationsAutoView.qml
+++ b/kcms/nightcolor/package/contents/ui/LocationsAutoView.qml
@@ -15,38 +15,28 @@
along with this program. If not, see .
*********************************************************************/
import QtQuick 2.1
-import QtQuick.Layouts 1.1
-import QtQuick.Controls 1.4 as Controls
+import org.kde.kirigami 2.5 as Kirigami
-GridLayout {
- columns: 2
- rowSpacing: units.smallSpacing
- columnSpacing: units.smallSpacing
+Kirigami.FormLayout {
+ twinFormLayouts: parentLayout
enabled: activator.checked
property double latitude
property double longitude
onLatitudeChanged: latitudeField.backend = latitude;
onLongitudeChanged: longitudeField.backend = longitude;
- Controls.Label {
- text: i18n("Latitude")
- Layout.alignment: Qt.AlignRight
- enabled: false
- }
NumberField {
id: latitudeField
+ Kirigami.FormData.label: i18n("Latitude:")
backend: locator.latitude
enabled: false
}
- Controls.Label {
- text: i18n("Longitude")
- Layout.alignment: Qt.AlignRight
- enabled: false
- }
+
NumberField {
id: longitudeField
+ Kirigami.FormData.label: i18n("Longitude:")
backend: locator.longitude
enabled: false
}
diff --git a/kcms/nightcolor/package/contents/ui/LocationsFixedView.qml b/kcms/nightcolor/package/contents/ui/LocationsFixedView.qml
--- a/kcms/nightcolor/package/contents/ui/LocationsFixedView.qml
+++ b/kcms/nightcolor/package/contents/ui/LocationsFixedView.qml
@@ -15,13 +15,11 @@
along with this program. If not, see .
*********************************************************************/
import QtQuick 2.1
-import QtQuick.Layouts 1.1
-import QtQuick.Controls 1.4 as Controls
+import org.kde.kirigami 2.5 as Kirigami
+import QtQuick.Controls 2.5 as QQC2
-GridLayout {
- columns: 2
- rowSpacing: units.smallSpacing
- columnSpacing: units.smallSpacing
+Kirigami.FormLayout {
+ twinFormLayouts: parentLayout
enabled: activator.checked
Connections {
@@ -34,12 +32,9 @@
longitudeFixedField.backend = cA.longitudeFixed;
}
- Controls.Label {
- text: i18n("Latitude")
- Layout.alignment: Qt.AlignRight
- }
NumberField {
id: latitudeFixedField
+ Kirigami.FormData.label: i18n("Latitude:")
backend: cA.latitudeFixedStaged
validator: DoubleValidator {bottom: -90; top: 90; decimals: 10}
onBackendChanged: {
@@ -49,24 +44,21 @@
}
}
- Controls.Label {
- text: i18n("Longitude")
- Layout.alignment: Qt.AlignRight
- }
NumberField {
id: longitudeFixedField
+ Kirigami.FormData.label: i18n("Longitude:")
backend: cA.longitudeFixedStaged
validator: DoubleValidator {bottom: -180; top: 180; decimals: 10}
onBackendChanged: {
cA.longitudeFixedStaged = backend;
manualLocationsViewRow.change();
calcNeedsSave();
}
}
- Controls.Button {
- Layout.columnSpan: 2
- Layout.alignment: Qt.AlignHCenter
+
+ QQC2.Button {
text: i18n("Detect location")
+ implicitWidth: longitudeFixedField.width // TODO: see if there is a smarter way for doing this
onClicked: {
latitudeFixedField.backend = locator.latitude;
longitudeFixedField.backend = locator.longitude;
diff --git a/kcms/nightcolor/package/contents/ui/NumberField.qml b/kcms/nightcolor/package/contents/ui/NumberField.qml
--- a/kcms/nightcolor/package/contents/ui/NumberField.qml
+++ b/kcms/nightcolor/package/contents/ui/NumberField.qml
@@ -15,9 +15,9 @@
along with this program. If not, see .
*********************************************************************/
import QtQuick 2.1
-import QtQuick.Controls 1.4 as Controls
+import QtQuick.Controls 2.5 as QQC2
-Controls.TextField {
+QQC2.TextField {
property double backend
maximumLength: 10
diff --git a/kcms/nightcolor/package/contents/ui/TimeField.qml b/kcms/nightcolor/package/contents/ui/TimeField.qml
--- a/kcms/nightcolor/package/contents/ui/TimeField.qml
+++ b/kcms/nightcolor/package/contents/ui/TimeField.qml
@@ -15,10 +15,9 @@
along with this program. If not, see .
*********************************************************************/
import QtQuick 2.1
-import QtQuick.Layouts 1.1
-import QtQuick.Controls 2.2 as Controls
+import QtQuick.Controls 2.5 as QQC2
-Controls.TextField {
+QQC2.TextField {
id: field
property date backend
diff --git a/kcms/nightcolor/package/contents/ui/TimingsView.qml b/kcms/nightcolor/package/contents/ui/TimingsView.qml
--- a/kcms/nightcolor/package/contents/ui/TimingsView.qml
+++ b/kcms/nightcolor/package/contents/ui/TimingsView.qml
@@ -15,13 +15,11 @@
along with this program. If not, see .
*********************************************************************/
import QtQuick 2.1
-import QtQuick.Layouts 1.1
-import QtQuick.Controls 1.4 as Controls
+import org.kde.kirigami 2.5 as Kirigami
+import QtQuick.Controls 2.5 as QQC2
-GridLayout {
- columns: 2
- rowSpacing: units.smallSpacing
- columnSpacing: units.smallSpacing
+Kirigami.FormLayout {
+ twinFormLayouts: parentLayout
enabled: activator.checked
property double latitude
@@ -35,43 +33,30 @@
eveningTimings = sunCalc.getEveningTimings(latitude, longitude);
}
- Controls.Label {
- text: i18n("Sunrise begins")
- Layout.alignment: Qt.AlignRight
- enabled: false
- }
TimeField {
id: mornBeginField
+ Kirigami.FormData.label: i18n("Sunrise begins:")
backend: morningTimings.begin
enabled: false
}
- Controls.Label {
- text: i18n("and ends")
- Layout.alignment: Qt.AlignRight
- enabled: false
- }
+
TimeField {
id: mornEndField
+ Kirigami.FormData.label: i18n("...and ends:")
backend: morningTimings.end
enabled: false
}
- Controls.Label {
- text: i18n("Sunset begins")
- Layout.alignment: Qt.AlignRight
- enabled: false
- }
+
TimeField {
id: evenBeginField
+ Kirigami.FormData.label: i18n("Sunset begins:")
backend: eveningTimings.begin
enabled: false
}
- Controls.Label {
- text: i18n("and ends")
- Layout.alignment: Qt.AlignRight
- enabled: false
- }
+
TimeField {
id: evenEndField
+ Kirigami.FormData.label: i18n("...and ends:")
backend: eveningTimings.end
enabled: false
}
diff --git a/kcms/nightcolor/package/contents/ui/main.qml b/kcms/nightcolor/package/contents/ui/main.qml
--- a/kcms/nightcolor/package/contents/ui/main.qml
+++ b/kcms/nightcolor/package/contents/ui/main.qml
@@ -14,23 +14,18 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*********************************************************************/
-import QtQuick 2.1
+import QtQuick 2.12
import QtQuick.Layouts 1.1
-import QtQuick.Controls 1.4 as Controls
+import QtQuick.Controls 2.5 as QQC2
-import org.kde.kquickcontrolsaddons 2.0
-import org.kde.plasma.core 2.0 as PlasmaCore
-import org.kde.plasma.extras 2.0 as PlasmaExtras
+import org.kde.kirigami 2.5 as Kirigami
+import org.kde.kcm 1.2 as KCM
import org.kde.colorcorrect 0.1 as CC
-Item {
+KCM.SimpleKCM {
id: root
-
- implicitHeight: units.gridUnit * 20
-
property int error: cA.error
-
property bool defaultRequested: false
CC.CompositorAdaptor {
@@ -91,41 +86,40 @@
}
signal reset()
- Item {
- id: main
- width: childrenRect.width
- height: childrenRect.height
-
- enabled: cA.nightColorAvailable
-
- Controls.CheckBox {
- id: activator
- text: i18n("Activate Night Color")
- checked: cA.active
-
- onCheckedChanged: {
- cA.activeStaged = checked;
- calcNeedsSave();
- }
+ header: ColumnLayout{
+ Kirigami.InlineMessage {
+ id: errorMessage
+ Layout.fillWidth: true
+ visible: error != CC.CompositorAdaptor.ErrorCodeSuccess
+ type: Kirigami.MessageType.Error
+ text: cA.errorText
}
+ }
- ColumnLayout {
- id: mainControls
- anchors.top: activator.bottom
- anchors.topMargin: units.largeSpacing
+ ColumnLayout {
+ spacing: 0
- enabled: activator.checked
+ Kirigami.FormLayout {
+ id: parentLayout
- Controls.Label {
- text: i18n("Night Color Temperature: ") + tempSlider.value + i18n(" K")
+ QQC2.CheckBox {
+ id: activator
+ text: i18n("Activate Night Color")
+ enabled: cA.nightColorAvailable
+ checked: cA.active
+
+ onCheckedChanged: {
+ cA.activeStaged = checked;
+ calcNeedsSave();
+ }
}
- Controls.Slider {
+ QQC2.Slider {
id: tempSlider
- implicitWidth: units.gridUnit * 15
-
- minimumValue: cA.minimalTemperature
- maximumValue: cA.neutralTemperature
+ Kirigami.FormData.label: i18n("Night Color temperature:")
+ enabled: activator.checked
+ from: cA.minimalTemperature
+ to: cA.neutralTemperature
value: cA.nightTemperature
stepSize: 100
@@ -136,106 +130,116 @@
}
RowLayout {
- spacing: units.largeSpacing
- Controls.Label {
- text: i18n("Operation mode:")
- }
- Controls.ComboBox {
- id: modeSwitcher
- width: theme.mSize(theme.defaultFont).width * 9
- model: [i18n("Automatic"),
- i18n("Location"),
- i18n("Times")]
- currentIndex: cA.mode
- onCurrentIndexChanged: {
- cA.modeStaged = currentIndex;
- advancedControlLoader.updatePage(currentIndex);
- calcNeedsSave();
- }
+ enabled: activator.checked
+ Layout.fillWidth: true
+
+ QQC2.Label {
+ Layout.fillWidth: true
+ horizontalAlignment: Text.AlignHCenter
+ text: tempSlider.value + i18n(" K")
}
}
- }
- Loader {
- id: advancedControlLoader
-
- anchors.top: mainControls.bottom
- anchors.topMargin: units.largeSpacing
-
- function updatePage(index) {
- sourceComponent = undefined;
- var page;
- if (index === CC.CompositorAdaptor.ModeLocation) {
- page = manualLocationsView;
- } else if (index === CC.CompositorAdaptor.ModeTimings) {
- page = manualTimingsView;
- } else {
- page = automaticView;
+ QQC2.ComboBox {
+ id: modeSwitcher
+ Kirigami.FormData.label: i18n("Operation mode:")
+ enabled: activator.checked
+ model: [i18n("Automatic"),
+ i18n("Location"),
+ i18n("Times")]
+ currentIndex: cA.mode
+ onCurrentIndexChanged: {
+ cA.modeStaged = currentIndex;
+ advancedControlLoader.updatePage(currentIndex);
+ calcNeedsSave();
}
-
- sourceComponent = page;
}
}
- Component {
- id: automaticView
- Row {
- spacing: units.largeSpacing
+ Kirigami.FormLayout {
+
+ Loader {
+ id: advancedControlLoader
+
- Loader {
- sourceComponent: TimingsView {
- latitude: locator.latitude
- longitude: locator.longitude
+ function updatePage(index) {
+ sourceComponent = undefined;
+ var page;
+ if (index === CC.CompositorAdaptor.ModeLocation) {
+ page = manualLocationsView;
+ } else if (index === CC.CompositorAdaptor.ModeTimings) {
+ page = manualTimingsView;
+ } else {
+ page = automaticView;
}
+
+ sourceComponent = page;
}
- Loader {
- sourceComponent: LocationsAutoView {
- latitude: locator.latitude
- longitude: locator.longitude
+ }
+
+ Component {
+ id: automaticView
+
+ ColumnLayout {
+
+ Loader {
+ sourceComponent: TimingsView {
+ latitude: locator.latitude
+ longitude: locator.longitude
+ }
+ }
+
+ Kirigami.Separator {
+ Layout.fillWidth: true
+ Kirigami.FormData.isSection: true
+ }
+
+ Loader {
+ sourceComponent: LocationsAutoView {
+ latitude: locator.latitude
+ longitude: locator.longitude
+ }
}
}
}
- }
- Component {
- id: manualLocationsView
+ Component {
+ id: manualLocationsView
- Row {
- id: manualLocationsViewRow
- spacing: units.largeSpacing
+ ColumnLayout {
+ id: manualLocationsViewRow
+ signal change()
- signal change()
+ Loader {
+ sourceComponent: TimingsView {
+ latitude: cA.latitudeFixedStaged
+ longitude: cA.longitudeFixedStaged
- Loader {
- sourceComponent: TimingsView {
- latitude: cA.latitudeFixedStaged
- longitude: cA.longitudeFixedStaged
-
- Connections {
- target: manualLocationsViewRow
- onChange: {
- reset();
+ Connections {
+ target: manualLocationsViewRow
+ onChange: {
+ reset();
+ }
}
}
}
- }
- Loader {
- sourceComponent: LocationsFixedView {}
+
+ Kirigami.Separator {
+ Layout.fillWidth: true
+ Kirigami.FormData.isSection: true
+ }
+
+ Loader {
+ sourceComponent: LocationsFixedView {}
+ }
}
}
- }
- Component {
- id: manualTimingsView
- Column {
- spacing: units.smallSpacing
+ Component {
+ id: manualTimingsView
- GridLayout {
- id: manualTimingsViewGrid
-
- columns: 3
- rowSpacing: units.smallSpacing
- columnSpacing: units.smallSpacing
+ Kirigami.FormLayout {
+ twinFormLayouts: parentLayout
enabled: activator.checked && cA.timingsEnabled
Connections {
@@ -247,116 +251,72 @@
}
}
- Controls.Label {
- text: i18n("Sunrise begins")
- Layout.alignment: Qt.AlignRight
- }
TimeField {
id: mornBeginManField
+ Kirigami.FormData.label: i18n("Sunrise begins:")
backend: cA.morningBeginFixedStaged
onBackendChanged: {cA.morningBeginFixedStaged = backend;
calcNeedsSave();
}
+
+ QQC2.ToolTip {
+ text: i18n("(Input format: HH:MM)")
+ }
}
- Controls.Label {
- enabled: false
- text: i18n("(HH:MM)")
- }
- Controls.Label {
- text: i18n("Sunset begins")
- Layout.alignment: Qt.AlignRight
- }
+
TimeField {
id: evenBeginManField
+ Kirigami.FormData.label: i18n("Sunset begins:")
backend: cA.eveningBeginFixedStaged
onBackendChanged: {cA.eveningBeginFixedStaged = backend;
calcNeedsSave();
}
+
+ QQC2.ToolTip {
+ text: i18n("Input format: HH:MM")
+ }
}
- Controls.Label {
- enabled: false
- text: i18n("(HH:MM)")
- }
- Controls.Label {
- text: i18n("Transition duration")
- Layout.alignment: Qt.AlignRight
- }
+
NumberField {
id: transTimeField
+ Kirigami.FormData.label: i18n("Transition duration:")
backend: cA.transitionTimeStaged
onBackendChanged: {cA.transitionTimeStaged = backend;
calcNeedsSave();
}
inputMethodHints: Qt.ImhDigitsOnly
validator: IntValidator {bottom: 1; top: 600;} // less than 12 hours (in minutes: 720)
- }
- Controls.Label {
- enabled: false
- text: i18n("(In minutes - min. 1, max. 600)")
- }
- }
- Controls.Label {
- id: manualTimingsError1
- anchors.horizontalCenter: manualTimingsViewGrid.horizontalCenter
- visible: evenBeginManField.getNormedDate() - mornBeginManField.getNormedDate() <= 0
- font.italic: true
- text: i18n("Error: Morning not before evening.")
- }
- Controls.Label {
- id: manualTimingsError2
- anchors.horizontalCenter: manualTimingsViewGrid.horizontalCenter
- visible: {
- if (manualTimingsError1.visible) {
- return false;
+ QQC2.ToolTip {
+ text: i18n("Input minutes - min. 1, max. 600")
}
- var trTime = transTimeField.backend * 60 * 1000;
- var mor = mornBeginManField.getNormedDate();
- var eve = evenBeginManField.getNormedDate();
-
- return eve - mor <= trTime || eve - mor >= 86400000 - trTime;
}
- font.italic: true
- text: i18n("Error: Transition time overlaps.")
- }
- }
- }
- }
- // error message as overlay
- Item {
- width: 0.8 * main.width
- height: 0.8 * main.height
- anchors.centerIn: main
-
- visible: error != CC.CompositorAdaptor.ErrorCodeSuccess
+ QQC2.Label {
+ id: manualTimingsError1
+ visible: evenBeginManField.getNormedDate() - mornBeginManField.getNormedDate() <= 0
+ font.italic: true
+ text: i18n("Error: Morning is before evening.")
+ }
- Rectangle {
- anchors.centerIn: parent
- width: errorMessage.contentWidth * 1.1
- height: errorMessage.contentHeight * 1.1
- color: theme.backgroundColor
- opacity: 0.8
+ QQC2.Label {
+ id: manualTimingsError2
+ visible: {
+ if (manualTimingsError1.visible) {
+ return false;
+ }
+ var trTime = transTimeField.backend * 60 * 1000;
+ var mor = mornBeginManField.getNormedDate();
+ var eve = evenBeginManField.getNormedDate();
- border {
- width: units.devicePixelRatio
- color: theme.textColor
+ return eve - mor <= trTime || eve - mor >= 86400000 - trTime;
+ }
+ font.italic: true
+ text: i18n("Error: Transition time overlaps.")
+ }
+ }
}
}
-
- PlasmaExtras.Heading {
- id: errorMessage
- anchors.fill: parent
-
- level: 4
- text: cA.errorText
-
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
-
- wrapMode: Text.Wrap
- textFormat: Text.PlainText
- }
}
}