mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-27 23:12:49 -05:00
cleanup and qmlfmt some modules
This commit is contained in:
@@ -17,15 +17,16 @@ Item {
|
||||
implicitHeight: row.height
|
||||
|
||||
function movePinnedApp(fromIndex, toIndex) {
|
||||
if (fromIndex === toIndex)
|
||||
if (fromIndex === toIndex) {
|
||||
return
|
||||
}
|
||||
|
||||
var currentPinned = [...(SessionData.pinnedApps || [])]
|
||||
if (fromIndex < 0 || fromIndex >= currentPinned.length || toIndex < 0
|
||||
|| toIndex >= currentPinned.length)
|
||||
const currentPinned = [...(SessionData.pinnedApps || [])]
|
||||
if (fromIndex < 0 || fromIndex >= currentPinned.length || toIndex < 0 || toIndex >= currentPinned.length) {
|
||||
return
|
||||
}
|
||||
|
||||
var movedApp = currentPinned.splice(fromIndex, 1)[0]
|
||||
const movedApp = currentPinned.splice(fromIndex, 1)[0]
|
||||
currentPinned.splice(toIndex, 0, movedApp)
|
||||
|
||||
SessionData.setPinnedApps(currentPinned)
|
||||
@@ -47,60 +48,48 @@ Item {
|
||||
function updateModel() {
|
||||
clear()
|
||||
|
||||
var items = []
|
||||
var pinnedApps = [...(SessionData.pinnedApps || [])]
|
||||
const items = []
|
||||
const pinnedApps = [...(SessionData.pinnedApps || [])]
|
||||
|
||||
// First section: Pinned apps (always visible, not representing running windows)
|
||||
pinnedApps.forEach(appId => {
|
||||
items.push({
|
||||
"type": "pinned",
|
||||
"appId": appId,
|
||||
"windowId": -1,
|
||||
"windowTitle"// Use -1 instead of null to avoid ListModel warnings
|
||||
: "",
|
||||
"windowTitle": "",
|
||||
"workspaceId": -1,
|
||||
"isPinned"// Use -1 instead of null
|
||||
: true,
|
||||
"isRunning": false,
|
||||
"isPinned": true,
|
||||
"isRunning": false
|
||||
})
|
||||
})
|
||||
|
||||
root.pinnedAppCount = pinnedApps.length
|
||||
|
||||
// Get sorted toplevels from CompositorService
|
||||
var sortedToplevels = CompositorService.sortedToplevels
|
||||
|
||||
// Add separator between pinned and running if both exist
|
||||
if (pinnedApps.length > 0
|
||||
&& sortedToplevels.length > 0) {
|
||||
const sortedToplevels = CompositorService.sortedToplevels
|
||||
|
||||
if (pinnedApps.length > 0 && sortedToplevels.length > 0) {
|
||||
items.push({
|
||||
"type": "separator",
|
||||
"appId": "__SEPARATOR__",
|
||||
"windowId": -1,
|
||||
"windowTitle"// Use -1 instead of null
|
||||
: "",
|
||||
"windowTitle": "",
|
||||
"workspaceId": -1,
|
||||
"isPinned"// Use -1 instead of null
|
||||
: false,
|
||||
"isPinned": false,
|
||||
"isRunning": false,
|
||||
"isFocused": false
|
||||
})
|
||||
}
|
||||
|
||||
// Second section: Running windows (sorted using Theme.sortToplevels)
|
||||
sortedToplevels.forEach((toplevel, index) => {
|
||||
// Limit window title length for tooltip
|
||||
var title = toplevel.title || "(Unnamed)"
|
||||
if (title.length > 50) {
|
||||
title = title.substring(0, 47) + "..."
|
||||
}
|
||||
var uniqueId = toplevel.title + "|" + (toplevel.appId || "") + "|" + index
|
||||
|
||||
const title = toplevel.title || "(Unnamed)"
|
||||
const truncatedTitle = title.length > 50 ? title.substring(0, 47) + "..." : title
|
||||
const uniqueId = toplevel.title + "|" + (toplevel.appId || "") + "|" + index
|
||||
|
||||
items.push({
|
||||
"type": "window",
|
||||
"appId": toplevel.appId,
|
||||
"windowId": index,
|
||||
"windowTitle": title,
|
||||
"windowTitle": truncatedTitle,
|
||||
"workspaceId": -1,
|
||||
"isPinned": false,
|
||||
"isRunning": true,
|
||||
@@ -108,9 +97,7 @@ Item {
|
||||
})
|
||||
})
|
||||
|
||||
items.forEach(item => {
|
||||
append(item)
|
||||
})
|
||||
items.forEach(item => append(item))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,8 +112,7 @@ Item {
|
||||
visible: model.type === "separator"
|
||||
width: 2
|
||||
height: 20
|
||||
color: Qt.rgba(Theme.outline.r, Theme.outline.g,
|
||||
Theme.outline.b, 0.3)
|
||||
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.3)
|
||||
radius: 1
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
@@ -159,8 +145,6 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Connections {
|
||||
target: SessionData
|
||||
function onPinnedAppsChanged() {
|
||||
|
||||
Reference in New Issue
Block a user