mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-08 04:09:15 -04:00
118 lines
3.0 KiB
QML
118 lines
3.0 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
import QtQuick
|
|
import qs.Common
|
|
import qs.Modals.Clipboard
|
|
import qs.Modals.Common
|
|
import qs.Services
|
|
import qs.Widgets
|
|
|
|
DankPopout {
|
|
id: root
|
|
|
|
layerNamespace: "dms:clipboard-popout"
|
|
|
|
property var parentWidget: null
|
|
property var triggerScreen: null
|
|
property string activeTab: "recents"
|
|
|
|
readonly property bool clipboardAvailable: ClipboardService.clipboardAvailable
|
|
readonly property int pinnedCount: ClipboardService.pinnedCount
|
|
readonly property var confirmDialog: clearConfirmDialog
|
|
readonly property var modalFocusScope: contentLoader.item ?? null
|
|
|
|
function show() {
|
|
open();
|
|
|
|
Qt.callLater(function () {
|
|
if (contentLoader.item) {
|
|
contentLoader.item.activeTab = activeTab;
|
|
contentLoader.item.resetState();
|
|
}
|
|
if (contentLoader.item?.searchField) {
|
|
contentLoader.item.searchField.text = "";
|
|
contentLoader.item.searchField.forceActiveFocus();
|
|
}
|
|
});
|
|
}
|
|
|
|
function hide() {
|
|
close();
|
|
}
|
|
|
|
function clearAll() {
|
|
ClipboardService.clearAll();
|
|
}
|
|
|
|
popupWidth: ClipboardConstants.popoutWidth
|
|
popupHeight: ClipboardConstants.popoutHeight
|
|
triggerWidth: 55
|
|
positioning: ""
|
|
screen: triggerScreen
|
|
shouldBeVisible: false
|
|
contentHandlesKeys: true
|
|
|
|
onBackgroundClicked: hide()
|
|
|
|
onShouldBeVisibleChanged: {
|
|
if (!shouldBeVisible) {
|
|
return;
|
|
}
|
|
if (clipboardAvailable) {
|
|
if (Theme.isConnectedEffect) {
|
|
Qt.callLater(() => {
|
|
if (root.shouldBeVisible) {
|
|
ClipboardService.refresh();
|
|
}
|
|
});
|
|
} else {
|
|
ClipboardService.refresh();
|
|
}
|
|
}
|
|
Qt.callLater(function () {
|
|
if (contentLoader.item) {
|
|
contentLoader.item.activeTab = activeTab;
|
|
contentLoader.item.resetState();
|
|
}
|
|
if (contentLoader.item?.searchField) {
|
|
contentLoader.item.searchField.text = "";
|
|
contentLoader.item.searchField.forceActiveFocus();
|
|
}
|
|
});
|
|
}
|
|
|
|
onPopoutClosed: {
|
|
if (contentLoader.item) {
|
|
contentLoader.item.resetState();
|
|
}
|
|
}
|
|
|
|
Ref {
|
|
service: ClipboardService
|
|
}
|
|
|
|
ConfirmModal {
|
|
id: clearConfirmDialog
|
|
confirmButtonText: I18n.tr("Clear All")
|
|
confirmButtonColor: Theme.primary
|
|
}
|
|
|
|
content: Component {
|
|
ClipboardHistoryContent {
|
|
LayoutMirroring.enabled: I18n.isRtl
|
|
LayoutMirroring.childrenInherit: true
|
|
|
|
clearConfirmDialog: clearConfirmDialog
|
|
onCloseRequested: root.hide()
|
|
onInstantCloseRequested: root.close()
|
|
|
|
Component.onCompleted: {
|
|
activeTab = root.activeTab;
|
|
if (root.shouldBeVisible) {
|
|
forceActiveFocus();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|