]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinmainwindow.h
Cleanup of URL drop handling (simplified code, modifier keys work again). After furth...
[dolphin.git] / src / dolphinmainwindow.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
3 * Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com> *
4 * Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21
22 #ifndef _DOLPHIN_MAINWINDOW_H_
23 #define _DOLPHIN_MAINWINDOW_H_
24
25 #include "dolphinview.h"
26
27 #include <kmainwindow.h>
28 #include <ksortablelist.h>
29 #include <konq_operations.h>
30
31 #include <QList>
32
33 class KNewMenu;
34 class KPrinter;
35 class KUrl;
36 class QLineEdit;
37 class KFileIconView;
38 class KHBox;
39 class Q3IconViewItem;
40 class QSplitter;
41 class KAction;
42 class UrlNavigator;
43 class DolphinApplication;
44
45 /**
46 * @short Main window for Dolphin.
47 *
48 * Handles the menus, toolbars and Dolphin views.
49 *
50 * @author Peter Penz <peter.penz@gmx.at>
51 */
52 class DolphinMainWindow: public KMainWindow
53 {
54 Q_OBJECT
55 friend class DolphinApplication;
56 public:
57 virtual ~DolphinMainWindow();
58
59 /**
60 * Activates the given view, which means that
61 * all menu actions are applied to this view. When
62 * having a split view setup the nonactive view
63 * is usually shown in darker colors.
64 */
65 void setActiveView(DolphinView* view);
66
67 /**
68 * Returns the currently active view. See
69 * DolphinMainWindow::setActiveView() for more details.
70 */
71 DolphinView* activeView() const { return m_activeView; }
72
73 /**
74 * Handles the dropping of Urls to the given
75 * destination. A context menu with the options
76 * 'Move Here', 'Copy Here', 'Link Here' and
77 * 'Cancel' is offered to the user.
78 * @param urls List of Urls which have been
79 * dropped.
80 * @param destination Destination Url, where the
81 * list or Urls should be moved,
82 * copied or linked to.
83 */
84 void dropUrls(const KUrl::List& urls,
85 const KUrl& destination);
86
87 /**
88 * Refreshs the views of the main window by recreating them dependent from
89 * the given Dolphin settings.
90 */
91 void refreshViews();
92
93 /**
94 * Returns the 'Create New...' sub menu which also can be shared
95 * with other menus (e. g. a context menu).
96 */
97 KNewMenu* newMenu() const { return m_newMenu; }
98
99 signals:
100 /**
101 * Is send if the active view has been changed in
102 * the split view mode.
103 */
104 void activeViewChanged();
105
106 /**
107 * Is send if the selection of the currently active view has
108 * been changed.
109 */
110 void selectionChanged();
111
112 protected:
113 /** @see QMainWindow::closeEvent */
114 virtual void closeEvent(QCloseEvent* event);
115
116 /**
117 * This method is called when it is time for the app to save its
118 * properties for session management purposes.
119 */
120 void saveProperties(KConfig*);
121
122 /**
123 * This method is called when this app is restored. The KConfig
124 * object points to the session management config file that was saved
125 * with @ref saveProperties
126 */
127 void readProperties(KConfig*);
128
129 private slots:
130 /** Updates the 'Create New...' sub menu. */
131 void updateNewMenu();
132
133 /** Renames the selected item of the active view. */
134 void rename();
135
136 /** Moves the selected items of the active view to the trash. */
137 void moveToTrash();
138
139 /** Deletes the selected items of the active view. */
140 void deleteItems();
141
142 /**
143 * Opens the properties window for the selected items of the
144 * active view. The properties windows shows informations
145 * like name, size and permissions.
146 */
147 void properties();
148
149 /** Stores all settings and quits Dolphin. */
150 void quit();
151
152 /**
153 * Shows the error information of the job \a job
154 * in the status bar.
155 */
156 void slotHandleJobError(KJob* job);
157
158 /**
159 * Indicates in the status bar that the delete operation
160 * of the job \a job has been finished.
161 */
162 void slotDeleteFileFinished(KJob* job);
163
164 /**
165 * Updates the state of the 'Undo' menu action dependent
166 * from the parameter \a available.
167 */
168 void slotUndoAvailable(bool available);
169
170 /** Sets the text of the 'Undo' menu action to \a text. */
171 void slotUndoTextChanged(const QString& text);
172
173 /**
174 * Copies all selected items to the clipboard and marks
175 * the items as cutted.
176 */
177 void cut();
178
179 /** Copies all selected items to the clipboard. */
180 void copy();
181
182 /** Pastes the clipboard data to the active view. */
183 void paste();
184
185 /**
186 * Updates the text of the paste action dependent from
187 * the number of items which are in the clipboard.
188 */
189 void updatePasteAction();
190
191 /** Selects all items from the active view. */
192 void selectAll();
193
194 /**
195 * Inverts the selection of all items of the active view:
196 * Selected items get nonselected and nonselected items get
197 * selected.
198 */
199 void invertSelection();
200
201 /** The current active view is switched to the icons mode. */
202 void setIconsView();
203
204 /** The current active view is switched to the details mode. */
205 void setDetailsView();
206
207 /** The sorting of the current view should be done by the name. */
208 void sortByName();
209
210 /** The sorting of the current view should be done by the size. */
211 void sortBySize();
212
213 /** The sorting of the current view should be done by the date. */
214 void sortByDate();
215
216 /** Switches between an ascending and descending sorting order. */
217 void toggleSortOrder();
218
219 /**
220 * Switches between one and two views:
221 * If one view is visible, it will get split into two views.
222 * If already two views are visible, the nonactivated view gets closed.
223 */
224 void toggleSplitView();
225
226 /** Reloads the current active view. */
227 void reloadView();
228
229 /** Stops the loading process for the current active view. */
230 void stopLoading();
231
232 /** Switches between showing a preview of the file content and showing the icon. */
233 void togglePreview();
234
235 /**
236 * Switches between showing and hiding of hidden marked files dependent
237 * from the current state of the 'Show Hidden Files' menu toggle action.
238 */
239 void toggleShowHiddenFiles();
240
241 /**
242 * Switches between showing and hiding of the filter bar dependent
243 * from the current state of the 'Show Filter Bar' menu toggle action.
244 */
245 void showFilterBar();
246
247 /** Increases the size of the current set view mode. */
248 void zoomIn();
249
250 /** Decreases the size of the current set view mode. */
251 void zoomOut();
252
253 /**
254 * Toggles between edit and brose mode of the navigation bar.
255 */
256 void toggleEditLocation();
257
258 /**
259 * Switches to the edit mode of the navigation bar. If the edit mode is
260 * already active, it is assured that the navigation bar get focused.
261 */
262 void editLocation();
263
264 /**
265 * Opens the view properties dialog, which allows to modify the properties
266 * of the currently active view.
267 */
268 void adjustViewProperties();
269
270 /** Goes back on step of the Url history. */
271 void goBack();
272
273 /** Goes forward one step of the Url history. */
274 void goForward();
275
276 /** Goes up one hierarchy of the current Url. */
277 void goUp();
278
279 /** Goes to the home Url. */
280 void goHome();
281
282 /** Opens a terminal for the current shown directory. */
283 void openTerminal();
284
285 /** Opens KFind for the current shown directory. */
286 void findFile();
287
288 /** Opens Kompare for 2 selected files. */
289 void compareFiles();
290
291 /** Opens the settings dialog for Dolphin. */
292 void editSettings();
293
294 /** Updates the state of all 'View' menu actions. */
295 void slotViewModeChanged();
296
297 /** Updates the state of the 'Show hidden files' menu action. */
298 void slotShowHiddenFilesChanged();
299
300 /** Updates the state of the 'Sort by' actions. */
301 void slotSortingChanged(DolphinView::Sorting sorting);
302
303 /** Updates the state of the 'Sort Ascending/Descending' action. */
304 void slotSortOrderChanged(Qt::SortOrder order);
305
306 /** Updates the state of the 'Edit' menu actions. */
307 void slotSelectionChanged();
308
309 /**
310 * Updates the state of the 'Back' and 'Forward' menu
311 * actions corresponding the the current history.
312 */
313 void slotHistoryChanged();
314
315 /**
316 * Updates the caption of the main window and the state
317 * of all menu actions which depend from a changed Url.
318 */
319 void slotUrlChanged(const KUrl& url);
320
321 /** Updates the state of the 'Show filter bar' menu action. */
322 void updateFilterBarAction(bool show);
323
324 /** Open a new main window. */
325 void openNewMainWindow();
326
327 private:
328 DolphinMainWindow();
329 void init();
330 void loadSettings();
331
332 void setupAccel();
333 void setupActions();
334 void setupDockWidgets();
335 void updateHistory();
336 void updateEditActions();
337 void updateViewActions();
338 void updateGoActions();
339 void copyUrls(const KUrl::List& source, const KUrl& dest);
340 void moveUrls(const KUrl::List& source, const KUrl& dest);
341 void clearStatusBar();
342
343 /**
344 * Connects the signals from the created DolphinView with
345 * the index \a viewIndex with the corresponding slots of
346 * the DolphinMainWindow. This method must be invoked each
347 * time a DolphinView has been created.
348 */
349 void connectViewSignals(int viewIndex);
350
351 private:
352 KNewMenu* m_newMenu;
353 QSplitter* m_splitter;
354 DolphinView* m_activeView;
355
356 /**
357 * DolphinMainWindowsupports only one or two views, which
358 * are handled internally as primary and secondary view.
359 */
360 enum ViewIndex
361 {
362 PrimaryIdx = 0,
363 SecondaryIdx = 1
364 };
365 DolphinView* m_view[SecondaryIdx + 1];
366
367 /// remember pending undo operations until they are finished
368 QList<KonqOperations::Operation> m_undoOperations;
369
370 /** Contains meta information for creating files. */
371 struct CreateFileEntry
372 {
373 QString name;
374 QString filePath;
375 QString templatePath;
376 QString icon;
377 QString comment;
378 };
379 };
380
381 #endif // _DOLPHIN_H_
382