]>
cloud.milkyroute.net Git - dolphin.git/blob - 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> *
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_operations.h>
30 #include <konq_undo.h>
44 class DolphinApplication
;
47 * @short Main window for Dolphin.
49 * Handles the menus, toolbars and Dolphin views.
51 class DolphinMainWindow
: public KMainWindow
54 Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
55 Q_PROPERTY(int id READ getId SCRIPTABLE
true)
56 friend class DolphinApplication
;
59 virtual ~DolphinMainWindow();
62 * Activates the given view, which means that
63 * all menu actions are applied to this view. When
64 * having a split view setup the nonactive view
65 * is usually shown in darker colors.
67 void setActiveView(DolphinView
* view
);
70 * Returns the currently active view. See
71 * DolphinMainWindow::setActiveView() for more details.
73 DolphinView
* activeView() const { return m_activeView
; }
76 * Handles the dropping of Urls to the given
77 * destination. A context menu with the options
78 * 'Move Here', 'Copy Here', 'Link Here' and
79 * 'Cancel' is offered to the user.
80 * @param urls List of Urls which have been
82 * @param destination Destination Url, where the
83 * list or Urls should be moved,
84 * copied or linked to.
86 void dropUrls(const KUrl::List
& urls
,
87 const KUrl
& destination
);
90 * Refreshs the views of the main window by recreating them dependent from
91 * the given Dolphin settings.
96 * Returns the 'Create New...' sub menu which also can be shared
97 * with other menus (e. g. a context menu).
99 KNewMenu
* newMenu() const { return m_newMenu
; }
103 * Returns the main windows ID, mainly used throught DBus.
105 int getId() const { return m_id
; }
108 * Changes the URL of the current active DolphinView to \a url.
110 void changeUrl(const QString
& url
);
112 /** Stores all settings and quits Dolphin. */
117 * Is send if the active view has been changed in
118 * the split view mode.
120 void activeViewChanged();
123 * Is send if the selection of the currently active view has
126 void selectionChanged();
129 /** @see QMainWindow::closeEvent */
130 virtual void closeEvent(QCloseEvent
* event
);
133 * This method is called when it is time for the app to save its
134 * properties for session management purposes.
136 void saveProperties(KConfig
*);
139 * This method is called when this app is restored. The KConfig
140 * object points to the session management config file that was saved
141 * with @ref saveProperties
143 void readProperties(KConfig
*);
146 /** Updates the 'Create New...' sub menu. */
147 void updateNewMenu();
149 /** Renames the selected item of the active view. */
152 /** Moves the selected items of the active view to the trash. */
155 /** Deletes the selected items of the active view. */
159 * Opens the properties window for the selected items of the
160 * active view. The properties windows shows informations
161 * like name, size and permissions.
166 * Shows the error information of the job \a job
169 void slotHandleJobError(KJob
* job
);
172 * Indicates in the status bar that the delete operation
173 * of the job \a job has been finished.
175 void slotDeleteFileFinished(KJob
* job
);
178 * Updates the state of the 'Undo' menu action dependent
179 * from the parameter \a available.
181 void slotUndoAvailable(bool available
);
183 /** Sets the text of the 'Undo' menu action to \a text. */
184 void slotUndoTextChanged(const QString
& text
);
186 /** Performs the current undo operation. */
190 * Copies all selected items to the clipboard and marks
191 * the items as cutted.
195 /** Copies all selected items to the clipboard. */
198 /** Pastes the clipboard data to the active view. */
202 * Updates the text of the paste action dependent from
203 * the number of items which are in the clipboard.
205 void updatePasteAction();
207 /** Selects all items from the active view. */
211 * Inverts the selection of all items of the active view:
212 * Selected items get nonselected and nonselected items get
215 void invertSelection();
217 /** The current active view is switched to the icons mode. */
220 /** The current active view is switched to the details mode. */
221 void setDetailsView();
223 /** The sorting of the current view should be done by the name. */
226 /** The sorting of the current view should be done by the size. */
229 /** The sorting of the current view should be done by the date. */
232 /** The sorting of the current view should be done by the permissions. */
233 void sortByPermissions();
235 /** The sorting of the current view should be done by the owner. */
238 /** The sorting of the current view should be done by the group. */
241 /** Switches between an ascending and descending sorting order. */
242 void toggleSortOrder();
245 * Switches between one and two views:
246 * If one view is visible, it will get split into two views.
247 * If already two views are visible, the nonactivated view gets closed.
249 void toggleSplitView();
251 /** Reloads the current active view. */
254 /** Stops the loading process for the current active view. */
257 /** Switches between showing a preview of the file content and showing the icon. */
258 void togglePreview();
261 * Switches between showing and hiding of hidden marked files dependent
262 * from the current state of the 'Show Hidden Files' menu toggle action.
264 void toggleShowHiddenFiles();
267 * Switches between showing and hiding of the filter bar dependent
268 * from the current state of the 'Show Filter Bar' menu toggle action.
270 void showFilterBar();
272 /** Increases the size of the current set view mode. */
275 /** Decreases the size of the current set view mode. */
279 * Toggles between edit and brose mode of the navigation bar.
281 void toggleEditLocation();
284 * Switches to the edit mode of the navigation bar. If the edit mode is
285 * already active, it is assured that the navigation bar get focused.
290 * Opens the view properties dialog, which allows to modify the properties
291 * of the currently active view.
293 void adjustViewProperties();
295 /** Goes back on step of the Url history. */
298 /** Goes forward one step of the Url history. */
301 /** Goes up one hierarchy of the current Url. */
304 /** Goes to the home Url. */
307 /** Opens a terminal for the current shown directory. */
310 /** Opens KFind for the current shown directory. */
313 /** Opens Kompare for 2 selected files. */
316 /** Opens the settings dialog for Dolphin. */
319 /** Updates the state of all 'View' menu actions. */
320 void slotViewModeChanged();
322 /** Updates the state of the 'Show preview' menu action. */
323 void slowShowPreviewChanged();
325 /** Updates the state of the 'Show hidden files' menu action. */
326 void slotShowHiddenFilesChanged();
328 /** Updates the state of the 'Sort by' actions. */
329 void slotSortingChanged(DolphinView::Sorting sorting
);
331 /** Updates the state of the 'Sort Ascending/Descending' action. */
332 void slotSortOrderChanged(Qt::SortOrder order
);
334 /** Updates the state of the 'Edit' menu actions. */
335 void slotSelectionChanged();
338 * Updates the state of the 'Back' and 'Forward' menu
339 * actions corresponding the the current history.
341 void slotHistoryChanged();
344 * Updates the caption of the main window and the state
345 * of all menu actions which depend from a changed Url.
347 void slotUrlChanged(const KUrl
& url
);
349 /** Updates the state of the 'Show filter bar' menu action. */
350 void updateFilterBarAction(bool show
);
352 /** Open a new main window. */
353 void openNewMainWindow();
356 DolphinMainWindow(int id
);
362 void setupDockWidgets();
363 void updateHistory();
364 void updateEditActions();
365 void updateViewActions();
366 void updateGoActions();
367 void copyUrls(const KUrl::List
& source
, const KUrl
& dest
);
368 void moveUrls(const KUrl::List
& source
, const KUrl
& dest
);
369 void linkUrls(const KUrl::List
& source
, const KUrl
& dest
);
370 void clearStatusBar();
373 * Connects the signals from the created DolphinView with
374 * the index \a viewIndex with the corresponding slots of
375 * the DolphinMainWindow. This method must be invoked each
376 * time a DolphinView has been created.
378 void connectViewSignals(int viewIndex
);
382 * DolphinMainWindowsupports only one or two views, which
383 * are handled internally as primary and secondary view.
392 * Implements a custom error handling for the undo manager. This
393 * assures that all errors are shown in the status bar of Dolphin
394 * instead as modal error dialog with an OK button.
396 class UndoUiInterface
: public KonqUndoManager::UiInterface
399 UndoUiInterface(DolphinMainWindow
* mainWin
);
400 virtual ~UndoUiInterface();
401 virtual void jobError(KIO::Job
* job
);
404 DolphinMainWindow
* m_mainWin
;
408 QSplitter
* m_splitter
;
409 DolphinView
* m_activeView
;
412 DolphinView
* m_view
[SecondaryIdx
+ 1];
414 /// remember pending undo operations until they are finished
415 QList
<KonqOperations::Operation
> m_undoOperations
;
418 #endif // _DOLPHIN_H_