mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-05 21:15:38 -05:00
dankbar: support multiple bars and per-display bars
- Migrate settings to v2 - Up to 4 bars - Per-bar settings instead of global
This commit is contained in:
@@ -9,155 +9,167 @@ Singleton {
|
||||
property var currentPopoutsByScreen: ({})
|
||||
property var currentPopoutTriggers: ({})
|
||||
|
||||
function showPopout(popout) {
|
||||
if (!popout || !popout.screen) return
|
||||
signal popoutOpening
|
||||
signal popoutChanged
|
||||
|
||||
const screenName = popout.screen.name
|
||||
function showPopout(popout) {
|
||||
if (!popout || !popout.screen)
|
||||
return;
|
||||
popoutOpening();
|
||||
|
||||
const screenName = popout.screen.name;
|
||||
|
||||
for (const otherScreenName in currentPopoutsByScreen) {
|
||||
const otherPopout = currentPopoutsByScreen[otherScreenName]
|
||||
if (!otherPopout || otherPopout === popout) continue
|
||||
|
||||
const otherPopout = currentPopoutsByScreen[otherScreenName];
|
||||
if (!otherPopout || otherPopout === popout)
|
||||
continue;
|
||||
if (otherPopout.dashVisible !== undefined) {
|
||||
otherPopout.dashVisible = false
|
||||
otherPopout.dashVisible = false;
|
||||
} else if (otherPopout.notificationHistoryVisible !== undefined) {
|
||||
otherPopout.notificationHistoryVisible = false
|
||||
otherPopout.notificationHistoryVisible = false;
|
||||
} else {
|
||||
otherPopout.close()
|
||||
otherPopout.close();
|
||||
}
|
||||
}
|
||||
|
||||
currentPopoutsByScreen[screenName] = popout
|
||||
ModalManager.closeAllModalsExcept(null)
|
||||
TrayMenuManager.closeAllMenus()
|
||||
currentPopoutsByScreen[screenName] = popout;
|
||||
popoutChanged();
|
||||
ModalManager.closeAllModalsExcept(null);
|
||||
}
|
||||
|
||||
function hidePopout(popout) {
|
||||
if (!popout || !popout.screen) return
|
||||
|
||||
const screenName = popout.screen.name
|
||||
if (!popout || !popout.screen)
|
||||
return;
|
||||
const screenName = popout.screen.name;
|
||||
if (currentPopoutsByScreen[screenName] === popout) {
|
||||
currentPopoutsByScreen[screenName] = null
|
||||
currentPopoutTriggers[screenName] = null
|
||||
currentPopoutsByScreen[screenName] = null;
|
||||
currentPopoutTriggers[screenName] = null;
|
||||
popoutChanged();
|
||||
}
|
||||
}
|
||||
|
||||
function closeAllPopouts() {
|
||||
for (const screenName in currentPopoutsByScreen) {
|
||||
const popout = currentPopoutsByScreen[screenName]
|
||||
if (!popout) continue
|
||||
|
||||
const popout = currentPopoutsByScreen[screenName];
|
||||
if (!popout)
|
||||
continue;
|
||||
if (popout.dashVisible !== undefined) {
|
||||
popout.dashVisible = false
|
||||
popout.dashVisible = false;
|
||||
} else if (popout.notificationHistoryVisible !== undefined) {
|
||||
popout.notificationHistoryVisible = false
|
||||
popout.notificationHistoryVisible = false;
|
||||
} else {
|
||||
popout.close()
|
||||
popout.close();
|
||||
}
|
||||
}
|
||||
currentPopoutsByScreen = {}
|
||||
currentPopoutsByScreen = {};
|
||||
}
|
||||
|
||||
function getActivePopout(screen) {
|
||||
if (!screen) return null
|
||||
return currentPopoutsByScreen[screen.name] || null
|
||||
if (!screen)
|
||||
return null;
|
||||
return currentPopoutsByScreen[screen.name] || null;
|
||||
}
|
||||
|
||||
function requestPopout(popout, tabIndex, triggerSource) {
|
||||
if (!popout || !popout.screen) return
|
||||
if (!popout || !popout.screen)
|
||||
return;
|
||||
const screenName = popout.screen.name;
|
||||
const currentPopout = currentPopoutsByScreen[screenName];
|
||||
const triggerId = triggerSource !== undefined ? triggerSource : tabIndex;
|
||||
|
||||
const screenName = popout.screen.name
|
||||
const currentPopout = currentPopoutsByScreen[screenName]
|
||||
const triggerId = triggerSource !== undefined ? triggerSource : tabIndex
|
||||
const willOpen = !(currentPopout === popout && popout.shouldBeVisible && triggerId !== undefined && currentPopoutTriggers[screenName] === triggerId);
|
||||
if (willOpen) {
|
||||
popoutOpening();
|
||||
}
|
||||
|
||||
let justClosedSamePopout = false
|
||||
let justClosedSamePopout = false;
|
||||
for (const otherScreenName in currentPopoutsByScreen) {
|
||||
if (otherScreenName === screenName) continue
|
||||
const otherPopout = currentPopoutsByScreen[otherScreenName]
|
||||
if (!otherPopout) continue
|
||||
|
||||
if (otherScreenName === screenName)
|
||||
continue;
|
||||
const otherPopout = currentPopoutsByScreen[otherScreenName];
|
||||
if (!otherPopout)
|
||||
continue;
|
||||
if (otherPopout === popout) {
|
||||
justClosedSamePopout = true
|
||||
justClosedSamePopout = true;
|
||||
}
|
||||
|
||||
if (otherPopout.dashVisible !== undefined) {
|
||||
otherPopout.dashVisible = false
|
||||
otherPopout.dashVisible = false;
|
||||
} else if (otherPopout.notificationHistoryVisible !== undefined) {
|
||||
otherPopout.notificationHistoryVisible = false
|
||||
otherPopout.notificationHistoryVisible = false;
|
||||
} else {
|
||||
otherPopout.close()
|
||||
otherPopout.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (currentPopout && currentPopout !== popout) {
|
||||
if (currentPopout.dashVisible !== undefined) {
|
||||
currentPopout.dashVisible = false
|
||||
currentPopout.dashVisible = false;
|
||||
} else if (currentPopout.notificationHistoryVisible !== undefined) {
|
||||
currentPopout.notificationHistoryVisible = false
|
||||
currentPopout.notificationHistoryVisible = false;
|
||||
} else {
|
||||
currentPopout.close()
|
||||
currentPopout.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (currentPopout === popout && popout.shouldBeVisible) {
|
||||
if (triggerId !== undefined && currentPopoutTriggers[screenName] === triggerId) {
|
||||
if (popout.dashVisible !== undefined) {
|
||||
popout.dashVisible = false
|
||||
popout.dashVisible = false;
|
||||
} else if (popout.notificationHistoryVisible !== undefined) {
|
||||
popout.notificationHistoryVisible = false
|
||||
popout.notificationHistoryVisible = false;
|
||||
} else {
|
||||
popout.close()
|
||||
popout.close();
|
||||
}
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
if (triggerId === undefined) {
|
||||
if (popout.dashVisible !== undefined) {
|
||||
popout.dashVisible = false
|
||||
popout.dashVisible = false;
|
||||
} else if (popout.notificationHistoryVisible !== undefined) {
|
||||
popout.notificationHistoryVisible = false
|
||||
popout.notificationHistoryVisible = false;
|
||||
} else {
|
||||
popout.close()
|
||||
popout.close();
|
||||
}
|
||||
return
|
||||
return;
|
||||
}
|
||||
|
||||
if (tabIndex !== undefined && popout.currentTabIndex !== undefined) {
|
||||
popout.currentTabIndex = tabIndex
|
||||
popout.currentTabIndex = tabIndex;
|
||||
}
|
||||
currentPopoutTriggers[screenName] = triggerId
|
||||
return
|
||||
currentPopoutTriggers[screenName] = triggerId;
|
||||
}
|
||||
|
||||
currentPopoutTriggers[screenName] = triggerId
|
||||
currentPopoutsByScreen[screenName] = popout
|
||||
currentPopoutTriggers[screenName] = triggerId;
|
||||
currentPopoutsByScreen[screenName] = popout;
|
||||
popoutChanged();
|
||||
|
||||
if (tabIndex !== undefined && popout.currentTabIndex !== undefined) {
|
||||
popout.currentTabIndex = tabIndex
|
||||
popout.currentTabIndex = tabIndex;
|
||||
}
|
||||
|
||||
if (currentPopout !== popout) {
|
||||
ModalManager.closeAllModalsExcept(null)
|
||||
ModalManager.closeAllModalsExcept(null);
|
||||
}
|
||||
TrayMenuManager.closeAllMenus()
|
||||
|
||||
if (justClosedSamePopout) {
|
||||
Qt.callLater(() => {
|
||||
if (popout.dashVisible !== undefined) {
|
||||
popout.dashVisible = true
|
||||
popout.dashVisible = true;
|
||||
} else if (popout.notificationHistoryVisible !== undefined) {
|
||||
popout.notificationHistoryVisible = true
|
||||
popout.notificationHistoryVisible = true;
|
||||
} else {
|
||||
popout.open()
|
||||
popout.open();
|
||||
}
|
||||
})
|
||||
});
|
||||
} else {
|
||||
if (popout.dashVisible !== undefined) {
|
||||
popout.dashVisible = true
|
||||
popout.dashVisible = true;
|
||||
} else if (popout.notificationHistoryVisible !== undefined) {
|
||||
popout.notificationHistoryVisible = true
|
||||
popout.notificationHistoryVisible = true;
|
||||
} else {
|
||||
popout.open()
|
||||
popout.open();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,13 +67,21 @@ Singleton {
|
||||
})
|
||||
|
||||
out.streamFinished.connect(function() {
|
||||
capturedOut = out.text || ""
|
||||
try {
|
||||
capturedOut = out.text || ""
|
||||
} catch (e) {
|
||||
capturedOut = ""
|
||||
}
|
||||
outSeen = true
|
||||
maybeComplete()
|
||||
})
|
||||
|
||||
err.streamFinished.connect(function() {
|
||||
capturedErr = err.text || ""
|
||||
try {
|
||||
capturedErr = err.text || ""
|
||||
} catch (e) {
|
||||
capturedErr = ""
|
||||
}
|
||||
errSeen = true
|
||||
maybeComplete()
|
||||
})
|
||||
@@ -88,8 +96,14 @@ Singleton {
|
||||
function maybeComplete() {
|
||||
if (!exitSeen || !outSeen || !errSeen) return
|
||||
timeoutTimer.stop()
|
||||
if (typeof entry.callback === "function") {
|
||||
try { entry.callback(capturedOut, exitCodeValue) } catch (e) { console.warn("runCommand callback error:", e) }
|
||||
if (entry && entry.callback && typeof entry.callback === "function") {
|
||||
try {
|
||||
const safeOutput = capturedOut !== null && capturedOut !== undefined ? capturedOut : ""
|
||||
const safeExitCode = exitCodeValue !== null && exitCodeValue !== undefined ? exitCodeValue : -1
|
||||
entry.callback(safeOutput, safeExitCode)
|
||||
} catch (e) {
|
||||
console.warn("runCommand callback error for command:", entry.command, "Error:", e)
|
||||
}
|
||||
}
|
||||
try { proc.destroy() } catch (_) {}
|
||||
try { timeoutTimer.destroy() } catch (_) {}
|
||||
|
||||
@@ -15,7 +15,7 @@ import "settings/SettingsStore.js" as Store
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
readonly property int settingsConfigVersion: 1
|
||||
readonly property int settingsConfigVersion: 2
|
||||
|
||||
readonly property bool isGreeterMode: Quickshell.env("DMS_RUN_GREETER") === "1" || Quickshell.env("DMS_RUN_GREETER") === "true"
|
||||
|
||||
@@ -70,8 +70,6 @@ Singleton {
|
||||
property string matugenScheme: "scheme-tonal-spot"
|
||||
property bool runUserMatugenTemplates: true
|
||||
property string matugenTargetMonitor: ""
|
||||
property real dankBarTransparency: 1.0
|
||||
property real dankBarWidgetTransparency: 1.0
|
||||
property real popupTransparency: 1.0
|
||||
property real dockTransparency: 1
|
||||
property string widgetBackgroundColor: "sch"
|
||||
@@ -168,10 +166,6 @@ Singleton {
|
||||
property string lockDateFormat: ""
|
||||
property int mediaSize: 1
|
||||
|
||||
property var dankBarLeftWidgets: ["launcherButton", "workspaceSwitcher", "focusedWindow"]
|
||||
property var dankBarCenterWidgets: ["music", "clock", "weather"]
|
||||
property var dankBarRightWidgets: ["systemTray", "clipboard", "cpuUsage", "memUsage", "notificationButton", "battery", "controlCenterButton"]
|
||||
property var dankBarWidgetOrder: []
|
||||
|
||||
property string appLauncherViewMode: "list"
|
||||
property string spotlightModalViewMode: "list"
|
||||
@@ -268,39 +262,9 @@ Singleton {
|
||||
property string dockIndicatorStyle: "circle"
|
||||
|
||||
property bool notificationOverlayEnabled: false
|
||||
property bool dankBarAutoHide: false
|
||||
property int dankBarAutoHideDelay: 250
|
||||
property bool dankBarOpenOnOverview: false
|
||||
property bool dankBarVisible: true
|
||||
property int overviewRows: 2
|
||||
property int overviewColumns: 5
|
||||
property real overviewScale: 0.16
|
||||
property real dankBarSpacing: 4
|
||||
property real dankBarBottomGap: 0
|
||||
property real dankBarInnerPadding: 4
|
||||
property int dankBarPosition: SettingsData.Position.Top
|
||||
property bool dankBarIsVertical: dankBarPosition === SettingsData.Position.Left || dankBarPosition === SettingsData.Position.Right
|
||||
|
||||
onDankBarAutoHideDelayChanged: saveSettings()
|
||||
|
||||
property bool dankBarSquareCorners: false
|
||||
property bool dankBarNoBackground: false
|
||||
property bool dankBarGothCornersEnabled: false
|
||||
property bool dankBarGothCornerRadiusOverride: false
|
||||
property real dankBarGothCornerRadiusValue: 12
|
||||
property bool dankBarBorderEnabled: false
|
||||
property string dankBarBorderColor: "surfaceText"
|
||||
property real dankBarBorderOpacity: 1.0
|
||||
property real dankBarBorderThickness: 1
|
||||
|
||||
onDankBarGothCornerRadiusOverrideChanged: saveSettings()
|
||||
onDankBarGothCornerRadiusValueChanged: saveSettings()
|
||||
onDankBarBorderColorChanged: saveSettings()
|
||||
onDankBarBorderOpacityChanged: saveSettings()
|
||||
onDankBarBorderThicknessChanged: saveSettings()
|
||||
|
||||
property bool popupGapsAuto: true
|
||||
property int popupGapsManual: 4
|
||||
|
||||
property bool modalDarkenBackground: true
|
||||
|
||||
@@ -343,6 +307,39 @@ Singleton {
|
||||
property var screenPreferences: ({})
|
||||
property var showOnLastDisplay: ({})
|
||||
|
||||
property var barConfigs: [{
|
||||
id: "default",
|
||||
name: "Main Bar",
|
||||
enabled: true,
|
||||
position: 0,
|
||||
screenPreferences: ["all"],
|
||||
showOnLastDisplay: true,
|
||||
leftWidgets: ["launcherButton", "workspaceSwitcher", "focusedWindow"],
|
||||
centerWidgets: ["music", "clock", "weather"],
|
||||
rightWidgets: ["systemTray", "clipboard", "cpuUsage", "memUsage", "notificationButton", "battery", "controlCenterButton"],
|
||||
spacing: 4,
|
||||
innerPadding: 4,
|
||||
bottomGap: 0,
|
||||
transparency: 1.0,
|
||||
widgetTransparency: 1.0,
|
||||
squareCorners: false,
|
||||
noBackground: false,
|
||||
gothCornersEnabled: false,
|
||||
gothCornerRadiusOverride: false,
|
||||
gothCornerRadiusValue: 12,
|
||||
borderEnabled: false,
|
||||
borderColor: "surfaceText",
|
||||
borderOpacity: 1.0,
|
||||
borderThickness: 1,
|
||||
fontScale: 1.0,
|
||||
autoHide: false,
|
||||
autoHideDelay: 250,
|
||||
openOnOverview: false,
|
||||
visible: true,
|
||||
popupGapsAuto: true,
|
||||
popupGapsManual: 4
|
||||
}]
|
||||
|
||||
signal forceDankBarLayoutRefresh
|
||||
signal forceDockLayoutRefresh
|
||||
signal widgetDataChanged
|
||||
@@ -456,7 +453,8 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr
|
||||
applyStoredTheme: applyStoredTheme,
|
||||
regenSystemThemes: regenSystemThemes,
|
||||
updateNiriLayout: updateNiriLayout,
|
||||
applyStoredIconTheme: applyStoredIconTheme
|
||||
applyStoredIconTheme: applyStoredIconTheme,
|
||||
updateBarConfigs: updateBarConfigs
|
||||
})
|
||||
|
||||
function set(key, value) {
|
||||
@@ -467,24 +465,22 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr
|
||||
_loading = true
|
||||
try {
|
||||
const txt = settingsFile.text()
|
||||
const obj = (txt && txt.trim()) ? JSON.parse(txt) : null
|
||||
let obj = (txt && txt.trim()) ? JSON.parse(txt) : null
|
||||
|
||||
const oldVersion = obj?.configVersion ?? 0
|
||||
if (oldVersion < settingsConfigVersion) {
|
||||
const migrated = Store.migrateToVersion(obj, settingsConfigVersion)
|
||||
if (migrated) {
|
||||
settingsFile.setText(JSON.stringify(migrated, null, 2))
|
||||
obj = migrated
|
||||
}
|
||||
}
|
||||
|
||||
Store.parse(root, obj)
|
||||
const shouldMigrate = Store.migrate(root, obj)
|
||||
applyStoredTheme()
|
||||
applyStoredIconTheme()
|
||||
Processes.detectIcons()
|
||||
Processes.detectQtTools()
|
||||
if (obj && obj.configVersion === undefined) {
|
||||
const cleaned = Store.cleanup(txt)
|
||||
if (cleaned) {
|
||||
settingsFile.setText(cleaned)
|
||||
}
|
||||
saveSettings()
|
||||
}
|
||||
if (shouldMigrate) {
|
||||
savePluginSettings()
|
||||
saveSettings()
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("SettingsData: Failed to load settings:", e.message)
|
||||
applyStoredTheme()
|
||||
@@ -548,7 +544,10 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr
|
||||
}
|
||||
|
||||
function initializeListModels() {
|
||||
Lists.init(leftWidgetsModel, centerWidgetsModel, rightWidgetsModel, dankBarLeftWidgets, dankBarCenterWidgets, dankBarRightWidgets)
|
||||
const defaultBar = barConfigs[0] || getBarConfig("default")
|
||||
if (defaultBar) {
|
||||
Lists.init(leftWidgetsModel, centerWidgetsModel, rightWidgetsModel, defaultBar.leftWidgets, defaultBar.centerWidgets, defaultBar.rightWidgets)
|
||||
}
|
||||
}
|
||||
|
||||
function updateListModel(listModel, order) {
|
||||
@@ -579,77 +578,302 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr
|
||||
}
|
||||
|
||||
function getPopupYPosition(barHeight) {
|
||||
const gothOffset = dankBarGothCornersEnabled ? Theme.cornerRadius : 0
|
||||
return barHeight + dankBarSpacing + dankBarBottomGap - gothOffset + Theme.popupDistance
|
||||
const defaultBar = barConfigs[0] || getBarConfig("default")
|
||||
const gothOffset = defaultBar?.gothCornersEnabled ? Theme.cornerRadius : 0
|
||||
const spacing = defaultBar?.spacing ?? 4
|
||||
const bottomGap = defaultBar?.bottomGap ?? 0
|
||||
return barHeight + spacing + bottomGap - gothOffset + Theme.popupDistance
|
||||
}
|
||||
|
||||
function getPopupTriggerPosition(globalPos, screen, barThickness, widgetWidth) {
|
||||
function getPopupTriggerPosition(globalPos, screen, barThickness, widgetWidth, barSpacing, barPosition, barConfig) {
|
||||
const screenX = screen ? screen.x : 0
|
||||
const screenY = screen ? screen.y : 0
|
||||
const relativeX = globalPos.x - screenX
|
||||
const relativeY = globalPos.y - screenY
|
||||
const defaultBar = barConfigs[0] || getBarConfig("default")
|
||||
const spacing = barSpacing !== undefined ? barSpacing : (defaultBar?.spacing ?? 4)
|
||||
const position = barPosition !== undefined ? barPosition : (defaultBar?.position ?? SettingsData.Position.Top)
|
||||
const bottomGap = barConfig ? (barConfig.bottomGap !== undefined ? barConfig.bottomGap : (defaultBar?.bottomGap ?? 0)) : (defaultBar?.bottomGap ?? 0)
|
||||
|
||||
if (dankBarPosition === SettingsData.Position.Left || dankBarPosition === SettingsData.Position.Right) {
|
||||
const useAutoGaps = (barConfig && barConfig.popupGapsAuto !== undefined) ? barConfig.popupGapsAuto : (defaultBar?.popupGapsAuto ?? true)
|
||||
const manualGapValue = (barConfig && barConfig.popupGapsManual !== undefined) ? barConfig.popupGapsManual : (defaultBar?.popupGapsManual ?? 4)
|
||||
const popupGap = useAutoGaps ? Math.max(4, spacing) : manualGapValue
|
||||
|
||||
switch (position) {
|
||||
case SettingsData.Position.Left:
|
||||
return {
|
||||
"x": relativeY,
|
||||
"y": barThickness + dankBarSpacing + Theme.popupDistance,
|
||||
"x": barThickness + spacing + popupGap,
|
||||
"y": relativeY,
|
||||
"width": widgetWidth
|
||||
}
|
||||
case SettingsData.Position.Right:
|
||||
return {
|
||||
"x": (screen?.width || 0) - (barThickness + spacing + popupGap),
|
||||
"y": relativeY,
|
||||
"width": widgetWidth
|
||||
}
|
||||
case SettingsData.Position.Bottom:
|
||||
return {
|
||||
"x": relativeX,
|
||||
"y": (screen?.height || 0) - (barThickness + spacing + bottomGap + popupGap),
|
||||
"width": widgetWidth
|
||||
}
|
||||
default:
|
||||
return {
|
||||
"x": relativeX,
|
||||
"y": barThickness + spacing + bottomGap + popupGap,
|
||||
"width": widgetWidth
|
||||
}
|
||||
}
|
||||
return {
|
||||
"x": relativeX,
|
||||
"y": barThickness + dankBarSpacing + Theme.popupDistance,
|
||||
"width": widgetWidth
|
||||
}
|
||||
}
|
||||
|
||||
function getBarBounds(screen, barThickness) {
|
||||
function getAdjacentBarInfo(screen, barPosition, barConfig) {
|
||||
if (!screen || !barConfig) {
|
||||
return { "topBar": 0, "bottomBar": 0, "leftBar": 0, "rightBar": 0 }
|
||||
}
|
||||
|
||||
if (barConfig.autoHide) {
|
||||
return { "topBar": 0, "bottomBar": 0, "leftBar": 0, "rightBar": 0 }
|
||||
}
|
||||
|
||||
const enabledBars = getEnabledBarConfigs()
|
||||
const defaultBar = barConfigs[0] || getBarConfig("default")
|
||||
const position = barPosition !== undefined ? barPosition : (defaultBar?.position ?? SettingsData.Position.Top)
|
||||
let topBar = 0
|
||||
let bottomBar = 0
|
||||
let leftBar = 0
|
||||
let rightBar = 0
|
||||
|
||||
for (let i = 0; i < enabledBars.length; i++) {
|
||||
const other = enabledBars[i]
|
||||
if (other.id === barConfig.id) continue
|
||||
if (other.autoHide) continue
|
||||
|
||||
const otherScreens = other.screenPreferences || ["all"]
|
||||
const barScreens = barConfig.screenPreferences || ["all"]
|
||||
const onSameScreen = otherScreens.includes("all") || barScreens.includes("all") ||
|
||||
otherScreens.some(s => isScreenInPreferences(screen, [s]))
|
||||
|
||||
if (!onSameScreen) continue
|
||||
|
||||
const otherSpacing = other.spacing !== undefined ? other.spacing : (defaultBar?.spacing ?? 4)
|
||||
const otherPadding = other.innerPadding !== undefined ? other.innerPadding : (defaultBar?.innerPadding ?? 4)
|
||||
const otherThickness = Math.max(26 + otherPadding * 0.6, Theme.barHeight - 4 - (8 - otherPadding)) + otherSpacing
|
||||
|
||||
const useAutoGaps = other.popupGapsAuto !== undefined ? other.popupGapsAuto : (defaultBar?.popupGapsAuto ?? true)
|
||||
const manualGap = other.popupGapsManual !== undefined ? other.popupGapsManual : (defaultBar?.popupGapsManual ?? 4)
|
||||
const popupGap = useAutoGaps ? Math.max(4, otherSpacing) : manualGap
|
||||
|
||||
switch (other.position) {
|
||||
case SettingsData.Position.Top:
|
||||
topBar = Math.max(topBar, otherThickness + popupGap)
|
||||
break
|
||||
case SettingsData.Position.Bottom:
|
||||
bottomBar = Math.max(bottomBar, otherThickness + popupGap)
|
||||
break
|
||||
case SettingsData.Position.Left:
|
||||
leftBar = Math.max(leftBar, otherThickness + popupGap)
|
||||
break
|
||||
case SettingsData.Position.Right:
|
||||
rightBar = Math.max(rightBar, otherThickness + popupGap)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return { "topBar": topBar, "bottomBar": bottomBar, "leftBar": leftBar, "rightBar": rightBar }
|
||||
}
|
||||
|
||||
function getBarBounds(screen, barThickness, barPosition, barConfig) {
|
||||
if (!screen) {
|
||||
return { "x": 0, "y": 0, "width": 0, "height": 0, "wingSize": 0 }
|
||||
}
|
||||
|
||||
const wingRadius = dankBarGothCornerRadiusOverride ? dankBarGothCornerRadiusValue : Theme.cornerRadius
|
||||
const wingSize = dankBarGothCornersEnabled ? Math.max(0, wingRadius) : 0
|
||||
const defaultBar = barConfigs[0] || getBarConfig("default")
|
||||
const wingRadius = (defaultBar?.gothCornerRadiusOverride ?? false) ? (defaultBar?.gothCornerRadiusValue ?? 12) : Theme.cornerRadius
|
||||
const wingSize = (defaultBar?.gothCornersEnabled ?? false) ? Math.max(0, wingRadius) : 0
|
||||
const screenWidth = screen.width
|
||||
const screenHeight = screen.height
|
||||
const position = barPosition !== undefined ? barPosition : (defaultBar?.position ?? SettingsData.Position.Top)
|
||||
const bottomGap = barConfig ? (barConfig.bottomGap !== undefined ? barConfig.bottomGap : (defaultBar?.bottomGap ?? 0)) : (defaultBar?.bottomGap ?? 0)
|
||||
|
||||
if (dankBarPosition === SettingsData.Position.Top) {
|
||||
return {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": screenWidth,
|
||||
"height": barThickness + dankBarSpacing + wingSize,
|
||||
"wingSize": wingSize
|
||||
}
|
||||
} else if (dankBarPosition === SettingsData.Position.Bottom) {
|
||||
return {
|
||||
"x": 0,
|
||||
"y": screenHeight - barThickness - dankBarSpacing - wingSize,
|
||||
"width": screenWidth,
|
||||
"height": barThickness + dankBarSpacing + wingSize,
|
||||
"wingSize": wingSize
|
||||
}
|
||||
} else if (dankBarPosition === SettingsData.Position.Left) {
|
||||
return {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": barThickness + dankBarSpacing + wingSize,
|
||||
"height": screenHeight,
|
||||
"wingSize": wingSize
|
||||
}
|
||||
} else if (dankBarPosition === SettingsData.Position.Right) {
|
||||
return {
|
||||
"x": screenWidth - barThickness - dankBarSpacing - wingSize,
|
||||
"y": 0,
|
||||
"width": barThickness + dankBarSpacing + wingSize,
|
||||
"height": screenHeight,
|
||||
"wingSize": wingSize
|
||||
let topOffset = 0
|
||||
let bottomOffset = 0
|
||||
let leftOffset = 0
|
||||
let rightOffset = 0
|
||||
|
||||
if (barConfig) {
|
||||
const enabledBars = getEnabledBarConfigs()
|
||||
for (let i = 0; i < enabledBars.length; i++) {
|
||||
const other = enabledBars[i]
|
||||
if (other.id === barConfig.id) continue
|
||||
|
||||
const otherScreens = other.screenPreferences || ["all"]
|
||||
const barScreens = barConfig.screenPreferences || ["all"]
|
||||
const onSameScreen = otherScreens.includes("all") || barScreens.includes("all") ||
|
||||
otherScreens.some(s => isScreenInPreferences(screen, [s]))
|
||||
|
||||
if (!onSameScreen) continue
|
||||
|
||||
const otherSpacing = other.spacing !== undefined ? other.spacing : (defaultBar?.spacing ?? 4)
|
||||
const otherPadding = other.innerPadding !== undefined ? other.innerPadding : (defaultBar?.innerPadding ?? 4)
|
||||
const otherThickness = Math.max(26 + otherPadding * 0.6, Theme.barHeight - 4 - (8 - otherPadding)) + otherSpacing + wingSize
|
||||
const otherBottomGap = other.bottomGap !== undefined ? other.bottomGap : (defaultBar?.bottomGap ?? 0)
|
||||
|
||||
switch (other.position) {
|
||||
case SettingsData.Position.Top:
|
||||
if (position === SettingsData.Position.Top && other.id < barConfig.id) {
|
||||
topOffset += otherThickness // Simple stacking for same pos
|
||||
} else if (position === SettingsData.Position.Left || position === SettingsData.Position.Right) {
|
||||
topOffset = Math.max(topOffset, otherThickness)
|
||||
}
|
||||
break
|
||||
case SettingsData.Position.Bottom:
|
||||
if (position === SettingsData.Position.Bottom && other.id < barConfig.id) {
|
||||
bottomOffset += (otherThickness + otherBottomGap)
|
||||
} else if (position === SettingsData.Position.Left || position === SettingsData.Position.Right) {
|
||||
bottomOffset = Math.max(bottomOffset, otherThickness + otherBottomGap)
|
||||
}
|
||||
break
|
||||
case SettingsData.Position.Left:
|
||||
if (position === SettingsData.Position.Top || position === SettingsData.Position.Bottom) {
|
||||
leftOffset = Math.max(leftOffset, otherThickness)
|
||||
} else if (position === SettingsData.Position.Left && other.id < barConfig.id) {
|
||||
leftOffset += otherThickness
|
||||
}
|
||||
break
|
||||
case SettingsData.Position.Right:
|
||||
if (position === SettingsData.Position.Top || position === SettingsData.Position.Bottom) {
|
||||
rightOffset = Math.max(rightOffset, otherThickness)
|
||||
} else if (position === SettingsData.Position.Right && other.id < barConfig.id) {
|
||||
rightOffset += otherThickness
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (position) {
|
||||
case SettingsData.Position.Top:
|
||||
return {
|
||||
"x": leftOffset,
|
||||
"y": topOffset + bottomGap,
|
||||
"width": screenWidth - leftOffset - rightOffset,
|
||||
"height": barThickness + wingSize,
|
||||
"wingSize": wingSize
|
||||
}
|
||||
case SettingsData.Position.Bottom:
|
||||
return {
|
||||
"x": leftOffset,
|
||||
"y": screenHeight - barThickness - wingSize - bottomGap - bottomOffset,
|
||||
"width": screenWidth - leftOffset - rightOffset,
|
||||
"height": barThickness + wingSize,
|
||||
"wingSize": wingSize
|
||||
}
|
||||
case SettingsData.Position.Left:
|
||||
return {
|
||||
"x": 0,
|
||||
"y": topOffset,
|
||||
"width": barThickness + wingSize,
|
||||
"height": screenHeight - topOffset - bottomOffset,
|
||||
"wingSize": wingSize
|
||||
}
|
||||
case SettingsData.Position.Right:
|
||||
return {
|
||||
"x": screenWidth - barThickness - wingSize,
|
||||
"y": topOffset,
|
||||
"width": barThickness + wingSize,
|
||||
"height": screenHeight - topOffset - bottomOffset,
|
||||
"wingSize": wingSize
|
||||
}
|
||||
}
|
||||
|
||||
return { "x": 0, "y": 0, "width": 0, "height": 0, "wingSize": 0 }
|
||||
}
|
||||
|
||||
function updateBarConfigs() {
|
||||
barConfigsChanged()
|
||||
saveSettings()
|
||||
}
|
||||
|
||||
function getBarConfig(barId) {
|
||||
return barConfigs.find(cfg => cfg.id === barId) || null
|
||||
}
|
||||
|
||||
function addBarConfig(config) {
|
||||
const configs = JSON.parse(JSON.stringify(barConfigs))
|
||||
configs.push(config)
|
||||
barConfigs = configs
|
||||
updateBarConfigs()
|
||||
}
|
||||
|
||||
function updateBarConfig(barId, updates) {
|
||||
const configs = JSON.parse(JSON.stringify(barConfigs))
|
||||
const index = configs.findIndex(cfg => cfg.id === barId)
|
||||
if (index === -1) return
|
||||
|
||||
const positionChanged = updates.position !== undefined && configs[index].position !== updates.position
|
||||
|
||||
Object.assign(configs[index], updates)
|
||||
barConfigs = configs
|
||||
updateBarConfigs()
|
||||
|
||||
if (positionChanged) {
|
||||
NotificationService.clearAllPopups()
|
||||
}
|
||||
}
|
||||
|
||||
function checkBarCollisions(barId) {
|
||||
const bar = getBarConfig(barId)
|
||||
if (!bar || !bar.enabled) return []
|
||||
|
||||
const conflicts = []
|
||||
const enabledBars = getEnabledBarConfigs()
|
||||
|
||||
for (let i = 0; i < enabledBars.length; i++) {
|
||||
const other = enabledBars[i]
|
||||
if (other.id === barId) continue
|
||||
|
||||
const samePosition = bar.position === other.position
|
||||
if (!samePosition) continue
|
||||
|
||||
const barScreens = bar.screenPreferences || ["all"]
|
||||
const otherScreens = other.screenPreferences || ["all"]
|
||||
|
||||
const hasAll = barScreens.includes("all") || otherScreens.includes("all")
|
||||
if (hasAll) {
|
||||
conflicts.push({
|
||||
barId: other.id,
|
||||
barName: other.name,
|
||||
reason: "Same position on all screens"
|
||||
})
|
||||
continue
|
||||
}
|
||||
|
||||
const overlapping = barScreens.some(screen => otherScreens.includes(screen))
|
||||
if (overlapping) {
|
||||
conflicts.push({
|
||||
barId: other.id,
|
||||
barName: other.name,
|
||||
reason: "Same position on overlapping screens"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return conflicts
|
||||
}
|
||||
|
||||
function deleteBarConfig(barId) {
|
||||
if (barId === "default") return
|
||||
|
||||
const configs = barConfigs.filter(cfg => cfg.id !== barId)
|
||||
barConfigs = configs
|
||||
updateBarConfigs()
|
||||
}
|
||||
|
||||
function getEnabledBarConfigs() {
|
||||
return barConfigs.filter(cfg => cfg.enabled)
|
||||
}
|
||||
|
||||
function getScreenDisplayName(screen) {
|
||||
if (!screen) return ""
|
||||
if (displayNameMode === "model" && screen.model) {
|
||||
@@ -686,6 +910,7 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr
|
||||
}
|
||||
|
||||
function sendTestNotifications() {
|
||||
NotificationService.clearAllPopups()
|
||||
sendTestNotification(0)
|
||||
testNotifTimer1.start()
|
||||
testNotifTimer2.start()
|
||||
@@ -765,20 +990,22 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr
|
||||
|
||||
function setShowDock(enabled) {
|
||||
showDock = enabled
|
||||
if (enabled && dockPosition === dankBarPosition) {
|
||||
if (dankBarPosition === SettingsData.Position.Top) {
|
||||
const defaultBar = barConfigs[0] || getBarConfig("default")
|
||||
const barPos = defaultBar?.position ?? SettingsData.Position.Top
|
||||
if (enabled && dockPosition === barPos) {
|
||||
if (barPos === SettingsData.Position.Top) {
|
||||
setDockPosition(SettingsData.Position.Bottom)
|
||||
return
|
||||
}
|
||||
if (dankBarPosition === SettingsData.Position.Bottom) {
|
||||
if (barPos === SettingsData.Position.Bottom) {
|
||||
setDockPosition(SettingsData.Position.Top)
|
||||
return
|
||||
}
|
||||
if (dankBarPosition === SettingsData.Position.Left) {
|
||||
if (barPos === SettingsData.Position.Left) {
|
||||
setDockPosition(SettingsData.Position.Right)
|
||||
return
|
||||
}
|
||||
if (dankBarPosition === SettingsData.Position.Right) {
|
||||
if (barPos === SettingsData.Position.Right) {
|
||||
setDockPosition(SettingsData.Position.Left)
|
||||
return
|
||||
}
|
||||
@@ -788,16 +1015,18 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr
|
||||
|
||||
function setDockPosition(position) {
|
||||
dockPosition = position
|
||||
if (position === SettingsData.Position.Bottom && dankBarPosition === SettingsData.Position.Bottom && showDock) {
|
||||
const defaultBar = barConfigs[0] || getBarConfig("default")
|
||||
const barPos = defaultBar?.position ?? SettingsData.Position.Top
|
||||
if (position === SettingsData.Position.Bottom && barPos === SettingsData.Position.Bottom && showDock) {
|
||||
setDankBarPosition(SettingsData.Position.Top)
|
||||
}
|
||||
if (position === SettingsData.Position.Top && dankBarPosition === SettingsData.Position.Top && showDock) {
|
||||
if (position === SettingsData.Position.Top && barPos === SettingsData.Position.Top && showDock) {
|
||||
setDankBarPosition(SettingsData.Position.Bottom)
|
||||
}
|
||||
if (position === SettingsData.Position.Left && dankBarPosition === SettingsData.Position.Left && showDock) {
|
||||
if (position === SettingsData.Position.Left && barPos === SettingsData.Position.Left && showDock) {
|
||||
setDankBarPosition(SettingsData.Position.Right)
|
||||
}
|
||||
if (position === SettingsData.Position.Right && dankBarPosition === SettingsData.Position.Right && showDock) {
|
||||
if (position === SettingsData.Position.Right && barPos === SettingsData.Position.Right && showDock) {
|
||||
setDankBarPosition(SettingsData.Position.Left)
|
||||
}
|
||||
saveSettings()
|
||||
@@ -805,14 +1034,19 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr
|
||||
}
|
||||
|
||||
function setDankBarSpacing(spacing) {
|
||||
set("dankBarSpacing", spacing)
|
||||
const defaultBar = barConfigs[0] || getBarConfig("default")
|
||||
if (defaultBar) {
|
||||
updateBarConfig(defaultBar.id, { spacing: spacing })
|
||||
}
|
||||
if (typeof NiriService !== "undefined" && CompositorService.isNiri) {
|
||||
NiriService.generateNiriLayoutConfig()
|
||||
}
|
||||
}
|
||||
|
||||
function setDankBarPosition(position) {
|
||||
dankBarPosition = position
|
||||
const defaultBar = barConfigs[0] || getBarConfig("default")
|
||||
if (!defaultBar) return
|
||||
|
||||
if (position === SettingsData.Position.Bottom && dockPosition === SettingsData.Position.Bottom && showDock) {
|
||||
setDockPosition(SettingsData.Position.Top)
|
||||
return
|
||||
@@ -829,34 +1063,45 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr
|
||||
setDockPosition(SettingsData.Position.Left)
|
||||
return
|
||||
}
|
||||
saveSettings()
|
||||
updateBarConfig(defaultBar.id, { position: position })
|
||||
}
|
||||
|
||||
function setDankBarLeftWidgets(order) {
|
||||
dankBarLeftWidgets = order
|
||||
updateListModel(leftWidgetsModel, order)
|
||||
saveSettings()
|
||||
const defaultBar = barConfigs[0] || getBarConfig("default")
|
||||
if (defaultBar) {
|
||||
updateBarConfig(defaultBar.id, { leftWidgets: order })
|
||||
updateListModel(leftWidgetsModel, order)
|
||||
}
|
||||
}
|
||||
|
||||
function setDankBarCenterWidgets(order) {
|
||||
dankBarCenterWidgets = order
|
||||
updateListModel(centerWidgetsModel, order)
|
||||
saveSettings()
|
||||
const defaultBar = barConfigs[0] || getBarConfig("default")
|
||||
if (defaultBar) {
|
||||
updateBarConfig(defaultBar.id, { centerWidgets: order })
|
||||
updateListModel(centerWidgetsModel, order)
|
||||
}
|
||||
}
|
||||
|
||||
function setDankBarRightWidgets(order) {
|
||||
dankBarRightWidgets = order
|
||||
updateListModel(rightWidgetsModel, order)
|
||||
saveSettings()
|
||||
const defaultBar = barConfigs[0] || getBarConfig("default")
|
||||
if (defaultBar) {
|
||||
updateBarConfig(defaultBar.id, { rightWidgets: order })
|
||||
updateListModel(rightWidgetsModel, order)
|
||||
}
|
||||
}
|
||||
|
||||
function resetDankBarWidgetsToDefault() {
|
||||
var defaultLeft = ["launcherButton", "workspaceSwitcher", "focusedWindow"]
|
||||
var defaultCenter = ["music", "clock", "weather"]
|
||||
var defaultRight = ["systemTray", "clipboard", "notificationButton", "battery", "controlCenterButton"]
|
||||
dankBarLeftWidgets = defaultLeft
|
||||
dankBarCenterWidgets = defaultCenter
|
||||
dankBarRightWidgets = defaultRight
|
||||
const defaultBar = barConfigs[0] || getBarConfig("default")
|
||||
if (defaultBar) {
|
||||
updateBarConfig(defaultBar.id, {
|
||||
leftWidgets: defaultLeft,
|
||||
centerWidgets: defaultCenter,
|
||||
rightWidgets: defaultRight
|
||||
})
|
||||
}
|
||||
updateListModel(leftWidgetsModel, defaultLeft)
|
||||
updateListModel(centerWidgetsModel, defaultCenter)
|
||||
updateListModel(rightWidgetsModel, defaultRight)
|
||||
@@ -876,7 +1121,6 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr
|
||||
showBattery = true
|
||||
showControlCenterButton = true
|
||||
showCapsLockIndicator = true
|
||||
saveSettings()
|
||||
}
|
||||
|
||||
function setWorkspaceNameIcon(workspaceName, iconData) {
|
||||
@@ -900,8 +1144,10 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr
|
||||
}
|
||||
|
||||
function toggleDankBarVisible() {
|
||||
dankBarVisible = !dankBarVisible
|
||||
saveSettings()
|
||||
const defaultBar = barConfigs[0] || getBarConfig("default")
|
||||
if (defaultBar) {
|
||||
updateBarConfig(defaultBar.id, { visible: !defaultBar.visible })
|
||||
}
|
||||
}
|
||||
|
||||
function toggleShowDock() {
|
||||
@@ -1028,31 +1274,6 @@ rm -rf '${home}'/.cache/icon-cache '${home}'/.cache/thumbnails 2>/dev/null || tr
|
||||
|
||||
property bool pluginSettingsFileExists: false
|
||||
|
||||
IpcHandler {
|
||||
function reveal(): string {
|
||||
root.dankBarVisible = true
|
||||
root.saveSettings()
|
||||
return "BAR_SHOW_SUCCESS"
|
||||
}
|
||||
|
||||
function hide(): string {
|
||||
root.dankBarVisible = false
|
||||
root.saveSettings()
|
||||
return "BAR_HIDE_SUCCESS"
|
||||
}
|
||||
|
||||
function toggle(): string {
|
||||
root.toggleDankBarVisible()
|
||||
return root.dankBarVisible ? "BAR_SHOW_SUCCESS" : "BAR_HIDE_SUCCESS"
|
||||
}
|
||||
|
||||
function status(): string {
|
||||
return root.dankBarVisible ? "visible" : "hidden"
|
||||
}
|
||||
|
||||
target: "bar"
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
function reveal(): string {
|
||||
root.setShowDock(true)
|
||||
|
||||
@@ -15,6 +15,7 @@ import "StockThemes.js" as StockThemes
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
|
||||
readonly property string stateDir: Paths.strip(StandardPaths.writableLocation(StandardPaths.GenericCacheLocation).toString()) + "/DankMaterialShell"
|
||||
|
||||
readonly property bool envDisableMatugen: Quickshell.env("DMS_DISABLE_MATUGEN") === "1" || Quickshell.env("DMS_DISABLE_MATUGEN") === "true"
|
||||
@@ -22,7 +23,12 @@ Singleton {
|
||||
readonly property real popupDistance: {
|
||||
if (typeof SettingsData === "undefined")
|
||||
return 4
|
||||
return SettingsData.popupGapsAuto ? Math.max(4, SettingsData.dankBarSpacing) : SettingsData.popupGapsManual
|
||||
const defaultBar = SettingsData.barConfigs[0] || SettingsData.getBarConfig("default")
|
||||
if (!defaultBar) return 4
|
||||
const useAuto = defaultBar.popupGapsAuto ?? true
|
||||
const manualValue = defaultBar.popupGapsManual ?? 4
|
||||
const spacing = defaultBar.spacing ?? 4
|
||||
return useAuto ? Math.max(4, spacing) : manualValue
|
||||
}
|
||||
|
||||
property string currentTheme: "blue"
|
||||
@@ -465,7 +471,6 @@ Singleton {
|
||||
property real iconSizeLarge: 32
|
||||
|
||||
property real panelTransparency: 0.85
|
||||
property real widgetTransparency: typeof SettingsData !== "undefined" && SettingsData.dankBarWidgetTransparency !== undefined ? SettingsData.dankBarWidgetTransparency : 1.0
|
||||
property real popupTransparency: typeof SettingsData !== "undefined" && SettingsData.popupTransparency !== undefined ? SettingsData.popupTransparency : 1.0
|
||||
|
||||
function screenTransition() {
|
||||
@@ -650,20 +655,6 @@ Singleton {
|
||||
return isLightMode ? Qt.darker(baseColor, factor) : Qt.lighter(baseColor, factor)
|
||||
}
|
||||
|
||||
property var widgetBackground: {
|
||||
const colorMode = typeof SettingsData !== "undefined" ? SettingsData.widgetBackgroundColor : "sch"
|
||||
switch (colorMode) {
|
||||
case "s":
|
||||
return Qt.rgba(surface.r, surface.g, surface.b, widgetTransparency)
|
||||
case "sc":
|
||||
return Qt.rgba(surfaceContainer.r, surfaceContainer.g, surfaceContainer.b, widgetTransparency)
|
||||
case "sch":
|
||||
return Qt.rgba(surfaceContainerHigh.r, surfaceContainerHigh.g, surfaceContainerHigh.b, widgetTransparency)
|
||||
case "sth":
|
||||
default:
|
||||
return Qt.rgba(surfaceContainer.r, surfaceContainer.g, surfaceContainer.b, widgetTransparency)
|
||||
}
|
||||
}
|
||||
|
||||
property color widgetIconColor: {
|
||||
if (typeof SettingsData === "undefined") {
|
||||
@@ -703,9 +694,9 @@ Singleton {
|
||||
return Math.round((barThickness / 48) * (iconSize + defaultOffset))
|
||||
}
|
||||
|
||||
function barTextSize(barThickness) {
|
||||
function barTextSize(barThickness, fontScale) {
|
||||
const scale = barThickness / 48
|
||||
const dankBarScale = (typeof SettingsData !== "undefined" ? SettingsData.dankBarFontScale : 1.0)
|
||||
const dankBarScale = fontScale !== undefined ? fontScale : 1.0
|
||||
if (scale <= 0.75)
|
||||
return Math.round(fontSizeSmall * 0.9 * dankBarScale)
|
||||
if (scale >= 1.25)
|
||||
|
||||
@@ -6,26 +6,30 @@ import QtQuick
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
property var activeTrayBars: ({})
|
||||
property var activeTrayMenus: ({})
|
||||
|
||||
function register(screenName, trayBar) {
|
||||
if (!screenName || !trayBar) return
|
||||
activeTrayBars[screenName] = trayBar
|
||||
function registerMenu(screenName, menu) {
|
||||
if (!screenName || !menu) return
|
||||
const newMenus = Object.assign({}, activeTrayMenus)
|
||||
newMenus[screenName] = menu
|
||||
activeTrayMenus = newMenus
|
||||
}
|
||||
|
||||
function unregister(screenName) {
|
||||
function unregisterMenu(screenName) {
|
||||
if (!screenName) return
|
||||
delete activeTrayBars[screenName]
|
||||
const newMenus = Object.assign({}, activeTrayMenus)
|
||||
delete newMenus[screenName]
|
||||
activeTrayMenus = newMenus
|
||||
}
|
||||
|
||||
function closeAllMenus() {
|
||||
for (const screenName in activeTrayBars) {
|
||||
const trayBar = activeTrayBars[screenName]
|
||||
if (!trayBar) continue
|
||||
|
||||
trayBar.menuOpen = false
|
||||
if (trayBar.currentTrayMenu) {
|
||||
trayBar.currentTrayMenu.showMenu = false
|
||||
for (const screenName in activeTrayMenus) {
|
||||
const menu = activeTrayMenus[screenName]
|
||||
if (!menu) continue
|
||||
if (typeof menu.close === "function") {
|
||||
menu.close()
|
||||
} else if (menu.showMenu !== undefined) {
|
||||
menu.showMenu = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@ var SPEC = {
|
||||
runUserMatugenTemplates: { def: true, onChange: "regenSystemThemes" },
|
||||
matugenTargetMonitor: { def: "", onChange: "regenSystemThemes" },
|
||||
|
||||
dankBarTransparency: { def: 1.0, coerce: percentToUnit, migrate: ["topBarTransparency"] },
|
||||
dankBarWidgetTransparency: { def: 1.0, coerce: percentToUnit, migrate: ["topBarWidgetTransparency"] },
|
||||
popupTransparency: { def: 1.0, coerce: percentToUnit },
|
||||
dockTransparency: { def: 1.0, coerce: percentToUnit },
|
||||
|
||||
@@ -89,11 +87,6 @@ var SPEC = {
|
||||
lockDateFormat: { def: "" },
|
||||
mediaSize: { def: 1 },
|
||||
|
||||
dankBarLeftWidgets: { def: ["launcherButton", "workspaceSwitcher", "focusedWindow"], migrate: ["topBarLeftWidgets"] },
|
||||
dankBarCenterWidgets: { def: ["music", "clock", "weather"], migrate: ["topBarCenterWidgets"] },
|
||||
dankBarRightWidgets: { def: ["systemTray", "clipboard", "cpuUsage", "memUsage", "notificationButton", "battery", "controlCenterButton"], migrate: ["topBarRightWidgets"] },
|
||||
dankBarWidgetOrder: { def: [] },
|
||||
|
||||
appLauncherViewMode: { def: "list" },
|
||||
spotlightModalViewMode: { def: "list" },
|
||||
sortAppsAlphabetically: { def: false },
|
||||
@@ -127,7 +120,6 @@ var SPEC = {
|
||||
monoFontFamily: { def: "Fira Code" },
|
||||
fontWeight: { def: 400 },
|
||||
fontScale: { def: 1.0 },
|
||||
dankBarFontScale: { def: 1.0 },
|
||||
|
||||
notepadUseMonospace: { def: true },
|
||||
notepadFontFamily: { def: "" },
|
||||
@@ -177,31 +169,9 @@ var SPEC = {
|
||||
dockIndicatorStyle: { def: "circle" },
|
||||
|
||||
notificationOverlayEnabled: { def: false },
|
||||
dankBarAutoHide: { def: false, migrate: ["topBarAutoHide"] },
|
||||
dankBarAutoHideDelay: { def: 250 },
|
||||
dankBarOpenOnOverview: { def: false, migrate: ["topBarOpenOnOverview"] },
|
||||
dankBarVisible: { def: true, migrate: ["topBarVisible"] },
|
||||
overviewRows: { def: 2, persist: false },
|
||||
overviewColumns: { def: 5, persist: false },
|
||||
overviewScale: { def: 0.16, persist: false },
|
||||
dankBarSpacing: { def: 4, migrate: ["topBarSpacing"], onChange: "updateNiriLayout" },
|
||||
dankBarBottomGap: { def: 0, migrate: ["topBarBottomGap"] },
|
||||
dankBarInnerPadding: { def: 4, migrate: ["topBarInnerPadding"] },
|
||||
dankBarPosition: { def: 0, migrate: ["dankBarAtBottom", "topBarAtBottom"] },
|
||||
dankBarIsVertical: { def: false, persist: false },
|
||||
|
||||
dankBarSquareCorners: { def: false, migrate: ["topBarSquareCorners"] },
|
||||
dankBarNoBackground: { def: false, migrate: ["topBarNoBackground"] },
|
||||
dankBarGothCornersEnabled: { def: false, migrate: ["topBarGothCornersEnabled"] },
|
||||
dankBarGothCornerRadiusOverride: { def: false },
|
||||
dankBarGothCornerRadiusValue: { def: 12 },
|
||||
dankBarBorderEnabled: { def: false },
|
||||
dankBarBorderColor: { def: "surfaceText" },
|
||||
dankBarBorderOpacity: { def: 1.0 },
|
||||
dankBarBorderThickness: { def: 1 },
|
||||
|
||||
popupGapsAuto: { def: true },
|
||||
popupGapsManual: { def: 4 },
|
||||
|
||||
modalDarkenBackground: { def: true },
|
||||
|
||||
@@ -242,7 +212,40 @@ var SPEC = {
|
||||
|
||||
displayNameMode: { def: "system" },
|
||||
screenPreferences: { def: {} },
|
||||
showOnLastDisplay: { def: {} }
|
||||
showOnLastDisplay: { def: {} },
|
||||
|
||||
barConfigs: { def: [{
|
||||
id: "default",
|
||||
name: "Main Bar",
|
||||
enabled: true,
|
||||
position: 0,
|
||||
screenPreferences: ["all"],
|
||||
showOnLastDisplay: true,
|
||||
leftWidgets: ["launcherButton", "workspaceSwitcher", "focusedWindow"],
|
||||
centerWidgets: ["music", "clock", "weather"],
|
||||
rightWidgets: ["systemTray", "clipboard", "cpuUsage", "memUsage", "notificationButton", "battery", "controlCenterButton"],
|
||||
spacing: 4,
|
||||
innerPadding: 4,
|
||||
bottomGap: 0,
|
||||
transparency: 1.0,
|
||||
widgetTransparency: 1.0,
|
||||
squareCorners: false,
|
||||
noBackground: false,
|
||||
gothCornersEnabled: false,
|
||||
gothCornerRadiusOverride: false,
|
||||
gothCornerRadiusValue: 12,
|
||||
borderEnabled: false,
|
||||
borderColor: "surfaceText",
|
||||
borderOpacity: 1.0,
|
||||
borderThickness: 1,
|
||||
fontScale: 1.0,
|
||||
autoHide: false,
|
||||
autoHideDelay: 250,
|
||||
openOnOverview: false,
|
||||
visible: true,
|
||||
popupGapsAuto: true,
|
||||
popupGapsManual: 4
|
||||
}], onChange: "updateBarConfigs" }
|
||||
};
|
||||
|
||||
function getValidKeys() {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
function parse(root, jsonObj) {
|
||||
var SPEC = SpecModule.SPEC;
|
||||
for (var k in SPEC) {
|
||||
if (k === "pluginSettings") continue;
|
||||
var spec = SPEC[k];
|
||||
root[k] = spec.def;
|
||||
}
|
||||
@@ -13,6 +14,7 @@ function parse(root, jsonObj) {
|
||||
|
||||
for (var k in jsonObj) {
|
||||
if (!SPEC[k]) continue;
|
||||
if (k === "pluginSettings") continue;
|
||||
var raw = jsonObj[k];
|
||||
var spec = SPEC[k];
|
||||
var coerce = spec.coerce;
|
||||
@@ -25,72 +27,93 @@ function toJson(root) {
|
||||
var out = {};
|
||||
for (var k in SPEC) {
|
||||
if (SPEC[k].persist === false) continue;
|
||||
if (k === "pluginSettings") continue;
|
||||
out[k] = root[k];
|
||||
}
|
||||
out.configVersion = root.settingsConfigVersion;
|
||||
return out;
|
||||
}
|
||||
|
||||
function migrate(root, jsonObj) {
|
||||
var SPEC = SpecModule.SPEC;
|
||||
if (!jsonObj) return;
|
||||
function migrateToVersion(obj, targetVersion) {
|
||||
if (!obj) return null;
|
||||
|
||||
if (jsonObj.themeIndex !== undefined || jsonObj.themeIsDynamic !== undefined) {
|
||||
var themeNames = ["blue", "deepBlue", "purple", "green", "orange", "red", "cyan", "pink", "amber", "coral"];
|
||||
if (jsonObj.themeIsDynamic) {
|
||||
root.currentThemeName = "dynamic";
|
||||
} else if (jsonObj.themeIndex >= 0 && jsonObj.themeIndex < themeNames.length) {
|
||||
root.currentThemeName = themeNames[jsonObj.themeIndex];
|
||||
}
|
||||
console.info("Auto-migrated theme from index", jsonObj.themeIndex, "to", root.currentThemeName);
|
||||
var settings = JSON.parse(JSON.stringify(obj));
|
||||
var currentVersion = settings.configVersion || 0;
|
||||
|
||||
if (currentVersion >= targetVersion) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ((jsonObj.dankBarWidgetOrder && jsonObj.dankBarWidgetOrder.length > 0) ||
|
||||
(jsonObj.topBarWidgetOrder && jsonObj.topBarWidgetOrder.length > 0)) {
|
||||
if (jsonObj.dankBarLeftWidgets === undefined && jsonObj.dankBarCenterWidgets === undefined && jsonObj.dankBarRightWidgets === undefined) {
|
||||
var widgetOrder = jsonObj.dankBarWidgetOrder || jsonObj.topBarWidgetOrder;
|
||||
root.dankBarLeftWidgets = widgetOrder.filter(function(w) { return ["launcherButton", "workspaceSwitcher", "focusedWindow"].indexOf(w) >= 0; });
|
||||
root.dankBarCenterWidgets = widgetOrder.filter(function(w) { return ["clock", "music", "weather"].indexOf(w) >= 0; });
|
||||
root.dankBarRightWidgets = widgetOrder.filter(function(w) { return ["systemTray", "clipboard", "systemResources", "notificationButton", "battery", "controlCenterButton"].indexOf(w) >= 0; });
|
||||
}
|
||||
}
|
||||
if (currentVersion < 2) {
|
||||
console.info("Migrating settings from version", currentVersion, "to version 2");
|
||||
|
||||
if (jsonObj.useOSLogo !== undefined) {
|
||||
root.launcherLogoMode = jsonObj.useOSLogo ? "os" : "apps";
|
||||
root.launcherLogoColorOverride = jsonObj.osLogoColorOverride !== undefined ? jsonObj.osLogoColorOverride : "";
|
||||
root.launcherLogoBrightness = jsonObj.osLogoBrightness !== undefined ? jsonObj.osLogoBrightness : 0.5;
|
||||
root.launcherLogoContrast = jsonObj.osLogoContrast !== undefined ? jsonObj.osLogoContrast : 1;
|
||||
}
|
||||
|
||||
if (jsonObj.mediaCompactMode !== undefined && jsonObj.mediaSize === undefined) {
|
||||
root.mediaSize = jsonObj.mediaCompactMode ? 0 : 1;
|
||||
}
|
||||
|
||||
for (var k in SPEC) {
|
||||
var spec = SPEC[k];
|
||||
if (!spec.migrate) continue;
|
||||
for (var i = 0; i < spec.migrate.length; i++) {
|
||||
var oldKey = spec.migrate[i];
|
||||
if (jsonObj[oldKey] !== undefined && jsonObj[k] === undefined) {
|
||||
var raw = jsonObj[oldKey];
|
||||
var coerce = spec.coerce;
|
||||
root[k] = coerce ? (coerce(raw) !== undefined ? coerce(raw) : root[k]) : raw;
|
||||
break;
|
||||
if (settings.barConfigs === undefined) {
|
||||
var position = 0;
|
||||
if (settings.dankBarAtBottom !== undefined || settings.topBarAtBottom !== undefined) {
|
||||
var atBottom = settings.dankBarAtBottom !== undefined ? settings.dankBarAtBottom : settings.topBarAtBottom;
|
||||
position = atBottom ? 1 : 0;
|
||||
} else if (settings.dankBarPosition !== undefined) {
|
||||
position = settings.dankBarPosition;
|
||||
}
|
||||
|
||||
var defaultConfig = {
|
||||
id: "default",
|
||||
name: "Main Bar",
|
||||
enabled: true,
|
||||
position: position,
|
||||
screenPreferences: ["all"],
|
||||
showOnLastDisplay: true,
|
||||
leftWidgets: settings.dankBarLeftWidgets || ["launcherButton", "workspaceSwitcher", "focusedWindow"],
|
||||
centerWidgets: settings.dankBarCenterWidgets || ["music", "clock", "weather"],
|
||||
rightWidgets: settings.dankBarRightWidgets || ["systemTray", "clipboard", "cpuUsage", "memUsage", "notificationButton", "battery", "controlCenterButton"],
|
||||
spacing: settings.dankBarSpacing !== undefined ? settings.dankBarSpacing : 4,
|
||||
innerPadding: settings.dankBarInnerPadding !== undefined ? settings.dankBarInnerPadding : 4,
|
||||
bottomGap: settings.dankBarBottomGap !== undefined ? settings.dankBarBottomGap : 0,
|
||||
transparency: settings.dankBarTransparency !== undefined ? settings.dankBarTransparency : 1.0,
|
||||
widgetTransparency: settings.dankBarWidgetTransparency !== undefined ? settings.dankBarWidgetTransparency : 1.0,
|
||||
squareCorners: settings.dankBarSquareCorners !== undefined ? settings.dankBarSquareCorners : false,
|
||||
noBackground: settings.dankBarNoBackground !== undefined ? settings.dankBarNoBackground : false,
|
||||
gothCornersEnabled: settings.dankBarGothCornersEnabled !== undefined ? settings.dankBarGothCornersEnabled : false,
|
||||
gothCornerRadiusOverride: settings.dankBarGothCornerRadiusOverride !== undefined ? settings.dankBarGothCornerRadiusOverride : false,
|
||||
gothCornerRadiusValue: settings.dankBarGothCornerRadiusValue !== undefined ? settings.dankBarGothCornerRadiusValue : 12,
|
||||
borderEnabled: settings.dankBarBorderEnabled !== undefined ? settings.dankBarBorderEnabled : false,
|
||||
borderColor: settings.dankBarBorderColor || "surfaceText",
|
||||
borderOpacity: settings.dankBarBorderOpacity !== undefined ? settings.dankBarBorderOpacity : 1.0,
|
||||
borderThickness: settings.dankBarBorderThickness !== undefined ? settings.dankBarBorderThickness : 1,
|
||||
fontScale: settings.dankBarFontScale !== undefined ? settings.dankBarFontScale : 1.0,
|
||||
autoHide: settings.dankBarAutoHide !== undefined ? settings.dankBarAutoHide : false,
|
||||
autoHideDelay: settings.dankBarAutoHideDelay !== undefined ? settings.dankBarAutoHideDelay : 250,
|
||||
openOnOverview: settings.dankBarOpenOnOverview !== undefined ? settings.dankBarOpenOnOverview : false,
|
||||
visible: settings.dankBarVisible !== undefined ? settings.dankBarVisible : true,
|
||||
popupGapsAuto: settings.popupGapsAuto !== undefined ? settings.popupGapsAuto : true,
|
||||
popupGapsManual: settings.popupGapsManual !== undefined ? settings.popupGapsManual : 4
|
||||
};
|
||||
|
||||
settings.barConfigs = [defaultConfig];
|
||||
|
||||
var legacyKeys = [
|
||||
"dankBarLeftWidgets", "dankBarCenterWidgets", "dankBarRightWidgets",
|
||||
"dankBarWidgetOrder", "dankBarAutoHide", "dankBarAutoHideDelay",
|
||||
"dankBarOpenOnOverview", "dankBarVisible", "dankBarSpacing",
|
||||
"dankBarBottomGap", "dankBarInnerPadding", "dankBarPosition",
|
||||
"dankBarSquareCorners", "dankBarNoBackground", "dankBarGothCornersEnabled",
|
||||
"dankBarGothCornerRadiusOverride", "dankBarGothCornerRadiusValue",
|
||||
"dankBarBorderEnabled", "dankBarBorderColor", "dankBarBorderOpacity",
|
||||
"dankBarBorderThickness", "popupGapsAuto", "popupGapsManual",
|
||||
"dankBarAtBottom", "topBarAtBottom", "dankBarTransparency", "dankBarWidgetTransparency"
|
||||
];
|
||||
|
||||
for (var i = 0; i < legacyKeys.length; i++) {
|
||||
delete settings[legacyKeys[i]];
|
||||
}
|
||||
|
||||
console.info("Migrated single bar settings to barConfigs");
|
||||
}
|
||||
|
||||
settings.configVersion = 2;
|
||||
}
|
||||
|
||||
if (jsonObj.dankBarAtBottom !== undefined || jsonObj.topBarAtBottom !== undefined) {
|
||||
var atBottom = jsonObj.dankBarAtBottom !== undefined ? jsonObj.dankBarAtBottom : jsonObj.topBarAtBottom;
|
||||
root.dankBarPosition = atBottom ? 1 : 0;
|
||||
}
|
||||
|
||||
if (jsonObj.pluginSettings !== undefined) {
|
||||
root.pluginSettings = jsonObj.pluginSettings;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return settings;
|
||||
}
|
||||
|
||||
function cleanup(fileText) {
|
||||
@@ -104,7 +127,6 @@ function cleanup(fileText) {
|
||||
|
||||
for (var key in settings) {
|
||||
if (validKeys.indexOf(key) < 0) {
|
||||
console.log("SettingsData: Removing unused key:", key);
|
||||
delete settings[key];
|
||||
needsSave = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user