Settings: centralized migration to user settings. wip
This commit is contained in:
parent
d6e253fe7f
commit
498ee478e7
5 changed files with 115 additions and 117 deletions
|
|
@ -1,53 +0,0 @@
|
|||
import QtQuick
|
||||
import qs.Commons
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
signal entered
|
||||
signal exited
|
||||
signal clicked
|
||||
|
||||
// Per-instance overrides (default to global settings if not provided by parent)
|
||||
// Parent widgets like Bar `Clock.qml` can bind these
|
||||
property bool showDate: Settings.data.location.showDateWithClock
|
||||
property bool use12h: Settings.data.location.use12HourClock
|
||||
property bool showSeconds: false
|
||||
|
||||
width: textItem.paintedWidth
|
||||
height: textItem.paintedHeight
|
||||
color: Color.transparent
|
||||
|
||||
NText {
|
||||
id: textItem
|
||||
text: {
|
||||
const now = Time.date
|
||||
const timeFormat = use12h ? (showSeconds ? "h:mm:ss AP" : "h:mm AP") : (showSeconds ? "HH:mm:ss" : "HH:mm")
|
||||
const timeString = Qt.formatDateTime(now, timeFormat)
|
||||
|
||||
if (showDate) {
|
||||
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 timeString + " - " + (Settings.data.location.reverseDayMonth ? `${dayName}, ${month} ${day}` : `${dayName}, ${day} ${month}`)
|
||||
}
|
||||
return timeString
|
||||
}
|
||||
anchors.centerIn: parent
|
||||
font.pointSize: Style.fontSizeS * scaling
|
||||
font.weight: Style.fontWeightBold
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: clockMouseArea
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
hoverEnabled: true
|
||||
onEntered: root.entered()
|
||||
onExited: root.exited()
|
||||
onClicked: root.clicked()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue