mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
notifications: try to prevent zombies better, markdown, re-org
This commit is contained in:
@@ -44,6 +44,7 @@ Singleton {
|
||||
property bool wallpaperDynamicTheming: true
|
||||
property string wallpaperLastPath: ""
|
||||
property string profileLastPath: ""
|
||||
property bool doNotDisturb: false
|
||||
|
||||
function loadSettings() {
|
||||
parseSettings(settingsFile.text());
|
||||
@@ -85,6 +86,7 @@ Singleton {
|
||||
wallpaperDynamicTheming = settings.wallpaperDynamicTheming !== undefined ? settings.wallpaperDynamicTheming : true;
|
||||
wallpaperLastPath = settings.wallpaperLastPath !== undefined ? settings.wallpaperLastPath : "";
|
||||
profileLastPath = settings.profileLastPath !== undefined ? settings.profileLastPath : "";
|
||||
doNotDisturb = settings.doNotDisturb !== undefined ? settings.doNotDisturb : false;
|
||||
applyStoredTheme();
|
||||
detectAvailableIconThemes();
|
||||
updateGtkIconTheme(iconTheme);
|
||||
@@ -130,7 +132,8 @@ Singleton {
|
||||
"wallpaperPath": wallpaperPath,
|
||||
"wallpaperDynamicTheming": wallpaperDynamicTheming,
|
||||
"wallpaperLastPath": wallpaperLastPath,
|
||||
"profileLastPath": profileLastPath
|
||||
"profileLastPath": profileLastPath,
|
||||
"doNotDisturb": doNotDisturb
|
||||
}, null, 2));
|
||||
}
|
||||
|
||||
@@ -481,6 +484,11 @@ gtk-application-prefer-dark-theme=true`;
|
||||
}
|
||||
}
|
||||
|
||||
function setDoNotDisturb(enabled) {
|
||||
doNotDisturb = enabled;
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
Component.onCompleted: loadSettings()
|
||||
|
||||
|
||||
|
||||
57
Common/markdown2html.js
Normal file
57
Common/markdown2html.js
Normal file
@@ -0,0 +1,57 @@
|
||||
// This exists only beacause I haven't been able to get linkColor to work with MarkdownText
|
||||
// May not be necessary if that's possible tbh.
|
||||
function markdownToHtml(text) {
|
||||
if (!text) return "";
|
||||
|
||||
let html = text;
|
||||
|
||||
// Escape HTML entities first
|
||||
html = html.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
|
||||
// Headers
|
||||
html = html.replace(/^### (.*?)$/gm, '<h3>$1</h3>');
|
||||
html = html.replace(/^## (.*?)$/gm, '<h2>$1</h2>');
|
||||
html = html.replace(/^# (.*?)$/gm, '<h1>$1</h1>');
|
||||
|
||||
// Bold and italic
|
||||
html = html.replace(/\*\*\*(.*?)\*\*\*/g, '<b><i>$1</i></b>');
|
||||
html = html.replace(/\*\*(.*?)\*\*/g, '<b>$1</b>');
|
||||
html = html.replace(/\*(.*?)\*/g, '<i>$1</i>');
|
||||
html = html.replace(/___(.*?)___/g, '<b><i>$1</i></b>');
|
||||
html = html.replace(/__(.*?)__/g, '<b>$1</b>');
|
||||
html = html.replace(/_(.*?)_/g, '<i>$1</i>');
|
||||
|
||||
// Code blocks
|
||||
html = html.replace(/```([\s\S]*?)```/g, '<pre><code>$1</code></pre>');
|
||||
html = html.replace(/`(.*?)`/g, '<code>$1</code>');
|
||||
|
||||
// Links
|
||||
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>');
|
||||
|
||||
// Lists
|
||||
html = html.replace(/^\* (.*?)$/gm, '<li>$1</li>');
|
||||
html = html.replace(/^- (.*?)$/gm, '<li>$1</li>');
|
||||
html = html.replace(/^\d+\. (.*?)$/gm, '<li>$1</li>');
|
||||
|
||||
// Wrap consecutive list items in ul/ol tags
|
||||
html = html.replace(/(<li>[\s\S]*?<\/li>\s*)+/g, function(match) {
|
||||
return '<ul>' + match + '</ul>';
|
||||
});
|
||||
|
||||
// Detect plain URLs and wrap them in anchor tags (but not inside existing <a> or markdown links)
|
||||
html = html.replace(/(^|[^"'>])((https?|file):\/\/[^\s<]+)/g, '$1<a href="$2">$2</a>');
|
||||
|
||||
|
||||
// Line breaks
|
||||
html = html.replace(/\n\n/g, '</p><p>');
|
||||
html = html.replace(/\n/g, '<br/>');
|
||||
|
||||
// Wrap in paragraph tags if not already wrapped
|
||||
if (!html.startsWith('<')) {
|
||||
html = '<p>' + html + '</p>';
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
Reference in New Issue
Block a user