1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-04 12:38:31 -04:00

feat(Notepad): add notepad desktop entry & IPC commands file handling

This commit is contained in:
purian23
2026-07-04 16:10:56 -04:00
parent bfda5f2d66
commit 81a4d3b4e0
23 changed files with 129 additions and 1 deletions
+16
View File
@@ -385,6 +385,22 @@ Item {
return "NOTEPAD_OPEN_FAILED";
}
function openFile(path: string): string {
if (!path)
return open();
if (SettingsData.notepadDefaultMode === "popout") {
PopoutService.openNotepadPopoutWithFile(path);
return "NOTEPAD_OPEN_FILE_SUCCESS";
}
var instance = getActiveNotepadInstance();
if (instance) {
instance.show();
instance.loadedItem?.openExternalFile(path);
return "NOTEPAD_OPEN_FILE_SUCCESS";
}
return "NOTEPAD_OPEN_FILE_FAILED";
}
function close(): string {
if (SettingsData.notepadDefaultMode === "popout") {
PopoutService.notepadPopout?.hide();
@@ -787,6 +787,8 @@ Item {
if (isCategoryFiltered) {
var rawApps = AppSearchService.getAppsInCategory(appCategory);
for (var i = 0; i < rawApps.length; i++) {
if (AppSearchService.isShadowedByCoreApp(rawApps[i]))
continue;
allItems.push(getOrTransformApp(rawApps[i]));
}
// Also include core apps (DMS Settings etc.) that match this category
@@ -1182,6 +1184,8 @@ Item {
var items = [];
for (var i = 0; i < apps.length; i++) {
if (AppSearchService.isShadowedByCoreApp(apps[i]))
continue;
items.push(getOrTransformApp(apps[i]));
}
+19
View File
@@ -212,6 +212,25 @@ Item {
});
}
function openExternalFile(path) {
if (!path)
return;
for (var i = 0; i < NotepadStorageService.tabs.length; i++) {
var tab = NotepadStorageService.tabs[i];
if (tab && !tab.isTemporary && tab.filePath === path) {
textEditor.autoSaveToSession();
switchToTab(i);
return;
}
}
textEditor.autoSaveToSession();
NotepadStorageService.createTabForFile(path);
root.currentFileName = path.split('/').pop();
root.currentFileUrl = "file://" + path;
}
function loadFromFile(fileUrl) {
if (hasUnsavedChanges()) {
root.pendingFileUrl = fileUrl;
@@ -9,6 +9,7 @@ FloatingWindow {
id: win
property alias shouldBeVisible: win.visible
property alias notepad: notepad
function show() {
visible = true;
@@ -41,7 +41,7 @@ Item {
readonly property var mimeMapping: ({
[root.appCategory.WebBrowser]: ["x-scheme-handler/https", "x-scheme-handler/http", "text/html", "application/xhtml+xml"],
[root.appCategory.FileManager]: ["inode/directory", "x-scheme-handler/file"],
[root.appCategory.TextEditor]: ["text/plain", "application/x-zerosize", "text/x-c++src", "text/x-csrc", "text/x-python", "text/x-shellscript", "application/json"],
[root.appCategory.TextEditor]: ["text/plain", "text/markdown", "application/x-zerosize", "text/x-c++src", "text/x-csrc", "text/x-python", "text/x-shellscript", "application/json"],
[root.appCategory.ImageViewer]: ["image/png", "image/jpeg", "image/gif", "image/bmp", "image/webp", "image/avif", "image/svg+xml"],
[root.appCategory.VideoPlayer]: ["video/mp4", "video/x-matroska", "video/webm", "video/avi", "video/mpeg", "video/quicktime", "video/x-msvideo"],
[root.appCategory.MusicPlayer]: ["audio/mpeg", "audio/x-flac", "audio/wav", "audio/ogg", "audio/aac", "audio/webm"],
+10
View File
@@ -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
+18
View File
@@ -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);
}
}
}
+2
View File
@@ -31,6 +31,7 @@ PanelWindow {
property Component content: null
property string title: ""
property alias container: contentContainer
property alias loadedItem: contentLoader.item
property real customTransparency: -1
property bool mappedVisible: false
signal aboutToHide
@@ -259,6 +260,7 @@ PanelWindow {
anchors.bottomMargin: Theme.spacingL
Loader {
id: contentLoader
anchors.fill: parent
sourceComponent: root.content
}