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> *
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. *
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. *
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 ***************************************************************************/
22 #ifndef DOLPHIN_MAINWINDOW_H
23 #define DOLPHIN_MAINWINDOW_H
25 #include "dolphinview.h"
27 #include <kmainwindow.h>
28 #include <ksortablelist.h>
29 #include <konq_undo.h>
33 class DolphinApplication
;
39 * @short Main window for Dolphin.
41 * Handles the menus, toolbars and Dolphin views.
43 class DolphinMainWindow
: public KMainWindow
46 Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
47 Q_PROPERTY(int id READ getId SCRIPTABLE
true)
48 friend class DolphinApplication
;
51 virtual ~DolphinMainWindow();
54 * Activates the given view, which means that
55 * all menu actions are applied to this view. When
56 * having a split view setup the nonactive view
57 * is usually shown in darker colors.
59 void setActiveView(DolphinView
* view
);
62 * Returns the currently active view. See
63 * DolphinMainWindow::setActiveView() for more details.
65 DolphinView
* activeView() const { return m_activeView
; }
68 * Handles the dropping of URLs to the given
69 * destination. A context menu with the options
70 * 'Move Here', 'Copy Here', 'Link Here' and
71 * 'Cancel' is offered to the user.
72 * @param urls List of URLs which have been
74 * @param destination Destination URL, where the
75 * list or URLs should be moved,
76 * copied or linked to.
78 void dropUrls(const KUrl::List
& urls
,
79 const KUrl
& destination
);
81 /** Renames the item represented by \a oldUrl to \a newUrl. */
82 void rename(const KUrl
& oldUrl
, const KUrl
& newUrl
);
85 * Refreshs the views of the main window by recreating them dependent from
86 * the given Dolphin settings.
91 * Returns the 'Create New...' sub menu which also can be shared
92 * with other menus (e. g. a context menu).
94 KNewMenu
* newMenu() const { return m_newMenu
; }
98 * Returns the main window ID used through DBus.
100 int getId() const { return m_id
; }
103 * Changes the URL of the current active DolphinView to \a url.
105 void changeUrl(const QString
& url
);
107 /** Stores all settings and quits Dolphin. */
112 * Is send if the active view has been changed in
113 * the split view mode.
115 void activeViewChanged();
118 * Is send if the selection of the currently active view has
121 void selectionChanged();
124 /** @see QMainWindow::closeEvent */
125 virtual void closeEvent(QCloseEvent
* event
);
128 * This method is called when it is time for the app to save its
129 * properties for session management purposes.
131 void saveProperties(KConfig
*);
134 * This method is called when this app is restored. The KConfig
135 * object points to the session management config file that was saved
136 * with @ref saveProperties
138 void readProperties(KConfig
*);
141 /** Updates the 'Create New...' sub menu. */
142 void updateNewMenu();
145 * Let the user input a name for the selected item(s) and trigger
146 * a renaming afterwards.
150 /** Moves the selected items of the active view to the trash. */
153 /** Deletes the selected items of the active view. */
157 * Opens the properties window for the selected items of the
158 * active view. The properties windows shows informations
159 * like name, size and permissions.
164 * Shows the error information of the job \a job
167 void slotHandleJobError(KJob
* job
);
170 * Indicates in the status bar that the delete operation
171 * of the job \a job has been finished.
173 void slotDeleteFileFinished(KJob
* job
);
176 * Updates the state of the 'Undo' menu action dependent
177 * from the parameter \a available.
179 void slotUndoAvailable(bool available
);
181 /** Sets the text of the 'Undo' menu action to \a text. */
182 void slotUndoTextChanged(const QString
& text
);
184 /** Performs the current undo operation. */
188 * Copies all selected items to the clipboard and marks
189 * the items as cutted.
193 /** Copies all selected items to the clipboard. */
196 /** Pastes the clipboard data to the active view. */
200 * Updates the text of the paste action dependent from
201 * the number of items which are in the clipboard.
203 void updatePasteAction();
205 /** Selects all items from the active view. */
209 * Inverts the selection of all items of the active view:
210 * Selected items get nonselected and nonselected items get
213 void invertSelection();
215 /** The current active view is switched to the icons mode. */
218 /** The current active view is switched to the details mode. */
219 void setDetailsView();
221 /** The sorting of the current view should be done by the name. */
224 /** The sorting of the current view should be done by the size. */
227 /** The sorting of the current view should be done by the date. */
230 /** The sorting of the current view should be done by the permissions. */
231 void sortByPermissions();
233 /** The sorting of the current view should be done by the owner. */
236 /** The sorting of the current view should be done by the group. */
239 /** Switches between an ascending and descending sorting order. */
240 void toggleSortOrder();
243 * Clears any additional information for an item except for the
248 /** Shows the MIME type as additional information for the item. */
251 /** Shows the size as additional information for the item. */
254 /** Shows the date as additional information for the item. */
258 * Switches between one and two views:
259 * If one view is visible, it will get split into two views.
260 * If already two views are visible, the nonactivated view gets closed.
262 void toggleSplitView();
264 /** Reloads the current active view. */
267 /** Stops the loading process for the current active view. */
270 /** Switches between showing a preview of the file content and showing the icon. */
271 void togglePreview();
274 * Switches between showing and hiding of hidden marked files dependent
275 * from the current state of the 'Show Hidden Files' menu toggle action.
277 void toggleShowHiddenFiles();
280 * Switches between showing and hiding of the filter bar dependent
281 * from the current state of the 'Show Filter Bar' menu toggle action.
283 void showFilterBar();
285 /** Increases the size of the current set view mode. */
288 /** Decreases the size of the current set view mode. */
292 * Toggles between edit and brose mode of the navigation bar.
294 void toggleEditLocation();
297 * Switches to the edit mode of the navigation bar. If the edit mode is
298 * already active, it is assured that the navigation bar get focused.
303 * Opens the view properties dialog, which allows to modify the properties
304 * of the currently active view.
306 void adjustViewProperties();
308 /** Goes back on step of the URL history. */
311 /** Goes forward one step of the URL history. */
314 /** Goes up one hierarchy of the current URL. */
317 /** Goes to the home URL. */
320 /** Opens a terminal for the current shown directory. */
323 /** Opens KFind for the current shown directory. */
326 /** Opens Kompare for 2 selected files. */
329 /** Opens the settings dialog for Dolphin. */
332 /** Updates the state of all 'View' menu actions. */
333 void slotViewModeChanged();
335 /** Updates the state of the 'Show preview' menu action. */
336 void slotShowPreviewChanged();
338 /** Updates the state of the 'Show hidden files' menu action. */
339 void slotShowHiddenFilesChanged();
341 /** Updates the state of the 'Sort by' actions. */
342 void slotSortingChanged(DolphinView::Sorting sorting
);
344 /** Updates the state of the 'Sort Ascending/Descending' action. */
345 void slotSortOrderChanged(Qt::SortOrder order
);
347 /** Updates the state of the 'Additional Information' actions. */
348 void slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation info
);
350 /** Updates the state of the 'Edit' menu actions. */
351 void slotSelectionChanged();
354 * Updates the state of the 'Back' and 'Forward' menu
355 * actions corresponding the the current history.
357 void slotHistoryChanged();
360 * Updates the caption of the main window and the state
361 * of all menu actions which depend from a changed URL.
363 void slotUrlChanged(const KUrl
& url
);
365 /** Updates the state of the 'Show filter bar' menu action. */
366 void updateFilterBarAction(bool show
);
368 /** Open a new main window. */
369 void openNewMainWindow();
372 DolphinMainWindow(int id
);
378 void setupDockWidgets();
379 void updateHistory();
380 void updateEditActions();
381 void updateViewActions();
382 void updateGoActions();
383 void copyUrls(const KUrl::List
& source
, const KUrl
& dest
);
384 void moveUrls(const KUrl::List
& source
, const KUrl
& dest
);
385 void linkUrls(const KUrl::List
& source
, const KUrl
& dest
);
386 void clearStatusBar();
389 * Connects the signals from the created DolphinView with
390 * the index \a viewIndex with the corresponding slots of
391 * the DolphinMainWindow. This method must be invoked each
392 * time a DolphinView has been created.
394 void connectViewSignals(int viewIndex
);
398 * DolphinMainWindowsupports only one or two views, which
399 * are handled internally as primary and secondary view.
408 * Implements a custom error handling for the undo manager. This
409 * assures that all errors are shown in the status bar of Dolphin
410 * instead as modal error dialog with an OK button.
412 class UndoUiInterface
: public KonqUndoManager::UiInterface
415 UndoUiInterface(DolphinMainWindow
* mainWin
);
416 virtual ~UndoUiInterface();
417 virtual void jobError(KIO::Job
* job
);
420 DolphinMainWindow
* m_mainWin
;
424 QSplitter
* m_splitter
;
425 DolphinView
* m_activeView
;
428 DolphinView
* m_view
[SecondaryIdx
+ 1];
430 /// remember pending undo operations until they are finished
431 QList
<KonqUndoManager::CommandType
> m_undoCommandTypes
;
434 #endif // DOLPHIN_MAINWINDOW_H