Port digital clock settings to QQc2 and Kirigami

Summary:
use QQC2 and FormLayout for alignment

also, qqc2 combobox doesn't suffer from 390801 anymore

BUG: 390801

Test Plan: tried to set all the options

Reviewers: #plasma, #vdg, ngraham

Reviewed By: #vdg, ngraham

Subscribers: ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D17333
wilder-broken-krunner
Marco Martin 7 years ago
parent 76eba93be2
commit 39e812d57f
  1. 163
      applets/digital-clock/package/contents/ui/configAppearance.qml

@ -21,11 +21,12 @@
*/ */
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Controls 1.0 as QtControls import QtQuick.Controls 2.3 as QtControls
import QtQuick.Layouts 1.0 as QtLayouts import QtQuick.Layouts 1.0 as QtLayouts
import org.kde.plasma.calendar 2.0 as PlasmaCalendar import org.kde.plasma.calendar 2.0 as PlasmaCalendar
import org.kde.kirigami 2.5 as Kirigami
Item { QtLayouts.ColumnLayout {
id: appearancePage id: appearancePage
width: childrenRect.width width: childrenRect.width
height: childrenRect.height height: childrenRect.height
@ -43,7 +44,7 @@ Item {
property alias cfg_showDate: showDate.checked property alias cfg_showDate: showDate.checked
property string cfg_dateFormat: "shortDate" property string cfg_dateFormat: "shortDate"
property alias cfg_use24hFormat: use24hFormat.checkedState property alias cfg_use24hFormat: use24hFormat.checked
onCfg_fontFamilyChanged: { onCfg_fontFamilyChanged: {
// HACK by the time we populate our model and/or the ComboBox is finished the value is still undefined // HACK by the time we populate our model and/or the ComboBox is finished the value is still undefined
@ -72,107 +73,92 @@ Item {
} }
} }
QtLayouts.ColumnLayout { Kirigami.FormLayout {
anchors.left: parent.left QtLayouts.Layout.fillWidth: true
QtControls.GroupBox { QtControls.CheckBox {
QtLayouts.Layout.fillWidth: true id: showDate
title: i18n("Information") Kirigami.FormData.label: i18n("Information:")
flat: true text: i18n("Show date")
}
QtLayouts.ColumnLayout {
QtControls.CheckBox {
id: showDate
text: i18n("Show date")
}
QtControls.CheckBox { QtControls.CheckBox {
id: showSeconds id: showSeconds
text: i18n("Show seconds") text: i18n("Show seconds")
} }
QtControls.CheckBox { QtControls.CheckBox {
id: use24hFormat id: use24hFormat
text: i18nc("Checkbox label; means 24h clock format, without am/pm", "Use 24-hour Clock") text: i18nc("Checkbox label; means 24h clock format, without am/pm", "Use 24-hour Clock")
} }
QtControls.CheckBox { QtControls.CheckBox {
id: showLocalTimezone id: showLocalTimezone
text: i18n("Show local time zone") text: i18n("Show local time zone")
} }
QtControls.Label { QtLayouts.ColumnLayout {
text: i18n("Display time zone as:") Kirigami.FormData.label: i18n("Display time zone as:")
} Kirigami.FormData.buddyFor: timezoneCityRadio
QtControls.GroupBox { QtControls.RadioButton {
QtLayouts.Layout.fillWidth: true id: timezoneCityRadio
flat: true text: i18n("Time zone city")
QtLayouts.ColumnLayout { }
QtControls.ExclusiveGroup { id: timezoneDisplayType } QtControls.RadioButton {
id: timezoneCodeRadio
text: i18n("Time zone code")
}
}
QtControls.RadioButton { Item {
id: timezoneCityRadio Kirigami.FormData.isSection: true
text: i18n("Time zone city") }
exclusiveGroup: timezoneDisplayType
}
QtControls.RadioButton { QtControls.ComboBox {
id: timezoneCodeRadio id: dateFormat
text: i18n("Time zone code") Kirigami.FormData.label: i18n("Date format:")
exclusiveGroup: timezoneDisplayType enabled: showDate.checked
} textRole: "label"
} model: [
{
'label': i18n("Long Date"),
'name': "longDate"
},
{
'label': i18n("Short Date"),
'name': "shortDate"
},
{
'label': i18n("ISO Date"),
'name': "isoDate"
} }
]
onCurrentIndexChanged: cfg_dateFormat = model[currentIndex]["name"]
QtLayouts.RowLayout { Component.onCompleted: {
QtControls.Label { for (var i = 0; i < model.length; i++) {
text: i18n("Date format:") if (model[i]["name"] == plasmoid.configuration.dateFormat) {
} dateFormat.currentIndex = i;
QtControls.ComboBox {
id: dateFormat
enabled: showDate.checked
textRole: "label"
model: [
{
'label': i18n("Long Date"),
'name': "longDate"
},
{
'label': i18n("Short Date"),
'name': "shortDate"
},
{
'label': i18n("ISO Date"),
'name': "isoDate"
}
]
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;
}
}
}
} }
} }
} }
} }
Item {
Kirigami.FormData.isSection: true
}
QtLayouts.RowLayout { QtLayouts.RowLayout {
QtLayouts.Layout.fillWidth: true QtLayouts.Layout.fillWidth: true
QtControls.Label { Kirigami.FormData.label: i18n("Font style:")
text: i18n("Font style:")
}
QtControls.ComboBox { QtControls.ComboBox {
id: fontFamilyComboBox id: fontFamilyComboBox
QtLayouts.Layout.fillWidth: true QtLayouts.Layout.fillWidth: true
currentIndex: 0
// ComboBox's sizing is just utterly broken // ComboBox's sizing is just utterly broken
QtLayouts.Layout.minimumWidth: units.gridUnit * 10 QtLayouts.Layout.minimumWidth: units.gridUnit * 10
model: fontsModel model: fontsModel
@ -190,21 +176,28 @@ Item {
QtControls.Button { QtControls.Button {
id: boldCheckBox id: boldCheckBox
tooltip: i18n("Bold text") QtControls.ToolTip {
iconName: "format-text-bold" text: i18n("Bold text")
}
icon.name: "format-text-bold"
checkable: true checkable: true
Accessible.name: tooltip Accessible.name: tooltip
} }
QtControls.Button { QtControls.Button {
id: italicCheckBox id: italicCheckBox
tooltip: i18n("Italic text") QtControls.ToolTip {
iconName: "format-text-italic" text: i18n("Italic text")
}
icon.name: "format-text-italic"
checkable: true checkable: true
Accessible.name: tooltip Accessible.name: tooltip
} }
} }
} }
Item {
QtLayouts.Layout.fillHeight: true
}
Component.onCompleted: { Component.onCompleted: {
if (plasmoid.configuration.displayTimezoneAsCode) { if (plasmoid.configuration.displayTimezoneAsCode) {

Loading…
Cancel
Save