1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-06-15 07:35:20 -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:
jbwfu
2026-06-13 02:08:05 +08:00
committed by GitHub
parent 66794582c9
commit 820fa07846
5 changed files with 83 additions and 7 deletions
@@ -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) {
if (value <= 0)
return "∞";
@@ -187,6 +190,29 @@ Item {
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() {
configLoaded = false;
configError = false;
@@ -437,6 +463,24 @@ Item {
checked: SettingsData.clipboardEnterToPaste
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 {
@@ -64,6 +64,8 @@ Item {
property alias model: buttonGroup.model
property alias currentIndex: buttonGroup.currentIndex
property alias initialSelection: buttonGroup.initialSelection
property alias currentSelection: buttonGroup.currentSelection
property alias selectionMode: buttonGroup.selectionMode
property alias buttonHeight: buttonGroup.buttonHeight
property alias minButtonWidth: buttonGroup.minButtonWidth