1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 05:25:41 -05:00

Revert "modals: single window optimization"

This reverts commit 468e569bc7.
This commit is contained in:
bbedward
2025-12-03 10:34:40 -05:00
parent c331e2f39e
commit f3f7cc9077
19 changed files with 640 additions and 661 deletions

View File

@@ -1,9 +1,10 @@
import QtQuick
import qs.Common
import qs.Services
import qs.Widgets
import qs.Modals.Clipboard
FocusScope {
Item {
id: clipboardContent
required property var modal
@@ -14,7 +15,6 @@ FocusScope {
property alias clipboardListView: clipboardListView
anchors.fill: parent
focus: true
Column {
anchors.fill: parent
@@ -31,13 +31,14 @@ FocusScope {
onKeyboardHintsToggled: modal.showKeyboardHints = !modal.showKeyboardHints
onClearAllClicked: {
clearConfirmDialog.show(I18n.tr("Clear All History?"), I18n.tr("This will permanently delete all clipboard history."), function () {
modal.clearAll();
modal.hide();
}, function () {});
modal.clearAll()
modal.hide()
}, function () {})
}
onCloseClicked: modal.hide()
}
// Search Field
DankTextField {
id: searchField
width: parent.width
@@ -46,24 +47,27 @@ FocusScope {
showClearButton: true
focus: true
ignoreTabKeys: true
keyForwardTargets: [modal.modalFocusScope]
onTextChanged: {
modal.searchText = text;
modal.updateFilteredModel();
modal.searchText = text
modal.updateFilteredModel()
}
Keys.onPressed: event => {
if (event.key === Qt.Key_Escape) {
modal.hide();
event.accepted = true;
return;
}
modal.keyboardController?.handleKey(event);
Keys.onEscapePressed: function (event) {
modal.hide()
event.accepted = true
}
Component.onCompleted: {
Qt.callLater(function () {
forceActiveFocus()
})
}
Component.onCompleted: Qt.callLater(() => forceActiveFocus())
Connections {
target: modal
function onOpened() {
Qt.callLater(() => searchField.forceActiveFocus());
Qt.callLater(function () {
searchField.forceActiveFocus()
})
}
}
}
@@ -93,21 +97,21 @@ FocusScope {
function ensureVisible(index) {
if (index < 0 || index >= count) {
return;
return
}
const itemHeight = ClipboardConstants.itemHeight + spacing;
const itemY = index * itemHeight;
const itemBottom = itemY + itemHeight;
const itemHeight = ClipboardConstants.itemHeight + spacing
const itemY = index * itemHeight
const itemBottom = itemY + itemHeight
if (itemY < contentY) {
contentY = itemY;
contentY = itemY
} else if (itemBottom > contentY + height) {
contentY = itemBottom - height;
contentY = itemBottom - height
}
}
onCurrentIndexChanged: {
if (clipboardContent.modal && clipboardContent.modal.keyboardNavigationActive && currentIndex >= 0) {
ensureVisible(currentIndex);
ensureVisible(currentIndex)
}
}