1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-07 05:55:37 -05:00

Implement compact toggles for clock & media topbar widgets

This commit is contained in:
purian23
2025-08-05 20:33:01 -04:00
parent 1bd4eeb736
commit 7695078cb8
5 changed files with 95 additions and 5 deletions

View File

@@ -39,6 +39,8 @@ Singleton {
property bool showControlCenterButton: true property bool showControlCenterButton: true
property bool showWorkspaceIndex: false property bool showWorkspaceIndex: false
property bool showWorkspacePadding: false property bool showWorkspacePadding: false
property bool clockCompactMode: false
property bool mediaCompactMode: false
property var topBarLeftWidgets: ["launcherButton", "workspaceSwitcher", "focusedWindow"] property var topBarLeftWidgets: ["launcherButton", "workspaceSwitcher", "focusedWindow"]
property var topBarCenterWidgets: ["music", "clock", "weather"] property var topBarCenterWidgets: ["music", "clock", "weather"]
property var topBarRightWidgets: ["systemTray", "clipboard", "systemResources", "notificationButton", "battery", "controlCenterButton"] property var topBarRightWidgets: ["systemTray", "clipboard", "systemResources", "notificationButton", "battery", "controlCenterButton"]
@@ -165,6 +167,8 @@ Singleton {
showControlCenterButton = settings.showControlCenterButton !== undefined ? settings.showControlCenterButton : true; showControlCenterButton = settings.showControlCenterButton !== undefined ? settings.showControlCenterButton : true;
showWorkspaceIndex = settings.showWorkspaceIndex !== undefined ? settings.showWorkspaceIndex : false; showWorkspaceIndex = settings.showWorkspaceIndex !== undefined ? settings.showWorkspaceIndex : false;
showWorkspacePadding = settings.showWorkspacePadding !== undefined ? settings.showWorkspacePadding : false; showWorkspacePadding = settings.showWorkspacePadding !== undefined ? settings.showWorkspacePadding : false;
clockCompactMode = settings.clockCompactMode !== undefined ? settings.clockCompactMode : false;
mediaCompactMode = settings.mediaCompactMode !== undefined ? settings.mediaCompactMode : false;
if (settings.topBarWidgetOrder) { if (settings.topBarWidgetOrder) {
topBarLeftWidgets = settings.topBarWidgetOrder.filter(w => ["launcherButton", "workspaceSwitcher", "focusedWindow"].includes(w)); topBarLeftWidgets = settings.topBarWidgetOrder.filter(w => ["launcherButton", "workspaceSwitcher", "focusedWindow"].includes(w));
topBarCenterWidgets = settings.topBarWidgetOrder.filter(w => ["clock", "music", "weather"].includes(w)); topBarCenterWidgets = settings.topBarWidgetOrder.filter(w => ["clock", "music", "weather"].includes(w));
@@ -247,6 +251,8 @@ Singleton {
"showControlCenterButton": showControlCenterButton, "showControlCenterButton": showControlCenterButton,
"showWorkspaceIndex": showWorkspaceIndex, "showWorkspaceIndex": showWorkspaceIndex,
"showWorkspacePadding": showWorkspacePadding, "showWorkspacePadding": showWorkspacePadding,
"clockCompactMode": clockCompactMode,
"mediaCompactMode": mediaCompactMode,
"topBarLeftWidgets": topBarLeftWidgets, "topBarLeftWidgets": topBarLeftWidgets,
"topBarCenterWidgets": topBarCenterWidgets, "topBarCenterWidgets": topBarCenterWidgets,
"topBarRightWidgets": topBarRightWidgets, "topBarRightWidgets": topBarRightWidgets,
@@ -284,6 +290,16 @@ Singleton {
saveSettings(); saveSettings();
} }
function setClockCompactMode(enabled) {
clockCompactMode = enabled;
saveSettings();
}
function setMediaCompactMode(enabled) {
mediaCompactMode = enabled;
saveSettings();
}
function applyStoredTheme() { function applyStoredTheme() {
if (typeof Theme !== "undefined") { if (typeof Theme !== "undefined") {
Theme.isLightMode = isLightMode; Theme.isLightMode = isLightMode;

View File

@@ -471,6 +471,13 @@ ScrollView {
onSpacerSizeChanged: (sectionId, itemId, newSize) => { onSpacerSizeChanged: (sectionId, itemId, newSize) => {
widgetsTab.handleSpacerSizeChanged(sectionId, itemId, newSize); widgetsTab.handleSpacerSizeChanged(sectionId, itemId, newSize);
} }
onCompactModeChanged: (widgetId, enabled) => {
if (widgetId === "clock") {
Prefs.setClockCompactMode(enabled);
} else if (widgetId === "music") {
Prefs.setMediaCompactMode(enabled);
}
}
} }
DankSections { DankSections {
@@ -497,6 +504,13 @@ ScrollView {
onSpacerSizeChanged: (sectionId, itemId, newSize) => { onSpacerSizeChanged: (sectionId, itemId, newSize) => {
widgetsTab.handleSpacerSizeChanged(sectionId, itemId, newSize); widgetsTab.handleSpacerSizeChanged(sectionId, itemId, newSize);
} }
onCompactModeChanged: (widgetId, enabled) => {
if (widgetId === "clock") {
Prefs.setClockCompactMode(enabled);
} else if (widgetId === "music") {
Prefs.setMediaCompactMode(enabled);
}
}
} }
DankSections { DankSections {
@@ -523,6 +537,13 @@ ScrollView {
onSpacerSizeChanged: (sectionId, itemId, newSize) => { onSpacerSizeChanged: (sectionId, itemId, newSize) => {
widgetsTab.handleSpacerSizeChanged(sectionId, itemId, newSize); widgetsTab.handleSpacerSizeChanged(sectionId, itemId, newSize);
} }
onCompactModeChanged: (widgetId, enabled) => {
if (widgetId === "clock") {
Prefs.setClockCompactMode(enabled);
} else if (widgetId === "music") {
Prefs.setMediaCompactMode(enabled);
}
}
} }
} }

View File

@@ -43,7 +43,7 @@ Rectangle {
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: Theme.outlineButton color: Theme.outlineButton
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
visible: !compactMode visible: !Prefs.clockCompactMode
} }
StyledText { StyledText {
@@ -51,7 +51,7 @@ Rectangle {
font.pixelSize: Theme.fontSizeMedium - 1 font.pixelSize: Theme.fontSizeMedium - 1
color: Theme.surfaceText color: Theme.surfaceText
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
visible: !compactMode visible: !Prefs.clockCompactMode
} }
} }

View File

@@ -33,7 +33,7 @@ Rectangle {
PropertyChanges { PropertyChanges {
target: root target: root
opacity: 1 opacity: 1
width: compactMode ? compactContentWidth : normalContentWidth width: Prefs.mediaCompactMode ? compactContentWidth : normalContentWidth
} }
}, },
@@ -100,8 +100,8 @@ Rectangle {
id: mediaText id: mediaText
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: compactMode ? 60 : 140 width: Prefs.mediaCompactMode ? 60 : 140
visible: !compactMode visible: !Prefs.mediaCompactMode
text: { text: {
if (!activePlayer || !activePlayer.trackTitle) if (!activePlayer || !activePlayer.trackTitle)
return ""; return "";

View File

@@ -17,6 +17,7 @@ Column {
signal addWidget(string sectionId) signal addWidget(string sectionId)
signal removeWidget(string sectionId, string itemId) signal removeWidget(string sectionId, string itemId)
signal spacerSizeChanged(string sectionId, string itemId, int newSize) signal spacerSizeChanged(string sectionId, string itemId, int newSize)
signal compactModeChanged(string widgetId, bool enabled)
width: parent.width width: parent.width
spacing: Theme.spacingM spacing: Theme.spacingM
@@ -131,6 +132,58 @@ Column {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingXS spacing: Theme.spacingXS
Item {
width: 32
height: 32
visible: modelData.id === "clock" || modelData.id === "music"
DankActionButton {
id: compactModeButton
anchors.fill: parent
buttonSize: 32
iconName: (modelData.id === "clock" && Prefs.clockCompactMode) || (modelData.id === "music" && Prefs.mediaCompactMode) ? "zoom_out" : "zoom_in"
iconSize: 18
iconColor: ((modelData.id === "clock" && Prefs.clockCompactMode) || (modelData.id === "music" && Prefs.mediaCompactMode)) ? Theme.primary : Theme.outline
onClicked: {
if (modelData.id === "clock") {
root.compactModeChanged("clock", !Prefs.clockCompactMode);
} else if (modelData.id === "music") {
root.compactModeChanged("music", !Prefs.mediaCompactMode);
}
}
}
Rectangle {
id: compactModeTooltip
width: tooltipText.contentWidth + Theme.spacingM * 2
height: tooltipText.contentHeight + Theme.spacingS * 2
radius: Theme.cornerRadius
color: Theme.surfaceContainer
border.color: Theme.outline
border.width: 1
visible: compactModeButton.children[1] && compactModeButton.children[1].containsMouse
opacity: visible ? 1 : 0
x: -width - Theme.spacingS
y: (parent.height - height) / 2
z: 100
StyledText {
id: tooltipText
anchors.centerIn: parent
text: "Compact Mode"
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
}
Behavior on opacity {
NumberAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
}
}
DankActionButton { DankActionButton {
visible: modelData.id !== "spacer" visible: modelData.id !== "spacer"
buttonSize: 32 buttonSize: 32