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 "views/dolphinview.h"
21 class KActionCollection
;
25 * @short Handles all actions for DolphinView
27 * The action handler owns all the actions and slots related to DolphinView,
28 * but the view that it acts upon can be switched to another one
29 * (this is used in the case of split views).
31 * The purpose of this class is also to share this code between DolphinMainWindow
35 * @see DolphinMainWindow
38 class DOLPHIN_EXPORT DolphinViewActionHandler
: public QObject
43 explicit DolphinViewActionHandler(KActionCollection
* collection
, QObject
* parent
);
46 * Sets the view that this action handler should work on.
48 void setCurrentView(DolphinView
* view
);
51 * Returns the view that this action handler should work on.
53 DolphinView
* currentView();
56 * Returns the name of the action for the current viewmode
58 QString
currentViewModeActionName() const;
61 * Returns m_actionCollection
63 KActionCollection
* actionCollection();
67 * Update all actions in the 'View' menu, i.e. those that depend on the
68 * settings in the current view.
70 void updateViewActions();
74 * Emitted by DolphinViewActionHandler when the user triggered an action.
75 * This is only used for clearing the statusbar in DolphinMainWindow.
77 void actionBeingHandled();
80 * Emitted if the user requested creating a new directory by the F10 key.
81 * The receiver of the signal (DolphinMainWindow or DolphinPart) invokes
82 * the method createDirectory of their KNewFileMenu instance.
84 void createDirectoryTriggered();
88 * Emitted when the user requested a change of view mode
90 void slotViewModeActionTriggered(QAction
*);
93 * Let the user input a name for the selected item(s) and trigger
94 * a renaming afterwards.
99 * Moves the selected items of the active view to the trash.
100 * This methods adds "shift means del" handling.
102 void slotTrashActivated();
105 * Deletes the selected items of the active view.
107 void slotDeleteItems();
110 * Switches between showing a preview of the file content and showing the icon.
112 void togglePreview(bool);
114 /** Updates the state of the 'Show preview' menu action. */
115 void slotPreviewsShownChanged(bool shown
);
117 /** Increases the size of the current set view mode. */
120 /** Decreases the size of the current set view mode. */
123 /** Resets the size of the current set view mode to default. */
126 /** Switches between a separate sorting and a mixed sorting of files and folders. */
127 void toggleSortFoldersFirst();
130 * Updates the state of the 'Sort Ascending/Descending' action.
132 void slotSortOrderChanged(Qt::SortOrder order
);
135 * Updates the state of the 'Sort Folders First' action.
137 void slotSortFoldersFirstChanged(bool foldersFirst
);
140 * Updates the state of the 'Sort by' actions.
142 void slotSortRoleChanged(const QByteArray
& role
);
145 * Updates the state of the 'Zoom In' and 'Zoom Out' actions.
147 void slotZoomLevelChanged(int current
, int previous
);
150 * Switches on or off the displaying of additional information
151 * as specified by \a action.
153 void toggleVisibleRole(QAction
* action
);
156 * Changes the sorting of the current view.
158 void slotSortTriggered(QAction
*);
161 * Updates the state of the 'Additional Information' actions.
163 void slotVisibleRolesChanged(const QList
<QByteArray
>& current
,
164 const QList
<QByteArray
>& previous
);
167 * Switches between sorting by groups or not.
169 void toggleGroupedSorting(bool);
172 * Updates the state of the 'Categorized sorting' menu action.
174 void slotGroupedSortingChanged(bool sortCategorized
);
177 * Switches between showing and hiding of hidden marked files
179 void toggleShowHiddenFiles(bool);
182 * Updates the state of the 'Show hidden files' menu action.
184 void slotHiddenFilesShownChanged(bool shown
);
187 * Updates the state of the 'Create Folder...' action.
189 void slotWriteStateChanged(bool isFolderWritable
);
192 * Opens the view properties dialog, which allows to modify the properties
193 * of the currently active view.
195 void slotAdjustViewProperties();
198 * Begins a duplicate operation on the selected files
200 void slotDuplicate();
203 * Connected to the "properties" action.
204 * Opens the properties dialog for the selected items of the
205 * active view. The properties dialog shows information
206 * like name, size and permissions.
208 void slotProperties();
211 * Copies the path of the first selected KFileItem into Clipboard.
216 * Changes the name of the menu that contains basic actions like "Copy", "Rename", ...
217 * The name is changed to something like "Actions for 3 Selected Items" to be extra
218 * explicit of how these basic actions are used.
220 void slotSelectionChanged(const KFileItemList
& selection
);
224 * Create all the actions.
225 * This is called only once (by the constructor)
227 void createActions();
230 * Creates an action-group out of all roles from KFileItemModel.
231 * Dependent on the group-prefix either a radiobutton-group is
232 * created for sorting (prefix is "sort_by_") or a checkbox-group
233 * is created for additional information (prefix is "show_").
234 * The changes of actions are reported to slotSortTriggered() or
235 * toggleAdditionalInfo().
237 QActionGroup
* createFileItemRolesActionGroup(const QString
& groupPrefix
);
240 * Returns the "switch to icons mode" action.
241 * Helper method for createActions();
243 KToggleAction
* iconsModeAction();
246 * Returns the "switch to compact mode" action.
247 * Helper method for createActions();
249 KToggleAction
* compactModeAction();
252 * Returns the "switch to details mode" action.
253 * Helper method for createActions();
255 KToggleAction
* detailsModeAction();
257 KActionCollection
* m_actionCollection
;
258 DolphinView
* m_currentView
;
260 QHash
<QByteArray
, KToggleAction
*> m_sortByActions
;
261 QHash
<QByteArray
, KToggleAction
*> m_visibleRoles
;
264 #endif /* DOLPHINVIEWACTIONHANDLER_H */