mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
Multi-screen notepad support
This commit is contained in:
@@ -39,6 +39,11 @@ Item {
|
||||
"name": "Toast Messages",
|
||||
"description": "System toast notifications",
|
||||
"icon": "campaign"
|
||||
}, {
|
||||
"id": "notepad",
|
||||
"name": "Notepad Slideout",
|
||||
"description": "Quick note-taking slideout panel",
|
||||
"icon": "sticky_note_2"
|
||||
}]
|
||||
|
||||
function getScreenPreferences(componentId) {
|
||||
|
||||
@@ -20,6 +20,19 @@ PanelWindow {
|
||||
WlrLayershell.namespace: "quickshell:bar"
|
||||
|
||||
property var modelData
|
||||
property var notepadVariants: null
|
||||
|
||||
function getNotepadInstanceForScreen() {
|
||||
if (!notepadVariants || !notepadVariants.instances) return null
|
||||
|
||||
for (var i = 0; i < notepadVariants.instances.length; i++) {
|
||||
var instance = notepadVariants.instances[i]
|
||||
if (instance.modelData && instance.modelData.name === root.screen?.name) {
|
||||
return instance
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
property string screenName: modelData.name
|
||||
readonly property int notificationCount: NotificationService.notifications.length
|
||||
readonly property real effectiveBarHeight: Math.max(root.widgetHeight + SettingsData.topBarInnerPadding + 4, Theme.barHeight - 4 - (8 - SettingsData.topBarInnerPadding))
|
||||
@@ -151,13 +164,20 @@ PanelWindow {
|
||||
"loader": controlCenterLoader,
|
||||
"prop": "shouldBeVisible"
|
||||
}, {
|
||||
"loader": notepadSlideoutLoader,
|
||||
"instance": root.getNotepadInstanceForScreen(),
|
||||
"prop": "notepadVisible"
|
||||
}, {
|
||||
"loader": clipboardHistoryModalPopup,
|
||||
"prop": "visible"
|
||||
}]
|
||||
return loaders.some(item => item.loader?.item?.[item.prop])
|
||||
return loaders.some(item => {
|
||||
if (item.loader) {
|
||||
return item.loader?.item?.[item.prop]
|
||||
} else if (item.instance) {
|
||||
return item.instance?.[item.prop]
|
||||
}
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
Connections {
|
||||
@@ -947,18 +967,17 @@ PanelWindow {
|
||||
id: notepadButtonComponent
|
||||
|
||||
NotepadButton {
|
||||
isActive: notepadSlideoutLoader.item ? notepadSlideoutLoader.item.notepadVisible : false
|
||||
property var notepadInstance: root.getNotepadInstanceForScreen()
|
||||
isActive: notepadInstance ? notepadInstance.notepadVisible : false
|
||||
widgetHeight: root.widgetHeight
|
||||
barHeight: root.effectiveBarHeight
|
||||
section: topBarContent.getWidgetSection(parent) || "right"
|
||||
popupTarget: {
|
||||
notepadSlideoutLoader.active = true
|
||||
return notepadSlideoutLoader.item
|
||||
}
|
||||
popupTarget: notepadInstance
|
||||
parentScreen: root.screen
|
||||
onClicked: {
|
||||
notepadSlideoutLoader.active = true
|
||||
notepadSlideoutLoader.item?.toggle()
|
||||
if (notepadInstance) {
|
||||
notepadInstance.toggle()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
49
shell.qml
49
shell.qml
@@ -45,6 +45,7 @@ ShellRoot {
|
||||
|
||||
delegate: TopBar {
|
||||
modelData: item
|
||||
notepadVariants: notepadSlideoutVariants
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,15 +266,13 @@ ShellRoot {
|
||||
}
|
||||
}
|
||||
|
||||
LazyLoader {
|
||||
id: notepadSlideoutLoader
|
||||
Variants {
|
||||
id: notepadSlideoutVariants
|
||||
model: SettingsData.getFilteredScreens("notepad")
|
||||
|
||||
active: false
|
||||
|
||||
NotepadSlideout {
|
||||
delegate: NotepadSlideout {
|
||||
id: notepadSlideout
|
||||
|
||||
modelData: Quickshell.screens.length > 0 ? Quickshell.screens[0] : null
|
||||
modelData: item
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,27 +364,47 @@ ShellRoot {
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
function getActiveNotepadInstance() {
|
||||
if (notepadSlideoutVariants.instances.length === 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (notepadSlideoutVariants.instances.length === 1) {
|
||||
return notepadSlideoutVariants.instances[0]
|
||||
}
|
||||
|
||||
for (var i = 0; i < notepadSlideoutVariants.instances.length; i++) {
|
||||
var instance = notepadSlideoutVariants.instances[i]
|
||||
if (instance.notepadVisible) {
|
||||
return instance
|
||||
}
|
||||
}
|
||||
|
||||
return notepadSlideoutVariants.instances[0]
|
||||
}
|
||||
|
||||
function open(): string {
|
||||
notepadSlideoutLoader.active = true
|
||||
if (notepadSlideoutLoader.item) {
|
||||
notepadSlideoutLoader.item.show()
|
||||
var instance = getActiveNotepadInstance()
|
||||
if (instance) {
|
||||
instance.show()
|
||||
return "NOTEPAD_OPEN_SUCCESS"
|
||||
}
|
||||
return "NOTEPAD_OPEN_FAILED"
|
||||
}
|
||||
|
||||
function close(): string {
|
||||
if (notepadSlideoutLoader.item) {
|
||||
notepadSlideoutLoader.item.hide()
|
||||
var instance = getActiveNotepadInstance()
|
||||
if (instance) {
|
||||
instance.hide()
|
||||
return "NOTEPAD_CLOSE_SUCCESS"
|
||||
}
|
||||
return "NOTEPAD_CLOSE_FAILED"
|
||||
}
|
||||
|
||||
function toggle(): string {
|
||||
notepadSlideoutLoader.active = true
|
||||
if (notepadSlideoutLoader.item) {
|
||||
notepadSlideoutLoader.item.toggle()
|
||||
var instance = getActiveNotepadInstance()
|
||||
if (instance) {
|
||||
instance.toggle()
|
||||
return "NOTEPAD_TOGGLE_SUCCESS"
|
||||
}
|
||||
return "NOTEPAD_TOGGLE_FAILED"
|
||||
|
||||
Reference in New Issue
Block a user