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"
26 #include "sidebarpage.h"
28 #include <kmainwindow.h>
29 #include <ksortablelist.h>
30 #include <konq_undo.h>
34 class DolphinApplication
;
40 * @short Main window for Dolphin.
42 * Handles the menus, toolbars and Dolphin views.
44 class DolphinMainWindow
: public KMainWindow
47 Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
48 Q_PROPERTY(int id READ getId SCRIPTABLE
true)
49 friend class DolphinApplication
;
52 virtual ~DolphinMainWindow();
55 * Activates the given view, which means that
56 * all menu actions are applied to this view. When
57 * having a split view setup the nonactive view
58 * is usually shown in darker colors.
60 void setActiveView(DolphinView
* view
);
63 * Returns the currently active view. See
64 * DolphinMainWindow::setActiveView() for more details.
66 DolphinView
* activeView() const
71 /** Renames the item represented by \a oldUrl to \a newUrl. */
72 void rename(const KUrl
& oldUrl
, const KUrl
& newUrl
);
75 * Refreshs the views of the main window by recreating them dependent from
76 * the given Dolphin settings.
81 * Returns the 'Create New...' sub menu which also can be shared
82 * with other menus (e. g. a context menu).
84 KNewMenu
* newMenu() const
91 * Handles the dropping of URLs to the given
92 * destination. A context menu with the options
93 * 'Move Here', 'Copy Here', 'Link Here' and
94 * 'Cancel' is offered to the user.
95 * @param urls List of URLs which have been
97 * @param destination Destination URL, where the
98 * list or URLs should be moved,
99 * copied or linked to.
101 void dropUrls(const KUrl::List
& urls
,
102 const KUrl
& destination
);
105 * Returns the main window ID used through DBus.
113 * Inform all affected dolphin components (sidebars, views) of an URL
116 void changeUrl(const KUrl
& url
);
119 * Inform all affected dolphin components that a selection change is
122 void changeSelection(const KFileItemList
& selection
);
124 /** Stores all settings and quits Dolphin. */
129 * Is send if the active view has been changed in
130 * the split view mode.
132 void activeViewChanged();
135 * Is sent if the selection of the currently active view has
138 void selectionChanged(const KFileItemList
& selection
);
141 * Is sent if the url of the currently active view has
144 void urlChanged(const KUrl
& url
);
147 /** @see QMainWindow::closeEvent */
148 virtual void closeEvent(QCloseEvent
* event
);
151 * This method is called when it is time for the app to save its
152 * properties for session management purposes.
154 void saveProperties(KConfig
*);
157 * This method is called when this app is restored. The KConfig
158 * object points to the session management config file that was saved
159 * with @ref saveProperties
161 void readProperties(KConfig
*);
164 /** Updates the 'Create New...' sub menu. */
165 void updateNewMenu();
168 * Let the user input a name for the selected item(s) and trigger
169 * a renaming afterwards.
173 /** Moves the selected items of the active view to the trash. */
176 /** Deletes the selected items of the active view. */
180 * Opens the properties window for the selected items of the
181 * active view. The properties windows shows informations
182 * like name, size and permissions.
187 * Shows the error information of the job \a job
190 void slotHandleJobError(KJob
* job
);
193 * Indicates in the status bar that the delete operation
194 * of the job \a job has been finished.
196 void slotDeleteFileFinished(KJob
* job
);
199 * Updates the state of the 'Undo' menu action dependent
200 * from the parameter \a available.
202 void slotUndoAvailable(bool available
);
204 /** Sets the text of the 'Undo' menu action to \a text. */
205 void slotUndoTextChanged(const QString
& text
);
207 /** Performs the current undo operation. */
211 * Copies all selected items to the clipboard and marks
212 * the items as cutted.
216 /** Copies all selected items to the clipboard. */
219 /** Pastes the clipboard data to the active view. */
223 * Updates the text of the paste action dependent from
224 * the number of items which are in the clipboard.
226 void updatePasteAction();
228 /** Selects all items from the active view. */
232 * Inverts the selection of all items of the active view:
233 * Selected items get nonselected and nonselected items get
236 void invertSelection();
238 /** The current active view is switched to the icons mode. */
241 /** The current active view is switched to the details mode. */
242 void setDetailsView();
244 /** The current active view is switched to the column mode. */
245 void setColumnView();
247 /** The sorting of the current view should be done by the name. */
250 /** The sorting of the current view should be done by the size. */
253 /** The sorting of the current view should be done by the date. */
256 /** The sorting of the current view should be done by the permissions. */
257 void sortByPermissions();
259 /** The sorting of the current view should be done by the owner. */
262 /** The sorting of the current view should be done by the group. */
265 /** Switches between an ascending and descending sorting order. */
266 void toggleSortOrder();
268 /** Switches between sorting by categories or not. */
269 void toggleSortCategorization();
272 * Clears any additional information for an item except for the
277 /** Shows the MIME type as additional information for the item. */
280 /** Shows the size as additional information for the item. */
283 /** Shows the date as additional information for the item. */
287 * Switches between one and two views:
288 * If one view is visible, it will get split into two views.
289 * If already two views are visible, the nonactivated view gets closed.
291 void toggleSplitView();
293 /** Reloads the current active view. */
296 /** Stops the loading process for the current active view. */
299 /** Switches between showing a preview of the file content and showing the icon. */
300 void togglePreview();
303 * Switches between showing and hiding of hidden marked files dependent
304 * from the current state of the 'Show Hidden Files' menu toggle action.
306 void toggleShowHiddenFiles();
309 * Switches between showing and hiding of the filter bar dependent
310 * from the current state of the 'Show Filter Bar' menu toggle action.
312 void showFilterBar();
314 /** Increases the size of the current set view mode. */
317 /** Decreases the size of the current set view mode. */
321 * Toggles between edit and brose mode of the navigation bar.
323 void toggleEditLocation();
326 * Switches to the edit mode of the navigation bar. If the edit mode is
327 * already active, it is assured that the navigation bar get focused.
332 * Opens the view properties dialog, which allows to modify the properties
333 * of the currently active view.
335 void adjustViewProperties();
337 /** Goes back on step of the URL history. */
340 /** Goes forward one step of the URL history. */
343 /** Goes up one hierarchy of the current URL. */
346 /** Goes to the home URL. */
349 /** Opens a terminal for the current shown directory. */
352 /** Opens KFind for the current shown directory. */
355 /** Opens Kompare for 2 selected files. */
358 /** Opens the settings dialog for Dolphin. */
361 /** Updates the state of all 'View' menu actions. */
362 void slotViewModeChanged();
364 /** Updates the state of the 'Show preview' menu action. */
365 void slotShowPreviewChanged();
367 /** Updates the state of the 'Show hidden files' menu action. */
368 void slotShowHiddenFilesChanged();
370 /** Updates the state of the 'Categorized sorting' menu action. */
371 void slotCategorizedSortingChanged();
373 /** Updates the state of the 'Sort by' actions. */
374 void slotSortingChanged(DolphinView::Sorting sorting
);
376 /** Updates the state of the 'Sort Ascending/Descending' action. */
377 void slotSortOrderChanged(Qt::SortOrder order
);
379 /** Updates the state of the 'Additional Information' actions. */
380 void slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation info
);
382 /** Updates the state of the 'Edit' menu actions. */
383 void slotSelectionChanged(const KFileItemList
& selection
);
386 * Updates the state of the 'Back' and 'Forward' menu
387 * actions corresponding the the current history.
389 void slotHistoryChanged();
391 /** Updates the state of the 'Show filter bar' menu action. */
392 void updateFilterBarAction(bool show
);
394 /** Open a new main window. */
395 void openNewMainWindow();
398 DolphinMainWindow(int id
);
404 void setupDockWidgets();
405 void updateHistory();
406 void updateEditActions();
407 void updateViewActions();
408 void updateGoActions();
409 void copyUrls(const KUrl::List
& source
, const KUrl
& dest
);
410 void moveUrls(const KUrl::List
& source
, const KUrl
& dest
);
411 void linkUrls(const KUrl::List
& source
, const KUrl
& dest
);
412 void clearStatusBar();
415 * Connects the signals from the created DolphinView with
416 * the index \a viewIndex with the corresponding slots of
417 * the DolphinMainWindow. This method must be invoked each
418 * time a DolphinView has been created.
420 void connectViewSignals(int viewIndex
);
423 * Helper function to connect all signal/slots of the given \sidebar.
425 void connectSidebarPage(SidebarPage
* sidebar
);
429 * DolphinMainWindowsupports only one or two views, which
430 * are handled internally as primary and secondary view.
439 * Implements a custom error handling for the undo manager. This
440 * assures that all errors are shown in the status bar of Dolphin
441 * instead as modal error dialog with an OK button.
443 class UndoUiInterface
: public KonqUndoManager::UiInterface
446 UndoUiInterface(DolphinMainWindow
* mainWin
);
447 virtual ~UndoUiInterface();
448 virtual void jobError(KIO::Job
* job
);
451 DolphinMainWindow
* m_mainWin
;
455 QSplitter
* m_splitter
;
456 DolphinView
* m_activeView
;
459 DolphinView
* m_view
[SecondaryIdx
+ 1];
461 /// remember pending undo operations until they are finished
462 QList
<KonqUndoManager::CommandType
> m_undoCommandTypes
;
465 #endif // DOLPHIN_MAINWINDOW_H