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/selectionmodebottombar.h"
14 #include "views/dolphinview.h"
22 class KActionCollection
;
26 * @short Handles all actions for DolphinView
28 * The action handler owns all the actions and slots related to DolphinView,
29 * but the view that it acts upon can be switched to another one
30 * (this is used in the case of split views).
32 * The purpose of this class is also to share this code between DolphinMainWindow
36 * @see DolphinMainWindow
39 class DOLPHIN_EXPORT DolphinViewActionHandler
: public QObject
44 explicit DolphinViewActionHandler(KActionCollection
* collection
, QObject
* parent
);
47 * Sets the view that this action handler should work on.
49 void setCurrentView(DolphinView
* view
);
52 * Returns the view that this action handler should work on.
54 DolphinView
* currentView();
57 * Returns the name of the action for the current viewmode
59 QString
currentViewModeActionName() const;
62 * Returns m_actionCollection
64 KActionCollection
* actionCollection();
68 * Update all actions in the 'View' menu, i.e. those that depend on the
69 * settings in the current view.
71 void updateViewActions();
75 * Emitted by DolphinViewActionHandler when the user triggered an action.
76 * This is only used for clearing the statusbar in DolphinMainWindow.
78 void actionBeingHandled();
81 * Emitted if the user requested creating a new directory by the F10 key.
82 * The receiver of the signal (DolphinMainWindow or DolphinPart) invokes
83 * the method createDirectory of their KNewFileMenu instance.
85 void createDirectoryTriggered();
87 /** Used to request selection mode */
88 void setSelectionMode(bool enabled
, SelectionModeBottomBar::Contents bottomBarContents
= SelectionModeBottomBar::Contents::GeneralContents
);
92 * Emitted when the user requested a change of view mode
94 void slotViewModeActionTriggered(QAction
*);
97 * Let the user input a name for the selected item(s) and trigger
98 * a renaming afterwards.
103 * Moves the selected items of the active view to the trash.
104 * This methods adds "shift means del" handling.
106 void slotTrashActivated();
109 * Deletes the selected items of the active view.
111 void slotDeleteItems();
114 * Switches between showing a preview of the file content and showing the icon.
116 void togglePreview(bool);
118 /** Updates the state of the 'Show preview' menu action. */
119 void slotPreviewsShownChanged(bool shown
);
121 /** Increases the size of the current set view mode. */
124 /** Decreases the size of the current set view mode. */
127 /** Resets the size of the current set view mode to default. */
130 /** Switches between a separate sorting and a mixed sorting of files and folders. */
131 void toggleSortFoldersFirst();
134 * Updates the state of the 'Sort Ascending/Descending' action.
136 void slotSortOrderChanged(Qt::SortOrder order
);
139 * Updates the state of the 'Sort Folders First' action.
141 void slotSortFoldersFirstChanged(bool foldersFirst
);
144 * Switches between showing hidden files last or not.
146 void toggleSortHiddenLast();
149 * Updates the state of the 'Sort Hidden Last' action.
151 void slotSortHiddenLastChanged(bool hiddenLast
);
154 * Updates the state of the 'Sort by' actions.
156 void slotSortRoleChanged(const QByteArray
& role
);
159 * Updates the state of the 'Zoom In' and 'Zoom Out' actions.
161 void slotZoomLevelChanged(int current
, int previous
);
164 * Switches on or off the displaying of additional information
165 * as specified by \a action.
167 void toggleVisibleRole(QAction
* action
);
170 * Changes the sorting of the current view.
172 void slotSortTriggered(QAction
*);
175 * Updates the state of the 'Additional Information' actions.
177 void slotVisibleRolesChanged(const QList
<QByteArray
>& current
,
178 const QList
<QByteArray
>& previous
);
181 * Switches between sorting by groups or not.
183 void toggleGroupedSorting(bool);
186 * Updates the state of the 'Categorized sorting' menu action.
188 void slotGroupedSortingChanged(bool sortCategorized
);
191 * Switches between showing and hiding of hidden marked files
193 void toggleShowHiddenFiles(bool);
196 * Updates the state of the 'Show hidden files' menu action.
198 void slotHiddenFilesShownChanged(bool shown
);
201 * Updates the state of the 'Create Folder...' action.
203 void slotWriteStateChanged(bool isFolderWritable
);
206 * Opens the view properties dialog, which allows to modify the properties
207 * of the currently active view.
209 void slotAdjustViewProperties();
212 * Begins a duplicate operation on the selected files
214 void slotDuplicate();
217 * Connected to the "properties" action.
218 * Opens the properties dialog for the selected items of the
219 * active view. The properties dialog shows information
220 * like name, size and permissions.
222 void slotProperties();
225 * Copies the path of the first selected KFileItem into Clipboard.
230 * Changes the name of the menu that contains basic actions like "Copy", "Rename", ...
231 * The name is changed to something like "Actions for 3 Selected Items" to be extra
232 * explicit of how these basic actions are used.
234 void slotSelectionChanged(const KFileItemList
& selection
);
238 * Create all the actions.
239 * This is called only once (by the constructor)
241 void createActions();
244 * Creates an action-group out of all roles from KFileItemModel.
245 * Dependent on the group-prefix either a radiobutton-group is
246 * created for sorting (prefix is "sort_by_") or a checkbox-group
247 * is created for additional information (prefix is "show_").
248 * The changes of actions are reported to slotSortTriggered() or
249 * toggleAdditionalInfo().
251 QActionGroup
* createFileItemRolesActionGroup(const QString
& groupPrefix
);
254 * Returns the "switch to icons mode" action.
255 * Helper method for createActions();
257 KToggleAction
* iconsModeAction();
260 * Returns the "switch to compact mode" action.
261 * Helper method for createActions();
263 KToggleAction
* compactModeAction();
266 * Returns the "switch to details mode" action.
267 * Helper method for createActions();
269 KToggleAction
* detailsModeAction();
271 KActionCollection
* m_actionCollection
;
272 DolphinView
* m_currentView
;
274 QHash
<QByteArray
, KToggleAction
*> m_sortByActions
;
275 QHash
<QByteArray
, KToggleAction
*> m_visibleRoles
;
278 #endif /* DOLPHINVIEWACTIONHANDLER_H */