mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-31 00:42: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
|
||||||
|
import QtQuick.Effects
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Widgets
|
import Quickshell.Widgets
|
||||||
import Quickshell.Hyprland
|
import Quickshell.Hyprland
|
||||||
@@ -245,11 +246,14 @@ Item {
|
|||||||
if (!byApp[key]) {
|
if (!byApp[key]) {
|
||||||
const moddedId = Paths.moddedAppId(keyBase);
|
const moddedId = Paths.moddedAppId(keyBase);
|
||||||
const isSteamApp = moddedId.toLowerCase().includes("steam_app");
|
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] = {
|
byApp[key] = {
|
||||||
"type": "icon",
|
"type": "icon",
|
||||||
"icon": icon,
|
"icon": icon,
|
||||||
"isSteamApp": isSteamApp,
|
"isSteamApp": isSteamApp,
|
||||||
|
"isQuickshell": isQuickshell,
|
||||||
"active": !!((w.activated || w.is_focused) || (CompositorService.isNiri && w.is_focused)),
|
"active": !!((w.activated || w.is_focused) || (CompositorService.isNiri && w.is_focused)),
|
||||||
"count": 1,
|
"count": 1,
|
||||||
"windowId": w.address || w.id,
|
"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 padding: Math.max(Theme.spacingXS, Theme.spacingS * (widgetHeight / 30))
|
||||||
readonly property real visualWidth: isVertical ? widgetHeight : (workspaceRow.implicitWidth + padding * 2)
|
readonly property real visualWidth: isVertical ? widgetHeight : (workspaceRow.implicitWidth + padding * 2)
|
||||||
readonly property real visualHeight: isVertical ? (workspaceRow.implicitHeight + padding * 2) : widgetHeight
|
readonly property real visualHeight: isVertical ? (workspaceRow.implicitHeight + padding * 2) : widgetHeight
|
||||||
|
readonly property real appIconSize: Theme.barIconSize(barThickness, -6)
|
||||||
|
|
||||||
function getRealWorkspaces() {
|
function getRealWorkspaces() {
|
||||||
return root.workspaceList.filter(ws => {
|
return root.workspaceList.filter(ws => {
|
||||||
@@ -719,14 +724,14 @@ Item {
|
|||||||
readonly property real iconsExtraWidth: {
|
readonly property real iconsExtraWidth: {
|
||||||
if (!root.isVertical && SettingsData.showWorkspaceApps && loadedIcons.length > 0) {
|
if (!root.isVertical && SettingsData.showWorkspaceApps && loadedIcons.length > 0) {
|
||||||
const numIcons = Math.min(loadedIcons.length, SettingsData.maxWorkspaceIcons);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
readonly property real iconsExtraHeight: {
|
readonly property real iconsExtraHeight: {
|
||||||
if (root.isVertical && SettingsData.showWorkspaceApps && loadedIcons.length > 0) {
|
if (root.isVertical && SettingsData.showWorkspaceApps && loadedIcons.length > 0) {
|
||||||
const numIcons = Math.min(loadedIcons.length, SettingsData.maxWorkspaceIcons);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -897,7 +902,7 @@ Item {
|
|||||||
Item {
|
Item {
|
||||||
visible: loadedHasIcon && loadedIconData?.type === "icon"
|
visible: loadedHasIcon && loadedIconData?.type === "icon"
|
||||||
width: wsIcon.width + (isActive && loadedIcons.length > 0 ? 4 : 0)
|
width: wsIcon.width + (isActive && loadedIcons.length > 0 ? 4 : 0)
|
||||||
height: 18
|
height: root.appIconSize
|
||||||
|
|
||||||
DankIcon {
|
DankIcon {
|
||||||
id: wsIcon
|
id: wsIcon
|
||||||
@@ -912,7 +917,7 @@ Item {
|
|||||||
Item {
|
Item {
|
||||||
visible: loadedHasIcon && loadedIconData?.type === "text"
|
visible: loadedHasIcon && loadedIconData?.type === "text"
|
||||||
width: wsText.implicitWidth + (isActive && loadedIcons.length > 0 ? 4 : 0)
|
width: wsText.implicitWidth + (isActive && loadedIcons.length > 0 ? 4 : 0)
|
||||||
height: 18
|
height: root.appIconSize
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
id: wsText
|
id: wsText
|
||||||
@@ -927,7 +932,7 @@ Item {
|
|||||||
Item {
|
Item {
|
||||||
visible: SettingsData.showWorkspaceIndex && !loadedHasIcon
|
visible: SettingsData.showWorkspaceIndex && !loadedHasIcon
|
||||||
width: wsIndexText.implicitWidth + (isActive && loadedIcons.length > 0 ? 4 : 0)
|
width: wsIndexText.implicitWidth + (isActive && loadedIcons.length > 0 ? 4 : 0)
|
||||||
height: 18
|
height: root.appIconSize
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
id: wsIndexText
|
id: wsIndexText
|
||||||
@@ -944,48 +949,61 @@ Item {
|
|||||||
values: loadedIcons.slice(0, SettingsData.maxWorkspaceIcons)
|
values: loadedIcons.slice(0, SettingsData.maxWorkspaceIcons)
|
||||||
}
|
}
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
width: 18
|
width: root.appIconSize
|
||||||
height: 18
|
height: root.appIconSize
|
||||||
|
|
||||||
IconImage {
|
IconImage {
|
||||||
id: appIcon
|
id: rowAppIcon
|
||||||
property var windowId: modelData.windowId
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
source: modelData.icon
|
source: modelData.icon
|
||||||
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
|
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 {
|
DankIcon {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
size: 18
|
size: root.appIconSize
|
||||||
name: "sports_esports"
|
name: "sports_esports"
|
||||||
color: Theme.widgetTextColor
|
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
|
visible: modelData.isSteamApp
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: appMouseArea
|
id: rowAppMouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
enabled: isActive
|
enabled: isActive
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!appIcon.windowId)
|
const winId = modelData.windowId;
|
||||||
|
if (!winId)
|
||||||
return;
|
return;
|
||||||
if (CompositorService.isHyprland) {
|
if (CompositorService.isHyprland) {
|
||||||
Hyprland.dispatch(`focuswindow address:${appIcon.windowId}`);
|
Hyprland.dispatch(`focuswindow address:${winId}`);
|
||||||
} else if (CompositorService.isNiri) {
|
} else if (CompositorService.isNiri) {
|
||||||
NiriService.focusWindow(appIcon.windowId);
|
NiriService.focusWindow(winId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
visible: modelData.count > 1 && !isActive
|
visible: modelData.count > 1 && !isActive
|
||||||
width: 12
|
width: root.appIconSize * 0.67
|
||||||
height: 12
|
height: root.appIconSize * 0.67
|
||||||
radius: 6
|
radius: root.appIconSize * 0.33
|
||||||
color: "black"
|
color: "black"
|
||||||
border.color: "white"
|
border.color: "white"
|
||||||
border.width: 1
|
border.width: 1
|
||||||
@@ -996,7 +1014,7 @@ Item {
|
|||||||
Text {
|
Text {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: modelData.count
|
text: modelData.count
|
||||||
font.pixelSize: 8
|
font.pixelSize: root.appIconSize * 0.44
|
||||||
color: "white"
|
color: "white"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1034,48 +1052,61 @@ Item {
|
|||||||
values: loadedIcons.slice(0, SettingsData.maxWorkspaceIcons)
|
values: loadedIcons.slice(0, SettingsData.maxWorkspaceIcons)
|
||||||
}
|
}
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
width: 18
|
width: root.appIconSize
|
||||||
height: 18
|
height: root.appIconSize
|
||||||
|
|
||||||
IconImage {
|
IconImage {
|
||||||
id: appIcon
|
id: colAppIcon
|
||||||
property var windowId: modelData.windowId
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
source: modelData.icon
|
source: modelData.icon
|
||||||
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
|
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 {
|
DankIcon {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
size: 18
|
size: root.appIconSize
|
||||||
name: "sports_esports"
|
name: "sports_esports"
|
||||||
color: Theme.widgetTextColor
|
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
|
visible: modelData.isSteamApp
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: appMouseArea
|
id: colAppMouseArea
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
enabled: isActive
|
enabled: isActive
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!appIcon.windowId)
|
const winId = modelData.windowId;
|
||||||
|
if (!winId)
|
||||||
return;
|
return;
|
||||||
if (CompositorService.isHyprland) {
|
if (CompositorService.isHyprland) {
|
||||||
Hyprland.dispatch(`focuswindow address:${appIcon.windowId}`);
|
Hyprland.dispatch(`focuswindow address:${winId}`);
|
||||||
} else if (CompositorService.isNiri) {
|
} else if (CompositorService.isNiri) {
|
||||||
NiriService.focusWindow(appIcon.windowId);
|
NiriService.focusWindow(winId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
visible: modelData.count > 1 && !isActive
|
visible: modelData.count > 1 && !isActive
|
||||||
width: 12
|
width: root.appIconSize * 0.67
|
||||||
height: 12
|
height: root.appIconSize * 0.67
|
||||||
radius: 6
|
radius: root.appIconSize * 0.33
|
||||||
color: "black"
|
color: "black"
|
||||||
border.color: "white"
|
border.color: "white"
|
||||||
border.width: 1
|
border.width: 1
|
||||||
@@ -1086,7 +1117,7 @@ Item {
|
|||||||
Text {
|
Text {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: modelData.count
|
text: modelData.count
|
||||||
font.pixelSize: 8
|
font.pixelSize: root.appIconSize * 0.44
|
||||||
color: "white"
|
color: "white"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user