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>
42 class DolphinApplication
;
45 * @short Main window for Dolphin.
47 * Handles the menus, toolbars and Dolphin views.
49 class DolphinMainWindow
: public KMainWindow
52 Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
53 Q_PROPERTY(int id READ getId SCRIPTABLE
true)
54 friend class DolphinApplication
;
57 virtual ~DolphinMainWindow();
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.
65 void setActiveView(DolphinView
* view
);
68 * Returns the currently active view. See
69 * DolphinMainWindow::setActiveView() for more details.
71 DolphinView
* activeView() const { return m_activeView
; }
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
80 * @param destination Destination URL, where the
81 * list or URLs should be moved,
82 * copied or linked to.
84 void dropUrls(const KUrl::List
& urls
,
85 const KUrl
& destination
);
87 /** Renames the item represented by \a oldUrl to \a newUrl. */
88 void rename(const KUrl
& oldUrl
, const KUrl
& newUrl
);
91 * Refreshs the views of the main window by recreating them dependent from
92 * the given Dolphin settings.
97 * Returns the 'Create New...' sub menu which also can be shared
98 * with other menus (e. g. a context menu).
100 KNewMenu
* newMenu() const { return m_newMenu
; }
104 * Returns the main windows ID, mainly used throught DBus.
106 int getId() const { return m_id
; }
109 * Changes the URL of the current active DolphinView to \a url.
111 void changeUrl(const QString
& url
);
113 /** Stores all settings and quits Dolphin. */
118 * Is send if the active view has been changed in
119 * the split view mode.
121 void activeViewChanged();
124 * Is send if the selection of the currently active view has
127 void selectionChanged();
130 /** @see QMainWindow::closeEvent */
131 virtual void closeEvent(QCloseEvent
* event
);
134 * This method is called when it is time for the app to save its
135 * properties for session management purposes.
137 void saveProperties(KConfig
*);
140 * This method is called when this app is restored. The KConfig
141 * object points to the session management config file that was saved
142 * with @ref saveProperties
144 void readProperties(KConfig
*);
147 /** Updates the 'Create New...' sub menu. */
148 void updateNewMenu();
151 * Let the user input a name for the selected item(s) and trigger
152 * a renaming afterwards.
156 /** Moves the selected items of the active view to the trash. */
159 /** Deletes the selected items of the active view. */
163 * Opens the properties window for the selected items of the
164 * active view. The properties windows shows informations
165 * like name, size and permissions.
170 * Shows the error information of the job \a job
173 void slotHandleJobError(KJob
* job
);
176 * Indicates in the status bar that the delete operation
177 * of the job \a job has been finished.
179 void slotDeleteFileFinished(KJob
* job
);
182 * Updates the state of the 'Undo' menu action dependent
183 * from the parameter \a available.
185 void slotUndoAvailable(bool available
);
187 /** Sets the text of the 'Undo' menu action to \a text. */
188 void slotUndoTextChanged(const QString
& text
);
190 /** Performs the current undo operation. */
194 * Copies all selected items to the clipboard and marks
195 * the items as cutted.
199 /** Copies all selected items to the clipboard. */
202 /** Pastes the clipboard data to the active view. */
206 * Updates the text of the paste action dependent from
207 * the number of items which are in the clipboard.
209 void updatePasteAction();
211 /** Selects all items from the active view. */
215 * Inverts the selection of all items of the active view:
216 * Selected items get nonselected and nonselected items get
219 void invertSelection();
221 /** The current active view is switched to the icons mode. */
224 /** The current active view is switched to the details mode. */
225 void setDetailsView();
227 /** The sorting of the current view should be done by the name. */
230 /** The sorting of the current view should be done by the size. */
233 /** The sorting of the current view should be done by the date. */
236 /** The sorting of the current view should be done by the permissions. */
237 void sortByPermissions();
239 /** The sorting of the current view should be done by the owner. */
242 /** The sorting of the current view should be done by the group. */
245 /** Switches between an ascending and descending sorting order. */
246 void toggleSortOrder();
249 * Clears any additional information for an item except for the
254 /** Shows the MIME type as additional information for the item. */
257 /** Shows the size as additional information for the item. */
260 /** Shows the date as additional information for the item. */
264 * Switches between one and two views:
265 * If one view is visible, it will get split into two views.
266 * If already two views are visible, the nonactivated view gets closed.
268 void toggleSplitView();
270 /** Reloads the current active view. */
273 /** Stops the loading process for the current active view. */
276 /** Switches between showing a preview of the file content and showing the icon. */
277 void togglePreview();
280 * Switches between showing and hiding of hidden marked files dependent
281 * from the current state of the 'Show Hidden Files' menu toggle action.
283 void toggleShowHiddenFiles();
286 * Switches between showing and hiding of the filter bar dependent
287 * from the current state of the 'Show Filter Bar' menu toggle action.
289 void showFilterBar();
291 /** Increases the size of the current set view mode. */
294 /** Decreases the size of the current set view mode. */
298 * Toggles between edit and brose mode of the navigation bar.
300 void toggleEditLocation();
303 * Switches to the edit mode of the navigation bar. If the edit mode is
304 * already active, it is assured that the navigation bar get focused.
309 * Opens the view properties dialog, which allows to modify the properties
310 * of the currently active view.
312 void adjustViewProperties();
314 /** Goes back on step of the URL history. */
317 /** Goes forward one step of the URL history. */
320 /** Goes up one hierarchy of the current URL. */
323 /** Goes to the home URL. */
326 /** Opens a terminal for the current shown directory. */
329 /** Opens KFind for the current shown directory. */
332 /** Opens Kompare for 2 selected files. */
335 /** Opens the settings dialog for Dolphin. */
338 /** Updates the state of all 'View' menu actions. */
339 void slotViewModeChanged();
341 /** Updates the state of the 'Show preview' menu action. */
342 void slotShowPreviewChanged();
344 /** Updates the state of the 'Show hidden files' menu action. */
345 void slotShowHiddenFilesChanged();
347 /** Updates the state of the 'Sort by' actions. */
348 void slotSortingChanged(DolphinView::Sorting sorting
);
350 /** Updates the state of the 'Sort Ascending/Descending' action. */
351 void slotSortOrderChanged(Qt::SortOrder order
);
353 /** Updates the state of the 'Additional Information' actions. */
354 void slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation info
);
356 /** Updates the state of the 'Edit' menu actions. */
357 void slotSelectionChanged();
360 * Updates the state of the 'Back' and 'Forward' menu
361 * actions corresponding the the current history.
363 void slotHistoryChanged();
366 * Updates the caption of the main window and the state
367 * of all menu actions which depend from a changed URL.
369 void slotUrlChanged(const KUrl
& url
);
371 /** Updates the state of the 'Show filter bar' menu action. */
372 void updateFilterBarAction(bool show
);
374 /** Open a new main window. */
375 void openNewMainWindow();
378 DolphinMainWindow(int id
);
384 void setupDockWidgets();
385 void updateHistory();
386 void updateEditActions();
387 void updateViewActions();
388 void updateGoActions();
389 void copyUrls(const KUrl::List
& source
, const KUrl
& dest
);
390 void moveUrls(const KUrl::List
& source
, const KUrl
& dest
);
391 void linkUrls(const KUrl::List
& source
, const KUrl
& dest
);
392 void clearStatusBar();
395 * Connects the signals from the created DolphinView with
396 * the index \a viewIndex with the corresponding slots of
397 * the DolphinMainWindow. This method must be invoked each
398 * time a DolphinView has been created.
400 void connectViewSignals(int viewIndex
);
404 * DolphinMainWindowsupports only one or two views, which
405 * are handled internally as primary and secondary view.
414 * Implements a custom error handling for the undo manager. This
415 * assures that all errors are shown in the status bar of Dolphin
416 * instead as modal error dialog with an OK button.
418 class UndoUiInterface
: public KonqUndoManager::UiInterface
421 UndoUiInterface(DolphinMainWindow
* mainWin
);
422 virtual ~UndoUiInterface();
423 virtual void jobError(KIO::Job
* job
);
426 DolphinMainWindow
* m_mainWin
;
430 QSplitter
* m_splitter
;
431 DolphinView
* m_activeView
;
434 DolphinView
* m_view
[SecondaryIdx
+ 1];
436 /// remember pending undo operations until they are finished
437 QList
<KonqUndoManager::CommandType
> m_undoCommandTypes
;
440 #endif // _DOLPHIN_H_