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_
29 #include <kapplication.h>
30 #include <kmainwindow.h>
31 #include <q3valuelist.h>
32 #include <q3ptrlist.h>
35 #include <QCloseEvent>
36 #include <ksortablelist.h>
39 #include "dolphinview.h"
40 #include "undomanager.h"
51 class DolphinApplication
;
54 * @short Main window for Dolphin.
56 * Handles the menus, toolbars and Dolphin views.
58 * @author Peter Penz <peter.penz@gmx.at>
60 class DolphinMainWindow
: public KMainWindow
63 friend class DolphinApplication
;
65 virtual ~DolphinMainWindow();
68 * Activates the given view, which means that
69 * all menu actions are applied to this view. When
70 * having a split view setup the nonactive view
71 * is usually shown in darker colors.
73 void setActiveView(DolphinView
* view
);
76 * Returns the currently active view. See
77 * DolphinMainWindow::setActiveView() for more details.
79 DolphinView
* activeView() const { return m_activeView
; }
82 * Handles the dropping of Urls to the given
83 * destination. A context menu with the options
84 * 'Move Here', 'Copy Here', 'Link Here' and
85 * 'Cancel' is offered to the user.
86 * @param urls List of Urls which have been
88 * @param destination Destination Url, where the
89 * list or Urls should be moved,
90 * copied or linked to.
92 void dropUrls(const KUrl::List
& urls
,
93 const KUrl
& destination
);
96 * Returns 'true', if the clipboard contains data
97 * which has been cutted by the Cut action (Ctrl + X).
99 bool clipboardContainsCutData() const { return m_clipboardContainsCutData
; }
102 * Returns the list of actions which are part of the file group
103 * of the 'Create New...' sub menu. Usually the list contains actions
104 * for creating folders, text files, HTML files etc.
106 const Q3PtrList
<KAction
>& fileGroupActions() const { return m_fileGroupActions
; }
107 //const QPtrList<KAction>& linkGroupActions() const { return m_linkGroupActions; }
108 //const QPtrList<KAction>& linkToDeviceActions() const { return m_linkToDeviceActions; }
111 * Refreshs the views of the main window by recreating them dependent from
112 * the given Dolphin settings.
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();
131 * Updates the state of the 'Back' and 'Forward' menu
132 * actions corresponding the the current history.
134 void slotHistoryChanged();
137 * Updates the caption of the main window and the state
138 * of all menu actions which depend from a changed Url.
140 void slotUrlChanged(const KUrl
& url
);
143 * Go to the given Url.
145 void slotUrlChangeRequest(const KUrl
& url
);
147 /** Updates the state of all 'View' menu actions. */
148 void slotViewModeChanged();
150 /** Updates the state of the 'Show hidden files' menu action. */
151 void slotShowHiddenFilesChanged();
153 /** Updates the state of the 'Show filter bar' menu action. */
154 void slotShowFilterBarChanged();
156 /** Updates the state of the 'Sort by' actions. */
157 void slotSortingChanged(DolphinView::Sorting sorting
);
159 /** Updates the state of the 'Sort Ascending/Descending' action. */
160 void slotSortOrderChanged(Qt::SortOrder order
);
162 /** Updates the state of the 'Edit' menu actions. */
163 void slotSelectionChanged();
165 /** Executes Redo operation */
168 /** @see slotUndo() */
171 /** Open a new mainwindow */
172 void slotNewMainWindow();
175 /** @see QMainWindow::closeEvent */
176 virtual void closeEvent(QCloseEvent
* event
);
179 * This method is called when it is time for the app to save its
180 * properties for session management purposes.
182 void saveProperties(KConfig
*);
185 * This method is called when this app is restored. The KConfig
186 * object points to the session management config file that was saved
187 * with @ref saveProperties
189 void readProperties(KConfig
*);
192 /** Opens an input dialog for creating a new folder. */
195 /** Creates a file with the MIME type given by the sender. */
198 /** Renames the selected item of the active view. */
201 /** Moves the selected items of the active view to the trash. */
204 /** Deletes the selected items of the active view. */
208 * Opens the properties window for the selected items of the
209 * active view. The properties windows shows informations
210 * like name, size and permissions.
214 /** Stores all settings and quits Dolphin. */
218 * Shows the error information of the job \a job
221 void slotHandleJobError(KJob
* job
);
224 * Indicates in the status bar that the delete operation
225 * of the job \a job has been finished.
227 void slotDeleteFileFinished(KJob
* job
);
230 * Updates the state of the 'Undo' menu action dependent
231 * from the parameter \a available.
233 void slotUndoAvailable(bool available
);
235 /** Sets the text of the 'Undo' menu action to \a text. */
236 void slotUndoTextChanged(const QString
& text
);
239 * Updates the state of the 'Redo' menu action dependent
240 * from the parameter \a available.
242 void slotRedoAvailable(bool available
);
244 /** Sets the text of the 'Redo' menu action to \a text. */
245 void slotRedoTextChanged(const QString
& text
);
248 * Copies all selected items to the clipboard and marks
249 * the items as cutted.
253 /** Copies all selected items to the clipboard. */
256 /** Pastes the clipboard data to the active view. */
260 * Updates the text of the paste action dependent from
261 * the number of items which are in the clipboard.
263 void updatePasteAction();
265 /** Selects all items from the active view. */
269 * Inverts the selection of all items of the active view:
270 * Selected items get nonselected and nonselected items get
273 void invertSelection();
275 /** The current active view is switched to the icons mode. */
278 /** The current active view is switched to the details mode. */
279 void setDetailsView();
281 /** The current active view is switched to the previews mode. */
282 void setPreviewsView();
284 /** The sorting of the current view should be done by the name. */
287 /** The sorting of the current view should be done by the size. */
290 /** The sorting of the current view should be done by the date. */
293 /** Switches between an ascending and descending sorting order. */
294 void toggleSortOrder();
297 * Switches between one and two views:
298 * If one view is visible, it will get split into two views.
299 * If already two views are visible, the nonactivated view gets closed.
301 void toggleSplitView();
303 /** Reloads the current active view. */
306 /** Stops the loading process for the current active view. */
310 * Switches between showing and hiding of hidden marked files dependent
311 * from the current state of the 'Show Hidden Files' menu toggle action.
313 void showHiddenFiles();
316 * Switches between showing and hiding of the filter bar dependent
317 * from the current state of the 'Show Filter Bar' menu toggle action.
319 void showFilterBar();
321 /** Increases the size of the current set view mode. */
324 /** Decreases the size of the current set view mode. */
328 * Toggles between edit and brose mode of the navigation bar.
330 void toggleEditLocation();
333 * Switches to the edit mode of the navigation bar. If the edit mode is
334 * already active, it is assured that the navigation bar get focused.
339 * Opens the view properties dialog, which allows to modify the properties
340 * of the currently active view.
342 void adjustViewProperties();
344 /** Goes back on step of the Url history. */
347 /** Goes forward one step of the Url history. */
350 /** Goes up one hierarchy of the current Url. */
353 /** Goes to the home Url. */
356 /** Opens a terminal for the current shown directory. */
359 /** Opens KFind for the current shown directory. */
362 /** Opens Kompare for 2 selected files. */
365 /** Opens the settings dialog for Dolphin. */
369 * Adds the undo operation given by \a job
370 * to the UndoManager.
372 void addUndoOperation(KJob
* job
);
382 void setupDockWidgets();
383 void setupCreateNewMenuActions();
384 void updateHistory();
385 void updateEditActions();
386 void updateViewActions();
387 void updateGoActions();
388 void updateViewProperties(const KUrl::List
& urls
);
389 void copyUrls(const KUrl::List
& source
, const KUrl
& dest
);
390 void moveUrls(const KUrl::List
& source
, const KUrl
& dest
);
391 void addPendingUndoJob(KIO::Job
* job
,
392 DolphinCommand::Type commandType
,
393 const KUrl::List
& source
,
395 void clearStatusBar();
397 QSplitter
* m_splitter
;
398 DolphinView
* m_activeView
;
401 * DolphinMainWindowsupports only one or two views, which
402 * are handled internally as primary and secondary view.
409 DolphinView
* m_view
[SecondaryIdx
+ 1];
411 /// If set to true, the clipboard contains data which should be cutted after pasting.
412 bool m_clipboardContainsCutData
;
415 * Asynchronous operations like 'Move' and 'Copy' may only be added as undo
416 * operation after they have been finished successfully. When an asynchronous
417 * operation is started, it is added to a pending undo jobs list in the meantime.
418 * As soon as the job has been finished, the operation is added to the undo mangager.
420 * @see DolphinMainWindow::addPendingUndoJob
421 * @see DolphinMainWindow::addUndoOperation
426 DolphinCommand command
;
428 Q3ValueList
<UndoInfo
> m_pendingUndoJobs
;
430 /** Contains meta information for creating files. */
431 struct CreateFileEntry
435 QString templatePath
;
440 Q3PtrList
<KAction
> m_fileGroupActions
;
441 KSortableList
<CreateFileEntry
,QString
> m_createFileTemplates
;
443 // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
444 // and DolphinMainWindow::linkToDeviceActions() in for details.
445 //QPtrList<KAction> m_linkGroupActions;
446 //QPtrList<KAction> m_linkToDeviceActions;
449 #endif // _DOLPHIN_H_