mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-28 07:22:50 -05:00
clipboard: fix duplicate clear dialog
This commit is contained in:
@@ -30,7 +30,9 @@ Item {
|
|||||||
onKeyboardHintsToggled: modal.showKeyboardHints = !modal.showKeyboardHints
|
onKeyboardHintsToggled: modal.showKeyboardHints = !modal.showKeyboardHints
|
||||||
onTabChanged: tabName => modal.activeTab = tabName
|
onTabChanged: tabName => modal.activeTab = tabName
|
||||||
onClearAllClicked: {
|
onClearAllClicked: {
|
||||||
clearConfirmDialog.show(I18n.tr("Clear All History?"), I18n.tr("This will permanently delete all clipboard history."), function () {
|
const hasPinned = modal.pinnedCount > 0;
|
||||||
|
const message = hasPinned ? I18n.tr("This will delete all unpinned entries. %1 pinned entries will be kept.").arg(modal.pinnedCount) : I18n.tr("This will permanently delete all clipboard history.");
|
||||||
|
clearConfirmDialog.show(I18n.tr("Clear History?"), message, function () {
|
||||||
modal.clearAll();
|
modal.clearAll();
|
||||||
modal.hide();
|
modal.hide();
|
||||||
}, function () {});
|
}, function () {});
|
||||||
|
|||||||
@@ -239,20 +239,16 @@ DankModal {
|
|||||||
|
|
||||||
function clearAll() {
|
function clearAll() {
|
||||||
const hasPinned = pinnedCount > 0;
|
const hasPinned = pinnedCount > 0;
|
||||||
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.");
|
DMSService.sendRequest("clipboard.clearHistory", null, function (response) {
|
||||||
|
if (response.error) {
|
||||||
clearConfirmDialog.show(I18n.tr("Clear History?"), message, 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 getEntryPreview(entry) {
|
function getEntryPreview(entry) {
|
||||||
@@ -295,13 +291,18 @@ DankModal {
|
|||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
clipboardHistoryModal.shouldHaveFocus = false;
|
clipboardHistoryModal.shouldHaveFocus = false;
|
||||||
} else if (clipboardHistoryModal.shouldBeVisible) {
|
return;
|
||||||
|
}
|
||||||
|
Qt.callLater(function () {
|
||||||
|
if (!clipboardHistoryModal.shouldBeVisible) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
clipboardHistoryModal.shouldHaveFocus = true;
|
clipboardHistoryModal.shouldHaveFocus = true;
|
||||||
clipboardHistoryModal.modalFocusScope.forceActiveFocus();
|
clipboardHistoryModal.modalFocusScope.forceActiveFocus();
|
||||||
if (clipboardHistoryModal.contentLoader.item?.searchField) {
|
if (clipboardHistoryModal.contentLoader.item?.searchField) {
|
||||||
clipboardHistoryModal.contentLoader.item.searchField.forceActiveFocus();
|
clipboardHistoryModal.contentLoader.item.searchField.forceActiveFocus();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,31 +93,41 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: visibilityTimer
|
||||||
|
interval: 100
|
||||||
|
onTriggered: thumbnailImage.checkVisibility()
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkVisibility() {
|
||||||
|
if (entryType !== "image" || listView.height <= 0 || isVisible) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const itemY = itemIndex * (ClipboardConstants.itemHeight + listView.spacing);
|
||||||
|
const viewTop = listView.contentY - ClipboardConstants.viewportBuffer;
|
||||||
|
const viewBottom = viewTop + listView.height + ClipboardConstants.extendedBuffer;
|
||||||
|
const nowVisible = (itemY + ClipboardConstants.itemHeight >= viewTop && itemY <= viewBottom);
|
||||||
|
if (nowVisible) {
|
||||||
|
isVisible = true;
|
||||||
|
tryLoadImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: listView
|
target: listView
|
||||||
|
|
||||||
function checkVisibility() {
|
function onContentYChanged() {
|
||||||
if (entryType !== "image" || listView.height <= 0) {
|
if (thumbnailImage.isVisible || entryType !== "image") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
visibilityTimer.restart();
|
||||||
const itemY = itemIndex * (ClipboardConstants.itemHeight + listView.spacing);
|
|
||||||
const viewTop = listView.contentY - ClipboardConstants.viewportBuffer;
|
|
||||||
const viewBottom = viewTop + listView.height + ClipboardConstants.extendedBuffer;
|
|
||||||
const nowVisible = (itemY + ClipboardConstants.itemHeight >= viewTop && itemY <= viewBottom);
|
|
||||||
|
|
||||||
if (nowVisible && !thumbnailImage.isVisible) {
|
|
||||||
thumbnailImage.isVisible = true;
|
|
||||||
thumbnailImage.tryLoadImage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onContentYChanged() {
|
|
||||||
checkVisibility();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onHeightChanged() {
|
function onHeightChanged() {
|
||||||
checkVisibility();
|
if (thumbnailImage.isVisible || entryType !== "image") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
visibilityTimer.restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user