mirror of
https://gitgud.io/wackyideas/aerothemeplasma.git
synced 2026-10-21 06:14:23 +00:00
Compare commits
3 commits
6df7e92b6b
...
d7bf692ba1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7bf692ba1 | ||
|
|
ed0037c751 | ||
|
|
458449b1c9 |
4 changed files with 93 additions and 6 deletions
|
|
@ -77,14 +77,27 @@ Item {
|
||||||
baseView.currentIndex = -1;
|
baseView.currentIndex = -1;
|
||||||
}
|
}
|
||||||
Connections {
|
Connections {
|
||||||
target: kicker
|
target: Plasmoid
|
||||||
|
|
||||||
function onExpandedChanged() {
|
function onExpandedChanged() {
|
||||||
if (!kicker.expanded) {
|
if (!Plasmoid.expanded) {
|
||||||
baseView.currentIndex = -1;
|
baseView.currentIndex = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* The KSortFilterProxyModel has a nasty behavior (with this particular
|
||||||
|
* source model) where only the first row will be updated (twice instantly),
|
||||||
|
* which invalidates the index list. In that case, we want a full update
|
||||||
|
* instead of a partial update, so the filtering can update the index map.
|
||||||
|
*/
|
||||||
|
Timer {
|
||||||
|
id: refreshTimer
|
||||||
|
interval: 50
|
||||||
|
onTriggered: {
|
||||||
|
Qt.callLater(() => { recentUsageModel.refresh()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
KickoffListView {
|
KickoffListView {
|
||||||
id: baseView
|
id: baseView
|
||||||
|
|
@ -96,25 +109,43 @@ Item {
|
||||||
interactive: contentHeight > height
|
interactive: contentHeight > height
|
||||||
//model: recentUsageModel //rootModel.modelForRow(0)
|
//model: recentUsageModel //rootModel.modelForRow(0)
|
||||||
model: KItemModels.KSortFilterProxyModel {
|
model: KItemModels.KSortFilterProxyModel {
|
||||||
|
id: sortModel
|
||||||
sourceModel: recentUsageModel
|
sourceModel: recentUsageModel
|
||||||
property var favoritesModel: globalFavorites
|
property var favoritesModel: globalFavorites
|
||||||
property int favoritesCount: sourceModel.favoritesModel.count
|
property int favoritesCount: sourceModel.favoritesModel.count
|
||||||
property int favoritesFound: 0
|
property int favoritesFound: 0
|
||||||
|
/*
|
||||||
|
* Because the trigger function relies on the original model's
|
||||||
|
* index values, we need a way to map the index values from the filtered
|
||||||
|
* model to the values from the source model.
|
||||||
|
*/
|
||||||
|
property list<int> originalIndexList
|
||||||
onFavoritesCountChanged: Qt.callLater(() => { sourceModel.refresh()});
|
onFavoritesCountChanged: Qt.callLater(() => { sourceModel.refresh()});
|
||||||
onCountChanged: Qt.callLater(() => {
|
onCountChanged: Qt.callLater(() => {
|
||||||
if(count > Plasmoid.configuration.numberRows) sourceModel.refresh();
|
if(count > Plasmoid.configuration.numberRows) sourceModel.refresh();
|
||||||
})
|
})
|
||||||
function trigger(index, str, ptr) {
|
function trigger(index, str, ptr) {
|
||||||
sourceModel.trigger(index, str, ptr);
|
if(typeof originalIndexList[index] !== "undefined") {
|
||||||
|
sourceModel.trigger(originalIndexList[index], str, ptr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
filterRowCallback: function(source_row, source_parent) {
|
filterRowCallback: function(source_row, source_parent) {
|
||||||
if(source_row == 0) favoritesFound = 0;
|
if(source_row == 0) {
|
||||||
|
refreshTimer.start();
|
||||||
|
originalIndexList.length = 0;
|
||||||
|
favoritesFound = 0;
|
||||||
|
} else {
|
||||||
|
refreshTimer.stop();
|
||||||
|
}
|
||||||
const FavoriteIdRole = sourceModel.KItemModels.KRoleNames.role("favoriteId");
|
const FavoriteIdRole = sourceModel.KItemModels.KRoleNames.role("favoriteId");
|
||||||
const favoriteId = sourceModel.data(sourceModel.index(source_row, 0, source_parent), FavoriteIdRole);
|
const favoriteId = sourceModel.data(sourceModel.index(source_row, 0, source_parent), FavoriteIdRole);
|
||||||
var hasFavorite = favoritesIds.idList.indexOf(favoriteId) === -1
|
var hasFavorite = favoritesIds.idList.indexOf(favoriteId) === -1
|
||||||
if(!hasFavorite) favoritesFound++;
|
if(!hasFavorite) favoritesFound++;
|
||||||
|
var shouldAccept = hasFavorite && source_row < (Plasmoid.configuration.numberRows+favoritesFound);
|
||||||
return hasFavorite && source_row < (Plasmoid.configuration.numberRows+favoritesFound)// - sourceModel.favoritesModel.count;
|
if(shouldAccept) {
|
||||||
|
originalIndexList.push(source_row);
|
||||||
|
}
|
||||||
|
return shouldAccept;// - sourceModel.favoritesModel.count;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,10 @@
|
||||||
<label>Use drop shadows for icons on the desktop.</label>
|
<label>Use drop shadows for icons on the desktop.</label>
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
</entry>
|
</entry>
|
||||||
|
<entry name="useTypeAhead" type="Bool">
|
||||||
|
<label>Select icons on the desktop by typing their names.</label>
|
||||||
|
<default>true</default>
|
||||||
|
</entry>
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<group name="Watermark">
|
<group name="Watermark">
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ Item {
|
||||||
property alias cfg_iconShadows: iconShadows.checked
|
property alias cfg_iconShadows: iconShadows.checked
|
||||||
|
|
||||||
property alias cfg_selectionStyle: selectionStyle.currentIndex
|
property alias cfg_selectionStyle: selectionStyle.currentIndex
|
||||||
|
property alias cfg_useTypeAhead: typeAhead.checked
|
||||||
|
|
||||||
|
|
||||||
readonly property bool lockedByKiosk: !KAuthorized.authorize("editable_desktop_icons")
|
readonly property bool lockedByKiosk: !KAuthorized.authorize("editable_desktop_icons")
|
||||||
|
|
@ -314,6 +315,7 @@ Item {
|
||||||
text: i18n("Show selection markers")
|
text: i18n("Show selection markers")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: popups
|
id: popups
|
||||||
visible: !isPopup
|
visible: !isPopup
|
||||||
|
|
@ -361,6 +363,11 @@ Item {
|
||||||
i18nc("@item:inlistbox how the selection should be", "Classic"),
|
i18nc("@item:inlistbox how the selection should be", "Classic"),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
CheckBox {
|
||||||
|
id: typeAhead
|
||||||
|
text: i18n("Select items by typing on the desktop")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
CheckBox {
|
CheckBox {
|
||||||
id: previews
|
id: previews
|
||||||
|
|
|
||||||
|
|
@ -1017,6 +1017,12 @@ FocusScope {
|
||||||
Behavior on contentX { id: smoothX; enabled: false; SmoothedAnimation { velocity: 700 } }
|
Behavior on contentX { id: smoothX; enabled: false; SmoothedAnimation { velocity: 700 } }
|
||||||
Behavior on contentY { id: smoothY; enabled: false; SmoothedAnimation { velocity: 700 } }
|
Behavior on contentY { id: smoothY; enabled: false; SmoothedAnimation { velocity: 700 } }
|
||||||
|
|
||||||
|
property string searchString: ""
|
||||||
|
Timer {
|
||||||
|
id: typeAheadTimer
|
||||||
|
interval: 500 // Resets search string after 0.5 seconds of inactivity
|
||||||
|
onTriggered: searchString = ""
|
||||||
|
}
|
||||||
Keys.onReturnPressed: event => {
|
Keys.onReturnPressed: event => {
|
||||||
if (event.modifiers === Qt.AltModifier) {
|
if (event.modifiers === Qt.AltModifier) {
|
||||||
dir.openPropertiesDialog();
|
dir.openPropertiesDialog();
|
||||||
|
|
@ -1099,6 +1105,40 @@ FocusScope {
|
||||||
dir.refresh(true);
|
dir.refresh(true);
|
||||||
} else if (event.matches(StandardKey.SelectAll)) {
|
} else if (event.matches(StandardKey.SelectAll)) {
|
||||||
positioner.setRangeSelected(0, count - 1);
|
positioner.setRangeSelected(0, count - 1);
|
||||||
|
} else if ( (root.isPopup || Plasmoid.configuration.useTypeAhead) && event.text.length === 1 && event.modifiers === Qt.NoModifier) {
|
||||||
|
typeAheadTimer.restart();
|
||||||
|
const charPressed = event.text.toLowerCase();
|
||||||
|
|
||||||
|
if (searchString.length >= 1 && searchString.indexOf(charPressed) !== 0) {
|
||||||
|
searchString += charPressed;
|
||||||
|
} else if (searchString !== charPressed) {
|
||||||
|
searchString = charPressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
let matches = [];
|
||||||
|
for (let i = 0; i < gridView.count; i++) {
|
||||||
|
const itemData = positioner.data(positioner.index(i, 0), Qt.DisplayRole);
|
||||||
|
if (itemData && itemData.toLowerCase().indexOf(searchString) === 0) {
|
||||||
|
matches.push(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matches.length > 0) {
|
||||||
|
let nextIdx = matches[0];
|
||||||
|
if (searchString.length === 1) {
|
||||||
|
for (let j = 0; j < matches.length; j++) {
|
||||||
|
if (matches[j] > gridView.currentIndex) {
|
||||||
|
nextIdx = matches[j];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currentIndex = nextIdx;
|
||||||
|
dir.clearSelection();
|
||||||
|
dir.setSelected(positioner.map(nextIdx));
|
||||||
|
} else {
|
||||||
|
searchString = charPressed;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
event.accepted = false;
|
event.accepted = false;
|
||||||
}
|
}
|
||||||
|
|
@ -1269,6 +1309,11 @@ FocusScope {
|
||||||
previewPlugins: Plasmoid.configuration.previewPlugins
|
previewPlugins: Plasmoid.configuration.previewPlugins
|
||||||
applet: Plasmoid
|
applet: Plasmoid
|
||||||
|
|
||||||
|
onSelectionChanged: {
|
||||||
|
if(gridView.currentIndex === -1) {
|
||||||
|
gridView.searchString = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
onListingCompleted: {
|
onListingCompleted: {
|
||||||
if (!gridView.model && root.expanded) {
|
if (!gridView.model && root.expanded) {
|
||||||
gridView.model = positioner;
|
gridView.model = positioner;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue