mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-16 16:24:00 -04:00
fix(clipboard): multi-second tab switch bind & stale pinned count
- qml common fix & update
This commit is contained in:
+1
-1
Submodule dank-qml-common updated: 50ca5ccb49...0e6a5162d3
Generated
+3
-3
@@ -3,11 +3,11 @@
|
||||
"dank-qml-common": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1791670308,
|
||||
"narHash": "sha256-vcAOSK+6buTddG8sJi8JOnaFfxSztmL8nOzsnUTzGd0=",
|
||||
"lastModified": 1791704080,
|
||||
"narHash": "sha256-zcbXHrade9CzEgLU1Alc5sCjUPv+m5GLSYtAurU+WV8=",
|
||||
"owner": "AvengeMedia",
|
||||
"repo": "dank-qml-common",
|
||||
"rev": "50ca5ccb4913098b0b67807d9ff7f642e79067b0",
|
||||
"rev": "0e6a5162d34abaae4542e83b0751318990a75fe0",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -92,6 +92,18 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
ScriptModel {
|
||||
id: savedModel
|
||||
values: clipboardContent.modal.pinnedEntries
|
||||
objectProp: "id"
|
||||
}
|
||||
|
||||
ScriptModel {
|
||||
id: recentsModel
|
||||
values: clipboardContent.modal.unpinnedEntries
|
||||
objectProp: "id"
|
||||
}
|
||||
|
||||
ClipboardContextMenu {
|
||||
id: contextMenu
|
||||
modal: clipboardContent.modal
|
||||
@@ -223,10 +235,8 @@ Item {
|
||||
reuseItems: true
|
||||
highlightSelection: clipboardContent.modal.keyboardNavigationActive && clipboardContent.modal.selectedIndex >= 0
|
||||
anchors.fill: parent
|
||||
model: ScriptModel {
|
||||
values: clipboardContent.entries
|
||||
objectProp: "id"
|
||||
}
|
||||
// one model per tab; a shared model diffs the whole list on every tab switch
|
||||
model: clipboardContent.modal.activeTab === "saved" ? savedModel : recentsModel
|
||||
|
||||
currentIndex: clipboardContent.modal ? clipboardContent.modal.selectedIndex : 0
|
||||
spacing: Theme.groupedListGap
|
||||
|
||||
@@ -87,6 +87,7 @@ DModal {
|
||||
|
||||
Ref {
|
||||
service: ClipboardService
|
||||
active: clipboardHistoryModal.shouldBeVisible
|
||||
}
|
||||
|
||||
ConfirmModal {
|
||||
|
||||
@@ -98,6 +98,7 @@ DPopout {
|
||||
|
||||
Ref {
|
||||
service: ClipboardService
|
||||
active: root.shouldBeVisible
|
||||
}
|
||||
|
||||
ConfirmModal {
|
||||
|
||||
@@ -56,31 +56,17 @@ Singleton {
|
||||
|
||||
Connections {
|
||||
target: DMSService
|
||||
enabled: root.refCount > 0
|
||||
function onIsConnectedChanged() {
|
||||
root.refreshPasteSupport();
|
||||
}
|
||||
}
|
||||
|
||||
onRefCountChanged: {
|
||||
if (refCount > 0) {
|
||||
ensureSubscription();
|
||||
} else if (refCount === 0 && DMSService.activeSubscriptions.includes("clipboard")) {
|
||||
DMSService.removeSubscription("clipboard");
|
||||
}
|
||||
}
|
||||
// subscribed for the shell's lifetime; resubscribing replays every service's snapshot
|
||||
Component.onCompleted: DMSService.addSubscription("clipboard")
|
||||
|
||||
function ensureSubscription() {
|
||||
if (refCount <= 0)
|
||||
return;
|
||||
if (!_pasteSupportChecked)
|
||||
onRefCountChanged: {
|
||||
if (refCount > 0 && !_pasteSupportChecked)
|
||||
refreshPasteSupport();
|
||||
if (DMSService.activeSubscriptions.includes("clipboard"))
|
||||
return;
|
||||
if (DMSService.activeSubscriptions.includes("all"))
|
||||
return;
|
||||
DMSService.addSubscription("clipboard");
|
||||
refresh();
|
||||
}
|
||||
|
||||
function refreshPasteSupport() {
|
||||
@@ -163,13 +149,16 @@ Singleton {
|
||||
log.warn("Failed to get history:", response.error);
|
||||
return;
|
||||
}
|
||||
internalEntries = response.result || [];
|
||||
pinnedEntries = internalEntries.filter(e => e.pinned);
|
||||
pinnedCount = pinnedEntries.length;
|
||||
updateFilteredModel();
|
||||
applyHistory(response.result || []);
|
||||
});
|
||||
}
|
||||
|
||||
function applyHistory(history) {
|
||||
internalEntries = history;
|
||||
pinnedCount = history.filter(e => e.pinned).length;
|
||||
updateFilteredModel();
|
||||
}
|
||||
|
||||
function requestLauncherSearch(query, limit) {
|
||||
if (!clipboardAvailable) {
|
||||
return;
|
||||
@@ -333,28 +322,16 @@ Singleton {
|
||||
}
|
||||
|
||||
function pinEntry(entry) {
|
||||
DMSService.sendRequest("clipboard.getPinnedCount", null, function (countResponse) {
|
||||
if (countResponse.error) {
|
||||
ToastService.showError(I18n.tr("Failed to check pin limit"));
|
||||
DMSService.sendRequest("clipboard.pinEntry", {
|
||||
"id": entry.id
|
||||
}, function (response) {
|
||||
if (response.error) {
|
||||
// error text from core/internal/server/clipboard
|
||||
const limit = /^maximum pinned entries reached \((\d+)\)/.exec(response.error);
|
||||
ToastService.showError(limit ? I18n.tr("Maximum pinned entries reached") + " (" + limit[1] + ")" : I18n.tr("Failed to pin entry"));
|
||||
return;
|
||||
}
|
||||
|
||||
const maxPinned = 25;
|
||||
if (countResponse.result.count >= maxPinned) {
|
||||
ToastService.showError(I18n.tr("Maximum pinned entries reached") + " (" + maxPinned + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
DMSService.sendRequest("clipboard.pinEntry", {
|
||||
"id": entry.id
|
||||
}, function (response) {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Failed to pin entry"));
|
||||
return;
|
||||
}
|
||||
ToastService.showInfo(I18n.tr("Entry pinned"));
|
||||
refresh();
|
||||
});
|
||||
ToastService.showInfo(I18n.tr("Entry pinned"));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -367,7 +344,6 @@ Singleton {
|
||||
return;
|
||||
}
|
||||
ToastService.showInfo(I18n.tr("Entry unpinned"));
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -492,15 +468,16 @@ Singleton {
|
||||
refresh();
|
||||
}
|
||||
|
||||
// only pinnedCount is tracked while no surface is open; the bar menu reads it, surfaces refresh on open
|
||||
Connections {
|
||||
target: DMSService
|
||||
enabled: root.refCount > 0
|
||||
function onClipboardStateUpdate(data) {
|
||||
const newHistory = data.history || [];
|
||||
internalEntries = newHistory;
|
||||
pinnedEntries = newHistory.filter(e => e.pinned);
|
||||
pinnedCount = pinnedEntries.length;
|
||||
updateFilteredModel();
|
||||
const history = data.history || [];
|
||||
if (root.refCount > 0) {
|
||||
root.applyHistory(history);
|
||||
return;
|
||||
}
|
||||
root.pinnedCount = history.filter(e => e.pinned).length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user