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>
43 class DolphinApplication
;
46 * @short Main window for Dolphin.
48 * Handles the menus, toolbars and Dolphin views.
50 class DolphinMainWindow
: public KMainWindow
53 Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
54 Q_PROPERTY(int id READ getId SCRIPTABLE
true)
55 friend class DolphinApplication
;
58 virtual ~DolphinMainWindow();
61 * Activates the given view, which means that
62 * all menu actions are applied to this view. When
63 * having a split view setup the nonactive view
64 * is usually shown in darker colors.
66 void setActiveView(DolphinView
* view
);
69 * Returns the currently active view. See
70 * DolphinMainWindow::setActiveView() for more details.
72 DolphinView
* activeView() const { return m_activeView
; }
75 * Handles the dropping of URLs to the given
76 * destination. A context menu with the options
77 * 'Move Here', 'Copy Here', 'Link Here' and
78 * 'Cancel' is offered to the user.
79 * @param urls List of URLs which have been
81 * @param destination Destination URL, where the
82 * list or URLs should be moved,
83 * copied or linked to.
85 void dropUrls(const KUrl::List
& urls
,
86 const KUrl
& destination
);
88 /** Renames the item represented by \a oldUrl to \a newUrl. */
89 void rename(const KUrl
& oldUrl
, const KUrl
& newUrl
);
92 * Refreshs the views of the main window by recreating them dependent from
93 * the given Dolphin settings.
98 * Returns the 'Create New...' sub menu which also can be shared
99 * with other menus (e. g. a context menu).
101 KNewMenu
* newMenu() const { return m_newMenu
; }
105 * Returns the main windows ID, mainly used throught DBus.
107 int getId() const { return m_id
; }
110 * Changes the URL of the current active DolphinView to \a url.
112 void changeUrl(const QString
& url
);
114 /** Stores all settings and quits Dolphin. */
119 * Is send if the active view has been changed in
120 * the split view mode.
122 void activeViewChanged();
125 * Is send if the selection of the currently active view has
128 void selectionChanged();
131 /** @see QMainWindow::closeEvent */
132 virtual void closeEvent(QCloseEvent
* event
);
135 * This method is called when it is time for the app to save its
136 * properties for session management purposes.
138 void saveProperties(KConfig
*);
141 * This method is called when this app is restored. The KConfig
142 * object points to the session management config file that was saved
143 * with @ref saveProperties
145 void readProperties(KConfig
*);
148 /** Updates the 'Create New...' sub menu. */
149 void updateNewMenu();
152 * Let the user input a name for the selected item(s) and trigger
153 * a renaming afterwards.
157 /** Moves the selected items of the active view to the trash. */
160 /** Deletes the selected items of the active view. */
164 * Opens the properties window for the selected items of the
165 * active view. The properties windows shows informations
166 * like name, size and permissions.
171 * Shows the error information of the job \a job
174 void slotHandleJobError(KJob
* job
);
177 * Indicates in the status bar that the delete operation
178 * of the job \a job has been finished.
180 void slotDeleteFileFinished(KJob
* job
);
183 * Updates the state of the 'Undo' menu action dependent
184 * from the parameter \a available.
186 void slotUndoAvailable(bool available
);
188 /** Sets the text of the 'Undo' menu action to \a text. */
189 void slotUndoTextChanged(const QString
& text
);
191 /** Performs the current undo operation. */
195 * Copies all selected items to the clipboard and marks
196 * the items as cutted.
200 /** Copies all selected items to the clipboard. */
203 /** Pastes the clipboard data to the active view. */
207 * Updates the text of the paste action dependent from
208 * the number of items which are in the clipboard.
210 void updatePasteAction();
212 /** Selects all items from the active view. */
216 * Inverts the selection of all items of the active view:
217 * Selected items get nonselected and nonselected items get
220 void invertSelection();
222 /** The current active view is switched to the icons mode. */
225 /** The current active view is switched to the details mode. */
226 void setDetailsView();
228 /** The sorting of the current view should be done by the name. */
231 /** The sorting of the current view should be done by the size. */
234 /** The sorting of the current view should be done by the date. */
237 /** The sorting of the current view should be done by the permissions. */
238 void sortByPermissions();
240 /** The sorting of the current view should be done by the owner. */
243 /** The sorting of the current view should be done by the group. */
246 /** Switches between an ascending and descending sorting order. */
247 void toggleSortOrder();
250 * Clears any additional information for an item except for the
255 /** Shows the MIME type as additional information for the item. */
258 /** Shows the size as additional information for the item. */
261 /** Shows the date as additional information for the item. */
265 * Switches between one and two views:
266 * If one view is visible, it will get split into two views.
267 * If already two views are visible, the nonactivated view gets closed.
269 void toggleSplitView();
271 /** Reloads the current active view. */
274 /** Stops the loading process for the current active view. */
277 /** Switches between showing a preview of the file content and showing the icon. */
278 void togglePreview();
281 * Switches between showing and hiding of hidden marked files dependent
282 * from the current state of the 'Show Hidden Files' menu toggle action.
284 void toggleShowHiddenFiles();
287 * Switches between showing and hiding of the filter bar dependent
288 * from the current state of the 'Show Filter Bar' menu toggle action.
290 void showFilterBar();
292 /** Increases the size of the current set view mode. */
295 /** Decreases the size of the current set view mode. */
299 * Toggles between edit and brose mode of the navigation bar.
301 void toggleEditLocation();
304 * Switches to the edit mode of the navigation bar. If the edit mode is
305 * already active, it is assured that the navigation bar get focused.
310 * Opens the view properties dialog, which allows to modify the properties
311 * of the currently active view.
313 void adjustViewProperties();
315 /** Goes back on step of the URL history. */
318 /** Goes forward one step of the URL history. */
321 /** Goes up one hierarchy of the current URL. */
324 /** Goes to the home URL. */
327 /** Opens a terminal for the current shown directory. */
330 /** Opens KFind for the current shown directory. */
333 /** Opens Kompare for 2 selected files. */
336 /** Opens the settings dialog for Dolphin. */
339 /** Updates the state of all 'View' menu actions. */
340 void slotViewModeChanged();
342 /** Updates the state of the 'Show preview' menu action. */
343 void slotShowPreviewChanged();
345 /** Updates the state of the 'Show hidden files' menu action. */
346 void slotShowHiddenFilesChanged();
348 /** Updates the state of the 'Sort by' actions. */
349 void slotSortingChanged(DolphinView::Sorting sorting
);
351 /** Updates the state of the 'Sort Ascending/Descending' action. */
352 void slotSortOrderChanged(Qt::SortOrder order
);
354 /** Updates the state of the 'Additional Information' actions. */
355 void slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation info
);
357 /** Updates the state of the 'Edit' menu actions. */
358 void slotSelectionChanged();
361 * Updates the state of the 'Back' and 'Forward' menu
362 * actions corresponding the the current history.
364 void slotHistoryChanged();
367 * Updates the caption of the main window and the state
368 * of all menu actions which depend from a changed URL.
370 void slotUrlChanged(const KUrl
& url
);
372 /** Updates the state of the 'Show filter bar' menu action. */
373 void updateFilterBarAction(bool show
);
375 /** Open a new main window. */
376 void openNewMainWindow();
379 DolphinMainWindow(int id
);
385 void setupDockWidgets();
386 void updateHistory();
387 void updateEditActions();
388 void updateViewActions();
389 void updateGoActions();
390 void copyUrls(const KUrl::List
& source
, const KUrl
& dest
);
391 void moveUrls(const KUrl::List
& source
, const KUrl
& dest
);
392 void linkUrls(const KUrl::List
& source
, const KUrl
& dest
);
393 void clearStatusBar();
396 * Connects the signals from the created DolphinView with
397 * the index \a viewIndex with the corresponding slots of
398 * the DolphinMainWindow. This method must be invoked each
399 * time a DolphinView has been created.
401 void connectViewSignals(int viewIndex
);
405 * DolphinMainWindowsupports only one or two views, which
406 * are handled internally as primary and secondary view.
415 * Implements a custom error handling for the undo manager. This
416 * assures that all errors are shown in the status bar of Dolphin
417 * instead as modal error dialog with an OK button.
419 class UndoUiInterface
: public KonqUndoManager::UiInterface
422 UndoUiInterface(DolphinMainWindow
* mainWin
);
423 virtual ~UndoUiInterface();
424 virtual void jobError(KIO::Job
* job
);
427 DolphinMainWindow
* m_mainWin
;
431 QSplitter
* m_splitter
;
432 DolphinView
* m_activeView
;
435 DolphinView
* m_view
[SecondaryIdx
+ 1];
437 /// remember pending undo operations until they are finished
438 QList
<KonqUndoManager::CommandType
> m_undoCommandTypes
;
441 #endif // _DOLPHIN_H_