mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-02 03:28:28 -04:00
feat(Notepad): add notepad desktop entry & IPC commands file handling
This commit is contained in:
@@ -165,6 +165,16 @@ Singleton {
|
||||
|
||||
readonly property string dmsLogoPath: Qt.resolvedUrl("../assets/danklogo2.svg")
|
||||
|
||||
// Prevent desktop entry duplicates from core apps
|
||||
readonly property var builtInShadowDesktopIds: ["com.danklinux.dms.notepad"]
|
||||
|
||||
function isShadowedByCoreApp(app) {
|
||||
if (!app)
|
||||
return false;
|
||||
const id = (app.id || "").replace(/\.desktop$/, "");
|
||||
return builtInShadowDesktopIds.includes(id);
|
||||
}
|
||||
|
||||
readonly property var builtInPlugins: ({
|
||||
"dms_settings": {
|
||||
id: "dms_settings",
|
||||
|
||||
@@ -248,6 +248,29 @@ Singleton {
|
||||
return newTab
|
||||
}
|
||||
|
||||
function createTabForFile(path) {
|
||||
var id = Date.now()
|
||||
var fileName = path.split('/').pop()
|
||||
|
||||
var newTab = {
|
||||
id: id,
|
||||
title: fileName,
|
||||
filePath: path,
|
||||
isTemporary: false,
|
||||
lastModified: new Date().toISOString(),
|
||||
cursorPosition: 0,
|
||||
scrollPosition: 0
|
||||
}
|
||||
|
||||
var newTabs = tabs.slice()
|
||||
newTabs.push(newTab)
|
||||
tabs = newTabs
|
||||
currentTabIndex = tabs.length - 1
|
||||
saveMetadata()
|
||||
|
||||
return newTab
|
||||
}
|
||||
|
||||
function closeTab(tabIndex) {
|
||||
if (tabIndex < 0 || tabIndex >= tabs.length) return
|
||||
|
||||
|
||||
@@ -909,6 +909,7 @@ Singleton {
|
||||
property var notepadPopout: null
|
||||
property var notepadPopoutLoader: null
|
||||
property bool _notepadPopoutWantsOpen: false
|
||||
property string _notepadPendingOpenFilePath: ""
|
||||
|
||||
function openNotepadPopout() {
|
||||
closeNotepadSlideouts();
|
||||
@@ -920,10 +921,27 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
function openNotepadPopoutWithFile(path) {
|
||||
closeNotepadSlideouts();
|
||||
if (notepadPopout) {
|
||||
notepadPopout.show();
|
||||
notepadPopout.notepad?.openExternalFile(path);
|
||||
} else if (notepadPopoutLoader) {
|
||||
_notepadPendingOpenFilePath = path;
|
||||
_notepadPopoutWantsOpen = true;
|
||||
notepadPopoutLoader.active = true;
|
||||
}
|
||||
}
|
||||
|
||||
function _onNotepadPopoutLoaded() {
|
||||
if (_notepadPopoutWantsOpen && notepadPopout) {
|
||||
_notepadPopoutWantsOpen = false;
|
||||
notepadPopout.show();
|
||||
if (_notepadPendingOpenFilePath) {
|
||||
const pendingPath = _notepadPendingOpenFilePath;
|
||||
_notepadPendingOpenFilePath = "";
|
||||
notepadPopout.notepad?.openExternalFile(pendingPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user