1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-04-03 20:32:07 -04:00

refactor(Notepad): Streamline hide behavior & auto-save function

This commit is contained in:
purian23
2026-03-17 23:23:17 -04:00
parent 9070903512
commit 347f06b758
4 changed files with 18 additions and 5 deletions

View File

@@ -798,9 +798,8 @@ Item {
content: Component { content: Component {
Notepad { Notepad {
onHideRequested: { slideout: notepadSlideout
notepadSlideout.hide(); onHideRequested: notepadSlideout.hide()
}
} }
} }

View File

@@ -21,6 +21,7 @@ Item {
property var currentTab: NotepadStorageService.tabs.length > NotepadStorageService.currentTabIndex ? NotepadStorageService.tabs[NotepadStorageService.currentTabIndex] : null property var currentTab: NotepadStorageService.tabs.length > NotepadStorageService.currentTabIndex ? NotepadStorageService.tabs[NotepadStorageService.currentTabIndex] : null
property bool showSettingsMenu: false property bool showSettingsMenu: false
property string pendingSaveContent: "" property string pendingSaveContent: ""
property var slideout: null
signal hideRequested signal hideRequested
signal previewRequested(string content) signal previewRequested(string content)
@@ -29,6 +30,14 @@ Item {
service: NotepadStorageService service: NotepadStorageService
} }
Connections {
target: slideout
enabled: slideout !== null
function onAboutToHide() {
textEditor.autoSaveToSession()
}
}
function hasUnsavedChanges() { function hasUnsavedChanges() {
return textEditor.hasUnsavedChanges(); return textEditor.hasUnsavedChanges();
} }
@@ -204,7 +213,8 @@ Item {
} }
onEscapePressed: { onEscapePressed: {
root.hideRequested(); textEditor.autoSaveToSession()
root.hideRequested()
} }
onSettingsRequested: { onSettingsRequested: {

View File

@@ -555,7 +555,9 @@ Column {
}) })
} }
function onTabsChanged() { function onTabsChanged() {
if (NotepadStorageService.tabs.length > 0 && !contentLoaded) {/* Lines 444-445 omitted */} if (NotepadStorageService.tabs.length > 0 && !contentLoaded) {
loadCurrentTabContent()
}
} }
} }

View File

@@ -25,6 +25,7 @@ PanelWindow {
property string title: "" property string title: ""
property alias container: contentContainer property alias container: contentContainer
property real customTransparency: -1 property real customTransparency: -1
signal aboutToHide
function show() { function show() {
visible = true visible = true
@@ -32,6 +33,7 @@ PanelWindow {
} }
function hide() { function hide() {
aboutToHide()
isVisible = false isVisible = false
} }