Fix custom date format config

This commit is contained in:
qewer33 2021-12-17 17:59:30 +03:00
parent 8c7a876674
commit aced0d6a84
6 changed files with 21 additions and 21 deletions

0
ClearClock.files Normal file
View file

1
ClearClock.includes Normal file
View file

@ -0,0 +1 @@
package

1
build.sh Normal file
View file

@ -0,0 +1 @@

View file

@ -17,7 +17,7 @@
</entry> </entry>
<entry name="clockFontFamily" type="string"> <entry name="clockFontFamily" type="string">
<label>Sets the clock font family.</label> <label>Sets the clock font family.</label>
<default></default> <default>ClearClock Default</default>
</entry> </entry>
<entry name="clockBoldText" type="Bool"> <entry name="clockBoldText" type="Bool">
<label>Sets the clock font to bold.</label> <label>Sets the clock font to bold.</label>
@ -42,7 +42,7 @@
</entry> </entry>
<entry name="dayFontFamily" type="string"> <entry name="dayFontFamily" type="string">
<label>Sets the day font family.</label> <label>Sets the day font family.</label>
<default></default> <default>ClearClock Default</default>
</entry> </entry>
<entry name="dayBoldText" type="Bool"> <entry name="dayBoldText" type="Bool">
<label>Sets the day font to bold.</label> <label>Sets the day font to bold.</label>
@ -61,7 +61,7 @@
<label>Whether the date should be shown below the clock.</label> <label>Whether the date should be shown below the clock.</label>
<default>true</default> <default>true</default>
</entry> </entry>
<entry name="customDateFormat" type="string"> <entry name="dateCustomDateFormat" type="string">
<label>Custom date format string.</label> <label>Custom date format string.</label>
<default>d MMMM yyyy</default> <default>d MMMM yyyy</default>
</entry> </entry>
@ -71,7 +71,7 @@
</entry> </entry>
<entry name="dateFontFamily" type="string"> <entry name="dateFontFamily" type="string">
<label>Sets the date font family.</label> <label>Sets the date font family.</label>
<default></default> <default>ClearClock Default</default>
</entry> </entry>
<entry name="dateBoldText" type="Bool"> <entry name="dateBoldText" type="Bool">
<label>Sets the date font to bold.</label> <label>Sets the date font to bold.</label>

View file

@ -66,6 +66,10 @@ Item {
id: fontsModel id: fontsModel
Component.onCompleted: { Component.onCompleted: {
var arr = [] // use temp array to avoid constant binding stuff var arr = [] // use temp array to avoid constant binding stuff
arr.push({
"text": "ClearClock Default",
"value": "ClearClock Default"
})
arr.push({ arr.push({
"text": i18nc("Use default font", "Default"), "text": i18nc("Use default font", "Default"),
"value": "" "value": ""
@ -139,10 +143,8 @@ Item {
QtControls.ComboBox { QtControls.ComboBox {
id: clockFontFamilyComboBox id: clockFontFamilyComboBox
QtLayouts.Layout.fillWidth: true QtLayouts.Layout.fillWidth: true
// ComboBox's sizing is just utterly broken
QtLayouts.Layout.minimumWidth: units.gridUnit * 10 QtLayouts.Layout.minimumWidth: units.gridUnit * 10
model: fontsModel model: fontsModel
// doesn't autodeduce from model because we manually populate it
textRole: "text" textRole: "text"
onCurrentIndexChanged: { onCurrentIndexChanged: {
@ -239,10 +241,8 @@ Item {
QtControls.ComboBox { QtControls.ComboBox {
id: dayFontFamilyComboBox id: dayFontFamilyComboBox
QtLayouts.Layout.fillWidth: true QtLayouts.Layout.fillWidth: true
// ComboBox's sizing is just utterly broken
QtLayouts.Layout.minimumWidth: units.gridUnit * 10 QtLayouts.Layout.minimumWidth: units.gridUnit * 10
model: fontsModel model: fontsModel
// doesn't autodeduce from model because we manually populate it
textRole: "text" textRole: "text"
onCurrentIndexChanged: { onCurrentIndexChanged: {
@ -363,10 +363,8 @@ Item {
QtControls.ComboBox { QtControls.ComboBox {
id: dateFontFamilyComboBox id: dateFontFamilyComboBox
QtLayouts.Layout.fillWidth: true QtLayouts.Layout.fillWidth: true
// ComboBox's sizing is just utterly broken
QtLayouts.Layout.minimumWidth: units.gridUnit * 10 QtLayouts.Layout.minimumWidth: units.gridUnit * 10
model: fontsModel model: fontsModel
// doesn't autodeduce from model because we manually populate it
textRole: "text" textRole: "text"
onCurrentIndexChanged: { onCurrentIndexChanged: {

View file

@ -54,10 +54,10 @@ Item {
spacing: -20 spacing: -20
TextMetrics { TextMetrics {
id: textMetricsTimeLabel id: textMetricsClockLabel
font.family: timeLabel.font.family font.family: clockLabel.font.family
font.pixelSize: timeLabel.font.pixelSize font.pixelSize: clockLabel.font.pixelSize
font.bold: timeLabel.font.bold font.bold: clockLabel.font.bold
text: " 99:99 " text: " 99:99 "
} }
@ -69,18 +69,18 @@ Item {
} }
Item { Item {
width: max(textMetricsTimeLabel.width, textMetricsDayLabel.width) width: max(textMetricsClockLabel.width, textMetricsDayLabel.width)
height: max(textMetricsTimeLabel.height, textMetricsDayLabel.height) height: max(textMetricsClockLabel.height, textMetricsDayLabel.height)
Layout.alignment: Qt.AlignCenter Layout.alignment: Qt.AlignCenter
PlasmaComponents.Label { PlasmaComponents.Label {
id: timeLabel id: clockLabel
anchors.centerIn: parent anchors.centerIn: parent
text: Qt.formatTime(currentDateTime).replace(":", ".") text: Qt.formatTime(currentDateTime).replace(":", ".")
color: plasmoid.configuration.clockFontColor color: plasmoid.configuration.clockFontColor
font.family: if (plasmoid.configuration.clockFontFamily === "") fontOutfitBold.name font.family: if (plasmoid.configuration.clockFontFamily === "ClearClock Default") fontOutfitBold.name
else plasmoid.configuration.clockFontFamily else plasmoid.configuration.clockFontFamily
font.bold: plasmoid.configuration.clockBoldText font.bold: plasmoid.configuration.clockBoldText
font.italic: plasmoid.configuration.clockItalicText font.italic: plasmoid.configuration.clockItalicText
@ -95,7 +95,7 @@ Item {
text: Qt.formatDate(currentDateTime, "dddd") text: Qt.formatDate(currentDateTime, "dddd")
color: plasmoid.configuration.dayFontColor color: plasmoid.configuration.dayFontColor
font.family: if (plasmoid.configuration.dayFontFamily === "") fontSmooch.name font.family: if (plasmoid.configuration.dayFontFamily === "ClearClock Default") fontSmooch.name
else plasmoid.configuration.dayFontFamily else plasmoid.configuration.dayFontFamily
font.bold: plasmoid.configuration.daykBoldText font.bold: plasmoid.configuration.daykBoldText
font.italic: plasmoid.configuration.dayItalicText font.italic: plasmoid.configuration.dayItalicText
@ -108,10 +108,10 @@ Item {
visible: plasmoid.configuration.showDateDisplay visible: plasmoid.configuration.showDateDisplay
Layout.alignment: Qt.AlignCenter Layout.alignment: Qt.AlignCenter
text: Qt.formatDate(currentDateTime, plasmoid.configuration.customDateFormat) text: Qt.formatDate(currentDateTime, plasmoid.configuration.dateCustomDateFormat)
color: plasmoid.configuration.dateFontColor color: plasmoid.configuration.dateFontColor
font.family: if (plasmoid.configuration.dateFontFamily === "") fontOutfitRegular.name font.family: if (plasmoid.configuration.dateFontFamily === "ClearClock Default") fontOutfitRegular.name
else plasmoid.configuration.dateFontFamily else plasmoid.configuration.dateFontFamily
font.bold: plasmoid.configuration.dateBoldText font.bold: plasmoid.configuration.dateBoldText
font.italic: plasmoid.configuration.dateItalicText font.italic: plasmoid.configuration.dateItalicText