1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 13:32:50 -05:00

clipboard: fix header GUI and add tooltips

This commit is contained in:
bbedward
2026-01-21 10:19:52 -05:00
parent 132e799265
commit 417bf37515
2 changed files with 47 additions and 53 deletions

View File

@@ -44,26 +44,28 @@ Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingS spacing: Theme.spacingS
DankActionButton {
iconName: "history"
iconSize: Theme.iconSize - 4
iconColor: header.activeTab === "recents" ? Theme.primary : Theme.surfaceText
onClicked: tabChanged("recents")
}
DankActionButton { DankActionButton {
iconName: "push_pin" iconName: "push_pin"
iconSize: Theme.iconSize - 4 iconSize: Theme.iconSize - 4
iconColor: header.activeTab === "saved" ? Theme.primary : Theme.surfaceText iconColor: header.activeTab === "saved" ? Theme.primary : Theme.surfaceText
opacity: header.pinnedCount > 0 ? 1 : 0 visible: header.pinnedCount > 0
enabled: header.pinnedCount > 0 tooltipText: I18n.tr("Saved")
onClicked: tabChanged("saved") onClicked: tabChanged("saved")
} }
DankActionButton {
iconName: "history"
iconSize: Theme.iconSize - 4
iconColor: header.activeTab === "recents" ? Theme.primary : Theme.surfaceText
tooltipText: I18n.tr("History")
onClicked: tabChanged("recents")
}
DankActionButton { DankActionButton {
iconName: "info" iconName: "info"
iconSize: Theme.iconSize - 4 iconSize: Theme.iconSize - 4
iconColor: showKeyboardHints ? Theme.primary : Theme.surfaceText iconColor: showKeyboardHints ? Theme.primary : Theme.surfaceText
tooltipText: I18n.tr("Keyboard Shortcuts")
onClicked: keyboardHintsToggled() onClicked: keyboardHintsToggled()
} }
@@ -71,6 +73,7 @@ Item {
iconName: "delete_sweep" iconName: "delete_sweep"
iconSize: Theme.iconSize iconSize: Theme.iconSize
iconColor: Theme.surfaceText iconColor: Theme.surfaceText
tooltipText: I18n.tr("Clear All")
onClicked: clearAllClicked() onClicked: clearAllClicked()
} }

View File

@@ -82,14 +82,13 @@ DankModal {
filtered = internalEntries; filtered = internalEntries;
} else { } else {
const lowerQuery = query.toLowerCase(); const lowerQuery = query.toLowerCase();
filtered = internalEntries.filter(entry => filtered = internalEntries.filter(entry => entry.preview.toLowerCase().includes(lowerQuery));
entry.preview.toLowerCase().includes(lowerQuery)
);
} }
// Sort: pinned first, then by ID descending // Sort: pinned first, then by ID descending
filtered.sort((a, b) => { filtered.sort((a, b) => {
if (a.pinned !== b.pinned) return b.pinned ? 1 : -1; if (a.pinned !== b.pinned)
return b.pinned ? 1 : -1;
return b.id - a.id; return b.id - a.id;
}); });
@@ -193,24 +192,19 @@ DankModal {
} }
function deletePinnedEntry(entry) { function deletePinnedEntry(entry) {
clearConfirmDialog.show( clearConfirmDialog.show(I18n.tr("Delete Saved Item?"), I18n.tr("This will permanently remove this saved clipboard item. This action cannot be undone."), function () {
I18n.tr("Delete Saved Item?"), DMSService.sendRequest("clipboard.deleteEntry", {
I18n.tr("This will permanently remove this saved clipboard item. This action cannot be undone."), "id": entry.id
function () { }, function (response) {
DMSService.sendRequest("clipboard.deleteEntry", { if (response.error) {
"id": entry.id console.warn("ClipboardHistoryModal: Failed to delete entry:", response.error);
}, function (response) { return;
if (response.error) { }
console.warn("ClipboardHistoryModal: Failed to delete entry:", response.error); internalEntries = internalEntries.filter(e => e.id !== entry.id);
return; updateFilteredModel();
} ToastService.showInfo(I18n.tr("Saved item deleted"));
internalEntries = internalEntries.filter(e => e.id !== entry.id); });
updateFilteredModel(); }, function () {});
ToastService.showInfo(I18n.tr("Saved item deleted"));
});
},
function () {}
);
} }
function pinEntry(entry) { function pinEntry(entry) {
@@ -226,7 +220,9 @@ DankModal {
return; return;
} }
DMSService.sendRequest("clipboard.pinEntry", { "id": entry.id }, function (response) { DMSService.sendRequest("clipboard.pinEntry", {
"id": entry.id
}, function (response) {
if (response.error) { if (response.error) {
ToastService.showError(I18n.tr("Failed to pin entry")); ToastService.showError(I18n.tr("Failed to pin entry"));
return; return;
@@ -238,7 +234,9 @@ DankModal {
} }
function unpinEntry(entry) { function unpinEntry(entry) {
DMSService.sendRequest("clipboard.unpinEntry", { "id": entry.id }, function (response) { DMSService.sendRequest("clipboard.unpinEntry", {
"id": entry.id
}, function (response) {
if (response.error) { if (response.error) {
ToastService.showError(I18n.tr("Failed to unpin entry")); ToastService.showError(I18n.tr("Failed to unpin entry"));
return; return;
@@ -250,27 +248,20 @@ DankModal {
function clearAll() { function clearAll() {
const hasPinned = pinnedCount > 0; const hasPinned = pinnedCount > 0;
const message = hasPinned const message = hasPinned ? I18n.tr("This will delete all unpinned entries. %1 pinned entries will be kept.").arg(pinnedCount) : I18n.tr("This will permanently delete all clipboard history.");
? I18n.tr("This will delete all unpinned entries. %1 pinned entries will be kept.").arg(pinnedCount)
: I18n.tr("This will permanently delete all clipboard history.");
clearConfirmDialog.show( clearConfirmDialog.show(I18n.tr("Clear History?"), message, function () {
I18n.tr("Clear History?"), DMSService.sendRequest("clipboard.clearHistory", null, function (response) {
message, if (response.error) {
function () { console.warn("ClipboardHistoryModal: Failed to clear history:", response.error);
DMSService.sendRequest("clipboard.clearHistory", null, function (response) { return;
if (response.error) { }
console.warn("ClipboardHistoryModal: Failed to clear history:", response.error); refreshClipboard();
return; if (hasPinned) {
} ToastService.showInfo(I18n.tr("History cleared. %1 pinned entries kept.").arg(pinnedCount));
refreshClipboard(); }
if (hasPinned) { });
ToastService.showInfo(I18n.tr("History cleared. %1 pinned entries kept.").arg(pinnedCount)); }, function () {});
}
});
},
function () {}
);
} }
function getEntryPreview(entry) { function getEntryPreview(entry) {