mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-13 14:36:32 -04:00
Fix/clipboard pinned recents dedupe (#2605)
* fix(clipboard): unpin pinned duplicates from history entries * fix(clipboard): dedupe recents when using pinned entries
This commit is contained in:
@@ -149,8 +149,8 @@ Item {
|
||||
listView: clipboardListView
|
||||
onCopyRequested: clipboardContent.modal.copyEntry(modelData)
|
||||
onDeleteRequested: clipboardContent.modal.deleteEntry(modelData)
|
||||
onPinRequested: clipboardContent.modal.pinEntry(modelData)
|
||||
onUnpinRequested: clipboardContent.modal.unpinEntry(modelData)
|
||||
onPinRequested: targetEntry => clipboardContent.modal.pinEntry(targetEntry)
|
||||
onUnpinRequested: targetEntry => clipboardContent.modal.unpinEntry(targetEntry)
|
||||
onEditRequested: clipboardContent.modal.editEntry(modelData)
|
||||
}
|
||||
}
|
||||
@@ -223,8 +223,8 @@ Item {
|
||||
listView: savedListView
|
||||
onCopyRequested: clipboardContent.modal.copyEntry(modelData)
|
||||
onDeleteRequested: clipboardContent.modal.deletePinnedEntry(modelData)
|
||||
onPinRequested: clipboardContent.modal.pinEntry(modelData)
|
||||
onUnpinRequested: clipboardContent.modal.unpinEntry(modelData)
|
||||
onPinRequested: targetEntry => clipboardContent.modal.pinEntry(targetEntry)
|
||||
onUnpinRequested: targetEntry => clipboardContent.modal.unpinEntry(targetEntry)
|
||||
onEditRequested: clipboardContent.modal.editEntry(modelData)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,14 @@ Rectangle {
|
||||
|
||||
signal copyRequested
|
||||
signal deleteRequested
|
||||
signal pinRequested
|
||||
signal unpinRequested
|
||||
signal pinRequested(var targetEntry)
|
||||
signal unpinRequested(var targetEntry)
|
||||
signal editRequested
|
||||
|
||||
readonly property string entryType: modal ? modal.getEntryType(entry) : "text"
|
||||
readonly property string entryPreview: modal ? modal.getEntryPreview(entry) : ""
|
||||
readonly property bool hasPinnedDuplicate: !entry.pinned && ClipboardService.hashedPinnedEntry(entry.hash)
|
||||
readonly property var pinnedDuplicateEntry: !entry.pinned ? ClipboardService.getPinnedEntryByHash(entry.hash) : null
|
||||
readonly property bool effectivePinned: entry.pinned || pinnedDuplicateEntry !== null
|
||||
|
||||
radius: Theme.cornerRadius
|
||||
color: {
|
||||
@@ -66,9 +67,19 @@ Rectangle {
|
||||
DankActionButton {
|
||||
iconName: "push_pin"
|
||||
iconSize: Theme.iconSize - 6
|
||||
iconColor: (entry.pinned || hasPinnedDuplicate) ? Theme.primary : Theme.surfaceText
|
||||
backgroundColor: (entry.pinned || hasPinnedDuplicate) ? Theme.primarySelected : "transparent"
|
||||
onClicked: entry.pinned ? unpinRequested() : pinRequested()
|
||||
iconColor: effectivePinned ? Theme.primary : Theme.surfaceText
|
||||
backgroundColor: effectivePinned ? Theme.primarySelected : "transparent"
|
||||
onClicked: {
|
||||
if (entry.pinned) {
|
||||
unpinRequested(entry);
|
||||
return;
|
||||
}
|
||||
if (pinnedDuplicateEntry) {
|
||||
unpinRequested(pinnedDuplicateEntry);
|
||||
return;
|
||||
}
|
||||
pinRequested(entry);
|
||||
}
|
||||
}
|
||||
|
||||
DankActionButton {
|
||||
|
||||
@@ -59,8 +59,13 @@ QtObject {
|
||||
return;
|
||||
}
|
||||
const selectedEntry = entries[ClipboardService.selectedIndex];
|
||||
if (modal.activeTab === "saved") {
|
||||
if (selectedEntry.pinned) {
|
||||
modal.unpinEntry(selectedEntry);
|
||||
return;
|
||||
}
|
||||
const pinnedDuplicate = ClipboardService.getPinnedEntryByHash(selectedEntry.hash);
|
||||
if (pinnedDuplicate) {
|
||||
modal.unpinEntry(pinnedDuplicate);
|
||||
} else {
|
||||
modal.pinEntry(selectedEntry);
|
||||
}
|
||||
|
||||
@@ -388,11 +388,15 @@ Singleton {
|
||||
return "text";
|
||||
}
|
||||
|
||||
function hashedPinnedEntry(entryHash) {
|
||||
function getPinnedEntryByHash(entryHash) {
|
||||
if (!entryHash) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
return pinnedEntries.some(pinnedEntry => pinnedEntry.hash === entryHash);
|
||||
return internalEntries.find(entry => entry.pinned && entry.hash === entryHash) || null;
|
||||
}
|
||||
|
||||
function hashedPinnedEntry(entryHash) {
|
||||
return getPinnedEntryByHash(entryHash) !== null;
|
||||
}
|
||||
|
||||
onClipboardAvailableChanged: {
|
||||
|
||||
Reference in New Issue
Block a user