mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-05 21:15:38 -05:00
- Add surface shift option, start from surface by default (previously was surfaceContainer). Old colors can be attained by changing it back to "container" in theme colors - Remove borders on surface elements, mostly - Fix popup distances - Use surfaceContainer/sch by default on widgets
94 lines
2.9 KiB
QML
94 lines
2.9 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import qs.Common
|
|
import qs.Widgets
|
|
|
|
Rectangle {
|
|
id: root
|
|
|
|
property bool compactMode: false
|
|
property string section: "center"
|
|
property var popupTarget: null
|
|
property var parentScreen: null
|
|
property real barHeight: 48
|
|
property real widgetHeight: 30
|
|
readonly property real horizontalPadding: SettingsData.topBarNoBackground ? 2 : Theme.spacingS
|
|
|
|
signal clockClicked
|
|
|
|
width: clockRow.implicitWidth + horizontalPadding * 2
|
|
height: widgetHeight
|
|
radius: SettingsData.topBarNoBackground ? 0 : Theme.cornerRadius
|
|
color: {
|
|
if (SettingsData.topBarNoBackground) {
|
|
return "transparent";
|
|
}
|
|
|
|
const baseColor = clockMouseArea.containsMouse ? Theme.widgetBaseHoverColor : Theme.widgetBaseBackgroundColor;
|
|
return Qt.rgba(baseColor.r, baseColor.g, baseColor.b, baseColor.a * Theme.widgetTransparency);
|
|
}
|
|
|
|
Row {
|
|
id: clockRow
|
|
|
|
anchors.centerIn: parent
|
|
spacing: Theme.spacingS
|
|
|
|
StyledText {
|
|
text: {
|
|
const format = SettingsData.use24HourClock ? "HH:mm" : "h:mm AP"
|
|
return systemClock?.date?.toLocaleTimeString(Qt.locale(), format)
|
|
}
|
|
font.pixelSize: Theme.fontSizeMedium - 1
|
|
color: Theme.surfaceText
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
|
|
StyledText {
|
|
text: "•"
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
color: Theme.outlineButton
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
visible: !SettingsData.clockCompactMode
|
|
}
|
|
|
|
StyledText {
|
|
text: {
|
|
if (SettingsData.clockDateFormat && SettingsData.clockDateFormat.length > 0) {
|
|
return systemClock?.date?.toLocaleDateString(Qt.locale(), SettingsData.clockDateFormat)
|
|
}
|
|
|
|
return systemClock?.date?.toLocaleDateString(Qt.locale(), "ddd d")
|
|
}
|
|
font.pixelSize: Theme.fontSizeMedium - 1
|
|
color: Theme.surfaceText
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
visible: !SettingsData.clockCompactMode
|
|
}
|
|
}
|
|
|
|
SystemClock {
|
|
id: systemClock
|
|
precision: SystemClock.Seconds
|
|
}
|
|
|
|
MouseArea {
|
|
id: clockMouseArea
|
|
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
cursorShape: Qt.PointingHandCursor
|
|
onPressed: {
|
|
if (popupTarget && popupTarget.setTriggerPosition) {
|
|
const globalPos = mapToGlobal(0, 0)
|
|
const currentScreen = parentScreen || Screen
|
|
const screenX = currentScreen.x || 0
|
|
const relativeX = globalPos.x - screenX
|
|
popupTarget.setTriggerPosition(relativeX, barHeight + SettingsData.topBarSpacing + SettingsData.topBarBottomGap - 2 + Theme.popupDistance, width, section, currentScreen)
|
|
}
|
|
root.clockClicked()
|
|
}
|
|
}
|
|
|
|
}
|