mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-27 23:12:49 -05:00
feat: Wallpapers built into the Media Hub
- Thanks @TaylanTatli for the inspiration
This commit is contained in:
@@ -23,7 +23,6 @@ Item {
|
||||
signal colorPickerRequested
|
||||
|
||||
property alias barVariants: barVariants
|
||||
property var hyprlandOverviewLoader: null
|
||||
|
||||
function triggerControlCenterOnFocusedScreen() {
|
||||
let focusedScreenName = ""
|
||||
@@ -49,6 +48,30 @@ Item {
|
||||
return false
|
||||
}
|
||||
|
||||
function triggerWallpaperBrowserOnFocusedScreen() {
|
||||
let focusedScreenName = ""
|
||||
if (CompositorService.isHyprland && Hyprland.focusedWorkspace && Hyprland.focusedWorkspace.monitor) {
|
||||
focusedScreenName = Hyprland.focusedWorkspace.monitor.name
|
||||
} else if (CompositorService.isNiri && NiriService.currentOutput) {
|
||||
focusedScreenName = NiriService.currentOutput
|
||||
}
|
||||
|
||||
if (!focusedScreenName && barVariants.instances.length > 0) {
|
||||
const firstBar = barVariants.instances[0]
|
||||
firstBar.triggerWallpaperBrowser()
|
||||
return true
|
||||
}
|
||||
|
||||
for (var i = 0; i < barVariants.instances.length; i++) {
|
||||
const barInstance = barVariants.instances[i]
|
||||
if (barInstance.modelData && barInstance.modelData.name === focusedScreenName) {
|
||||
barInstance.triggerWallpaperBrowser()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Variants {
|
||||
id: barVariants
|
||||
model: SettingsData.getFilteredScreens("dankBar")
|
||||
@@ -57,6 +80,7 @@ Item {
|
||||
id: barWindow
|
||||
|
||||
property var controlCenterButtonRef: null
|
||||
property var clockButtonRef: null
|
||||
|
||||
function triggerControlCenter() {
|
||||
controlCenterLoader.active = true
|
||||
@@ -79,6 +103,27 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
function triggerWallpaperBrowser() {
|
||||
dankDashPopoutLoader.active = true
|
||||
if (!dankDashPopoutLoader.item) {
|
||||
return
|
||||
}
|
||||
|
||||
if (clockButtonRef && dankDashPopoutLoader.item.setTriggerPosition) {
|
||||
const globalPos = clockButtonRef.mapToGlobal(0, 0)
|
||||
const pos = SettingsData.getPopupTriggerPosition(globalPos, barWindow.screen, barWindow.effectiveBarThickness, clockButtonRef.width)
|
||||
const section = clockButtonRef.section || "center"
|
||||
dankDashPopoutLoader.item.setTriggerPosition(pos.x, pos.y, pos.width, section, barWindow.screen)
|
||||
} else {
|
||||
dankDashPopoutLoader.item.triggerScreen = barWindow.screen
|
||||
}
|
||||
|
||||
if (!dankDashPopoutLoader.item.dashVisible) {
|
||||
dankDashPopoutLoader.item.currentTabIndex = 2
|
||||
}
|
||||
dankDashPopoutLoader.item.dashVisible = !dankDashPopoutLoader.item.dashVisible
|
||||
}
|
||||
|
||||
readonly property var dBarLayer: {
|
||||
switch (Quickshell.env("DMS_DANKBAR_LAYER")) {
|
||||
case "bottom":
|
||||
@@ -773,7 +818,6 @@ Item {
|
||||
section: topBarContent.getWidgetSection(parent)
|
||||
popupTarget: appDrawerLoader.item
|
||||
parentScreen: barWindow.screen
|
||||
hyprlandOverviewLoader: root.hyprlandOverviewLoader
|
||||
onClicked: {
|
||||
appDrawerLoader.active = true
|
||||
appDrawerLoader.item?.toggle()
|
||||
@@ -787,7 +831,6 @@ Item {
|
||||
WorkspaceSwitcher {
|
||||
screenName: barWindow.screenName
|
||||
widgetHeight: barWindow.widgetThickness
|
||||
hyprlandOverviewLoader: root.hyprlandOverviewLoader
|
||||
}
|
||||
}
|
||||
|
||||
@@ -825,6 +868,17 @@ Item {
|
||||
return dankDashPopoutLoader.item
|
||||
}
|
||||
parentScreen: barWindow.screen
|
||||
|
||||
Component.onCompleted: {
|
||||
barWindow.clockButtonRef = this
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
if (barWindow.clockButtonRef === this) {
|
||||
barWindow.clockButtonRef = null
|
||||
}
|
||||
}
|
||||
|
||||
onClockClicked: {
|
||||
dankDashPopoutLoader.active = true
|
||||
if (dankDashPopoutLoader.item) {
|
||||
@@ -874,7 +928,7 @@ Item {
|
||||
dankDashPopoutLoader.active = true
|
||||
if (dankDashPopoutLoader.item) {
|
||||
dankDashPopoutLoader.item.dashVisible = !dankDashPopoutLoader.item.dashVisible
|
||||
dankDashPopoutLoader.item.currentTabIndex = 2
|
||||
dankDashPopoutLoader.item.currentTabIndex = 3
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1208,4 +1262,15 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "dankdash"
|
||||
|
||||
function wallpaper(): string {
|
||||
if (root.triggerWallpaperBrowserOnFocusedScreen()) {
|
||||
return "SUCCESS: Toggled wallpaper browser"
|
||||
}
|
||||
return "ERROR: Failed to toggle wallpaper browser"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,20 +74,14 @@ Rectangle {
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
if (!Hyprland.toplevels) return false
|
||||
const hyprlandToplevels = Array.from(Hyprland.toplevels.values)
|
||||
const activeHyprToplevel = hyprlandToplevels.find(t => t?.wayland === activeWindow)
|
||||
const hyprlandToplevels = Array.from(Hyprland.toplevels.values)
|
||||
const activeHyprToplevel = hyprlandToplevels.find(t => t.wayland === activeWindow)
|
||||
|
||||
if (!activeHyprToplevel || !activeHyprToplevel.workspace) {
|
||||
return false
|
||||
}
|
||||
|
||||
return activeHyprToplevel.workspace.id === Hyprland.focusedWorkspace.id
|
||||
} catch (e) {
|
||||
console.error("FocusedApp: hasWindowsOnCurrentWorkspace error:", e)
|
||||
if (!activeHyprToplevel || !activeHyprToplevel.workspace) {
|
||||
return false
|
||||
}
|
||||
|
||||
return activeHyprToplevel.workspace.id === Hyprland.focusedWorkspace.id
|
||||
}
|
||||
|
||||
return activeWindow && activeWindow.title
|
||||
|
||||
@@ -17,7 +17,6 @@ Item {
|
||||
property var parentScreen: null
|
||||
property real widgetThickness: 30
|
||||
property real barThickness: 48
|
||||
property var hyprlandOverviewLoader: null
|
||||
readonly property real horizontalPadding: SettingsData.dankBarNoBackground ? 0 : Math.max(Theme.spacingXS, Theme.spacingS * (widgetThickness / 30))
|
||||
|
||||
signal clicked()
|
||||
@@ -36,8 +35,6 @@ Item {
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
if (CompositorService.isNiri) {
|
||||
NiriService.toggleOverview()
|
||||
} else if (CompositorService.isHyprland && root.hyprlandOverviewLoader?.item) {
|
||||
root.hyprlandOverviewLoader.item.overviewOpen = !root.hyprlandOverviewLoader.item.overviewOpen
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -30,28 +30,22 @@ Rectangle {
|
||||
if (!SettingsData.runningAppsGroupByApp) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
const appGroups = new Map();
|
||||
sortedToplevels.forEach((toplevel, index) => {
|
||||
if (!toplevel) return;
|
||||
const appId = toplevel?.appId || "unknown";
|
||||
if (!appGroups.has(appId)) {
|
||||
appGroups.set(appId, {
|
||||
appId: appId,
|
||||
windows: []
|
||||
});
|
||||
}
|
||||
appGroups.get(appId).windows.push({
|
||||
toplevel: toplevel,
|
||||
windowId: index,
|
||||
windowTitle: toplevel?.title || "(Unnamed)"
|
||||
const appGroups = new Map();
|
||||
sortedToplevels.forEach((toplevel, index) => {
|
||||
const appId = toplevel.appId || "unknown";
|
||||
if (!appGroups.has(appId)) {
|
||||
appGroups.set(appId, {
|
||||
appId: appId,
|
||||
windows: []
|
||||
});
|
||||
}
|
||||
appGroups.get(appId).windows.push({
|
||||
toplevel: toplevel,
|
||||
windowId: index,
|
||||
windowTitle: toplevel.title || "(Unnamed)"
|
||||
});
|
||||
return Array.from(appGroups.values());
|
||||
} catch (e) {
|
||||
console.error("RunningApps: groupedWindows error:", e);
|
||||
return [];
|
||||
}
|
||||
});
|
||||
return Array.from(appGroups.values());
|
||||
}
|
||||
readonly property int windowCount: SettingsData.runningAppsGroupByApp ? groupedWindows.length : sortedToplevels.length
|
||||
readonly property int calculatedSize: {
|
||||
|
||||
@@ -15,7 +15,6 @@ Rectangle {
|
||||
property string screenName: ""
|
||||
property real widgetHeight: 30
|
||||
property real barThickness: 48
|
||||
property var hyprlandOverviewLoader: null
|
||||
readonly property var sortedToplevels: {
|
||||
return CompositorService.filterCurrentWorkspace(CompositorService.sortedToplevels, parentScreen?.name);
|
||||
}
|
||||
@@ -245,17 +244,11 @@ Rectangle {
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton
|
||||
acceptedButtons: Qt.NoButton
|
||||
|
||||
property real scrollAccumulator: 0
|
||||
property real touchpadThreshold: 500
|
||||
|
||||
onClicked: mouse => {
|
||||
if (mouse.button === Qt.RightButton && CompositorService.isHyprland && root.hyprlandOverviewLoader?.item) {
|
||||
root.hyprlandOverviewLoader.item.overviewOpen = !root.hyprlandOverviewLoader.item.overviewOpen
|
||||
}
|
||||
}
|
||||
|
||||
onWheel: wheel => {
|
||||
const deltaY = wheel.angleDelta.y
|
||||
const isMouseWheel = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0
|
||||
|
||||
Reference in New Issue
Block a user