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

modules cleanup and qmlfmt everywhere

- throw in 24H clock fix and app drawer fix too
This commit is contained in:
bbedward
2025-09-03 23:26:07 -04:00
parent 178ccd3634
commit 21867c842f
55 changed files with 2720 additions and 3236 deletions

View File

@@ -19,20 +19,21 @@ Rectangle {
// The visual root for this window
property Item windowRoot: (Window.window ? Window.window.contentItem : null)
readonly property var sortedToplevels: {
if (SettingsData.runningAppsCurrentWorkspace){
return CompositorService.filterCurrentWorkspace(CompositorService.sortedToplevels, parentScreen.name)
}
return CompositorService.sortedToplevels
if (SettingsData.runningAppsCurrentWorkspace) {
return CompositorService.filterCurrentWorkspace(CompositorService.sortedToplevels, parentScreen.name);
}
return CompositorService.sortedToplevels;
}
readonly property int windowCount: sortedToplevels.length
readonly property int calculatedWidth: {
if (windowCount === 0)
return 0
if (windowCount === 0) {
return 0;
}
if (SettingsData.runningAppsCompactMode) {
return windowCount * 24 + (windowCount - 1) * Theme.spacingXS + horizontalPadding * 2
return windowCount * 24 + (windowCount - 1) * Theme.spacingXS + horizontalPadding * 2;
} else {
return windowCount * (24 + Theme.spacingXS + 120)
+ (windowCount - 1) * Theme.spacingXS + horizontalPadding * 2
+ (windowCount - 1) * Theme.spacingXS + horizontalPadding * 2;
}
}
@@ -42,13 +43,16 @@ Rectangle {
visible: windowCount > 0
clip: false
color: {
if (windowCount === 0)
return "transparent"
if (windowCount === 0) {
return "transparent";
}
if (SettingsData.topBarNoBackground) return "transparent"
const baseColor = Theme.secondaryHover
if (SettingsData.topBarNoBackground) {
return "transparent";
}
const baseColor = Theme.secondaryHover;
return Qt.rgba(baseColor.r, baseColor.g, baseColor.b,
baseColor.a * Theme.widgetTransparency)
baseColor.a * Theme.widgetTransparency);
}
MouseArea {
@@ -60,26 +64,26 @@ Rectangle {
property real touchpadThreshold: 500
onWheel: (wheel) => {
const deltaY = wheel.angleDelta.y
const deltaY = wheel.angleDelta.y;
const isMouseWheel = Math.abs(deltaY) >= 120
&& (Math.abs(deltaY) % 120) === 0
&& (Math.abs(deltaY) % 120) === 0;
var windows = root.sortedToplevels;
const windows = root.sortedToplevels;
if (windows.length < 2) {
return;
}
if (isMouseWheel) {
// Direct mouse wheel action
var currentIndex = -1;
for (var i = 0; i < windows.length; i++) {
let currentIndex = -1;
for (let i = 0; i < windows.length; i++) {
if (windows[i].activated) {
currentIndex = i;
break;
}
}
var nextIndex;
let nextIndex;
if (deltaY < 0) {
if (currentIndex === -1) {
nextIndex = 0;
@@ -94,24 +98,24 @@ Rectangle {
}
}
var nextWindow = windows[nextIndex];
const nextWindow = windows[nextIndex];
if (nextWindow) {
nextWindow.activate();
}
} else {
// Touchpad - accumulate small deltas
scrollAccumulator += deltaY
scrollAccumulator += deltaY;
if (Math.abs(scrollAccumulator) >= touchpadThreshold) {
var currentIndex = -1;
for (var i = 0; i < windows.length; i++) {
let currentIndex = -1;
for (let i = 0; i < windows.length; i++) {
if (windows[i].activated) {
currentIndex = i;
break;
}
}
var nextIndex;
let nextIndex;
if (scrollAccumulator < 0) {
if (currentIndex === -1) {
nextIndex = 0;
@@ -126,16 +130,16 @@ Rectangle {
}
}
var nextWindow = windows[nextIndex];
const nextWindow = windows[nextIndex];
if (nextWindow) {
nextWindow.activate();
}
scrollAccumulator = 0
scrollAccumulator = 0;
}
}
wheel.accepted = true
wheel.accepted = true;
}
}
@@ -158,11 +162,11 @@ Rectangle {
property string windowTitle: modelData.title || "(Unnamed)"
property var toplevelObject: modelData
property string tooltipText: {
var appName = "Unknown"
let appName = "Unknown";
if (appId) {
var desktopEntry = DesktopEntries.heuristicLookup(appId)
const desktopEntry = DesktopEntries.heuristicLookup(appId);
appName = desktopEntry
&& desktopEntry.name ? desktopEntry.name : appId
&& desktopEntry.name ? desktopEntry.name : appId;
}
return appName + (windowTitle ? " • " + windowTitle : "")
}
@@ -174,7 +178,7 @@ Rectangle {
anchors.fill: parent
radius: Theme.cornerRadius
color: {
if (isFocused)
if (isFocused) {
return mouseArea.containsMouse ? Qt.rgba(
Theme.primary.r,
Theme.primary.g,
@@ -183,13 +187,14 @@ Rectangle {
Theme.primary.r,
Theme.primary.g,
Theme.primary.b,
0.2)
else
0.2);
} else {
return mouseArea.containsMouse ? Qt.rgba(
Theme.primaryHover.r,
Theme.primaryHover.g,
Theme.primaryHover.b,
0.1) : "transparent"
0.1) : "transparent";
}
}
Behavior on color {
@@ -220,14 +225,16 @@ Rectangle {
anchors.centerIn: parent
visible: !iconImg.visible
text: {
if (!appId)
return "?"
if (!appId) {
return "?";
}
var desktopEntry = DesktopEntries.heuristicLookup(appId)
if (desktopEntry && desktopEntry.name)
return desktopEntry.name.charAt(0).toUpperCase()
const desktopEntry = DesktopEntries.heuristicLookup(appId);
if (desktopEntry && desktopEntry.name) {
return desktopEntry.name.charAt(0).toUpperCase();
}
return appId.charAt(0).toUpperCase()
return appId.charAt(0).toUpperCase();
}
font.pixelSize: 10
color: Theme.surfaceText
@@ -260,45 +267,47 @@ Rectangle {
onClicked: (mouse) => {
if (mouse.button === Qt.LeftButton) {
if (toplevelObject) {
toplevelObject.activate()
toplevelObject.activate();
}
} else if (mouse.button === Qt.RightButton) {
if (tooltipLoader.item)
tooltipLoader.item.hideTooltip()
tooltipLoader.active = false
if (tooltipLoader.item) {
tooltipLoader.item.hideTooltip();
}
tooltipLoader.active = false;
windowContextMenuLoader.active = true
windowContextMenuLoader.active = true;
if (windowContextMenuLoader.item) {
windowContextMenuLoader.item.currentWindow = toplevelObject
var globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, 0)
var screenX = root.parentScreen ? root.parentScreen.x : 0
var screenY = root.parentScreen ? root.parentScreen.y : 0
var relativeX = globalPos.x - screenX
var yPos = Theme.barHeight + SettingsData.topBarSpacing - 7
windowContextMenuLoader.item.showAt(relativeX, yPos)
windowContextMenuLoader.item.currentWindow = toplevelObject;
const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, 0);
const screenX = root.parentScreen ? root.parentScreen.x : 0;
const screenY = root.parentScreen ? root.parentScreen.y : 0;
const relativeX = globalPos.x - screenX;
const yPos = Theme.barHeight + SettingsData.topBarSpacing - 7;
windowContextMenuLoader.item.showAt(relativeX, yPos);
}
}
}
onEntered: {
root.hoveredItem = delegateItem
var globalPos = delegateItem.mapToGlobal(
delegateItem.width / 2, delegateItem.height)
tooltipLoader.active = true
root.hoveredItem = delegateItem;
const globalPos = delegateItem.mapToGlobal(
delegateItem.width / 2, delegateItem.height);
tooltipLoader.active = true;
if (tooltipLoader.item) {
var tooltipY = Theme.barHeight
+ SettingsData.topBarSpacing + Theme.spacingXS
const tooltipY = Theme.barHeight
+ SettingsData.topBarSpacing + Theme.spacingXS;
tooltipLoader.item.showTooltip(
delegateItem.tooltipText, globalPos.x,
tooltipY, root.parentScreen)
tooltipY, root.parentScreen);
}
}
onExited: {
if (root.hoveredItem === delegateItem) {
root.hoveredItem = null
if (tooltipLoader.item)
tooltipLoader.item.hideTooltip()
root.hoveredItem = null;
if (tooltipLoader.item) {
tooltipLoader.item.hideTooltip();
}
tooltipLoader.active = false
tooltipLoader.active = false;
}
}
}
@@ -325,16 +334,16 @@ Rectangle {
property point anchorPos: Qt.point(0, 0)
function showAt(x, y) {
screen = root.parentScreen
anchorPos = Qt.point(x, y)
isVisible = true
visible = true
screen = root.parentScreen;
anchorPos = Qt.point(x, y);
isVisible = true;
visible = true;
}
function close() {
isVisible = false
visible = false
windowContextMenuLoader.active = false
isVisible = false;
visible = false;
windowContextMenuLoader.active = false;
}
implicitWidth: 100
@@ -355,15 +364,15 @@ Rectangle {
MouseArea {
anchors.fill: parent
onClicked: contextMenuWindow.close()
onClicked: contextMenuWindow.close();
}
Rectangle {
x: {
var left = 10
var right = contextMenuWindow.width - width - 10
var want = contextMenuWindow.anchorPos.x - width / 2
return Math.max(left, Math.min(right, want))
const left = 10;
const right = contextMenuWindow.width - width - 10;
const want = contextMenuWindow.anchorPos.x - width / 2;
return Math.max(left, Math.min(right, want));
}
y: contextMenuWindow.anchorPos.y
width: 100
@@ -394,9 +403,9 @@ Rectangle {
cursorShape: Qt.PointingHandCursor
onClicked: {
if (contextMenuWindow.currentWindow) {
contextMenuWindow.currentWindow.close()
contextMenuWindow.currentWindow.close();
}
contextMenuWindow.close()
contextMenuWindow.close();
}
}
}