mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-15 23:55:21 -04:00
feat(settings): add clipboard entry action visibility controls (#2621)
* feat(settings): add clipboard entry action visibility controls * fix(clipboard): show pinned indicator for saved entries when pin action is hidden
This commit is contained in:
@@ -108,6 +108,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
property bool clipboardEnterToPaste: false
|
property bool clipboardEnterToPaste: false
|
||||||
|
property var clipboardVisibleEntryActions: ["pin", "edit", "delete"]
|
||||||
|
|
||||||
property var launcherPluginVisibility: ({})
|
property var launcherPluginVisibility: ({})
|
||||||
|
|
||||||
|
|||||||
@@ -572,6 +572,7 @@ var SPEC = {
|
|||||||
|
|
||||||
builtInPluginSettings: { def: {} },
|
builtInPluginSettings: { def: {} },
|
||||||
clipboardEnterToPaste: { def: false },
|
clipboardEnterToPaste: { def: false },
|
||||||
|
clipboardVisibleEntryActions: { def: ["pin", "edit", "delete"] },
|
||||||
|
|
||||||
launcherPluginVisibility: { def: {} },
|
launcherPluginVisibility: { def: {} },
|
||||||
launcherPluginOrder: { def: [] },
|
launcherPluginOrder: { def: [] },
|
||||||
|
|||||||
@@ -22,7 +22,14 @@ Rectangle {
|
|||||||
readonly property string entryType: modal ? modal.getEntryType(entry) : "text"
|
readonly property string entryType: modal ? modal.getEntryType(entry) : "text"
|
||||||
readonly property string entryPreview: modal ? modal.getEntryPreview(entry) : ""
|
readonly property string entryPreview: modal ? modal.getEntryPreview(entry) : ""
|
||||||
readonly property var pinnedDuplicateEntry: !entry.pinned ? ClipboardService.getPinnedEntryByHash(entry.hash) : null
|
readonly property var pinnedDuplicateEntry: !entry.pinned ? ClipboardService.getPinnedEntryByHash(entry.hash) : null
|
||||||
readonly property bool effectivePinned: entry.pinned || pinnedDuplicateEntry !== null
|
readonly property bool hasPinnedDuplicate: pinnedDuplicateEntry !== null
|
||||||
|
readonly property bool effectivePinned: entry.pinned || hasPinnedDuplicate
|
||||||
|
readonly property var visibleEntryActions: SettingsData.clipboardVisibleEntryActions || ["pin", "edit", "delete"]
|
||||||
|
readonly property bool showPinAction: visibleEntryActions.includes("pin")
|
||||||
|
readonly property bool showEditAction: visibleEntryActions.includes("edit")
|
||||||
|
readonly property bool showDeleteAction: visibleEntryActions.includes("delete")
|
||||||
|
readonly property bool showPinnedIndicator: !showPinAction && effectivePinned
|
||||||
|
readonly property bool showAnyAction: showPinAction || showEditAction || showDeleteAction || showPinnedIndicator
|
||||||
|
|
||||||
radius: Theme.cornerRadius
|
radius: Theme.cornerRadius
|
||||||
color: {
|
color: {
|
||||||
@@ -63,12 +70,31 @@ Rectangle {
|
|||||||
anchors.rightMargin: Theme.spacingS
|
anchors.rightMargin: Theme.spacingS
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
spacing: Theme.spacingXS
|
spacing: Theme.spacingXS
|
||||||
|
visible: root.showAnyAction
|
||||||
|
|
||||||
DankActionButton {
|
DankActionButton {
|
||||||
iconName: "push_pin"
|
iconName: "push_pin"
|
||||||
iconSize: Theme.iconSize - 6
|
iconSize: Theme.iconSize - 6
|
||||||
iconColor: effectivePinned ? Theme.primary : Theme.surfaceText
|
iconColor: Theme.primary
|
||||||
backgroundColor: effectivePinned ? Theme.primarySelected : "transparent"
|
backgroundColor: Theme.primarySelected
|
||||||
|
visible: root.showPinnedIndicator
|
||||||
|
onClicked: {
|
||||||
|
if (entry.pinned) {
|
||||||
|
unpinRequested(entry);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pinnedDuplicateEntry) {
|
||||||
|
unpinRequested(pinnedDuplicateEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DankActionButton {
|
||||||
|
iconName: "push_pin"
|
||||||
|
iconSize: Theme.iconSize - 6
|
||||||
|
iconColor: (entry.pinned || hasPinnedDuplicate) ? Theme.primary : Theme.surfaceText
|
||||||
|
backgroundColor: (entry.pinned || hasPinnedDuplicate) ? Theme.primarySelected : "transparent"
|
||||||
|
visible: root.showPinAction
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (entry.pinned) {
|
if (entry.pinned) {
|
||||||
unpinRequested(entry);
|
unpinRequested(entry);
|
||||||
@@ -86,6 +112,7 @@ Rectangle {
|
|||||||
iconName: "edit"
|
iconName: "edit"
|
||||||
iconSize: Theme.iconSize - 6
|
iconSize: Theme.iconSize - 6
|
||||||
iconColor: Theme.surfaceText
|
iconColor: Theme.surfaceText
|
||||||
|
visible: root.showEditAction
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (entryType === "image") {
|
if (entryType === "image") {
|
||||||
@@ -99,6 +126,7 @@ Rectangle {
|
|||||||
iconName: "close"
|
iconName: "close"
|
||||||
iconSize: Theme.iconSize - 6
|
iconSize: Theme.iconSize - 6
|
||||||
iconColor: Theme.surfaceText
|
iconColor: Theme.surfaceText
|
||||||
|
visible: root.showDeleteAction
|
||||||
onClicked: deleteRequested()
|
onClicked: deleteRequested()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,8 +134,8 @@ Rectangle {
|
|||||||
Item {
|
Item {
|
||||||
anchors.left: indexBadge.right
|
anchors.left: indexBadge.right
|
||||||
anchors.leftMargin: Theme.spacingM
|
anchors.leftMargin: Theme.spacingM
|
||||||
anchors.right: actionButtons.left
|
anchors.right: root.showAnyAction ? actionButtons.left : parent.right
|
||||||
anchors.rightMargin: Theme.spacingM
|
anchors.rightMargin: root.showAnyAction ? Theme.spacingM : Theme.spacingS
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
// height: contentColumn.implicitHeight
|
// height: contentColumn.implicitHeight
|
||||||
height: ClipboardConstants.itemHeight
|
height: ClipboardConstants.itemHeight
|
||||||
@@ -168,8 +196,8 @@ Rectangle {
|
|||||||
MouseArea {
|
MouseArea {
|
||||||
id: mouseArea
|
id: mouseArea
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: actionButtons.left
|
anchors.right: root.showAnyAction ? actionButtons.left : parent.right
|
||||||
anchors.rightMargin: Theme.spacingS
|
anchors.rightMargin: root.showAnyAction ? Theme.spacingS : 0
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
|||||||
@@ -152,6 +152,9 @@ Item {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
readonly property var entryActionKeys: ["pin", "edit", "delete"]
|
||||||
|
readonly property var entryActionLabels: [I18n.tr("Pin"), I18n.tr("Edit"), I18n.tr("Delete")]
|
||||||
|
|
||||||
function getMaxHistoryText(value) {
|
function getMaxHistoryText(value) {
|
||||||
if (value <= 0)
|
if (value <= 0)
|
||||||
return "∞";
|
return "∞";
|
||||||
@@ -187,6 +190,29 @@ Item {
|
|||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function visibleEntryActionKeys() {
|
||||||
|
return SettingsData.clipboardVisibleEntryActions || ["pin", "edit", "delete"];
|
||||||
|
}
|
||||||
|
|
||||||
|
function visibleEntryActionLabels() {
|
||||||
|
const visibleKeys = visibleEntryActionKeys();
|
||||||
|
return entryActionKeys.map((key, index) => visibleKeys.includes(key) ? entryActionLabels[index] : null).filter(label => label !== null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setVisibleEntryAction(index, selected) {
|
||||||
|
const actionKey = entryActionKeys[index];
|
||||||
|
if (!actionKey)
|
||||||
|
return;
|
||||||
|
|
||||||
|
let actions = visibleEntryActionKeys().slice();
|
||||||
|
if (selected && !actions.includes(actionKey)) {
|
||||||
|
actions.push(actionKey);
|
||||||
|
} else if (!selected && actions.includes(actionKey)) {
|
||||||
|
actions = actions.filter(action => action !== actionKey);
|
||||||
|
}
|
||||||
|
SettingsData.set("clipboardVisibleEntryActions", actions);
|
||||||
|
}
|
||||||
|
|
||||||
function loadConfig() {
|
function loadConfig() {
|
||||||
configLoaded = false;
|
configLoaded = false;
|
||||||
configError = false;
|
configError = false;
|
||||||
@@ -437,6 +463,24 @@ Item {
|
|||||||
checked: SettingsData.clipboardEnterToPaste
|
checked: SettingsData.clipboardEnterToPaste
|
||||||
onToggled: checked => SettingsData.set("clipboardEnterToPaste", checked)
|
onToggled: checked => SettingsData.set("clipboardEnterToPaste", checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SettingsButtonGroupRow {
|
||||||
|
tab: "clipboard"
|
||||||
|
tags: ["clipboard", "actions", "buttons", "hide", "density", "pin", "edit", "delete"]
|
||||||
|
settingKey: "clipboardVisibleEntryActions"
|
||||||
|
text: I18n.tr("Visible Entry Actions")
|
||||||
|
description: I18n.tr("Choose which action buttons appear on clipboard entries")
|
||||||
|
selectionMode: "multi"
|
||||||
|
model: root.entryActionLabels
|
||||||
|
currentSelection: root.visibleEntryActionLabels()
|
||||||
|
checkEnabled: false
|
||||||
|
buttonHeight: 28
|
||||||
|
minButtonWidth: 56
|
||||||
|
buttonPadding: Theme.spacingS
|
||||||
|
textSize: Theme.fontSizeSmall
|
||||||
|
spacing: 1
|
||||||
|
onSelectionChanged: (index, selected) => root.setVisibleEntryAction(index, selected)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsCard {
|
SettingsCard {
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ Item {
|
|||||||
|
|
||||||
property alias model: buttonGroup.model
|
property alias model: buttonGroup.model
|
||||||
property alias currentIndex: buttonGroup.currentIndex
|
property alias currentIndex: buttonGroup.currentIndex
|
||||||
|
property alias initialSelection: buttonGroup.initialSelection
|
||||||
|
property alias currentSelection: buttonGroup.currentSelection
|
||||||
property alias selectionMode: buttonGroup.selectionMode
|
property alias selectionMode: buttonGroup.selectionMode
|
||||||
property alias buttonHeight: buttonGroup.buttonHeight
|
property alias buttonHeight: buttonGroup.buttonHeight
|
||||||
property alias minButtonWidth: buttonGroup.minButtonWidth
|
property alias minButtonWidth: buttonGroup.minButtonWidth
|
||||||
|
|||||||
Reference in New Issue
Block a user