mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
launcher: built-in plugins, add settings search plugin with ? default
trigger
This commit is contained in:
@@ -62,6 +62,22 @@ Singleton {
|
||||
property bool _hasUnsavedChanges: false
|
||||
property var _loadedSettingsSnapshot: null
|
||||
property var pluginSettings: ({})
|
||||
property var builtInPluginSettings: ({})
|
||||
|
||||
function getBuiltInPluginSetting(pluginId, key, defaultValue) {
|
||||
if (!builtInPluginSettings[pluginId])
|
||||
return defaultValue;
|
||||
return builtInPluginSettings[pluginId][key] !== undefined ? builtInPluginSettings[pluginId][key] : defaultValue;
|
||||
}
|
||||
|
||||
function setBuiltInPluginSetting(pluginId, key, value) {
|
||||
const updated = JSON.parse(JSON.stringify(builtInPluginSettings));
|
||||
if (!updated[pluginId])
|
||||
updated[pluginId] = {};
|
||||
updated[pluginId][key] = value;
|
||||
builtInPluginSettings = updated;
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
property alias dankBarLeftWidgetsModel: leftWidgetsModel
|
||||
property alias dankBarCenterWidgetsModel: centerWidgetsModel
|
||||
|
||||
@@ -382,7 +382,9 @@ var SPEC = {
|
||||
desktopWidgetPositions: { def: {} },
|
||||
desktopWidgetGridSettings: { def: {} },
|
||||
|
||||
desktopWidgetInstances: { def: [] }
|
||||
desktopWidgetInstances: { def: [] },
|
||||
|
||||
builtInPluginSettings: { def: {} }
|
||||
};
|
||||
|
||||
function getValidKeys() {
|
||||
|
||||
@@ -606,9 +606,7 @@ Item {
|
||||
|
||||
active: false
|
||||
|
||||
Component.onCompleted: {
|
||||
PopoutService.processListModalLoader = processListModalLoader;
|
||||
}
|
||||
Component.onCompleted: PopoutService.processListModalLoader = processListModalLoader
|
||||
|
||||
ProcessListModal {
|
||||
id: processListModal
|
||||
@@ -646,17 +644,6 @@ Item {
|
||||
expandedWidthValue: 960
|
||||
customTransparency: SettingsData.notepadTransparencyOverride
|
||||
|
||||
Component.onCompleted: {
|
||||
PopoutService.notepadSlideouts.push(notepadSlideout);
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
const index = PopoutService.notepadSlideouts.indexOf(notepadSlideout);
|
||||
if (index > -1) {
|
||||
PopoutService.notepadSlideouts.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
content: Component {
|
||||
Notepad {
|
||||
onHideRequested: {
|
||||
@@ -673,6 +660,9 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onInstancesChanged: PopoutService.notepadSlideouts = instances
|
||||
Component.onCompleted: PopoutService.notepadSlideouts = instances
|
||||
}
|
||||
|
||||
LazyLoader {
|
||||
|
||||
@@ -22,12 +22,8 @@ DankModal {
|
||||
function resetContent() {
|
||||
if (!spotlightContent)
|
||||
return;
|
||||
if (spotlightContent.appLauncher) {
|
||||
spotlightContent.appLauncher.suppressUpdatesWhileLaunching = false;
|
||||
spotlightContent.appLauncher.searchQuery = "";
|
||||
spotlightContent.appLauncher.selectedIndex = 0;
|
||||
spotlightContent.appLauncher.setCategory(I18n.tr("All"));
|
||||
}
|
||||
if (spotlightContent.appLauncher)
|
||||
spotlightContent.appLauncher.reset();
|
||||
if (spotlightContent.fileSearchController)
|
||||
spotlightContent.fileSearchController.reset();
|
||||
if (spotlightContent.resetScroll)
|
||||
|
||||
@@ -96,7 +96,11 @@ Item {
|
||||
_updatingFromTrigger = true;
|
||||
selectedCategory = triggerResult.pluginCategory;
|
||||
_updatingFromTrigger = false;
|
||||
apps = AppSearchService.getPluginItems(triggerResult.pluginCategory, triggerResult.query);
|
||||
if (triggerResult.isBuiltIn) {
|
||||
apps = AppSearchService.getBuiltInLauncherItems(triggerResult.pluginId, triggerResult.query);
|
||||
} else {
|
||||
apps = AppSearchService.getPluginItems(triggerResult.pluginCategory, triggerResult.query);
|
||||
}
|
||||
} else {
|
||||
if (_isTriggered) {
|
||||
_updatingFromTrigger = true;
|
||||
@@ -114,7 +118,11 @@ Item {
|
||||
const items = AppSearchService.getPluginItems(pluginCategory, "");
|
||||
emptyTriggerItems = emptyTriggerItems.concat(items);
|
||||
});
|
||||
// Add Core Apps
|
||||
const builtInEmptyTrigger = AppSearchService.getBuiltInLauncherPluginsWithEmptyTrigger();
|
||||
builtInEmptyTrigger.forEach(pluginId => {
|
||||
const items = AppSearchService.getBuiltInLauncherItems(pluginId, "");
|
||||
emptyTriggerItems = emptyTriggerItems.concat(items);
|
||||
});
|
||||
const coreItems = AppSearchService.getCoreApps("");
|
||||
apps = AppSearchService.applications.concat(emptyTriggerItems).concat(coreItems);
|
||||
} else {
|
||||
@@ -133,6 +141,11 @@ Item {
|
||||
const items = AppSearchService.getPluginItems(pluginCategory, searchQuery);
|
||||
emptyTriggerItems = emptyTriggerItems.concat(items);
|
||||
});
|
||||
const builtInEmptyTrigger = AppSearchService.getBuiltInLauncherPluginsWithEmptyTrigger();
|
||||
builtInEmptyTrigger.forEach(pluginId => {
|
||||
const items = AppSearchService.getBuiltInLauncherItems(pluginId, searchQuery);
|
||||
emptyTriggerItems = emptyTriggerItems.concat(items);
|
||||
});
|
||||
|
||||
const coreItems = AppSearchService.getCoreApps(searchQuery);
|
||||
apps = apps.concat(emptyTriggerItems).concat(coreItems);
|
||||
@@ -191,6 +204,7 @@ Item {
|
||||
"categories": app.categories || [],
|
||||
"isPlugin": isPluginItem,
|
||||
"isCore": app.isCore === true,
|
||||
"isBuiltInLauncher": app.isBuiltInLauncher === true,
|
||||
"appIndex": uniqueApps.length - 1
|
||||
});
|
||||
}
|
||||
@@ -240,13 +254,18 @@ Item {
|
||||
}
|
||||
|
||||
function launchApp(appData) {
|
||||
if (!appData || typeof appData.appIndex === "undefined" || appData.appIndex < 0 || appData.appIndex >= _uniqueApps.length) {
|
||||
if (!appData || typeof appData.appIndex === "undefined" || appData.appIndex < 0 || appData.appIndex >= _uniqueApps.length)
|
||||
return;
|
||||
}
|
||||
suppressUpdatesWhileLaunching = true;
|
||||
|
||||
const actualApp = _uniqueApps[appData.appIndex];
|
||||
|
||||
if (appData.isBuiltInLauncher) {
|
||||
AppSearchService.executeBuiltInLauncherItem(actualApp);
|
||||
appLaunched(appData);
|
||||
return;
|
||||
}
|
||||
|
||||
if (appData.isCore) {
|
||||
AppSearchService.executeCoreApp(actualApp);
|
||||
appLaunched(appData);
|
||||
@@ -260,11 +279,20 @@ Item {
|
||||
appLaunched(appData);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
SessionService.launchDesktopEntry(actualApp);
|
||||
appLaunched(appData);
|
||||
AppUsageHistoryData.addAppUsage(actualApp);
|
||||
return;
|
||||
}
|
||||
|
||||
SessionService.launchDesktopEntry(actualApp);
|
||||
appLaunched(appData);
|
||||
AppUsageHistoryData.addAppUsage(actualApp);
|
||||
}
|
||||
|
||||
function reset() {
|
||||
suppressUpdatesWhileLaunching = false;
|
||||
searchQuery = "";
|
||||
selectedIndex = 0;
|
||||
setCategory(I18n.tr("All"));
|
||||
updateFilteredModel();
|
||||
}
|
||||
|
||||
function setCategory(category) {
|
||||
@@ -320,42 +348,50 @@ Item {
|
||||
onTriggered: updateFilteredModel()
|
||||
}
|
||||
|
||||
// Plugin trigger system functions
|
||||
function checkPluginTriggers(query) {
|
||||
if (!query || typeof PluginService === "undefined") {
|
||||
if (!query)
|
||||
return { triggered: false, pluginCategory: "", query: "" };
|
||||
|
||||
const builtInTriggers = AppSearchService.getBuiltInLauncherTriggers();
|
||||
for (const trigger in builtInTriggers) {
|
||||
if (!query.startsWith(trigger))
|
||||
continue;
|
||||
const pluginId = builtInTriggers[trigger];
|
||||
const plugin = AppSearchService.builtInPlugins[pluginId];
|
||||
if (!plugin)
|
||||
continue;
|
||||
return {
|
||||
triggered: false,
|
||||
pluginCategory: "",
|
||||
query: ""
|
||||
triggered: true,
|
||||
pluginId: pluginId,
|
||||
pluginCategory: plugin.name,
|
||||
query: query.substring(trigger.length).trim(),
|
||||
trigger: trigger,
|
||||
isBuiltIn: true
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof PluginService === "undefined")
|
||||
return { triggered: false, pluginCategory: "", query: "" };
|
||||
|
||||
const triggers = PluginService.getAllPluginTriggers();
|
||||
|
||||
for (const trigger in triggers) {
|
||||
if (query.startsWith(trigger)) {
|
||||
const pluginId = triggers[trigger];
|
||||
const plugin = PluginService.getLauncherPlugin(pluginId);
|
||||
|
||||
if (plugin) {
|
||||
const remainingQuery = query.substring(trigger.length).trim();
|
||||
const result = {
|
||||
triggered: true,
|
||||
pluginId: pluginId,
|
||||
pluginCategory: plugin.name || pluginId,
|
||||
query: remainingQuery,
|
||||
trigger: trigger
|
||||
};
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (!query.startsWith(trigger))
|
||||
continue;
|
||||
const pluginId = triggers[trigger];
|
||||
const plugin = PluginService.getLauncherPlugin(pluginId);
|
||||
if (!plugin)
|
||||
continue;
|
||||
return {
|
||||
triggered: true,
|
||||
pluginId: pluginId,
|
||||
pluginCategory: plugin.name || pluginId,
|
||||
query: query.substring(trigger.length).trim(),
|
||||
trigger: trigger,
|
||||
isBuiltIn: false
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
triggered: false,
|
||||
pluginCategory: "",
|
||||
query: ""
|
||||
};
|
||||
return { triggered: false, pluginCategory: "", query: "" };
|
||||
}
|
||||
|
||||
function getPluginIdForItem(item) {
|
||||
|
||||
@@ -378,6 +378,90 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
SettingsCard {
|
||||
id: builtInPluginsCard
|
||||
width: parent.width
|
||||
iconName: "extension"
|
||||
title: "DMS"
|
||||
settingKey: "builtInPlugins"
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingS
|
||||
|
||||
Repeater {
|
||||
model: ["dms_settings", "dms_notepad", "dms_sysmon", "dms_settings_search"]
|
||||
|
||||
delegate: Rectangle {
|
||||
id: pluginDelegate
|
||||
required property string modelData
|
||||
required property int index
|
||||
readonly property var plugin: AppSearchService.builtInPlugins[modelData]
|
||||
|
||||
width: parent.width
|
||||
height: 56
|
||||
radius: Theme.cornerRadius
|
||||
color: Qt.rgba(Theme.surfaceContainer.r, Theme.surfaceContainer.g, Theme.surfaceContainer.b, 0.3)
|
||||
|
||||
Row {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: Theme.spacingM
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingM
|
||||
|
||||
DankIcon {
|
||||
name: pluginDelegate.plugin?.cornerIcon ?? "extension"
|
||||
size: Theme.iconSize
|
||||
color: Theme.primary
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 2
|
||||
|
||||
StyledText {
|
||||
text: pluginDelegate.plugin?.name ?? pluginDelegate.modelData
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceText
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: pluginDelegate.plugin?.comment ?? ""
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: Theme.spacingM
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingM
|
||||
|
||||
DankTextField {
|
||||
id: triggerField
|
||||
width: 60
|
||||
visible: pluginDelegate.plugin?.isLauncher === true
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
placeholderText: I18n.tr("Trigger")
|
||||
onTextEdited: SettingsData.setBuiltInPluginSetting(pluginDelegate.modelData, "trigger", text)
|
||||
Component.onCompleted: text = SettingsData.getBuiltInPluginSetting(pluginDelegate.modelData, "trigger", pluginDelegate.plugin?.defaultTrigger ?? "")
|
||||
}
|
||||
|
||||
DankToggle {
|
||||
id: enableToggle
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
checked: SettingsData.getBuiltInPluginSetting(pluginDelegate.modelData, "enabled", true)
|
||||
onToggled: SettingsData.setBuiltInPluginSetting(pluginDelegate.modelData, "enabled", checked)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SettingsCard {
|
||||
id: recentAppsCard
|
||||
width: parent.width
|
||||
|
||||
@@ -42,64 +42,179 @@ Singleton {
|
||||
_cachedCategories = null;
|
||||
}
|
||||
|
||||
readonly property var coreApps: [
|
||||
{
|
||||
name: I18n.tr("DMS"),
|
||||
icon: "svg:../assets/danklogo2.svg",
|
||||
comment: I18n.tr("Settings"),
|
||||
action: "ipc:settings",
|
||||
categories: ["Settings", "System"],
|
||||
isCore: true
|
||||
},
|
||||
{
|
||||
name: I18n.tr("DMS"),
|
||||
icon: "material:description",
|
||||
comment: I18n.tr("Notepad"),
|
||||
action: "ipc:notepad",
|
||||
categories: ["Office", "Utility"],
|
||||
isCore: true
|
||||
},
|
||||
{
|
||||
name: I18n.tr("DMS"),
|
||||
icon: "material:monitor_heart",
|
||||
comment: I18n.tr("System Monitor"),
|
||||
action: "ipc:processlist",
|
||||
categories: ["System", "Monitor"],
|
||||
isCore: true
|
||||
readonly property string dmsLogoPath: Qt.resolvedUrl("../assets/danklogo2.svg")
|
||||
|
||||
readonly property var builtInPlugins: ({
|
||||
"dms_settings": {
|
||||
id: "dms_settings",
|
||||
name: I18n.tr("Settings", "settings window title"),
|
||||
icon: "svg+corner:" + dmsLogoPath + "|settings",
|
||||
cornerIcon: "settings",
|
||||
comment: "DMS",
|
||||
action: "ipc:settings",
|
||||
categories: ["Settings", "System"],
|
||||
defaultTrigger: "",
|
||||
isLauncher: false
|
||||
},
|
||||
"dms_notepad": {
|
||||
id: "dms_notepad",
|
||||
name: I18n.tr("Notepad", "Notepad"),
|
||||
icon: "svg+corner:" + dmsLogoPath + "|description",
|
||||
cornerIcon: "description",
|
||||
comment: "DMS",
|
||||
action: "ipc:notepad",
|
||||
categories: ["Office", "Utility"],
|
||||
defaultTrigger: "",
|
||||
isLauncher: false
|
||||
},
|
||||
"dms_sysmon": {
|
||||
id: "dms_sysmon",
|
||||
name: I18n.tr("System Monitor", "sysmon window title"),
|
||||
icon: "svg+corner:" + dmsLogoPath + "|monitor_heart",
|
||||
cornerIcon: "monitor_heart",
|
||||
comment: "DMS",
|
||||
action: "ipc:processlist",
|
||||
categories: ["System", "Monitor"],
|
||||
defaultTrigger: "",
|
||||
isLauncher: false
|
||||
},
|
||||
"dms_settings_search": {
|
||||
id: "dms_settings_search",
|
||||
name: I18n.tr("Settings", "settings window title"),
|
||||
cornerIcon: "search",
|
||||
comment: "DMS",
|
||||
defaultTrigger: "?",
|
||||
isLauncher: true
|
||||
}
|
||||
})
|
||||
|
||||
function getBuiltInPluginTrigger(pluginId) {
|
||||
const plugin = builtInPlugins[pluginId];
|
||||
if (!plugin)
|
||||
return null;
|
||||
return SettingsData.getBuiltInPluginSetting(pluginId, "trigger", plugin.defaultTrigger);
|
||||
}
|
||||
|
||||
readonly property var coreApps: {
|
||||
SettingsData.builtInPluginSettings;
|
||||
const apps = [];
|
||||
for (const pluginId in builtInPlugins) {
|
||||
if (!SettingsData.getBuiltInPluginSetting(pluginId, "enabled", true))
|
||||
continue;
|
||||
const plugin = builtInPlugins[pluginId];
|
||||
if (plugin.isLauncher)
|
||||
continue;
|
||||
apps.push({
|
||||
name: plugin.name,
|
||||
icon: plugin.icon,
|
||||
comment: plugin.comment,
|
||||
action: plugin.action,
|
||||
categories: plugin.categories,
|
||||
isCore: true,
|
||||
builtInPluginId: pluginId
|
||||
});
|
||||
}
|
||||
]
|
||||
return apps;
|
||||
}
|
||||
|
||||
function getBuiltInLauncherPlugins() {
|
||||
const result = {};
|
||||
for (const pluginId in builtInPlugins) {
|
||||
const plugin = builtInPlugins[pluginId];
|
||||
if (!plugin.isLauncher)
|
||||
continue;
|
||||
if (!SettingsData.getBuiltInPluginSetting(pluginId, "enabled", true))
|
||||
continue;
|
||||
result[pluginId] = plugin;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function getBuiltInLauncherTriggers() {
|
||||
const triggers = {};
|
||||
const launchers = getBuiltInLauncherPlugins();
|
||||
for (const pluginId in launchers) {
|
||||
const trigger = getBuiltInPluginTrigger(pluginId);
|
||||
if (trigger && trigger.trim() !== "")
|
||||
triggers[trigger] = pluginId;
|
||||
}
|
||||
return triggers;
|
||||
}
|
||||
|
||||
function getBuiltInLauncherPluginsWithEmptyTrigger() {
|
||||
const result = [];
|
||||
const launchers = getBuiltInLauncherPlugins();
|
||||
for (const pluginId in launchers) {
|
||||
const trigger = getBuiltInPluginTrigger(pluginId);
|
||||
if (!trigger || trigger.trim() === "")
|
||||
result.push(pluginId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function getBuiltInLauncherItems(pluginId, query) {
|
||||
if (pluginId !== "dms_settings_search")
|
||||
return [];
|
||||
|
||||
SettingsSearchService.search(query);
|
||||
const results = SettingsSearchService.results;
|
||||
const items = [];
|
||||
for (let i = 0; i < results.length; i++) {
|
||||
const r = results[i];
|
||||
items.push({
|
||||
name: r.label,
|
||||
icon: "material:" + r.icon,
|
||||
comment: r.category,
|
||||
action: "settings_nav:" + r.tabIndex + ":" + r.section,
|
||||
categories: ["Settings"],
|
||||
isCore: true,
|
||||
isBuiltInLauncher: true,
|
||||
builtInPluginId: pluginId
|
||||
});
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
function executeBuiltInLauncherItem(item) {
|
||||
if (!item?.action)
|
||||
return false;
|
||||
|
||||
const parts = item.action.split(":");
|
||||
if (parts[0] !== "settings_nav")
|
||||
return false;
|
||||
|
||||
const tabIndex = parseInt(parts[1]);
|
||||
const section = parts.slice(2).join(":");
|
||||
SettingsSearchService.navigateToSection(section);
|
||||
PopoutService.openSettingsWithTabIndex(tabIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
function getCoreApps(query) {
|
||||
if (!query || query.length === 0) {
|
||||
if (!query || query.length === 0)
|
||||
return coreApps;
|
||||
}
|
||||
|
||||
const lowerQuery = query.toLowerCase();
|
||||
return coreApps.filter(app => {
|
||||
return app.name.toLowerCase().includes(lowerQuery) || app.comment.toLowerCase().includes(lowerQuery);
|
||||
});
|
||||
return coreApps.filter(app => app.name.toLowerCase().includes(lowerQuery) || app.comment.toLowerCase().includes(lowerQuery));
|
||||
}
|
||||
|
||||
function executeCoreApp(app) {
|
||||
if (!app || !app.action) {
|
||||
if (!app?.action)
|
||||
return false;
|
||||
}
|
||||
|
||||
const actionParts = app.action.split(":");
|
||||
const actionType = actionParts[0];
|
||||
const actionTarget = actionParts[1];
|
||||
const parts = app.action.split(":");
|
||||
if (parts[0] !== "ipc")
|
||||
return false;
|
||||
|
||||
if (actionType === "ipc") {
|
||||
if (actionTarget === "settings") {
|
||||
PopoutService.focusOrToggleSettings();
|
||||
return true;
|
||||
} else if (actionTarget === "notepad") {
|
||||
PopoutService.toggleNotepad();
|
||||
return true;
|
||||
} else if (actionTarget === "processlist") {
|
||||
PopoutService.toggleProcessListModal();
|
||||
return true;
|
||||
}
|
||||
switch (parts[1]) {
|
||||
case "settings":
|
||||
PopoutService.focusOrToggleSettings();
|
||||
return true;
|
||||
case "notepad":
|
||||
PopoutService.openNotepad();
|
||||
return true;
|
||||
case "processlist":
|
||||
PopoutService.showProcessListModal();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -202,6 +202,7 @@ Singleton {
|
||||
property bool _settingsWantsToggle: false
|
||||
|
||||
property string _settingsPendingTab: ""
|
||||
property int _settingsPendingTabIndex: -1
|
||||
|
||||
function openSettings() {
|
||||
if (settingsModal) {
|
||||
@@ -226,6 +227,19 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
function openSettingsWithTabIndex(tabIndex: int) {
|
||||
if (settingsModal) {
|
||||
settingsModal.showWithTab(tabIndex);
|
||||
return;
|
||||
}
|
||||
if (settingsModalLoader) {
|
||||
_settingsPendingTabIndex = tabIndex;
|
||||
_settingsWantsOpen = true;
|
||||
_settingsWantsToggle = false;
|
||||
settingsModalLoader.activeAsync = true;
|
||||
}
|
||||
}
|
||||
|
||||
function closeSettings() {
|
||||
settingsModal?.close();
|
||||
}
|
||||
@@ -303,7 +317,10 @@ Singleton {
|
||||
function _onSettingsModalLoaded() {
|
||||
if (_settingsWantsOpen) {
|
||||
_settingsWantsOpen = false;
|
||||
if (_settingsPendingTab) {
|
||||
if (_settingsPendingTabIndex >= 0) {
|
||||
settingsModal?.showWithTab(_settingsPendingTabIndex);
|
||||
_settingsPendingTabIndex = -1;
|
||||
} else if (_settingsPendingTab) {
|
||||
settingsModal?.showWithTabName(_settingsPendingTab);
|
||||
_settingsPendingTab = "";
|
||||
} else {
|
||||
@@ -313,7 +330,10 @@ Singleton {
|
||||
}
|
||||
if (_settingsWantsToggle) {
|
||||
_settingsWantsToggle = false;
|
||||
if (_settingsPendingTab) {
|
||||
if (_settingsPendingTabIndex >= 0) {
|
||||
settingsModal.currentTabIndex = _settingsPendingTabIndex;
|
||||
_settingsPendingTabIndex = -1;
|
||||
} else if (_settingsPendingTab) {
|
||||
var idx = settingsModal?.resolveTabIndex(_settingsPendingTab) ?? -1;
|
||||
if (idx >= 0)
|
||||
settingsModal.currentTabIndex = idx;
|
||||
@@ -358,10 +378,12 @@ Singleton {
|
||||
}
|
||||
|
||||
function showProcessListModal() {
|
||||
if (processListModalLoader) {
|
||||
if (processListModal) {
|
||||
processListModal.show();
|
||||
} else if (processListModalLoader) {
|
||||
processListModalLoader.active = true;
|
||||
Qt.callLater(() => processListModal?.show());
|
||||
}
|
||||
processListModal?.show();
|
||||
}
|
||||
|
||||
function hideProcessListModal() {
|
||||
@@ -369,10 +391,12 @@ Singleton {
|
||||
}
|
||||
|
||||
function toggleProcessListModal() {
|
||||
if (processListModalLoader) {
|
||||
if (processListModal) {
|
||||
processListModal.toggle();
|
||||
} else if (processListModalLoader) {
|
||||
processListModalLoader.active = true;
|
||||
Qt.callLater(() => processListModal?.show());
|
||||
}
|
||||
processListModal?.toggle();
|
||||
}
|
||||
|
||||
function showColorPicker() {
|
||||
|
||||
@@ -24,13 +24,21 @@ Item {
|
||||
|
||||
readonly property bool isMaterial: iconValue.startsWith("material:")
|
||||
readonly property bool isUnicode: iconValue.startsWith("unicode:")
|
||||
readonly property bool isSvg: iconValue.startsWith("svg:")
|
||||
readonly property bool isSvgCorner: iconValue.startsWith("svg+corner:")
|
||||
readonly property bool isSvg: !isSvgCorner && iconValue.startsWith("svg:")
|
||||
readonly property string materialName: isMaterial ? iconValue.substring(9) : ""
|
||||
readonly property string unicodeChar: isUnicode ? iconValue.substring(8) : ""
|
||||
readonly property string svgPath: isSvg ? iconValue.substring(4) : ""
|
||||
readonly property bool isFileUrl: iconValue.startsWith("file://") || iconValue.startsWith("qrc:/")
|
||||
readonly property string iconPath: (isMaterial || isUnicode || isSvg || isFileUrl) ? "" : Quickshell.iconPath(iconValue, true) || DesktopService.resolveIconPath(iconValue)
|
||||
readonly property string resolvedIconPath: isSvg ? Qt.resolvedUrl(svgPath) : (isFileUrl ? iconValue : iconPath)
|
||||
readonly property string svgSource: {
|
||||
if (isSvgCorner) {
|
||||
const parts = iconValue.substring(11).split("|");
|
||||
return parts[0] || "";
|
||||
}
|
||||
if (isSvg)
|
||||
return iconValue.substring(4);
|
||||
return "";
|
||||
}
|
||||
readonly property string svgCornerIcon: isSvgCorner ? (iconValue.substring(11).split("|")[1] || "") : ""
|
||||
readonly property string iconPath: isMaterial || isUnicode || isSvg || isSvgCorner ? "" : Quickshell.iconPath(iconValue, true) || DesktopService.resolveIconPath(iconValue)
|
||||
|
||||
visible: iconValue !== undefined && iconValue !== ""
|
||||
|
||||
@@ -50,19 +58,12 @@ Item {
|
||||
visible: root.isUnicode
|
||||
}
|
||||
|
||||
Image {
|
||||
id: svgOrFileUrlImg
|
||||
|
||||
anchors.fill: parent
|
||||
source: root.resolvedIconPath
|
||||
sourceSize.width: root.iconSize * 2
|
||||
sourceSize.height: root.iconSize * 2
|
||||
smooth: true
|
||||
mipmap: true
|
||||
asynchronous: true
|
||||
cache: true
|
||||
fillMode: Image.PreserveAspectFit
|
||||
visible: (root.isSvg || root.isFileUrl) && status === Image.Ready
|
||||
DankSVGIcon {
|
||||
anchors.centerIn: parent
|
||||
source: root.svgSource
|
||||
size: root.iconSize
|
||||
cornerIcon: root.svgCornerIcon
|
||||
visible: root.isSvg || root.isSvgCorner
|
||||
}
|
||||
|
||||
IconImage {
|
||||
@@ -72,7 +73,7 @@ Item {
|
||||
source: root.iconPath
|
||||
smooth: true
|
||||
asynchronous: true
|
||||
visible: !root.isMaterial && !root.isUnicode && !root.isSvg && !root.isFileUrl && root.iconPath !== "" && status === Image.Ready
|
||||
visible: !root.isMaterial && !root.isUnicode && !root.isSvg && !root.isSvgCorner && root.iconPath !== "" && status === Image.Ready
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -83,7 +84,7 @@ Item {
|
||||
anchors.rightMargin: root.fallbackRightMargin
|
||||
anchors.topMargin: root.fallbackTopMargin
|
||||
anchors.bottomMargin: root.fallbackBottomMargin
|
||||
visible: !root.isMaterial && !root.isUnicode && !root.isSvg && !root.isFileUrl && (root.iconPath === "" || iconImg.status !== Image.Ready)
|
||||
visible: !root.isMaterial && !root.isUnicode && !root.isSvg && !root.isSvgCorner && (root.iconPath === "" || iconImg.status !== Image.Ready)
|
||||
color: root.fallbackBackgroundColor
|
||||
radius: Theme.cornerRadius
|
||||
border.width: 0
|
||||
|
||||
@@ -2,7 +2,6 @@ import QtQuick
|
||||
import QtQuick.Effects
|
||||
import Quickshell.Widgets
|
||||
import qs.Common
|
||||
import qs.Widgets
|
||||
|
||||
Item {
|
||||
id: root
|
||||
@@ -36,18 +35,17 @@ Item {
|
||||
implicitWidth: size
|
||||
implicitHeight: size
|
||||
|
||||
Image {
|
||||
IconImage {
|
||||
id: iconImage
|
||||
|
||||
anchors.fill: parent
|
||||
source: root.resolvedSource
|
||||
sourceSize.width: root.size * 2
|
||||
sourceSize.height: root.size * 2
|
||||
smooth: true
|
||||
mipmap: true
|
||||
asynchronous: true
|
||||
cache: true
|
||||
fillMode: Image.PreserveAspectFit
|
||||
implicitSize: root.size * 2
|
||||
backer.sourceSize.width: root.size * 2
|
||||
backer.sourceSize.height: root.size * 2
|
||||
backer.cache: true
|
||||
layer.enabled: root.hasColorEffect
|
||||
layer.smooth: true
|
||||
layer.mipmap: true
|
||||
|
||||
Reference in New Issue
Block a user