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,39 +32,33 @@ 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: { cA.latitudeFixedStaged = backend; - manualLocationsViewRow.change(); + manualLocationsViewItem.change(); calcNeedsSave(); } } - 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(); + manualLocationsViewItem.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 @@ -16,21 +16,20 @@ *********************************************************************/ import QtQuick 2.1 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.kquickcontrolsaddons 2.0 import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.extras 2.0 as PlasmaExtras +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,77 +90,79 @@ } signal reset() - Item { - id: main - width: childrenRect.width - height: childrenRect.height + header: ColumnLayout{ + Kirigami.InlineMessage { + id: errorMessage + Layout.fillWidth: true + visible: error != CC.CompositorAdaptor.ErrorCodeSuccess + type: Kirigami.MessageType.Error + text: cA.errorText + } + } - enabled: cA.nightColorAvailable + Kirigami.FormLayout { + id: parentLayout - Controls.CheckBox { + QQC2.CheckBox { id: activator text: i18n("Activate Night Color") + enabled: cA.nightColorAvailable checked: cA.active onCheckedChanged: { cA.activeStaged = checked; calcNeedsSave(); } } - ColumnLayout { - id: mainControls - anchors.top: activator.bottom - anchors.topMargin: units.largeSpacing - + QQC2.Slider { + id: tempSlider + Kirigami.FormData.label: i18n("Night Color temperature:") enabled: activator.checked + from: cA.minimalTemperature + to: cA.neutralTemperature + value: cA.nightTemperature + stepSize: 100 - Controls.Label { - text: i18n("Night Color Temperature: ") + tempSlider.value + i18n(" K") + onValueChanged: { + cA.nightTemperatureStaged = value; + calcNeedsSave(); } + } - Controls.Slider { - id: tempSlider - implicitWidth: units.gridUnit * 15 + RowLayout { // TODO: find a better way to horizontally center the label + enabled: activator.checked + width: tempSlider.width + spacing: 0 - minimumValue: cA.minimalTemperature - maximumValue: cA.neutralTemperature - value: cA.nightTemperature - stepSize: 100 + Item { + width: parent.width / 2 - units.largeSpacing + } - onValueChanged: { - cA.nightTemperatureStaged = value; - calcNeedsSave(); - } + QQC2.Label { + text: tempSlider.value + i18n(" K") } + } - 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(); - } - } + QQC2.ComboBox { + id: modeSwitcher + Kirigami.FormData.label: i18n("Operation mode:") + //implicitWidth: tempSlider.width // TODO: decide if you want to have the box as wide as the slider + enabled: activator.checked + model: [i18n("Automatic"), + i18n("Location"), + i18n("Times")] + currentIndex: cA.mode + onCurrentIndexChanged: { + cA.modeStaged = currentIndex; + advancedControlLoader.updatePage(currentIndex); + calcNeedsSave(); } } Loader { id: advancedControlLoader - anchors.top: mainControls.bottom - anchors.topMargin: units.largeSpacing - function updatePage(index) { sourceComponent = undefined; var page; @@ -179,15 +180,20 @@ Component { id: automaticView - Row { - spacing: units.largeSpacing + + ColumnLayout { Loader { sourceComponent: TimingsView { latitude: locator.latitude longitude: locator.longitude } } + + Item { + Kirigami.FormData.isSection: true + } + Loader { sourceComponent: LocationsAutoView { latitude: locator.latitude @@ -200,113 +206,101 @@ Component { id: manualLocationsView - Row { - id: manualLocationsViewRow - spacing: units.largeSpacing - + ColumnLayout { + id: manualLocationsViewItem signal change() Loader { sourceComponent: TimingsView { latitude: cA.latitudeFixedStaged longitude: cA.longitudeFixedStaged Connections { - target: manualLocationsViewRow + target: manualLocationsViewItem onChange: { reset(); } } } } + + Item { + Kirigami.FormData.isSection: true + } + Loader { sourceComponent: LocationsFixedView {} } } } Component { id: manualTimingsView - Column { - spacing: units.smallSpacing - - GridLayout { - id: manualTimingsViewGrid - - columns: 3 - rowSpacing: units.smallSpacing - columnSpacing: units.smallSpacing - enabled: activator.checked && cA.timingsEnabled - - Connections { - target: root - onReset: { - mornBeginManField.backend = cA.morningBeginFixed; - evenBeginManField.backend = cA.eveningBeginFixed; - transTimeField.backend = cA.transitionTime; - } - } - Controls.Label { - text: i18n("Sunrise begins") - Layout.alignment: Qt.AlignRight + Kirigami.FormLayout { + twinFormLayouts: parentLayout + enabled: activator.checked && cA.timingsEnabled + + Connections { + target: root + onReset: { + mornBeginManField.backend = cA.morningBeginFixed; + evenBeginManField.backend = cA.eveningBeginFixed; + transTimeField.backend = cA.transitionTime; } - TimeField { - id: mornBeginManField - backend: cA.morningBeginFixedStaged - onBackendChanged: {cA.morningBeginFixedStaged = backend; - calcNeedsSave(); - } + } + + TimeField { + id: mornBeginManField + Kirigami.FormData.label: i18n("Sunrise begins:") + backend: cA.morningBeginFixedStaged + onBackendChanged: {cA.morningBeginFixedStaged = backend; + calcNeedsSave(); } - Controls.Label { - enabled: false + + QQC2.ToolTip { text: i18n("(HH:MM)") } - Controls.Label { - text: i18n("Sunset begins") - Layout.alignment: Qt.AlignRight - } - TimeField { - id: evenBeginManField - backend: cA.eveningBeginFixedStaged - onBackendChanged: {cA.eveningBeginFixedStaged = backend; - calcNeedsSave(); - } + } + + TimeField { + id: evenBeginManField + Kirigami.FormData.label: i18n("Sunset begins:") + backend: cA.eveningBeginFixedStaged + onBackendChanged: {cA.eveningBeginFixedStaged = backend; + calcNeedsSave(); } - Controls.Label { - enabled: false + + QQC2.ToolTip { text: i18n("(HH:MM)") } - Controls.Label { - text: i18n("Transition duration") - Layout.alignment: Qt.AlignRight - } - NumberField { - id: transTimeField - backend: cA.transitionTimeStaged - onBackendChanged: {cA.transitionTimeStaged = backend; - calcNeedsSave(); - } + } - inputMethodHints: Qt.ImhDigitsOnly - validator: IntValidator {bottom: 1; top: 600;} // less than 12 hours (in minutes: 720) + NumberField { + id: transTimeField + Kirigami.FormData.label: i18n("Transition duration:") + backend: cA.transitionTimeStaged + onBackendChanged: {cA.transitionTimeStaged = backend; + calcNeedsSave(); } - Controls.Label { - enabled: false + + inputMethodHints: Qt.ImhDigitsOnly + validator: IntValidator {bottom: 1; top: 600;} // less than 12 hours (in minutes: 720) + + QQC2.ToolTip { text: i18n("(In minutes - min. 1, max. 600)") } } - Controls.Label { + + QQC2.Label { id: manualTimingsError1 - anchors.horizontalCenter: manualTimingsViewGrid.horizontalCenter visible: evenBeginManField.getNormedDate() - mornBeginManField.getNormedDate() <= 0 - font.italic: true - text: i18n("Error: Morning not before evening.") + text: i18n("Error: Morning is before evening.") } - Controls.Label { + + QQC2.Label { id: manualTimingsError2 - anchors.horizontalCenter: manualTimingsViewGrid.horizontalCenter visible: { if (manualTimingsError1.visible) { return false; @@ -323,40 +317,4 @@ } } } - - // error message as overlay - Item { - width: 0.8 * main.width - height: 0.8 * main.height - anchors.centerIn: main - - visible: error != CC.CompositorAdaptor.ErrorCodeSuccess - - Rectangle { - anchors.centerIn: parent - width: errorMessage.contentWidth * 1.1 - height: errorMessage.contentHeight * 1.1 - color: theme.backgroundColor - opacity: 0.8 - - border { - width: units.devicePixelRatio - color: theme.textColor - } - } - - PlasmaExtras.Heading { - id: errorMessage - anchors.fill: parent - - level: 4 - text: cA.errorText - - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - - wrapMode: Text.Wrap - textFormat: Text.PlainText - } - } }