From f5818306d014fafaf35ef10ee83e286eebea9cd7 Mon Sep 17 00:00:00 2001 From: Kostiantin Korchuhanov Date: Fri, 15 Aug 2025 16:29:34 +0300 Subject: itemactions: Add context menu actions to hide and unhide files using .hidden Summary: This patch introduces context menu actions that allow users to hide or unhide selected files by editing the .hidden file in their parent directories. What this patch does: - Implemented HideFileItemAction plugin based on KAbstractFileItemActionPlugin - Plugin is disabled by default unless explicitly enabled in kservicemenurc via the hidefileitemaction key - "Hide" action adds selected file names to the .hidden file, avoiding duplicates - "Unhide" action removes selected file names from the .hidden file - Action visibility logic: - If only visible or only hidden files are selected, only the relevant action is shown - If both are selected, both "Hide" and "Unhide" actions are shown - Write permission checks ensure actions are disabled if the .hidden file cannot be modified - Optimized redundant path computations by calculating parent directory and .hidden file paths once and reusing them --- src/itemactions/hidefileitemaction.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/itemactions/hidefileitemaction.h (limited to 'src/itemactions/hidefileitemaction.h') diff --git a/src/itemactions/hidefileitemaction.h b/src/itemactions/hidefileitemaction.h new file mode 100644 index 000000000..565f0d563 --- /dev/null +++ b/src/itemactions/hidefileitemaction.h @@ -0,0 +1,26 @@ +/* + * SPDX-FileCopyrightText: 2025 Kostiantyn Korchuhanov + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HIDEFILEITEMACTION_H +#define HIDEFILEITEMACTION_H + +#include +#include +#include +#include +#include + +class HideFileItemAction : public KAbstractFileItemActionPlugin +{ + Q_OBJECT + +public: + HideFileItemAction(QObject *parent); + + QList actions(const KFileItemListProperties &fileItemInfos, QWidget *parentWidget) override; +}; + +#endif // HIDEFILEITEMACTION_H -- cgit v1.3.1