clipboard: skip the clear confirmation when there is nothing to clear (#3730)

This commit is contained in:
Mario Mohar
2026-10-08 17:08:43 -04:00
committed by GitHub
parent 9073de5286
commit 1dc0790d77
2 changed files with 4 additions and 0 deletions
@@ -54,6 +54,7 @@ Item {
DActionButton {
Keys.forwardTo: [actions.modal.modalFocusScope]
iconName: "delete_sweep"
enabled: actions.modal.canClear
iconColor: Theme.onSecondaryContainer
backgroundColor: Theme.secondaryContainer
tooltipText: actions.modal.clearsFilteredOnly ? I18n.tr("Clear Filtered", "clipboard modal: clear button tooltip while a search filter is active") : I18n.tr("Clear All")
@@ -31,6 +31,7 @@ FocusScope {
readonly property int selectedIndex: ClipboardService.selectedIndex
readonly property bool keyboardNavigationActive: ClipboardService.keyboardNavigationActive
readonly property bool clearsFilteredOnly: activeTab === "recents" && ClipboardService.filterActive
readonly property bool canClear: clearsFilteredOnly ? unpinnedEntries.length > 0 : ClipboardService.internalEntries.length > pinnedCount
readonly property var currentEntry: selectedEntry()
readonly property var modalFocusScope: root
@@ -187,6 +188,8 @@ FocusScope {
}, function () {});
return;
}
if (!canClear)
return;
const hasPinned = pinnedCount > 0;
const message = hasPinned ? I18n.tr("This will delete all unpinned entries. %1 pinned entries will be kept.", "clear clipboard history confirmation, %1 is a count").arg(pinnedCount) : I18n.tr("This will permanently delete all clipboard history.");
clearConfirmDialog.show(I18n.tr("Clear History?"), message, function () {