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