mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 13:32:50 -05:00
workspaces: make icons scale with bar size, fixi valign of numbers fixes #990
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import QtQuick
|
||||
import QtQuick.Effects
|
||||
import Quickshell
|
||||
import Quickshell.Widgets
|
||||
import Quickshell.Hyprland
|
||||
@@ -245,11 +246,14 @@ Item {
|
||||
if (!byApp[key]) {
|
||||
const moddedId = Paths.moddedAppId(keyBase);
|
||||
const isSteamApp = moddedId.toLowerCase().includes("steam_app");
|
||||
const icon = isSteamApp ? "" : DesktopService.resolveIconPath(moddedId);
|
||||
const isQuickshell = keyBase === "org.quickshell";
|
||||
const desktopEntry = DesktopEntries.heuristicLookup(keyBase);
|
||||
const icon = isSteamApp ? "" : Paths.getAppIcon(keyBase, desktopEntry);
|
||||
byApp[key] = {
|
||||
"type": "icon",
|
||||
"icon": icon,
|
||||
"isSteamApp": isSteamApp,
|
||||
"isQuickshell": isQuickshell,
|
||||
"active": !!((w.activated || w.is_focused) || (CompositorService.isNiri && w.is_focused)),
|
||||
"count": 1,
|
||||
"windowId": w.address || w.id,
|
||||
@@ -446,6 +450,7 @@ Item {
|
||||
readonly property real padding: Math.max(Theme.spacingXS, Theme.spacingS * (widgetHeight / 30))
|
||||
readonly property real visualWidth: isVertical ? widgetHeight : (workspaceRow.implicitWidth + padding * 2)
|
||||
readonly property real visualHeight: isVertical ? (workspaceRow.implicitHeight + padding * 2) : widgetHeight
|
||||
readonly property real appIconSize: Theme.barIconSize(barThickness, -6)
|
||||
|
||||
function getRealWorkspaces() {
|
||||
return root.workspaceList.filter(ws => {
|
||||
@@ -719,14 +724,14 @@ Item {
|
||||
readonly property real iconsExtraWidth: {
|
||||
if (!root.isVertical && SettingsData.showWorkspaceApps && loadedIcons.length > 0) {
|
||||
const numIcons = Math.min(loadedIcons.length, SettingsData.maxWorkspaceIcons);
|
||||
return numIcons * 18 + (numIcons > 0 ? (numIcons - 1) * Theme.spacingXS : 0) + (isActive ? Theme.spacingXS : 0);
|
||||
return numIcons * root.appIconSize + (numIcons > 0 ? (numIcons - 1) * Theme.spacingXS : 0) + (isActive ? Theme.spacingXS : 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
readonly property real iconsExtraHeight: {
|
||||
if (root.isVertical && SettingsData.showWorkspaceApps && loadedIcons.length > 0) {
|
||||
const numIcons = Math.min(loadedIcons.length, SettingsData.maxWorkspaceIcons);
|
||||
return numIcons * 18 + (numIcons > 0 ? (numIcons - 1) * Theme.spacingXS : 0) + (isActive ? Theme.spacingXS : 0);
|
||||
return numIcons * root.appIconSize + (numIcons > 0 ? (numIcons - 1) * Theme.spacingXS : 0) + (isActive ? Theme.spacingXS : 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -897,7 +902,7 @@ Item {
|
||||
Item {
|
||||
visible: loadedHasIcon && loadedIconData?.type === "icon"
|
||||
width: wsIcon.width + (isActive && loadedIcons.length > 0 ? 4 : 0)
|
||||
height: 18
|
||||
height: root.appIconSize
|
||||
|
||||
DankIcon {
|
||||
id: wsIcon
|
||||
@@ -912,7 +917,7 @@ Item {
|
||||
Item {
|
||||
visible: loadedHasIcon && loadedIconData?.type === "text"
|
||||
width: wsText.implicitWidth + (isActive && loadedIcons.length > 0 ? 4 : 0)
|
||||
height: 18
|
||||
height: root.appIconSize
|
||||
|
||||
StyledText {
|
||||
id: wsText
|
||||
@@ -927,7 +932,7 @@ Item {
|
||||
Item {
|
||||
visible: SettingsData.showWorkspaceIndex && !loadedHasIcon
|
||||
width: wsIndexText.implicitWidth + (isActive && loadedIcons.length > 0 ? 4 : 0)
|
||||
height: 18
|
||||
height: root.appIconSize
|
||||
|
||||
StyledText {
|
||||
id: wsIndexText
|
||||
@@ -944,48 +949,61 @@ Item {
|
||||
values: loadedIcons.slice(0, SettingsData.maxWorkspaceIcons)
|
||||
}
|
||||
delegate: Item {
|
||||
width: 18
|
||||
height: 18
|
||||
width: root.appIconSize
|
||||
height: root.appIconSize
|
||||
|
||||
IconImage {
|
||||
id: appIcon
|
||||
property var windowId: modelData.windowId
|
||||
id: rowAppIcon
|
||||
anchors.fill: parent
|
||||
source: modelData.icon
|
||||
opacity: modelData.active ? 1.0 : appMouseArea.containsMouse ? 0.8 : 0.6
|
||||
visible: !modelData.isSteamApp
|
||||
opacity: modelData.active ? 1.0 : rowAppMouseArea.containsMouse ? 0.8 : 0.6
|
||||
visible: !modelData.isSteamApp && !modelData.isQuickshell
|
||||
}
|
||||
|
||||
IconImage {
|
||||
anchors.fill: parent
|
||||
source: modelData.icon
|
||||
opacity: modelData.active ? 1.0 : rowAppMouseArea.containsMouse ? 0.8 : 0.6
|
||||
visible: modelData.isQuickshell
|
||||
layer.enabled: true
|
||||
layer.effect: MultiEffect {
|
||||
saturation: 0
|
||||
colorization: 1
|
||||
colorizationColor: isActive ? Theme.primaryContainer : Theme.primary
|
||||
}
|
||||
}
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
size: 18
|
||||
size: root.appIconSize
|
||||
name: "sports_esports"
|
||||
color: Theme.widgetTextColor
|
||||
opacity: modelData.active ? 1.0 : appMouseArea.containsMouse ? 0.8 : 0.6
|
||||
opacity: modelData.active ? 1.0 : rowAppMouseArea.containsMouse ? 0.8 : 0.6
|
||||
visible: modelData.isSteamApp
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: appMouseArea
|
||||
id: rowAppMouseArea
|
||||
anchors.fill: parent
|
||||
enabled: isActive
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (!appIcon.windowId)
|
||||
const winId = modelData.windowId;
|
||||
if (!winId)
|
||||
return;
|
||||
if (CompositorService.isHyprland) {
|
||||
Hyprland.dispatch(`focuswindow address:${appIcon.windowId}`);
|
||||
Hyprland.dispatch(`focuswindow address:${winId}`);
|
||||
} else if (CompositorService.isNiri) {
|
||||
NiriService.focusWindow(appIcon.windowId);
|
||||
NiriService.focusWindow(winId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
visible: modelData.count > 1 && !isActive
|
||||
width: 12
|
||||
height: 12
|
||||
radius: 6
|
||||
width: root.appIconSize * 0.67
|
||||
height: root.appIconSize * 0.67
|
||||
radius: root.appIconSize * 0.33
|
||||
color: "black"
|
||||
border.color: "white"
|
||||
border.width: 1
|
||||
@@ -996,7 +1014,7 @@ Item {
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: modelData.count
|
||||
font.pixelSize: 8
|
||||
font.pixelSize: root.appIconSize * 0.44
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
@@ -1034,48 +1052,61 @@ Item {
|
||||
values: loadedIcons.slice(0, SettingsData.maxWorkspaceIcons)
|
||||
}
|
||||
delegate: Item {
|
||||
width: 18
|
||||
height: 18
|
||||
width: root.appIconSize
|
||||
height: root.appIconSize
|
||||
|
||||
IconImage {
|
||||
id: appIcon
|
||||
property var windowId: modelData.windowId
|
||||
id: colAppIcon
|
||||
anchors.fill: parent
|
||||
source: modelData.icon
|
||||
opacity: modelData.active ? 1.0 : appMouseArea.containsMouse ? 0.8 : 0.6
|
||||
visible: !modelData.isSteamApp
|
||||
opacity: modelData.active ? 1.0 : colAppMouseArea.containsMouse ? 0.8 : 0.6
|
||||
visible: !modelData.isSteamApp && !modelData.isQuickshell
|
||||
}
|
||||
|
||||
IconImage {
|
||||
anchors.fill: parent
|
||||
source: modelData.icon
|
||||
opacity: modelData.active ? 1.0 : colAppMouseArea.containsMouse ? 0.8 : 0.6
|
||||
visible: modelData.isQuickshell
|
||||
layer.enabled: true
|
||||
layer.effect: MultiEffect {
|
||||
saturation: 0
|
||||
colorization: 1
|
||||
colorizationColor: isActive ? Theme.primaryContainer : Theme.primary
|
||||
}
|
||||
}
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
size: 18
|
||||
size: root.appIconSize
|
||||
name: "sports_esports"
|
||||
color: Theme.widgetTextColor
|
||||
opacity: modelData.active ? 1.0 : appMouseArea.containsMouse ? 0.8 : 0.6
|
||||
opacity: modelData.active ? 1.0 : colAppMouseArea.containsMouse ? 0.8 : 0.6
|
||||
visible: modelData.isSteamApp
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: appMouseArea
|
||||
id: colAppMouseArea
|
||||
anchors.fill: parent
|
||||
enabled: isActive
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (!appIcon.windowId)
|
||||
const winId = modelData.windowId;
|
||||
if (!winId)
|
||||
return;
|
||||
if (CompositorService.isHyprland) {
|
||||
Hyprland.dispatch(`focuswindow address:${appIcon.windowId}`);
|
||||
Hyprland.dispatch(`focuswindow address:${winId}`);
|
||||
} else if (CompositorService.isNiri) {
|
||||
NiriService.focusWindow(appIcon.windowId);
|
||||
NiriService.focusWindow(winId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
visible: modelData.count > 1 && !isActive
|
||||
width: 12
|
||||
height: 12
|
||||
radius: 6
|
||||
width: root.appIconSize * 0.67
|
||||
height: root.appIconSize * 0.67
|
||||
radius: root.appIconSize * 0.33
|
||||
color: "black"
|
||||
border.color: "white"
|
||||
border.width: 1
|
||||
@@ -1086,7 +1117,7 @@ Item {
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: modelData.count
|
||||
font.pixelSize: 8
|
||||
font.pixelSize: root.appIconSize * 0.44
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user