1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

launcher v2: retire spotlight launcher in favor of dank launcher

This commit is contained in:
bbedward
2026-01-21 21:34:31 -05:00
parent 6735989455
commit b140afca8e
27 changed files with 311 additions and 4306 deletions

View File

@@ -24,8 +24,9 @@ Item {
property bool keyboardNavigationActive: false
property var sectionViewModes: ({})
property var pluginViewPreferences: ({})
property int gridColumns: 4
property int gridColumns: SettingsData.appLauncherGridColumns
property int viewModeVersion: 0
property string viewModeContext: "spotlight"
signal itemExecuted
signal searchCompleted
@@ -96,7 +97,9 @@ Item {
if (sectionViewModes[sectionId])
return sectionViewModes[sectionId];
var savedModes = SettingsData.spotlightSectionViewModes || {};
var savedModes = viewModeContext === "appDrawer"
? (SettingsData.appDrawerSectionViewModes || {})
: (SettingsData.spotlightSectionViewModes || {});
if (savedModes[sectionId])
return savedModes[sectionId];
@@ -116,10 +119,17 @@ Item {
[sectionId]: mode
});
viewModeVersion++;
var savedModes = Object.assign({}, SettingsData.spotlightSectionViewModes || {}, {
[sectionId]: mode
});
SettingsData.spotlightSectionViewModes = savedModes;
if (viewModeContext === "appDrawer") {
var savedModes = Object.assign({}, SettingsData.appDrawerSectionViewModes || {}, {
[sectionId]: mode
});
SettingsData.appDrawerSectionViewModes = savedModes;
} else {
var savedModes = Object.assign({}, SettingsData.spotlightSectionViewModes || {}, {
[sectionId]: mode
});
SettingsData.spotlightSectionViewModes = savedModes;
}
viewModeChanged(sectionId, mode);
}
@@ -273,10 +283,11 @@ Item {
activePluginName = "";
clearActivePluginViewPreference();
sections = cachedSections.map(function (s) {
var copy = Object.assign({}, s);
if (collapsedSections[s.id] !== undefined) {
var copy = Object.assign({}, s, {
items: s.items ? s.items.slice() : []
});
if (collapsedSections[s.id] !== undefined)
copy.collapsed = collapsedSections[s.id];
}
return copy;
});
flatModel = Scorer.flattenSections(sections);
@@ -344,6 +355,27 @@ Item {
}
if (searchMode === "apps") {
var cachedSections = AppSearchService.getCachedDefaultSections();
if (cachedSections && !searchQuery) {
var appSectionIds = ["favorites", "apps"];
sections = cachedSections.filter(function (s) {
return appSectionIds.indexOf(s.id) !== -1;
}).map(function (s) {
var copy = Object.assign({}, s, {
items: s.items ? s.items.slice() : []
});
if (collapsedSections[s.id] !== undefined)
copy.collapsed = collapsedSections[s.id];
return copy;
});
flatModel = Scorer.flattenSections(sections);
selectedFlatIndex = getFirstItemIndex();
updateSelectedItem();
isSearching = false;
searchCompleted();
return;
}
var apps = searchApps(searchQuery);
for (var i = 0; i < apps.length; i++) {
allItems.push(apps[i]);

View File

@@ -12,6 +12,7 @@ FocusScope {
LayoutMirroring.childrenInherit: true
property var parentModal: null
property string viewModeContext: "spotlight"
property alias searchField: searchField
property alias controller: controller
property alias resultsList: resultsList
@@ -87,6 +88,7 @@ FocusScope {
Controller {
id: controller
viewModeContext: root.viewModeContext
onItemExecuted: {
if (root.parentModal) {

View File

@@ -59,7 +59,7 @@ Item {
itemHeight = 52;
} else {
var cols = controller.getGridColumns(sectionId);
var cellWidth = mode === "tile" ? Math.floor(mainFlickable.width / 3) : Math.floor((mainFlickable.width - (root.gridColumns - 1) * 4) / root.gridColumns);
var cellWidth = mode === "tile" ? Math.floor(mainFlickable.width / 3) : Math.floor(mainFlickable.width / root.gridColumns);
var cellHeight = mode === "tile" ? cellWidth * 0.75 : cellWidth + 24;
var row = Math.floor(itemInSection / cols);
itemY = row * cellHeight;
@@ -88,7 +88,7 @@ Item {
} else {
var cols = controller?.getGridColumns(section.id) ?? root.gridColumns;
var rows = Math.ceil((section.items?.length ?? 0) / cols);
var cellWidth = mode === "tile" ? Math.floor(root.width / 3) : Math.floor((root.width - (cols - 1) * 4) / cols);
var cellWidth = mode === "tile" ? Math.floor(root.width / 3) : Math.floor(root.width / cols);
var cellHeight = mode === "tile" ? cellWidth * 0.75 : cellWidth + 24;
return 32 + rows * cellHeight;
}
@@ -129,7 +129,7 @@ Item {
itemH = 52;
} else {
var cols = controller.getGridColumns(entry.sectionId);
var cellWidth = mode === "tile" ? Math.floor(width / 3) : Math.floor((width - (cols - 1) * 4) / cols);
var cellWidth = mode === "tile" ? Math.floor(width / 3) : Math.floor(width / cols);
var cellHeight = mode === "tile" ? cellWidth * 0.75 : cellWidth + 24;
var row = Math.floor(itemInSection / cols);
var col = itemInSection % cols;
@@ -245,7 +245,7 @@ Item {
visible: sectionDelegate.isGridMode && !sectionDelegate.isCollapsed
columns: sectionDelegate.currentViewMode === "tile" ? 3 : root.gridColumns
readonly property real cellWidth: sectionDelegate.currentViewMode === "tile" ? Math.floor(width / 3) : Math.floor((width - (root.gridColumns - 1) * 4) / root.gridColumns)
readonly property real cellWidth: sectionDelegate.currentViewMode === "tile" ? Math.floor(width / 3) : Math.floor(width / root.gridColumns)
readonly property real cellHeight: sectionDelegate.currentViewMode === "tile" ? cellWidth * 0.75 : cellWidth + 24
Repeater {

View File

@@ -95,7 +95,7 @@ Item {
required property var modelData
required property int index
width: Math.floor((contentLoader.width - (root.gridColumns - 1) * 4) / root.gridColumns)
width: Math.floor(contentLoader.width / root.gridColumns)
height: width + 24
item: modelData
isSelected: (root.startIndex + index) === root.controller?.selectedFlatIndex