mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-04 12:52:06 -04:00
clipboard: add popout variant
This commit is contained in:
@@ -555,14 +555,57 @@ Item {
|
||||
id: clipboardComponent
|
||||
|
||||
ClipboardButton {
|
||||
id: clipboardWidget
|
||||
widgetThickness: barWindow.widgetThickness
|
||||
barThickness: barWindow.effectiveBarThickness
|
||||
axis: barWindow.axis
|
||||
section: topBarContent.getWidgetSection(parent)
|
||||
parentScreen: barWindow.screen
|
||||
clipboardHistoryModal: PopoutService.clipboardHistoryModal
|
||||
onClicked: {
|
||||
clipboardHistoryModalPopup.toggle();
|
||||
popoutTarget: {
|
||||
clipboardHistoryPopoutLoader.active = true;
|
||||
return clipboardHistoryPopoutLoader.item;
|
||||
}
|
||||
|
||||
function openClipboardPopout(initialTab) {
|
||||
clipboardHistoryPopoutLoader.active = true;
|
||||
if (!clipboardHistoryPopoutLoader.item) {
|
||||
return;
|
||||
}
|
||||
const popout = clipboardHistoryPopoutLoader.item;
|
||||
const effectiveBarConfig = topBarContent.barConfig;
|
||||
const barPosition = barWindow.axis?.edge === "left" ? 2 : (barWindow.axis?.edge === "right" ? 3 : (barWindow.axis?.edge === "top" ? 0 : 1));
|
||||
if (popout.setBarContext) {
|
||||
popout.setBarContext(barPosition, effectiveBarConfig?.bottomGap ?? 0);
|
||||
}
|
||||
if (popout.setTriggerPosition) {
|
||||
const globalPos = clipboardWidget.mapToItem(null, 0, 0);
|
||||
const pos = SettingsData.getPopupTriggerPosition(globalPos, barWindow.screen, barWindow.effectiveBarThickness, clipboardWidget.width, effectiveBarConfig?.spacing ?? 4, barPosition, effectiveBarConfig);
|
||||
const widgetSection = topBarContent.getWidgetSection(parent) || "right";
|
||||
popout.setTriggerPosition(pos.x, pos.y, pos.width, widgetSection, barWindow.screen, barPosition, barWindow.effectiveBarThickness, effectiveBarConfig?.spacing ?? 4, effectiveBarConfig);
|
||||
}
|
||||
if (initialTab) {
|
||||
popout.activeTab = initialTab;
|
||||
}
|
||||
PopoutManager.requestPopout(popout, undefined, "clipboard");
|
||||
}
|
||||
|
||||
onClipboardClicked: openClipboardPopout("recents")
|
||||
|
||||
onShowSavedItemsRequested: openClipboardPopout("saved")
|
||||
|
||||
onClearAllRequested: {
|
||||
clipboardHistoryPopoutLoader.active = true;
|
||||
const popout = clipboardHistoryPopoutLoader.item;
|
||||
if (!popout?.confirmDialog) {
|
||||
return;
|
||||
}
|
||||
const hasPinned = popout.pinnedCount > 0;
|
||||
const message = hasPinned ? I18n.tr("This will delete all unpinned entries. %1 pinned entries will be kept.").arg(popout.pinnedCount) : I18n.tr("This will permanently delete all clipboard history.");
|
||||
popout.confirmDialog.show(I18n.tr("Clear History?"), message, function () {
|
||||
if (popout && typeof popout.clearAll === "function") {
|
||||
popout.clearAll();
|
||||
}
|
||||
}, function () {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,30 +4,30 @@ import Quickshell.Wayland
|
||||
import qs.Common
|
||||
import qs.Modules.Plugins
|
||||
import qs.Widgets
|
||||
import qs.Services
|
||||
|
||||
BasePill {
|
||||
id: root
|
||||
|
||||
property bool isActive: false
|
||||
property var clipboardHistoryModal: null
|
||||
property var popoutTarget: null
|
||||
property var parentScreen: null
|
||||
property Item windowRoot: (Window.window ? Window.window.contentItem : null)
|
||||
property bool isAutoHideBar: false
|
||||
|
||||
signal clipboardClicked
|
||||
signal showSavedItemsRequested
|
||||
signal clearAllRequested
|
||||
|
||||
readonly property real minTooltipY: {
|
||||
if (!parentScreen || !(axis?.isVertical ?? false)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (isAutoHideBar) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (parentScreen.y > 0) {
|
||||
return barThickness + barSpacing;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -51,15 +51,11 @@ BasePill {
|
||||
let anchorY = relativeY;
|
||||
|
||||
if (isVertical) {
|
||||
anchorX = edge === "left"
|
||||
? (root.barThickness + root.barSpacing + gap)
|
||||
: (screen.width - (root.barThickness + root.barSpacing + gap));
|
||||
anchorX = edge === "left" ? (root.barThickness + root.barSpacing + gap) : (screen.width - (root.barThickness + root.barSpacing + gap));
|
||||
anchorY = relativeY + root.minTooltipY;
|
||||
} else {
|
||||
anchorX = relativeX;
|
||||
anchorY = edge === "bottom"
|
||||
? (screen.height - (root.barThickness + root.barSpacing + gap))
|
||||
: (root.barThickness + root.barSpacing + gap);
|
||||
anchorY = edge === "bottom" ? (screen.height - (root.barThickness + root.barSpacing + gap)) : (root.barThickness + root.barSpacing + gap);
|
||||
}
|
||||
|
||||
contextMenuWindow.showAt(anchorX, anchorY, isVertical, edge, screen);
|
||||
@@ -67,10 +63,16 @@ BasePill {
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton
|
||||
onClicked: function(mouse) {
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: function (mouse) {
|
||||
switch (mouse.button) {
|
||||
case Qt.RightButton:
|
||||
openContextMenu();
|
||||
break;
|
||||
case Qt.LeftButton:
|
||||
clipboardClicked();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -232,23 +234,7 @@ BasePill {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
contextMenuWindow.closeMenu();
|
||||
if (root.clipboardHistoryModal && root.clipboardHistoryModal.confirmDialog) {
|
||||
const hasPinned = root.clipboardHistoryModal.pinnedCount > 0;
|
||||
const message = hasPinned
|
||||
? I18n.tr("This will delete all unpinned entries. %1 pinned entries will be kept.").arg(root.clipboardHistoryModal.pinnedCount)
|
||||
: I18n.tr("This will permanently delete all clipboard history.");
|
||||
|
||||
root.clipboardHistoryModal.confirmDialog.show(
|
||||
I18n.tr("Clear History?"),
|
||||
message,
|
||||
function () {
|
||||
if (root.clipboardHistoryModal && typeof root.clipboardHistoryModal.clearAll === "function") {
|
||||
root.clipboardHistoryModal.clearAll();
|
||||
}
|
||||
},
|
||||
function () {}
|
||||
);
|
||||
}
|
||||
root.clearAllRequested();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,16 +274,7 @@ BasePill {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
contextMenuWindow.closeMenu();
|
||||
if (root.clipboardHistoryModal) {
|
||||
if (typeof root.clipboardHistoryModal.show === "function") {
|
||||
root.clipboardHistoryModal.show();
|
||||
}
|
||||
Qt.callLater(function () {
|
||||
if (root.clipboardHistoryModal) {
|
||||
root.clipboardHistoryModal.activeTab = "saved";
|
||||
}
|
||||
});
|
||||
}
|
||||
root.showSavedItemsRequested();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user