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
;
24 * @short Handles all actions for DolphinView
26 * The action handler owns all the actions and slots related to DolphinView,
27 * but the view that it acts upon can be switched to another one
28 * (this is used in the case of split views).
30 * The purpose of this class is also to share this code between DolphinMainWindow
34 * @see DolphinMainWindow
37 class DOLPHIN_EXPORT DolphinViewActionHandler
: public QObject
42 explicit DolphinViewActionHandler(KActionCollection
* collection
, QObject
* parent
);
45 * Sets the view that this action handler should work on.
47 void setCurrentView(DolphinView
* view
);
50 * Returns the view that this action handler should work on.
52 DolphinView
* currentView();
55 * Returns the name of the action for the current viewmode
57 QString
currentViewModeActionName() const;
60 * Returns m_actionCollection
62 KActionCollection
* actionCollection();
66 * Update all actions in the 'View' menu, i.e. those that depend on the
67 * settings in the current view.
69 void updateViewActions();
73 * Emitted by DolphinViewActionHandler when the user triggered an action.
74 * This is only used for clearing the statusbar in DolphinMainWindow.
76 void actionBeingHandled();
79 * Emitted if the user requested creating a new directory by the F10 key.
80 * The receiver of the signal (DolphinMainWindow or DolphinPart) invokes
81 * the method createDirectory of their KNewFileMenu instance.
83 void createDirectoryTriggered();
87 * Emitted when the user requested a change of view mode
89 void slotViewModeActionTriggered(QAction
*);
92 * Let the user input a name for the selected item(s) and trigger
93 * a renaming afterwards.
98 * Moves the selected items of the active view to the trash.
99 * This methods adds "shift means del" handling.
101 void slotTrashActivated();
104 * Deletes the selected items of the active view.
106 void slotDeleteItems();
109 * Switches between showing a preview of the file content and showing the icon.
111 void togglePreview(bool);
113 /** Updates the state of the 'Show preview' menu action. */
114 void slotPreviewsShownChanged(bool shown
);
116 /** Increases the size of the current set view mode. */
119 /** Decreases the size of the current set view mode. */
122 /** Resets the size of the current set view mode to default. */
125 /** Switches between a separate sorting and a mixed sorting of files and folders. */
126 void toggleSortFoldersFirst();
129 * Updates the state of the 'Sort Ascending/Descending' action.
131 void slotSortOrderChanged(Qt::SortOrder order
);
134 * Updates the state of the 'Sort Folders First' action.
136 void slotSortFoldersFirstChanged(bool foldersFirst
);
139 * Updates the state of the 'Sort by' actions.
141 void slotSortRoleChanged(const QByteArray
& role
);
144 * Updates the state of the 'Zoom In' and 'Zoom Out' actions.
146 void slotZoomLevelChanged(int current
, int previous
);
149 * Switches on or off the displaying of additional information
150 * as specified by \a action.
152 void toggleVisibleRole(QAction
* action
);
155 * Changes the sorting of the current view.
157 void slotSortTriggered(QAction
*);
160 * Updates the state of the 'Additional Information' actions.
162 void slotVisibleRolesChanged(const QList
<QByteArray
>& current
,
163 const QList
<QByteArray
>& previous
);
166 * Switches between sorting by groups or not.
168 void toggleGroupedSorting(bool);
171 * Updates the state of the 'Categorized sorting' menu action.
173 void slotGroupedSortingChanged(bool sortCategorized
);
176 * Switches between showing and hiding of hidden marked files
178 void toggleShowHiddenFiles(bool);
181 * Updates the state of the 'Show hidden files' menu action.
183 void slotHiddenFilesShownChanged(bool shown
);
186 * Updates the state of the 'Create Folder...' action.
188 void slotWriteStateChanged(bool isFolderWritable
);
191 * Opens the view properties dialog, which allows to modify the properties
192 * of the currently active view.
194 void slotAdjustViewProperties();
197 * Begins a duplicate operation on the selected files
199 void slotDuplicate();
202 * Connected to the "properties" action.
203 * Opens the properties dialog for the selected items of the
204 * active view. The properties dialog shows information
205 * like name, size and permissions.
207 void slotProperties();
210 * Copies the path of the first selected KFileItem into Clipboard.
216 * Create all the actions.
217 * This is called only once (by the constructor)
219 void createActions();
222 * Creates an action-group out of all roles from KFileItemModel.
223 * Dependent on the group-prefix either a radiobutton-group is
224 * created for sorting (prefix is "sort_by_") or a checkbox-group
225 * is created for additional information (prefix is "show_").
226 * The changes of actions are reported to slotSortTriggered() or
227 * toggleAdditionalInfo().
229 QActionGroup
* createFileItemRolesActionGroup(const QString
& groupPrefix
);
232 * Returns the "switch to icons mode" action.
233 * Helper method for createActions();
235 KToggleAction
* iconsModeAction();
238 * Returns the "switch to compact mode" action.
239 * Helper method for createActions();
241 KToggleAction
* compactModeAction();
244 * Returns the "switch to details mode" action.
245 * Helper method for createActions();
247 KToggleAction
* detailsModeAction();
249 KActionCollection
* m_actionCollection
;
250 DolphinView
* m_currentView
;
252 QHash
<QByteArray
, KToggleAction
*> m_sortByActions
;
253 QHash
<QByteArray
, KToggleAction
*> m_visibleRoles
;
256 #endif /* DOLPHINVIEWACTIONHANDLER_H */