diff --git a/applets/digital-clock/package/contents/ui/configAppearance.qml b/applets/digital-clock/package/contents/ui/configAppearance.qml index 66bd5c917..bac7a0889 100644 --- a/applets/digital-clock/package/contents/ui/configAppearance.qml +++ b/applets/digital-clock/package/contents/ui/configAppearance.qml @@ -1,261 +1,259 @@ /* * Copyright 2013 Bhushan Shah * Copyright 2013 Sebastian Kügler * Copyright 2015 Kai Uwe Broulik * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see */ import QtQuick 2.0 import QtQuick.Controls 2.3 as QtControls import QtQuick.Layouts 1.0 as QtLayouts import org.kde.plasma.calendar 2.0 as PlasmaCalendar import org.kde.kquickcontrolsaddons 2.0 import org.kde.kirigami 2.5 as Kirigami QtLayouts.ColumnLayout { id: appearancePage - width: childrenRect.width - height: childrenRect.height signal configurationChanged property string cfg_fontFamily property alias cfg_boldText: boldCheckBox.checked property string cfg_timeFormat: "" property alias cfg_italicText: italicCheckBox.checked property alias cfg_showLocalTimezone: showLocalTimezone.checked property alias cfg_displayTimezoneAsCode: timezoneCodeRadio.checked property alias cfg_showSeconds: showSeconds.checked property alias cfg_showDate: showDate.checked property string cfg_dateFormat: "shortDate" property alias cfg_customDateFormat: customDateFormat.text property alias cfg_use24hFormat: use24hFormat.currentIndex onCfg_fontFamilyChanged: { // HACK by the time we populate our model and/or the ComboBox is finished the value is still undefined if (cfg_fontFamily) { for (var i = 0, j = fontsModel.count; i < j; ++i) { if (fontsModel.get(i).value === cfg_fontFamily) { fontFamilyComboBox.currentIndex = i break } } } } ListModel { id: fontsModel Component.onCompleted: { var arr = [] // use temp array to avoid constant binding stuff arr.push({text: i18nc("Use default font", "Default"), value: ""}) var fonts = Qt.fontFamilies() var foundIndex = 0 for (var i = 0, j = fonts.length; i < j; ++i) { arr.push({text: fonts[i], value: fonts[i]}) } append(arr) } } Kirigami.FormLayout { QtLayouts.Layout.fillWidth: true QtControls.CheckBox { id: showDate Kirigami.FormData.label: i18n("Information:") text: i18n("Show date") } QtControls.CheckBox { id: showSeconds text: i18n("Show seconds") } QtControls.CheckBox { id: showLocalTimezone text: i18n("Show local time zone") } Item { Kirigami.FormData.isSection: true } QtLayouts.ColumnLayout { Kirigami.FormData.label: i18n("Display time zone as:") Kirigami.FormData.buddyFor: timezoneCityRadio QtControls.RadioButton { id: timezoneCityRadio text: i18n("Time zone city") } QtControls.RadioButton { id: timezoneCodeRadio text: i18n("Time zone code") } } Item { Kirigami.FormData.isSection: true } QtLayouts.RowLayout { QtLayouts.Layout.fillWidth: true Kirigami.FormData.label: i18n("Time display:") QtControls.ComboBox { id: use24hFormat model: [ i18n("12-Hour"), i18n("Use Region Defaults"), i18n("24-Hour") ] onCurrentIndexChanged: cfg_use24hFormat = currentIndex } QtControls.Button { visible: KCMShell.authorize("formats.desktop").length > 0 text: i18n("Change Regional Settings...") icon.name: "preferences-desktop-locale" onClicked: KCMShell.open("formats.desktop") } } Item { Kirigami.FormData.isSection: true } QtControls.ComboBox { id: dateFormat Kirigami.FormData.label: i18n("Date format:") enabled: showDate.checked textRole: "label" model: [ { 'label': i18n("Long Date"), 'name': "longDate" }, { 'label': i18n("Short Date"), 'name': "shortDate" }, { 'label': i18n("ISO Date"), 'name': "isoDate" }, { 'label': i18nc("custom date format", "Custom"), 'name': "custom" } ] onCurrentIndexChanged: cfg_dateFormat = model[currentIndex]["name"] Component.onCompleted: { for (var i = 0; i < model.length; i++) { if (model[i]["name"] === plasmoid.configuration.dateFormat) { dateFormat.currentIndex = i; } } } } QtControls.TextField { id: customDateFormat QtLayouts.Layout.fillWidth: true visible: cfg_dateFormat == "custom" } QtControls.Label { text: i18n("Time Format Documentation") visible: cfg_dateFormat == "custom" wrapMode: Text.Wrap QtLayouts.Layout.preferredWidth: QtLayouts.Layout.maximumWidth QtLayouts.Layout.maximumWidth: units.gridUnit * 16 onLinkActivated: Qt.openUrlExternally(link) MouseArea { anchors.fill: parent acceptedButtons: Qt.NoButton // We don't want to eat clicks on the Label cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor } } Item { Kirigami.FormData.isSection: true } QtLayouts.RowLayout { QtLayouts.Layout.fillWidth: true Kirigami.FormData.label: i18n("Font style:") QtControls.ComboBox { id: fontFamilyComboBox QtLayouts.Layout.fillWidth: true currentIndex: 0 // ComboBox's sizing is just utterly broken QtLayouts.Layout.minimumWidth: units.gridUnit * 10 model: fontsModel // doesn't autodeduce from model because we manually populate it textRole: "text" onCurrentIndexChanged: { var current = model.get(currentIndex) if (current) { cfg_fontFamily = current.value appearancePage.configurationChanged() } } } QtControls.Button { id: boldCheckBox QtControls.ToolTip { text: i18n("Bold text") } icon.name: "format-text-bold" checkable: true - Accessible.name: tooltip + Accessible.name: QtControls.ToolTip.text } QtControls.Button { id: italicCheckBox QtControls.ToolTip { text: i18n("Italic text") } icon.name: "format-text-italic" checkable: true - Accessible.name: tooltip + Accessible.name: QtControls.ToolTip.text } } } Item { QtLayouts.Layout.fillHeight: true } Component.onCompleted: { if (plasmoid.configuration.displayTimezoneAsCode) { timezoneCodeRadio.checked = true; } else { timezoneCityRadio.checked = true; } } } diff --git a/applets/digital-clock/package/contents/ui/configTimeZones.qml b/applets/digital-clock/package/contents/ui/configTimeZones.qml index 2b20a3220..aacd5f00b 100644 --- a/applets/digital-clock/package/contents/ui/configTimeZones.qml +++ b/applets/digital-clock/package/contents/ui/configTimeZones.qml @@ -1,209 +1,134 @@ /* * Copyright 2013 Kai Uwe Broulik * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see */ import QtQuick 2.0 import QtQuick.Controls 1.2 as QtControls import QtQuick.Layouts 1.0 import QtQuick.Dialogs 1.1 import org.kde.plasma.private.digitalclock 1.0 import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.kirigami 2.5 as Kirigami -Item { +ColumnLayout { id: timeZonesPage - width: parent.width - height: parent.height property alias cfg_selectedTimeZones: timeZones.selectedTimeZones property alias cfg_wheelChangesTimezone: enableWheelCheckBox.checked TimeZoneModel { id: timeZones onSelectedTimeZonesChanged: { if (selectedTimeZones.length === 0) { messageWidget.visible = true; timeZones.selectLocalTimeZone(); } } } // This is just for getting the column width QtControls.CheckBox { id: checkbox visible: false } + Kirigami.InlineMessage { + id: messageWidget - ColumnLayout { - anchors.fill: parent + Layout.fillWidth: true - Rectangle { - id: messageWidget + type: Kirigami.MessageType.Warning + text: i18n("At least one time zone needs to be enabled. 'Local' was enabled automatically.") - anchors { - left: parent.left - right: parent.right - margins: 1 - } - - height: 0 + showCloseButton: true + } - //TODO: This is the actual color KMessageWidget uses as its base color but here it gives - // a different color, figure out why - //property color gradBaseColor: Qt.rgba(0.69, 0.5, 0, 1) - gradient: Gradient { - GradientStop { position: 0.0; color: "#FFD86D" } //Qt.lighter(messageWidget.gradBaseColor, 1.1) - GradientStop { position: 0.1; color: "#EAC360" } // messageWidget.gradBaseColor - GradientStop { position: 1.0; color: "#CAB064" } //Qt.darker(messageWidget.gradBaseColor, 1.1) - } + QtControls.TextField { + id: filter + Layout.fillWidth: true + placeholderText: i18n("Search Time Zones") + } - radius: 5 - border.width: 1 - border.color: "#79735B" + QtControls.TableView { + id: timeZoneView - visible: false + signal toggleCurrent - Behavior on visible { - ParallelAnimation { - PropertyAnimation { - target: messageWidget - property: "opacity" - to: messageWidget.visible ? 0 : 1.0 - easing.type: Easing.Linear - } - PropertyAnimation { - target: messageWidget - property: "Layout.minimumHeight" - to: messageWidget.visible ? 0 : messageWidgetLabel.height + (2 *units.largeSpacing) - easing.type: Easing.Linear - } - } - } + Layout.fillWidth: true + Layout.fillHeight: true - RowLayout { - anchors.fill: parent - anchors.margins: units.largeSpacing - anchors.leftMargin: units.smallSpacing - anchors.rightMargin: units.smallSpacing - spacing: units.smallSpacing - - PlasmaCore.IconItem { - anchors.verticalCenter: parent.verticalCenter - height: units.iconSizes.smallMedium - width: height - source: "dialog-warning" - } + Keys.onSpacePressed: toggleCurrent() - QtControls.Label { - id: messageWidgetLabel - anchors.verticalCenter: parent.verticalCenter - Layout.fillWidth: true - text: i18n("At least one time zone needs to be enabled. 'Local' was enabled automatically.") - verticalAlignment: Text.AlignVCenter - wrapMode: Text.WordWrap - } - - PlasmaComponents.ToolButton { - anchors.verticalCenter: parent.verticalCenter - iconName: "dialog-close" - flat: true + model: TimeZoneFilterProxy { + sourceModel: timeZones + filterString: filter.text + } + QtControls.TableViewColumn { + role: "checked" + width: checkbox.width + delegate: + QtControls.CheckBox { + id: checkBox + anchors.centerIn: parent + checked: styleData.value + activeFocusOnTab: false // only let the TableView as a whole get focus onClicked: { - messageWidget.visible = false; + //needed for model's setData to be called + model.checked = checked; } - } - } - } - - QtControls.TextField { - id: filter - Layout.fillWidth: true - placeholderText: i18n("Search Time Zones") - } - - QtControls.TableView { - id: timeZoneView - signal toggleCurrent - - Layout.fillWidth: true - Layout.fillHeight: true - - Keys.onSpacePressed: toggleCurrent() - - model: TimeZoneFilterProxy { - sourceModel: timeZones - filterString: filter.text - } - - QtControls.TableViewColumn { - role: "checked" - width: checkbox.width - delegate: - QtControls.CheckBox { - id: checkBox - anchors.centerIn: parent - checked: styleData.value - activeFocusOnTab: false // only let the TableView as a whole get focus - onClicked: { - //needed for model's setData to be called - model.checked = checked; - } - - Connections { - target: timeZoneView - onToggleCurrent: { - if (styleData.row === timeZoneView.currentRow) { - model.checked = !checkBox.checked - } + Connections { + target: timeZoneView + onToggleCurrent: { + if (styleData.row === timeZoneView.currentRow) { + model.checked = !checkBox.checked } } } + } - resizable: false - movable: false - } - QtControls.TableViewColumn { - role: "city" - title: i18n("City") - } - QtControls.TableViewColumn { - role: "region" - title: i18n("Region") - } - QtControls.TableViewColumn { - role: "comment" - title: i18n("Comment") - } + resizable: false + movable: false } - - RowLayout { - Layout.fillWidth: true - QtControls.CheckBox { - id: enableWheelCheckBox - text: i18n("Switch time zone with mouse wheel") - } + QtControls.TableViewColumn { + role: "city" + title: i18n("City") } + QtControls.TableViewColumn { + role: "region" + title: i18n("Region") + } + QtControls.TableViewColumn { + role: "comment" + title: i18n("Comment") + } + } + RowLayout { + Layout.fillWidth: true + QtControls.CheckBox { + id: enableWheelCheckBox + text: i18n("Switch time zone with mouse wheel") + } } }