Clock: small changes to compact mode
This commit is contained in:
parent
a1cbd35202
commit
baafe54d13
3 changed files with 9 additions and 31 deletions
|
|
@ -35,8 +35,6 @@ Rectangle {
|
||||||
readonly property bool reverseDayMonth: widgetSettings.reverseDayMonth
|
readonly property bool reverseDayMonth: widgetSettings.reverseDayMonth
|
||||||
!== undefined ? widgetSettings.reverseDayMonth : widgetMetadata.reverseDayMonth
|
!== undefined ? widgetSettings.reverseDayMonth : widgetMetadata.reverseDayMonth
|
||||||
readonly property bool compactMode: widgetSettings.compactMode !== undefined ? widgetSettings.compactMode : widgetMetadata.compactMode
|
readonly property bool compactMode: widgetSettings.compactMode !== undefined ? widgetSettings.compactMode : widgetMetadata.compactMode
|
||||||
readonly property bool compactDateNumeric: widgetSettings.compactDateNumeric
|
|
||||||
!== undefined ? widgetSettings.compactDateNumeric : widgetMetadata.compactDateNumeric
|
|
||||||
|
|
||||||
implicitWidth: (compactMode ? Math.max(timeText.implicitWidth,
|
implicitWidth: (compactMode ? Math.max(timeText.implicitWidth,
|
||||||
dateText.implicitWidth) : clock.width) + Style.marginM * 2 * scaling
|
dateText.implicitWidth) : clock.width) + Style.marginM * 2 * scaling
|
||||||
|
|
@ -50,12 +48,12 @@ Rectangle {
|
||||||
Item {
|
Item {
|
||||||
id: clockContainer
|
id: clockContainer
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: Math.round((compactMode ? Style.marginS : Style.marginM) * scaling)
|
anchors.margins: Math.round((compactMode ? Style.marginXS : Style.marginM) * scaling)
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: compactColumn
|
id: compactColumn
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
spacing: Math.round(Style.marginXXS * scaling)
|
spacing: compactMode ? 0 : Math.round(Style.marginXXS * scaling)
|
||||||
visible: compactMode
|
visible: compactMode
|
||||||
|
|
||||||
NText {
|
NText {
|
||||||
|
|
@ -77,21 +75,13 @@ Rectangle {
|
||||||
visible: compactMode || showDate
|
visible: compactMode || showDate
|
||||||
text: {
|
text: {
|
||||||
const now = Time.date
|
const now = Time.date
|
||||||
if (compactDateNumeric) {
|
const day = now.getDate()
|
||||||
const day = now.getDate()
|
const month = now.getMonth() + 1
|
||||||
const month = now.getMonth() + 1
|
const dd = (day < 10 ? "0" + day : "" + day)
|
||||||
const dd = (day < 10 ? "0" + day : "" + day)
|
const mm = (month < 10 ? "0" + month : "" + month)
|
||||||
const mm = (month < 10 ? "0" + month : "" + month)
|
return reverseDayMonth ? `${mm}/${dd}` : `${dd}/${mm}`
|
||||||
return reverseDayMonth ? `${mm}/${dd}` : `${dd}/${mm}`
|
|
||||||
} else {
|
|
||||||
let dayName = now.toLocaleDateString(Qt.locale(), "ddd")
|
|
||||||
dayName = dayName.charAt(0).toUpperCase() + dayName.slice(1)
|
|
||||||
let day = now.getDate()
|
|
||||||
let month = now.toLocaleDateString(Qt.locale(), "MMM")
|
|
||||||
return reverseDayMonth ? `${dayName}, ${month} ${day}` : `${dayName}, ${day} ${month}`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
font.pointSize: Math.max(Style.fontSizeXS, Style.fontSizeXS * scaling)
|
font.pointSize: Math.max(Style.fontSizeXXS, Style.fontSizeXXS * scaling)
|
||||||
font.weight: Style.fontWeightRegular
|
font.weight: Style.fontWeightRegular
|
||||||
color: Color.mPrimary
|
color: Color.mPrimary
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,6 @@ ColumnLayout {
|
||||||
property bool valueShowSeconds: widgetData.showSeconds !== undefined ? widgetData.showSeconds : widgetMetadata.showSeconds
|
property bool valueShowSeconds: widgetData.showSeconds !== undefined ? widgetData.showSeconds : widgetMetadata.showSeconds
|
||||||
property bool valueReverseDayMonth: widgetData.reverseDayMonth !== undefined ? widgetData.reverseDayMonth : widgetMetadata.reverseDayMonth
|
property bool valueReverseDayMonth: widgetData.reverseDayMonth !== undefined ? widgetData.reverseDayMonth : widgetMetadata.reverseDayMonth
|
||||||
property bool valueCompactMode: widgetData.compactMode !== undefined ? widgetData.compactMode : widgetMetadata.compactMode
|
property bool valueCompactMode: widgetData.compactMode !== undefined ? widgetData.compactMode : widgetMetadata.compactMode
|
||||||
property bool valueCompactDateNumeric: widgetData.compactDateNumeric
|
|
||||||
!== undefined ? widgetData.compactDateNumeric : widgetMetadata.compactDateNumeric
|
|
||||||
|
|
||||||
function saveSettings() {
|
function saveSettings() {
|
||||||
var settings = Object.assign({}, widgetData || {})
|
var settings = Object.assign({}, widgetData || {})
|
||||||
|
|
@ -29,7 +27,6 @@ ColumnLayout {
|
||||||
settings.showSeconds = valueShowSeconds
|
settings.showSeconds = valueShowSeconds
|
||||||
settings.reverseDayMonth = valueReverseDayMonth
|
settings.reverseDayMonth = valueReverseDayMonth
|
||||||
settings.compactMode = valueCompactMode
|
settings.compactMode = valueCompactMode
|
||||||
settings.compactDateNumeric = valueCompactDateNumeric
|
|
||||||
return settings
|
return settings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,14 +42,6 @@ ColumnLayout {
|
||||||
onToggled: checked => valueCompactMode = checked
|
onToggled: checked => valueCompactMode = checked
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only visible when compact mode is enabled
|
|
||||||
NToggle {
|
|
||||||
visible: valueCompactMode
|
|
||||||
label: "Compact date numeric (DD/MM)"
|
|
||||||
checked: valueCompactDateNumeric
|
|
||||||
onToggled: checked => valueCompactDateNumeric = checked
|
|
||||||
}
|
|
||||||
|
|
||||||
NToggle {
|
NToggle {
|
||||||
label: "Use 12-hour clock"
|
label: "Use 12-hour clock"
|
||||||
checked: valueUse12h
|
checked: valueUse12h
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,7 @@ Singleton {
|
||||||
"use12HourClock": false,
|
"use12HourClock": false,
|
||||||
"showSeconds": false,
|
"showSeconds": false,
|
||||||
"reverseDayMonth": true,
|
"reverseDayMonth": true,
|
||||||
"compactMode": false,
|
"compactMode": false
|
||||||
"compactDateNumeric": true
|
|
||||||
},
|
},
|
||||||
"CustomButton": {
|
"CustomButton": {
|
||||||
"allowUserSettings": true,
|
"allowUserSettings": true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue