mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-26 14:32:52 -05:00
launcher: Dank Launcher V2 (beta)
- Aggregate plugins/extensions in new "all" tab - Quick tab actions - New tile mode for results - Plugins can enforce/require view mode, or set preferred default - Danksearch under "files" category
This commit is contained in:
@@ -13,6 +13,12 @@ Singleton {
|
||||
property var _cachedVisibleApps: null
|
||||
property var _hiddenAppsSet: new Set()
|
||||
|
||||
property var _transformCache: ({})
|
||||
property var _cachedDefaultSections: []
|
||||
property var _cachedDefaultFlatModel: []
|
||||
property bool _defaultCacheValid: false
|
||||
property int cacheVersion: 0
|
||||
|
||||
readonly property int maxResults: 10
|
||||
readonly property int frecencySampleSize: 10
|
||||
|
||||
@@ -43,6 +49,50 @@ Singleton {
|
||||
applications = DesktopEntries.applications.values;
|
||||
_cachedCategories = null;
|
||||
_cachedVisibleApps = null;
|
||||
invalidateLauncherCache();
|
||||
}
|
||||
|
||||
function invalidateLauncherCache() {
|
||||
_transformCache = {};
|
||||
_defaultCacheValid = false;
|
||||
_cachedDefaultSections = [];
|
||||
_cachedDefaultFlatModel = [];
|
||||
cacheVersion++;
|
||||
}
|
||||
|
||||
function getOrTransformApp(app, transformFn) {
|
||||
const id = app.id || app.execString || app.exec || "";
|
||||
if (!id)
|
||||
return transformFn(app);
|
||||
const cached = _transformCache[id];
|
||||
if (cached) {
|
||||
const currentIcon = app.icon || "";
|
||||
const cachedSourceIcon = cached._sourceIcon || "";
|
||||
if (currentIcon === cachedSourceIcon)
|
||||
return cached;
|
||||
}
|
||||
const transformed = transformFn(app);
|
||||
transformed._sourceIcon = app.icon || "";
|
||||
_transformCache[id] = transformed;
|
||||
return transformed;
|
||||
}
|
||||
|
||||
function getCachedDefaultSections() {
|
||||
if (!_defaultCacheValid)
|
||||
return null;
|
||||
return _cachedDefaultSections;
|
||||
}
|
||||
|
||||
function setCachedDefaultSections(sections, flatModel) {
|
||||
_cachedDefaultSections = sections.map(function (s) {
|
||||
return Object.assign({}, s);
|
||||
});
|
||||
_cachedDefaultFlatModel = flatModel.slice();
|
||||
_defaultCacheValid = true;
|
||||
}
|
||||
|
||||
function isCacheValid() {
|
||||
return _defaultCacheValid;
|
||||
}
|
||||
|
||||
function _rebuildHiddenSet() {
|
||||
@@ -68,9 +118,18 @@ Singleton {
|
||||
target: SessionData
|
||||
function onHiddenAppsChanged() {
|
||||
root._rebuildHiddenSet();
|
||||
root.invalidateLauncherCache();
|
||||
}
|
||||
function onAppOverridesChanged() {
|
||||
root._cachedVisibleApps = null;
|
||||
root.invalidateLauncherCache();
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: AppUsageHistoryData
|
||||
function onAppUsageRankingChanged() {
|
||||
root.invalidateLauncherCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -293,7 +293,6 @@ Singleton {
|
||||
pluginDaemonComponents = newDaemons;
|
||||
} else if (isLauncher) {
|
||||
const instance = comp.createObject(root, {
|
||||
"pluginId": pluginId,
|
||||
"pluginService": root
|
||||
});
|
||||
if (!instance) {
|
||||
@@ -702,6 +701,17 @@ Singleton {
|
||||
return plugins;
|
||||
}
|
||||
|
||||
function getPluginViewPreference(pluginId) {
|
||||
const plugin = availablePlugins[pluginId];
|
||||
if (!plugin)
|
||||
return null;
|
||||
|
||||
return {
|
||||
mode: plugin.viewMode || null,
|
||||
enforced: plugin.viewModeEnforced === true
|
||||
};
|
||||
}
|
||||
|
||||
function getGlobalVar(pluginId, varName, defaultValue) {
|
||||
if (globalVars[pluginId] && varName in globalVars[pluginId]) {
|
||||
return globalVars[pluginId][varName];
|
||||
|
||||
@@ -21,6 +21,8 @@ Singleton {
|
||||
property var settingsModalLoader: null
|
||||
property var clipboardHistoryModal: null
|
||||
property var spotlightModal: null
|
||||
property var spotlightV2Modal: null
|
||||
property var spotlightV2ModalLoader: null
|
||||
property var powerMenuModal: null
|
||||
property var processListModal: null
|
||||
property var processListModalLoader: null
|
||||
@@ -361,6 +363,62 @@ Singleton {
|
||||
spotlightModal?.close();
|
||||
}
|
||||
|
||||
property bool _spotlightV2WantsOpen: false
|
||||
property bool _spotlightV2WantsToggle: false
|
||||
property string _spotlightV2PendingQuery: ""
|
||||
|
||||
function openSpotlightV2() {
|
||||
if (spotlightV2Modal) {
|
||||
spotlightV2Modal.show();
|
||||
} else if (spotlightV2ModalLoader) {
|
||||
_spotlightV2WantsOpen = true;
|
||||
_spotlightV2WantsToggle = false;
|
||||
spotlightV2ModalLoader.active = true;
|
||||
}
|
||||
}
|
||||
|
||||
function openSpotlightV2WithQuery(query: string) {
|
||||
if (spotlightV2Modal) {
|
||||
spotlightV2Modal.showWithQuery(query);
|
||||
} else if (spotlightV2ModalLoader) {
|
||||
_spotlightV2PendingQuery = query;
|
||||
_spotlightV2WantsOpen = true;
|
||||
_spotlightV2WantsToggle = false;
|
||||
spotlightV2ModalLoader.active = true;
|
||||
}
|
||||
}
|
||||
|
||||
function closeSpotlightV2() {
|
||||
spotlightV2Modal?.hide();
|
||||
}
|
||||
|
||||
function toggleSpotlightV2() {
|
||||
if (spotlightV2Modal) {
|
||||
spotlightV2Modal.toggle();
|
||||
} else if (spotlightV2ModalLoader) {
|
||||
_spotlightV2WantsToggle = true;
|
||||
_spotlightV2WantsOpen = false;
|
||||
spotlightV2ModalLoader.active = true;
|
||||
}
|
||||
}
|
||||
|
||||
function _onSpotlightV2ModalLoaded() {
|
||||
if (_spotlightV2WantsOpen) {
|
||||
_spotlightV2WantsOpen = false;
|
||||
if (_spotlightV2PendingQuery) {
|
||||
spotlightV2Modal?.showWithQuery(_spotlightV2PendingQuery);
|
||||
_spotlightV2PendingQuery = "";
|
||||
} else {
|
||||
spotlightV2Modal?.show();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (_spotlightV2WantsToggle) {
|
||||
_spotlightV2WantsToggle = false;
|
||||
spotlightV2Modal?.toggle();
|
||||
}
|
||||
}
|
||||
|
||||
function openPowerMenu() {
|
||||
powerMenuModal?.openCentered();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user