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
8 #ifndef DOLPHINVIEWACTIONHANDLER_H
9 #define DOLPHINVIEWACTIONHANDLER_H
11 #include "dolphin_export.h"
12 #include "selectionmode/bottombar.h"
13 #include "views/dolphinview.h"
21 class KActionCollection
;
23 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();
91 * Emitted if the user requested creating a new file.
92 * The receiver of the signal (DolphinMainWindow or DolphinPart) invokes
93 * the method createFile of their KNewFileMenu instance.
95 void createFileTriggered();
97 /** Used to request either entering or leaving of selection mode */
98 void selectionModeChangeTriggered(bool enabled
, SelectionMode::BottomBar::Contents bottomBarContents
= SelectionMode::BottomBar::Contents::GeneralContents
);
102 * Emitted when the user requested a change of view mode
104 void slotViewModeActionTriggered(QAction
*);
107 * Let the user input a name for the selected item(s) and trigger
108 * a renaming afterwards.
113 * Moves the selected items of the active view to the trash.
114 * This methods adds "shift means del" handling.
116 void slotTrashActivated();
119 * Deletes the selected items of the active view.
121 void slotDeleteItems();
124 * Switches between showing a preview of the file content and showing the icon.
126 void togglePreview(bool);
128 /** Updates the state of the 'Show preview' menu action. */
129 void slotPreviewsShownChanged(bool shown
);
131 /** Increases the size of the current set view mode. */
134 /** Decreases the size of the current set view mode. */
137 /** Resets the size of the current set view mode to default. */
140 /** Switches between a separate sorting and a mixed sorting of files and folders. */
141 void toggleSortFoldersFirst();
144 * Updates the state of the 'Sort Ascending/Descending' action.
146 void slotSortOrderChanged(Qt::SortOrder order
);
149 * Updates the state of the 'Sort Folders First' action.
151 void slotSortFoldersFirstChanged(bool foldersFirst
);
154 * Switches between showing hidden files last or not.
156 void toggleSortHiddenLast();
159 * Updates the state of the 'Sort Hidden Last' action.
161 void slotSortHiddenLastChanged(bool hiddenLast
);
164 * Updates the state of the 'Sort by' actions.
166 void slotSortRoleChanged(const QByteArray
&role
);
169 * Updates the state of the 'Group Ascending/Descending' action.
171 void slotGroupOrderChanged(Qt::SortOrder order
);
174 * Updates the state of the 'Group by' actions.
176 void slotGroupRoleChanged(const QByteArray
&role
);
179 * Updates the state of the 'Zoom In' and 'Zoom Out' actions.
181 void slotZoomLevelChanged(int current
, int previous
);
184 * Switches on or off the displaying of additional information
185 * as specified by \a action.
187 void toggleVisibleRole(QAction
*action
);
190 * Changes the sorting of the current view.
192 void slotSortTriggered(QAction
*);
195 * Updates the state of the 'Additional Information' actions.
197 void slotVisibleRolesChanged(const QList
<QByteArray
> ¤t
, const QList
<QByteArray
> &previous
);
200 * Changes the grouping of the current view.
202 void slotGroupTriggered(QAction
*);
205 * Switches between sorting by groups or not.
207 void toggleGroupedSorting(bool);
210 * Updates the state of the 'Categorized sorting' menu action.
212 void slotGroupedSortingChanged(bool sortCategorized
);
215 * Switches between showing and hiding of hidden marked files
217 void toggleShowHiddenFiles(bool);
220 * Updates the state of the 'Show hidden files' menu action.
222 void slotHiddenFilesShownChanged(bool shown
);
225 * Updates the state of the 'Create Folder...' action.
227 void slotWriteStateChanged(bool isFolderWritable
);
230 * Opens the view properties dialog, which allows to modify the properties
231 * of the currently active view.
233 void slotAdjustViewProperties();
236 * Begins a duplicate operation on the selected files
238 void slotDuplicate();
241 * Connected to the "properties" action.
242 * Opens the properties dialog for the selected items of the
243 * active view. The properties dialog shows information
244 * like name, size and permissions.
246 void slotProperties();
249 * Copies the path of the first selected KFileItem into Clipboard.
254 * Changes the name of the menu that contains basic actions like "Copy", "Rename", ...
255 * The name is changed to something like "Actions for 3 Selected Items" to be extra
256 * explicit of how these basic actions are used.
258 void slotSelectionChanged(const KFileItemList
&selection
);
262 * Create all the actions.
263 * This is called only once (by the constructor)
265 void createActions(SelectionMode::ActionTextHelper
*actionTextHelper
);
268 * Creates an action-group out of all roles from KFileItemModel.
269 * Dependent on the group-prefix either a radiobutton-group is
270 * created for sorting (prefix is "sort_by_") or a checkbox-group
271 * is created for additional information (prefix is "show_").
272 * The changes of actions are reported to slotSortTriggered() or
273 * toggleAdditionalInfo().
275 QActionGroup
*createFileItemRolesActionGroup(const QString
&groupPrefix
);
278 * Returns the "switch to icons mode" action.
279 * Helper method for createActions();
281 KToggleAction
*iconsModeAction();
284 * Returns the "switch to compact mode" action.
285 * Helper method for createActions();
287 KToggleAction
*compactModeAction();
290 * Returns the "switch to details mode" action.
291 * Helper method for createActions();
293 KToggleAction
*detailsModeAction();
295 KActionCollection
*m_actionCollection
;
296 DolphinView
*m_currentView
;
298 QHash
<QByteArray
, KToggleAction
*> m_sortByActions
;
299 QHash
<QByteArray
, KToggleAction
*> m_groupByActions
;
300 QHash
<QByteArray
, KToggleAction
*> m_visibleRoles
;
303 #endif /* DOLPHINVIEWACTIONHANDLER_H */