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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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"
52 class DolphinApplication
;
55 * @short Main window for Dolphin.
57 * Handles the menus, toolbars and Dolphin views.
59 * @author Peter Penz <peter.penz@gmx.at>
61 class DolphinMainWindow
: public KMainWindow
64 friend class DolphinApplication
;
66 virtual ~DolphinMainWindow();
69 * Activates the given view, which means that
70 * all menu actions are applied to this view. When
71 * having a split view setup the nonactive view
72 * is usually shown in darker colors.
74 void setActiveView(DolphinView
* view
);
77 * Returns the currently active view. See
78 * DolphinMainWindow::setActiveView() for more details.
80 DolphinView
* activeView() const { return m_activeView
; }
83 * Handles the dropping of Urls to the given
84 * destination. A context menu with the options
85 * 'Move Here', 'Copy Here', 'Link Here' and
86 * 'Cancel' is offered to the user.
87 * @param urls List of Urls which have been
89 * @param destination Destination Url, where the
90 * list or Urls should be moved,
91 * copied or linked to.
93 void dropUrls(const KUrl::List
& urls
,
94 const KUrl
& destination
);
97 * Returns 'true', if the clipboard contains data
98 * which has been cutted by the Cut action (Ctrl + X).
100 bool clipboardContainsCutData() const { return m_clipboardContainsCutData
; }
103 * Returns the list of actions which are part of the file group
104 * of the 'Create New...' sub menu. Usually the list contains actions
105 * for creating folders, text files, HTML files etc.
107 const Q3PtrList
<KAction
>& fileGroupActions() const { return m_fileGroupActions
; }
108 //const QPtrList<KAction>& linkGroupActions() const { return m_linkGroupActions; }
109 //const QPtrList<KAction>& linkToDeviceActions() const { return m_linkToDeviceActions; }
112 * Refreshs the views of the main window by recreating them dependent from
113 * the given Dolphin settings.
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();
132 * Updates the state of the 'Back' and 'Forward' menu
133 * actions corresponding the the current history.
135 void slotHistoryChanged();
138 * Updates the caption of the main window and the state
139 * of all menu actions which depend from a changed Url.
141 void slotUrlChanged(const KUrl
& url
);
144 * Go to the given Url.
146 void slotUrlChangeRequest(const KUrl
& url
);
148 /** Updates the state of all 'View' menu actions. */
149 void slotViewModeChanged();
151 /** Updates the state of the 'Show hidden files' menu action. */
152 void slotShowHiddenFilesChanged();
154 /** Updates the state of the 'Show filter bar' menu action. */
155 void slotShowFilterBarChanged();
157 /** Updates the state of the 'Sort by' actions. */
158 void slotSortingChanged(DolphinView::Sorting sorting
);
160 /** Updates the state of the 'Sort Ascending/Descending' action. */
161 void slotSortOrderChanged(Qt::SortOrder order
);
163 /** Updates the state of the 'Edit' menu actions. */
164 void slotSelectionChanged();
167 /** @see QMainWindow::closeEvent */
168 virtual void closeEvent(QCloseEvent
* event
);
171 * This method is called when it is time for the app to save its
172 * properties for session management purposes.
174 void saveProperties(KConfig
*);
177 * This method is called when this app is restored. The KConfig
178 * object points to the session management config file that was saved
179 * with @ref saveProperties
181 void readProperties(KConfig
*);
184 /** Opens an input dialog for creating a new folder. */
187 /** Creates a file with the MIME type given by the sender. */
190 /** Renames the selected item of the active view. */
193 /** Moves the selected items of the active view to the trash. */
196 /** Deletes the selected items of the active view. */
200 * Opens the properties window for the selected items of the
201 * active view. The properties windows shows informations
202 * like name, size and permissions.
206 /** Stores all settings and quits Dolphin. */
210 * Shows the error information of the job \a job
213 void slotHandleJobError(KJob
* job
);
216 * Indicates in the status bar that the delete operation
217 * of the job \a job has been finished.
219 void slotDeleteFileFinished(KJob
* job
);
222 * Updates the state of the 'Undo' menu action dependent
223 * from the parameter \a available.
225 void slotUndoAvailable(bool available
);
227 /** Sets the text of the 'Undo' menu action to \a text. */
228 void slotUndoTextChanged(const QString
& text
);
231 * Updates the state of the 'Redo' menu action dependent
232 * from the parameter \a available.
234 void slotRedoAvailable(bool available
);
236 /** Sets the text of the 'Redo' menu action to \a text. */
237 void slotRedoTextChanged(const QString
& text
);
240 * Copies all selected items to the clipboard and marks
241 * the items as cutted.
245 /** Copies all selected items to the clipboard. */
248 /** Pastes the clipboard data to the active view. */
252 * Updates the text of the paste action dependent from
253 * the number of items which are in the clipboard.
255 void updatePasteAction();
257 /** Selects all items from the active view. */
261 * Inverts the selection of all items of the active view:
262 * Selected items get nonselected and nonselected items get
265 void invertSelection();
267 /** The current active view is switched to the icons mode. */
270 /** The current active view is switched to the details mode. */
271 void setDetailsView();
273 /** The current active view is switched to the previews mode. */
274 void setPreviewsView();
276 /** The sorting of the current view should be done by the name. */
279 /** The sorting of the current view should be done by the size. */
282 /** The sorting of the current view should be done by the date. */
285 /** Switches between an ascending and descending sorting order. */
286 void toggleSortOrder();
289 * Switches between one and two views:
290 * If one view is visible, it will get split into two views.
291 * If already two views are visible, the nonactivated view gets closed.
293 void toggleSplitView();
295 /** Reloads the current active view. */
298 /** Stops the loading process for the current active view. */
302 * Switches between showing and hiding of hidden marked files dependent
303 * from the current state of the 'Show Hidden Files' menu toggle action.
305 void showHiddenFiles();
308 * Switches between showing and hiding of the filter bar dependent
309 * from the current state of the 'Show Filter Bar' menu toggle action.
311 void showFilterBar();
313 /** Increases the size of the current set view mode. */
316 /** Decreases the size of the current set view mode. */
320 * Toggles between edit and brose mode of the navigation bar.
322 void toggleEditLocation();
325 * Switches to the edit mode of the navigation bar. If the edit mode is
326 * already active, it is assured that the navigation bar get focused.
331 * Opens the view properties dialog, which allows to modify the properties
332 * of the currently active view.
334 void adjustViewProperties();
336 /** Goes back on step of the Url history. */
339 /** Goes forward one step of the Url history. */
342 /** Goes up one hierarchy of the current Url. */
345 /** Goes to the home Url. */
348 /** Opens a terminal for the current shown directory. */
351 /** Opens KFind for the current shown directory. */
354 /** Opens Kompare for 2 selected files. */
357 /** Opens the settings dialog for Dolphin. */
361 * Adds the undo operation given by \a job
362 * to the UndoManager.
364 void addUndoOperation(KJob
* job
);
367 void toggleSidebar();
370 * Stores the current sidebar width and closes
382 void setupCreateNewMenuActions();
383 void updateHistory();
384 void updateEditActions();
385 void updateViewActions();
386 void updateGoActions();
387 void updateViewProperties(const KUrl::List
& urls
);
388 void copyUrls(const KUrl::List
& source
, const KUrl
& dest
);
389 void moveUrls(const KUrl::List
& source
, const KUrl
& dest
);
390 void addPendingUndoJob(KIO::Job
* job
,
391 DolphinCommand::Type commandType
,
392 const KUrl::List
& source
,
394 void clearStatusBar();
397 QSplitter
* m_splitter
;
399 DolphinView
* m_activeView
;
402 * DolphinMainWindowsupports only one or two views, which
403 * are handled internally as primary and secondary view.
410 DolphinView
* m_view
[SecondaryIdx
+ 1];
412 /// If set to true, the clipboard contains data which should be cutted after pasting.
413 bool m_clipboardContainsCutData
;
416 * Asynchronous operations like 'Move' and 'Copy' may only be added as undo
417 * operation after they have been finished successfully. When an asynchronous
418 * operation is started, it is added to a pending undo jobs list in the meantime.
419 * As soon as the job has been finished, the operation is added to the undo mangager.
421 * @see DolphinMainWindow::addPendingUndoJob
422 * @see DolphinMainWindow::addUndoOperation
427 DolphinCommand command
;
429 Q3ValueList
<UndoInfo
> m_pendingUndoJobs
;
431 /** Contains meta information for creating files. */
432 struct CreateFileEntry
436 QString templatePath
;
441 Q3PtrList
<KAction
> m_fileGroupActions
;
442 KSortableList
<CreateFileEntry
,QString
> m_createFileTemplates
;
444 // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
445 // and DolphinMainWindow::linkToDeviceActions() in for details.
446 //QPtrList<KAction> m_linkGroupActions;
447 //QPtrList<KAction> m_linkToDeviceActions;
450 #endif // _DOLPHIN_H_