]>
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 * @author Peter Penz <peter.penz@gmx.at>
53 class DolphinMainWindow
: public KMainWindow
56 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
);
89 * Refreshs the views of the main window by recreating them dependent from
90 * the given Dolphin settings.
95 * Returns the 'Create New...' sub menu which also can be shared
96 * with other menus (e. g. a context menu).
98 KNewMenu
* newMenu() const { return m_newMenu
; }
102 * Is send if the active view has been changed in
103 * the split view mode.
105 void activeViewChanged();
108 * Is send if the selection of the currently active view has
111 void selectionChanged();
114 /** @see QMainWindow::closeEvent */
115 virtual void closeEvent(QCloseEvent
* event
);
118 * This method is called when it is time for the app to save its
119 * properties for session management purposes.
121 void saveProperties(KConfig
*);
124 * This method is called when this app is restored. The KConfig
125 * object points to the session management config file that was saved
126 * with @ref saveProperties
128 void readProperties(KConfig
*);
131 /** Updates the 'Create New...' sub menu. */
132 void updateNewMenu();
134 /** Renames the selected item of the active view. */
137 /** Moves the selected items of the active view to the trash. */
140 /** Deletes the selected items of the active view. */
144 * Opens the properties window for the selected items of the
145 * active view. The properties windows shows informations
146 * like name, size and permissions.
150 /** Stores all settings and quits Dolphin. */
154 * Shows the error information of the job \a job
157 void slotHandleJobError(KJob
* job
);
160 * Indicates in the status bar that the delete operation
161 * of the job \a job has been finished.
163 void slotDeleteFileFinished(KJob
* job
);
166 * Updates the state of the 'Undo' menu action dependent
167 * from the parameter \a available.
169 void slotUndoAvailable(bool available
);
171 /** Sets the text of the 'Undo' menu action to \a text. */
172 void slotUndoTextChanged(const QString
& text
);
174 /** Performs the current undo operation. */
178 * Copies all selected items to the clipboard and marks
179 * the items as cutted.
183 /** Copies all selected items to the clipboard. */
186 /** Pastes the clipboard data to the active view. */
190 * Updates the text of the paste action dependent from
191 * the number of items which are in the clipboard.
193 void updatePasteAction();
195 /** Selects all items from the active view. */
199 * Inverts the selection of all items of the active view:
200 * Selected items get nonselected and nonselected items get
203 void invertSelection();
205 /** The current active view is switched to the icons mode. */
208 /** The current active view is switched to the details mode. */
209 void setDetailsView();
211 /** The sorting of the current view should be done by the name. */
214 /** The sorting of the current view should be done by the size. */
217 /** The sorting of the current view should be done by the date. */
220 /** Switches between an ascending and descending sorting order. */
221 void toggleSortOrder();
224 * Switches between one and two views:
225 * If one view is visible, it will get split into two views.
226 * If already two views are visible, the nonactivated view gets closed.
228 void toggleSplitView();
230 /** Reloads the current active view. */
233 /** Stops the loading process for the current active view. */
236 /** Switches between showing a preview of the file content and showing the icon. */
237 void togglePreview();
240 * Switches between showing and hiding of hidden marked files dependent
241 * from the current state of the 'Show Hidden Files' menu toggle action.
243 void toggleShowHiddenFiles();
246 * Switches between showing and hiding of the filter bar dependent
247 * from the current state of the 'Show Filter Bar' menu toggle action.
249 void showFilterBar();
251 /** Increases the size of the current set view mode. */
254 /** Decreases the size of the current set view mode. */
258 * Toggles between edit and brose mode of the navigation bar.
260 void toggleEditLocation();
263 * Switches to the edit mode of the navigation bar. If the edit mode is
264 * already active, it is assured that the navigation bar get focused.
269 * Opens the view properties dialog, which allows to modify the properties
270 * of the currently active view.
272 void adjustViewProperties();
274 /** Goes back on step of the Url history. */
277 /** Goes forward one step of the Url history. */
280 /** Goes up one hierarchy of the current Url. */
283 /** Goes to the home Url. */
286 /** Opens a terminal for the current shown directory. */
289 /** Opens KFind for the current shown directory. */
292 /** Opens Kompare for 2 selected files. */
295 /** Opens the settings dialog for Dolphin. */
298 /** Updates the state of all 'View' menu actions. */
299 void slotViewModeChanged();
301 /** Updates the state of the 'Show hidden files' menu action. */
302 void slotShowHiddenFilesChanged();
304 /** Updates the state of the 'Sort by' actions. */
305 void slotSortingChanged(DolphinView::Sorting sorting
);
307 /** Updates the state of the 'Sort Ascending/Descending' action. */
308 void slotSortOrderChanged(Qt::SortOrder order
);
310 /** Updates the state of the 'Edit' menu actions. */
311 void slotSelectionChanged();
314 * Updates the state of the 'Back' and 'Forward' menu
315 * actions corresponding the the current history.
317 void slotHistoryChanged();
320 * Updates the caption of the main window and the state
321 * of all menu actions which depend from a changed Url.
323 void slotUrlChanged(const KUrl
& url
);
325 /** Updates the state of the 'Show filter bar' menu action. */
326 void updateFilterBarAction(bool show
);
328 /** Open a new main window. */
329 void openNewMainWindow();
338 void setupDockWidgets();
339 void updateHistory();
340 void updateEditActions();
341 void updateViewActions();
342 void updateGoActions();
343 void copyUrls(const KUrl::List
& source
, const KUrl
& dest
);
344 void moveUrls(const KUrl::List
& source
, const KUrl
& dest
);
345 void linkUrls(const KUrl::List
& source
, const KUrl
& dest
);
346 void clearStatusBar();
349 * Connects the signals from the created DolphinView with
350 * the index \a viewIndex with the corresponding slots of
351 * the DolphinMainWindow. This method must be invoked each
352 * time a DolphinView has been created.
354 void connectViewSignals(int viewIndex
);
358 * DolphinMainWindowsupports only one or two views, which
359 * are handled internally as primary and secondary view.
368 * Implements a custom error handling for the undo manager. This
369 * assures that all errors are shown in the status bar of Dolphin
370 * instead as modal error dialog with an OK button.
372 class UndoUiInterface
: public KonqUndoManager::UiInterface
375 UndoUiInterface(DolphinMainWindow
* mainWin
);
376 virtual ~UndoUiInterface();
377 virtual void jobError(KIO::Job
* job
);
380 DolphinMainWindow
* m_mainWin
;
384 QSplitter
* m_splitter
;
385 DolphinView
* m_activeView
;
387 DolphinView
* m_view
[SecondaryIdx
+ 1];
389 /// remember pending undo operations until they are finished
390 QList
<KonqOperations::Operation
> m_undoOperations
;
393 #endif // _DOLPHIN_H_