mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
Modularize the Notepad
This commit is contained in:
64
shell.qml
64
shell.qml
@@ -18,6 +18,8 @@ import qs.Modules.ControlCenter
|
||||
import qs.Modules.Dock
|
||||
import qs.Modules.Lock
|
||||
import qs.Modules.Notifications.Center
|
||||
import qs.Widgets
|
||||
import "./Modules/Notepad"
|
||||
import qs.Modules.Notifications.Popup
|
||||
import qs.Modules.OSD
|
||||
import qs.Modules.ProcessList
|
||||
@@ -287,29 +289,28 @@ ShellRoot {
|
||||
id: notepadSlideoutVariants
|
||||
model: SettingsData.getFilteredScreens("notepad")
|
||||
|
||||
delegate: Loader {
|
||||
id: notepadLoader
|
||||
property var modelData: item
|
||||
active: false
|
||||
|
||||
sourceComponent: Component {
|
||||
NotepadSlideout {
|
||||
id: notepadSlideout
|
||||
modelData: notepadLoader.modelData
|
||||
|
||||
Component.onCompleted: {
|
||||
notepadLoader.loaded = true
|
||||
delegate: DankSlideout {
|
||||
id: notepadSlideout
|
||||
modelData: item
|
||||
title: qsTr("Notepad")
|
||||
slideoutWidth: 480
|
||||
expandable: true
|
||||
expandedWidthValue: 960
|
||||
|
||||
content: Component {
|
||||
Notepad {
|
||||
onHideRequested: {
|
||||
notepadSlideout.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property bool loaded: false
|
||||
|
||||
function ensureLoaded() {
|
||||
if (!active) {
|
||||
active = true
|
||||
|
||||
function toggle() {
|
||||
if (isVisible) {
|
||||
hide()
|
||||
} else {
|
||||
show()
|
||||
}
|
||||
return item
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -474,30 +475,29 @@ ShellRoot {
|
||||
if (notepadSlideoutVariants.instances.length === 0) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
if (notepadSlideoutVariants.instances.length === 1) {
|
||||
return notepadSlideoutVariants.instances[0].ensureLoaded()
|
||||
return notepadSlideoutVariants.instances[0]
|
||||
}
|
||||
|
||||
|
||||
var focusedScreen = getFocusedScreenName()
|
||||
if (focusedScreen && notepadSlideoutVariants.instances.length > 0) {
|
||||
for (var i = 0; i < notepadSlideoutVariants.instances.length; i++) {
|
||||
var loader = notepadSlideoutVariants.instances[i]
|
||||
if (loader.modelData && loader.modelData.name === focusedScreen) {
|
||||
loader.ensureLoaded()
|
||||
return loader.item
|
||||
var slideout = notepadSlideoutVariants.instances[i]
|
||||
if (slideout.modelData && slideout.modelData.name === focusedScreen) {
|
||||
return slideout
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (var i = 0; i < notepadSlideoutVariants.instances.length; i++) {
|
||||
var loader = notepadSlideoutVariants.instances[i]
|
||||
if (loader.active && loader.item && loader.item.notepadVisible) {
|
||||
return loader.item
|
||||
var slideout = notepadSlideoutVariants.instances[i]
|
||||
if (slideout.isVisible) {
|
||||
return slideout
|
||||
}
|
||||
}
|
||||
|
||||
return notepadSlideoutVariants.instances[0].ensureLoaded()
|
||||
|
||||
return notepadSlideoutVariants.instances[0]
|
||||
}
|
||||
|
||||
function open(): string {
|
||||
|
||||
Reference in New Issue
Block a user