Make configuration use Kirigami FormLayout

This commit is contained in:
qewer33 2024-04-18 21:49:46 +03:00
parent cee507a227
commit fa0bb4f9fb
4 changed files with 230 additions and 279 deletions

View file

@ -11,10 +11,9 @@ import QtQuick.Dialogs
import org.kde.kirigami 2.3 as Kirigami import org.kde.kirigami 2.3 as Kirigami
import org.kde.kcmutils as KCM import org.kde.kcmutils as KCM
import "../lib" import "../lib"
KCM.ScrollViewKCM { KCM.SimpleKCM {
id: appearancePage id: appearancePage
width: childrenRect.width width: childrenRect.width
height: childrenRect.height height: childrenRect.height
@ -81,54 +80,48 @@ KCM.ScrollViewKCM {
} }
} }
QtLayouts.ColumnLayout { Kirigami.FormLayout {
id: layout id: layout
anchors.fill: parent anchors.fill: parent
spacing: 30
QtLayouts.ColumnLayout {
QtLayouts.Layout.fillWidth: true
spacing: 10
QtControls.Label { Kirigami.Separator {
text: i18n("Clock Display Settings") Kirigami.FormData.isSection: true
font.bold: true Kirigami.FormData.label: "Clock Display Settings"
font.pixelSize: 17
} }
QtControls.CheckBox { QtControls.CheckBox {
Kirigami.FormData.label: "Use 24-hour clock"
id: use24hFormat id: use24hFormat
text: i18n("Use 24-hour clock")
tristate: false tristate: false
checked: cfg_clockUse24hFormat checked: cfg_clockUse24hFormat
} }
QtControls.CheckBox { QtControls.CheckBox {
Kirigami.FormData.label: "Show seconds"
id: showSeconds id: showSeconds
text: i18n("Show seconds")
tristate: false tristate: false
checked: cfg_clockShowSeconds checked: cfg_clockShowSeconds
} }
QtLayouts.RowLayout {
QtControls.Label {
text: i18n("Separator:")
}
QtControls.TextField { QtControls.TextField {
Kirigami.FormData.label: "Separator"
id: clockSeparatorTextField id: clockSeparatorTextField
maximumLength: 1 maximumLength: 1
} }
ColorButton {
Kirigami.FormData.label: "Color"
onValueChanged: {
cfg_clockFontColor = value
}
} }
FontConfig { FontConfig {
Kirigami.FormData.label: "Font"
fontModel: fontsModel fontModel: fontsModel
colorValue: cfg_clockFontColor
onColorValueChanged: {
cfg_clockFontColor = colorValue
}
fontValue: cfg_clockFontFamily fontValue: cfg_clockFontFamily
onFontValueChanged: { onFontValueChanged: {
cfg_clockFontFamily = fontValue cfg_clockFontFamily = fontValue
@ -158,6 +151,7 @@ KCM.ScrollViewKCM {
} }
ShadowConfig { ShadowConfig {
Kirigami.FormData.label: "Shadow"
enabled: clockShadowCheckBox.checked enabled: clockShadowCheckBox.checked
colorValue: cfg_clockShadowColor colorValue: cfg_clockShadowColor
@ -180,32 +174,31 @@ KCM.ScrollViewKCM {
cfg_clockShadowYOffset = offsetYValue cfg_clockShadowYOffset = offsetYValue
} }
} }
}
QtLayouts.ColumnLayout {
QtLayouts.Layout.fillWidth: true
spacing: 10
QtControls.Label { Kirigami.Separator {
text: i18n("Day Display Settings") Kirigami.FormData.isSection: true
font.bold: true Kirigami.FormData.label: "Day Display Settings"
font.pixelSize: 17
} }
QtControls.CheckBox { QtControls.CheckBox {
Kirigami.FormData.label: "Show day display"
id: showDayDisplayCheckBox id: showDayDisplayCheckBox
text: i18n("Show day display") }
ColorButton {
Kirigami.FormData.label: "Color"
onValueChanged: {
cfg_dayFontColor = value
}
} }
FontConfig { FontConfig {
Kirigami.FormData.label: "Font"
fontModel: fontsModel fontModel: fontsModel
enabled: showDayDisplayCheckBox.checked enabled: showDayDisplayCheckBox.checked
colorValue: cfg_dayFontColor
onColorValueChanged: {
cfg_dayFontColor = colorValue
}
fontValue: cfg_dayFontFamily fontValue: cfg_dayFontFamily
onFontValueChanged: { onFontValueChanged: {
cfg_dayFontFamily = fontValue cfg_dayFontFamily = fontValue
@ -235,6 +228,7 @@ KCM.ScrollViewKCM {
} }
ShadowConfig { ShadowConfig {
Kirigami.FormData.label: "Shadow"
enabled: dayShadowCheckBox.checked enabled: dayShadowCheckBox.checked
colorValue: cfg_dayShadowColor colorValue: cfg_dayShadowColor
@ -257,33 +251,22 @@ KCM.ScrollViewKCM {
cfg_dayShadowYOffset = offsetYValue cfg_dayShadowYOffset = offsetYValue
} }
} }
}
QtLayouts.ColumnLayout {
QtLayouts.Layout.fillWidth: true
spacing: 10
QtControls.Label { Kirigami.Separator {
text: i18n("Date Display Settings") Kirigami.FormData.isSection: true
font.bold: true Kirigami.FormData.label: "Date Display Settings"
font.pixelSize: 17
} }
QtControls.CheckBox { QtControls.CheckBox {
Kirigami.FormData.label: "Show date display"
id: showDateDisplayCheckBox id: showDateDisplayCheckBox
text: i18n("Show date display")
} }
QtLayouts.RowLayout { QtLayouts.RowLayout {
Kirigami.FormData.label: "Date format"
enabled: showDateDisplayCheckBox.checked enabled: showDateDisplayCheckBox.checked
QtControls.Label {
text: i18n("Date format:")
opacity: if (enabled) 1
else 0.4
}
QtLayouts.RowLayout {
QtControls.TextField { QtControls.TextField {
id: customDateFormat id: customDateFormat
QtLayouts.Layout.fillWidth: true QtLayouts.Layout.fillWidth: true
@ -294,17 +277,20 @@ KCM.ScrollViewKCM {
onClicked: Qt.openUrlExternally("https://doc.qt.io/qt-5/qml-qtqml-qt.html#formatDateTime-method") onClicked: Qt.openUrlExternally("https://doc.qt.io/qt-5/qml-qtqml-qt.html#formatDateTime-method")
} }
} }
ColorButton {
Kirigami.FormData.label: "Color"
onValueChanged: {
cfg_dateFontColor = value
}
} }
FontConfig { FontConfig {
Kirigami.FormData.label: "Font"
fontModel: fontsModel fontModel: fontsModel
enabled: showDateDisplayCheckBox.checked enabled: showDateDisplayCheckBox.checked
colorValue: cfg_dateFontColor
onColorValueChanged: {
cfg_dateFontColor = colorValue
}
fontValue: cfg_dateFontFamily fontValue: cfg_dateFontFamily
onFontValueChanged: { onFontValueChanged: {
cfg_dateFontFamily = fontValue cfg_dateFontFamily = fontValue
@ -334,6 +320,7 @@ KCM.ScrollViewKCM {
} }
ShadowConfig { ShadowConfig {
Kirigami.FormData.label: "Shadow"
enabled: dateShadowCheckBox.checked enabled: dateShadowCheckBox.checked
colorValue: cfg_dateShadowColor colorValue: cfg_dateShadowColor
@ -357,12 +344,5 @@ KCM.ScrollViewKCM {
} }
} }
} }
}
} }
/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}D{i:1}D{i:3}D{i:2}
}
##^##*/

View file

@ -1,17 +1,16 @@
import QtQuick 2.4
import QtQuick.Controls 2.12 as QtControls
import QtQuick.Layouts 1.12 as QtLayouts
/* /*
SPDX-FileCopyrightText: 2022 qewer33 SPDX-FileCopyrightText: 2022 qewer33
SPDX-License-Identifier: GPL-3.0-or-later SPDX-License-Identifier: GPL-3.0-or-later
*/ */
import QtQuick 2.4
import QtQuick.Controls 2.12 as QtControls
import QtQuick.Layouts 1.12 as QtLayouts
import QtQuick.Dialogs import QtQuick.Dialogs
QtControls.Button { QtControls.Button {
id: clockFontColorButton id: clockFontColorButton
implicitWidth: 50 implicitWidth: 50
implicitHeight: parent.height
property color value property color value
@ -21,8 +20,7 @@ QtControls.Button {
anchors.margins: 5 anchors.margins: 5
radius: 3 radius: 3
color: value color: value
opacity: if (enabled) 1 opacity: enabled ? 1 : 0.4
else 0.4
} }
MouseArea { MouseArea {

View file

@ -16,41 +16,22 @@ QtLayouts.RowLayout {
property var fontModel property var fontModel
property color colorValue
property string fontValue property string fontValue
property bool boldValue property bool boldValue
property bool italicValue property bool italicValue
property int pxSizeValue property int pxSizeValue
QtControls.Label {
text: i18n("Font style:")
opacity: if (enabled) 1
else 0.4
}
ColorButton {
id: fontColorButton
value: colorValue
onValueChanged: {
colorValue = value
}
}
QtControls.ComboBox { QtControls.ComboBox {
id: fontFamilyComboBox id: fontFamilyComboBox
QtLayouts.Layout.fillWidth: true QtLayouts.Layout.maximumWidth: Kirigami.Units.gridUnit * 10
QtLayouts.Layout.minimumWidth: Kirigami.Units.gridUnit * 10
model: fontModel model: fontModel
textRole: "text" textRole: "text"
currentIndex: getIdFromModel() currentIndex: getIdFromModel()
function getIdFromModel(){ function getIdFromModel() {
for(var i = 0; i < model.count; i++){ for (var i = 0; i < model.count; i++) {
if(model.get(i).value === fontValue){ if (model.get(i).value === fontValue) return i;
return i;
}
} }
return 0; return 0;
} }

View file

@ -18,12 +18,6 @@ QtLayouts.RowLayout {
property int offsetYValue property int offsetYValue
QtControls.Label {
text: i18n("Shadow style:")
opacity: if (enabled) 1
else 0.4
}
ColorButton { ColorButton {
id: shadowColorButton id: shadowColorButton
value: colorValue value: colorValue
@ -35,8 +29,7 @@ QtLayouts.RowLayout {
QtControls.Label { QtControls.Label {
text: i18n("Radius") text: i18n("Radius")
opacity: if (enabled) 1 opacity: enabled ? 1 : 0.4
else 0.4
} }
QtControls.SpinBox { QtControls.SpinBox {
@ -52,8 +45,7 @@ QtLayouts.RowLayout {
QtControls.Label { QtControls.Label {
text: i18n("Offset") text: i18n("Offset")
opacity: if (enabled) 1 opacity: enabled ? 1 : 0.4
else 0.4
} }
QtControls.SpinBox { QtControls.SpinBox {