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 * Switches between showing hidden files last or not.
142 void toggleSortHiddenLast();
145 * Updates the state of the 'Sort Hidden Last' action.
147 void slotSortHiddenLastChanged(bool hiddenLast
);
150 * Updates the state of the 'Sort by' actions.
152 void slotSortRoleChanged(const QByteArray
& role
);
155 * Updates the state of the 'Zoom In' and 'Zoom Out' actions.
157 void slotZoomLevelChanged(int current
, int previous
);
160 * Switches on or off the displaying of additional information
161 * as specified by \a action.
163 void toggleVisibleRole(QAction
* action
);
166 * Changes the sorting of the current view.
168 void slotSortTriggered(QAction
*);
171 * Updates the state of the 'Additional Information' actions.
173 void slotVisibleRolesChanged(const QList
<QByteArray
>& current
,
174 const QList
<QByteArray
>& previous
);
177 * Switches between sorting by groups or not.
179 void toggleGroupedSorting(bool);
182 * Updates the state of the 'Categorized sorting' menu action.
184 void slotGroupedSortingChanged(bool sortCategorized
);
187 * Switches between showing and hiding of hidden marked files
189 void toggleShowHiddenFiles(bool);
192 * Updates the state of the 'Show hidden files' menu action.
194 void slotHiddenFilesShownChanged(bool shown
);
197 * Updates the state of the 'Create Folder...' action.
199 void slotWriteStateChanged(bool isFolderWritable
);
202 * Opens the view properties dialog, which allows to modify the properties
203 * of the currently active view.
205 void slotAdjustViewProperties();
208 * Begins a duplicate operation on the selected files
210 void slotDuplicate();
213 * Connected to the "properties" action.
214 * Opens the properties dialog for the selected items of the
215 * active view. The properties dialog shows information
216 * like name, size and permissions.
218 void slotProperties();
221 * Copies the path of the first selected KFileItem into Clipboard.
226 * Changes the name of the menu that contains basic actions like "Copy", "Rename", ...
227 * The name is changed to something like "Actions for 3 Selected Items" to be extra
228 * explicit of how these basic actions are used.
230 void slotSelectionChanged(const KFileItemList
& selection
);
234 * Create all the actions.
235 * This is called only once (by the constructor)
237 void createActions();
240 * Creates an action-group out of all roles from KFileItemModel.
241 * Dependent on the group-prefix either a radiobutton-group is
242 * created for sorting (prefix is "sort_by_") or a checkbox-group
243 * is created for additional information (prefix is "show_").
244 * The changes of actions are reported to slotSortTriggered() or
245 * toggleAdditionalInfo().
247 QActionGroup
* createFileItemRolesActionGroup(const QString
& groupPrefix
);
250 * Returns the "switch to icons mode" action.
251 * Helper method for createActions();
253 KToggleAction
* iconsModeAction();
256 * Returns the "switch to compact mode" action.
257 * Helper method for createActions();
259 KToggleAction
* compactModeAction();
262 * Returns the "switch to details mode" action.
263 * Helper method for createActions();
265 KToggleAction
* detailsModeAction();
267 KActionCollection
* m_actionCollection
;
268 DolphinView
* m_currentView
;
270 QHash
<QByteArray
, KToggleAction
*> m_sortByActions
;
271 QHash
<QByteArray
, KToggleAction
*> m_visibleRoles
;
274 #endif /* DOLPHINVIEWACTIONHANDLER_H */