]> cloud.milkyroute.net Git - dolphin.git/blob - src/views/dolphinviewactionhandler.h
Revert "Revert "Configurable Show hidden files and folders last toggle""
[dolphin.git] / src / views / dolphinviewactionhandler.h
1 /*
2 * SPDX-FileCopyrightText: 2008 David Faure <faure@kde.org>
3 * SPDX-FileCopyrightText: 2012 Peter Penz <peter.penz19@gmail.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
8
9 #ifndef DOLPHINVIEWACTIONHANDLER_H
10 #define DOLPHINVIEWACTIONHANDLER_H
11
12 #include "dolphin_export.h"
13 #include "views/dolphinview.h"
14
15 #include <QObject>
16
17 class KToggleAction;
18 class QAction;
19 class QActionGroup;
20 class DolphinView;
21 class KActionCollection;
22 class KFileItemList;
23
24 /**
25 * @short Handles all actions for DolphinView
26 *
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).
30 *
31 * The purpose of this class is also to share this code between DolphinMainWindow
32 * and DolphinPart.
33 *
34 * @see DolphinView
35 * @see DolphinMainWindow
36 * @see DolphinPart
37 */
38 class DOLPHIN_EXPORT DolphinViewActionHandler : public QObject
39 {
40 Q_OBJECT
41
42 public:
43 explicit DolphinViewActionHandler(KActionCollection* collection, QObject* parent);
44
45 /**
46 * Sets the view that this action handler should work on.
47 */
48 void setCurrentView(DolphinView* view);
49
50 /**
51 * Returns the view that this action handler should work on.
52 */
53 DolphinView* currentView();
54
55 /**
56 * Returns the name of the action for the current viewmode
57 */
58 QString currentViewModeActionName() const;
59
60 /**
61 * Returns m_actionCollection
62 */
63 KActionCollection* actionCollection();
64
65 public Q_SLOTS:
66 /**
67 * Update all actions in the 'View' menu, i.e. those that depend on the
68 * settings in the current view.
69 */
70 void updateViewActions();
71
72 Q_SIGNALS:
73 /**
74 * Emitted by DolphinViewActionHandler when the user triggered an action.
75 * This is only used for clearing the statusbar in DolphinMainWindow.
76 */
77 void actionBeingHandled();
78
79 /**
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.
83 */
84 void createDirectoryTriggered();
85
86 private Q_SLOTS:
87 /**
88 * Emitted when the user requested a change of view mode
89 */
90 void slotViewModeActionTriggered(QAction*);
91
92 /**
93 * Let the user input a name for the selected item(s) and trigger
94 * a renaming afterwards.
95 */
96 void slotRename();
97
98 /**
99 * Moves the selected items of the active view to the trash.
100 * This methods adds "shift means del" handling.
101 */
102 void slotTrashActivated();
103
104 /**
105 * Deletes the selected items of the active view.
106 */
107 void slotDeleteItems();
108
109 /**
110 * Switches between showing a preview of the file content and showing the icon.
111 */
112 void togglePreview(bool);
113
114 /** Updates the state of the 'Show preview' menu action. */
115 void slotPreviewsShownChanged(bool shown);
116
117 /** Increases the size of the current set view mode. */
118 void zoomIn();
119
120 /** Decreases the size of the current set view mode. */
121 void zoomOut();
122
123 /** Resets the size of the current set view mode to default. */
124 void zoomReset();
125
126 /** Switches between a separate sorting and a mixed sorting of files and folders. */
127 void toggleSortFoldersFirst();
128
129 /**
130 * Updates the state of the 'Sort Ascending/Descending' action.
131 */
132 void slotSortOrderChanged(Qt::SortOrder order);
133
134 /**
135 * Updates the state of the 'Sort Folders First' action.
136 */
137 void slotSortFoldersFirstChanged(bool foldersFirst);
138
139 /**
140 * Switches between showing hidden files last or not.
141 */
142 void toggleSortHiddenLast();
143
144 /**
145 * Updates the state of the 'Sort Hidden Last' action.
146 */
147 void slotSortHiddenLastChanged(bool hiddenLast);
148
149 /**
150 * Updates the state of the 'Sort by' actions.
151 */
152 void slotSortRoleChanged(const QByteArray& role);
153
154 /**
155 * Updates the state of the 'Zoom In' and 'Zoom Out' actions.
156 */
157 void slotZoomLevelChanged(int current, int previous);
158
159 /**
160 * Switches on or off the displaying of additional information
161 * as specified by \a action.
162 */
163 void toggleVisibleRole(QAction* action);
164
165 /**
166 * Changes the sorting of the current view.
167 */
168 void slotSortTriggered(QAction*);
169
170 /**
171 * Updates the state of the 'Additional Information' actions.
172 */
173 void slotVisibleRolesChanged(const QList<QByteArray>& current,
174 const QList<QByteArray>& previous);
175
176 /**
177 * Switches between sorting by groups or not.
178 */
179 void toggleGroupedSorting(bool);
180
181 /**
182 * Updates the state of the 'Categorized sorting' menu action.
183 */
184 void slotGroupedSortingChanged(bool sortCategorized);
185
186 /**
187 * Switches between showing and hiding of hidden marked files
188 */
189 void toggleShowHiddenFiles(bool);
190
191 /**
192 * Updates the state of the 'Show hidden files' menu action.
193 */
194 void slotHiddenFilesShownChanged(bool shown);
195
196 /**
197 * Updates the state of the 'Create Folder...' action.
198 */
199 void slotWriteStateChanged(bool isFolderWritable);
200
201 /**
202 * Opens the view properties dialog, which allows to modify the properties
203 * of the currently active view.
204 */
205 void slotAdjustViewProperties();
206
207 /**
208 * Begins a duplicate operation on the selected files
209 */
210 void slotDuplicate();
211
212 /**
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.
217 */
218 void slotProperties();
219
220 /**
221 * Copies the path of the first selected KFileItem into Clipboard.
222 */
223 void slotCopyPath();
224
225 /**
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.
229 */
230 void slotSelectionChanged(const KFileItemList& selection);
231
232 private:
233 /**
234 * Create all the actions.
235 * This is called only once (by the constructor)
236 */
237 void createActions();
238
239 /**
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().
246 */
247 QActionGroup* createFileItemRolesActionGroup(const QString& groupPrefix);
248
249 /**
250 * Returns the "switch to icons mode" action.
251 * Helper method for createActions();
252 */
253 KToggleAction* iconsModeAction();
254
255 /**
256 * Returns the "switch to compact mode" action.
257 * Helper method for createActions();
258 */
259 KToggleAction* compactModeAction();
260
261 /**
262 * Returns the "switch to details mode" action.
263 * Helper method for createActions();
264 */
265 KToggleAction* detailsModeAction();
266
267 KActionCollection* m_actionCollection;
268 DolphinView* m_currentView;
269
270 QHash<QByteArray, KToggleAction*> m_sortByActions;
271 QHash<QByteArray, KToggleAction*> m_visibleRoles;
272 };
273
274 #endif /* DOLPHINVIEWACTIONHANDLER_H */