mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-27 15:02:50 -05:00
dankbar: add a mask while popouts are open
- Retains ability to click items on the bar, while another is open
This commit is contained in:
113
quickshell/Common/PopoutManager.qml
Normal file
113
quickshell/Common/PopoutManager.qml
Normal file
@@ -0,0 +1,113 @@
|
||||
pragma Singleton
|
||||
|
||||
import Quickshell
|
||||
import QtQuick
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
property var currentPopoutsByScreen: ({})
|
||||
property var currentPopoutTriggers: ({})
|
||||
|
||||
function showPopout(popout) {
|
||||
if (!popout || !popout.screen) return
|
||||
|
||||
const screenName = popout.screen.name
|
||||
const currentPopout = currentPopoutsByScreen[screenName]
|
||||
|
||||
if (currentPopout && currentPopout !== popout) {
|
||||
if (currentPopout.dashVisible !== undefined) {
|
||||
currentPopout.dashVisible = false
|
||||
} else if (currentPopout.notificationHistoryVisible !== undefined) {
|
||||
currentPopout.notificationHistoryVisible = false
|
||||
} else {
|
||||
currentPopout.close()
|
||||
}
|
||||
}
|
||||
|
||||
currentPopoutsByScreen[screenName] = popout
|
||||
ModalManager.closeAllModalsExcept(null)
|
||||
TrayMenuManager.closeAllMenus()
|
||||
}
|
||||
|
||||
function hidePopout(popout) {
|
||||
if (!popout || !popout.screen) return
|
||||
|
||||
const screenName = popout.screen.name
|
||||
if (currentPopoutsByScreen[screenName] === popout) {
|
||||
currentPopoutsByScreen[screenName] = null
|
||||
currentPopoutTriggers[screenName] = null
|
||||
}
|
||||
}
|
||||
|
||||
function closeAllPopouts() {
|
||||
for (const screenName in currentPopoutsByScreen) {
|
||||
const popout = currentPopoutsByScreen[screenName]
|
||||
if (!popout) continue
|
||||
|
||||
if (popout.dashVisible !== undefined) {
|
||||
popout.dashVisible = false
|
||||
} else if (popout.notificationHistoryVisible !== undefined) {
|
||||
popout.notificationHistoryVisible = false
|
||||
} else {
|
||||
popout.close()
|
||||
}
|
||||
}
|
||||
currentPopoutsByScreen = {}
|
||||
}
|
||||
|
||||
function getActivePopout(screen) {
|
||||
if (!screen) return null
|
||||
return currentPopoutsByScreen[screen.name] || null
|
||||
}
|
||||
|
||||
function requestPopout(popout, tabIndex, triggerSource) {
|
||||
if (!popout || !popout.screen) return
|
||||
|
||||
const screenName = popout.screen.name
|
||||
const currentPopout = currentPopoutsByScreen[screenName]
|
||||
const triggerId = triggerSource !== undefined ? triggerSource : tabIndex
|
||||
|
||||
if (currentPopout === popout && popout.shouldBeVisible) {
|
||||
if (triggerId !== undefined && currentPopoutTriggers[screenName] === triggerId) {
|
||||
if (popout.dashVisible !== undefined) {
|
||||
popout.dashVisible = false
|
||||
} else if (popout.notificationHistoryVisible !== undefined) {
|
||||
popout.notificationHistoryVisible = false
|
||||
} else {
|
||||
popout.close()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (triggerId === undefined) {
|
||||
if (popout.dashVisible !== undefined) {
|
||||
popout.dashVisible = false
|
||||
} else if (popout.notificationHistoryVisible !== undefined) {
|
||||
popout.notificationHistoryVisible = false
|
||||
} else {
|
||||
popout.close()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (tabIndex !== undefined && popout.currentTabIndex !== undefined) {
|
||||
popout.currentTabIndex = tabIndex
|
||||
}
|
||||
currentPopoutTriggers[screenName] = triggerId
|
||||
return
|
||||
}
|
||||
|
||||
currentPopoutTriggers[screenName] = triggerId
|
||||
|
||||
if (tabIndex !== undefined && popout.currentTabIndex !== undefined) {
|
||||
popout.currentTabIndex = tabIndex
|
||||
}
|
||||
|
||||
if (popout.dashVisible !== undefined) {
|
||||
popout.dashVisible = true
|
||||
} else {
|
||||
popout.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user