2 * SPDX-FileCopyrightText: 2008 David Faure <faure@kde.org>
3 * SPDX-FileCopyrightText: 2012 Peter Penz <peter.penz19@gmail.com>
5 * SPDX-License-Identifier: GPL-2.0-or-later
9 #ifndef DOLPHINVIEWACTIONHANDLER_H
10 #define DOLPHINVIEWACTIONHANDLER_H
12 #include "dolphin_export.h"
13 #include "selectionmode/bottombar.h"
14 #include "views/dolphinview.h"
22 class KActionCollection
;
24 namespace SelectionMode
{
25 class ActionTextHelper
;
29 * @short Handles all actions for DolphinView
31 * The action handler owns all the actions and slots related to DolphinView,
32 * but the view that it acts upon can be switched to another one
33 * (this is used in the case of split views).
35 * The purpose of this class is also to share this code between DolphinMainWindow
39 * @see DolphinMainWindow
42 class DOLPHIN_EXPORT DolphinViewActionHandler
: public QObject
47 explicit DolphinViewActionHandler(KActionCollection
* collection
, SelectionMode::ActionTextHelper
* actionTextHelper
, QObject
* parent
);
50 * Sets the view that this action handler should work on.
52 void setCurrentView(DolphinView
* view
);
55 * Returns the view that this action handler should work on.
57 DolphinView
* currentView();
60 * Returns the name of the action for the current viewmode
62 QString
currentViewModeActionName() const;
65 * Returns m_actionCollection
67 KActionCollection
* actionCollection();
71 * Update all actions in the 'View' menu, i.e. those that depend on the
72 * settings in the current view.
74 void updateViewActions();
78 * Emitted by DolphinViewActionHandler when the user triggered an action.
79 * This is only used for clearing the statusbar in DolphinMainWindow.
81 void actionBeingHandled();
84 * Emitted if the user requested creating a new directory by the F10 key.
85 * The receiver of the signal (DolphinMainWindow or DolphinPart) invokes
86 * the method createDirectory of their KNewFileMenu instance.
88 void createDirectoryTriggered();
90 /** Used to request either entering or leaving of selection mode */
91 void selectionModeChangeTriggered(bool enabled
, SelectionMode::BottomBar::Contents bottomBarContents
= SelectionMode::BottomBar::Contents::GeneralContents
);
95 * Emitted when the user requested a change of view mode
97 void slotViewModeActionTriggered(QAction
*);
100 * Let the user input a name for the selected item(s) and trigger
101 * a renaming afterwards.
106 * Moves the selected items of the active view to the trash.
107 * This methods adds "shift means del" handling.
109 void slotTrashActivated();
112 * Deletes the selected items of the active view.
114 void slotDeleteItems();
117 * Switches between showing a preview of the file content and showing the icon.
119 void togglePreview(bool);
121 /** Updates the state of the 'Show preview' menu action. */
122 void slotPreviewsShownChanged(bool shown
);
124 /** Increases the size of the current set view mode. */
127 /** Decreases the size of the current set view mode. */
130 /** Resets the size of the current set view mode to default. */
133 /** Switches between a separate sorting and a mixed sorting of files and folders. */
134 void toggleSortFoldersFirst();
137 * Updates the state of the 'Sort Ascending/Descending' action.
139 void slotSortOrderChanged(Qt::SortOrder order
);
142 * Updates the state of the 'Sort Folders First' action.
144 void slotSortFoldersFirstChanged(bool foldersFirst
);
147 * Switches between showing hidden files last or not.
149 void toggleSortHiddenLast();
152 * Updates the state of the 'Sort Hidden Last' action.
154 void slotSortHiddenLastChanged(bool hiddenLast
);
157 * Updates the state of the 'Sort by' actions.
159 void slotSortRoleChanged(const QByteArray
& role
);
162 * Updates the state of the 'Zoom In' and 'Zoom Out' actions.
164 void slotZoomLevelChanged(int current
, int previous
);
167 * Switches on or off the displaying of additional information
168 * as specified by \a action.
170 void toggleVisibleRole(QAction
* action
);
173 * Changes the sorting of the current view.
175 void slotSortTriggered(QAction
*);
178 * Updates the state of the 'Additional Information' actions.
180 void slotVisibleRolesChanged(const QList
<QByteArray
>& current
,
181 const QList
<QByteArray
>& previous
);
184 * Switches between sorting by groups or not.
186 void toggleGroupedSorting(bool);
189 * Updates the state of the 'Categorized sorting' menu action.
191 void slotGroupedSortingChanged(bool sortCategorized
);
194 * Switches between showing and hiding of hidden marked files
196 void toggleShowHiddenFiles(bool);
199 * Updates the state of the 'Show hidden files' menu action.
201 void slotHiddenFilesShownChanged(bool shown
);
204 * Updates the state of the 'Create Folder...' action.
206 void slotWriteStateChanged(bool isFolderWritable
);
209 * Opens the view properties dialog, which allows to modify the properties
210 * of the currently active view.
212 void slotAdjustViewProperties();
215 * Begins a duplicate operation on the selected files
217 void slotDuplicate();
220 * Connected to the "properties" action.
221 * Opens the properties dialog for the selected items of the
222 * active view. The properties dialog shows information
223 * like name, size and permissions.
225 void slotProperties();
228 * Copies the path of the first selected KFileItem into Clipboard.
233 * Changes the name of the menu that contains basic actions like "Copy", "Rename", ...
234 * The name is changed to something like "Actions for 3 Selected Items" to be extra
235 * explicit of how these basic actions are used.
237 void slotSelectionChanged(const KFileItemList
& selection
);
241 * Create all the actions.
242 * This is called only once (by the constructor)
244 void createActions(SelectionMode::ActionTextHelper
*actionTextHelper
);
247 * Creates an action-group out of all roles from KFileItemModel.
248 * Dependent on the group-prefix either a radiobutton-group is
249 * created for sorting (prefix is "sort_by_") or a checkbox-group
250 * is created for additional information (prefix is "show_").
251 * The changes of actions are reported to slotSortTriggered() or
252 * toggleAdditionalInfo().
254 QActionGroup
* createFileItemRolesActionGroup(const QString
& groupPrefix
);
257 * Returns the "switch to icons mode" action.
258 * Helper method for createActions();
260 KToggleAction
* iconsModeAction();
263 * Returns the "switch to compact mode" action.
264 * Helper method for createActions();
266 KToggleAction
* compactModeAction();
269 * Returns the "switch to details mode" action.
270 * Helper method for createActions();
272 KToggleAction
* detailsModeAction();
274 KActionCollection
* m_actionCollection
;
275 DolphinView
* m_currentView
;
277 QHash
<QByteArray
, KToggleAction
*> m_sortByActions
;
278 QHash
<QByteArray
, KToggleAction
*> m_visibleRoles
;
281 #endif /* DOLPHINVIEWACTIONHANDLER_H */