]>
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"
26 #include "panels/panel.h"
28 #include <config-nepomuk.h>
30 #include <kfileitemdelegate.h>
31 #include <kio/fileundomanager.h>
32 #include <ksortablelist.h>
33 #include <kxmlguiwindow.h>
35 #include <QtCore/QList>
37 typedef KIO::FileUndoManager::CommandType CommandType
;
40 class DolphinViewActionHandler
;
41 class DolphinApplication
;
42 class DolphinSettingsDialog
;
43 class DolphinViewContainer
;
52 * @short Main window for Dolphin.
54 * Handles the menus, toolbars and Dolphin views.
56 class DolphinMainWindow
: public KXmlGuiWindow
59 Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
60 Q_PROPERTY(int id READ getId SCRIPTABLE
true)
61 friend class DolphinApplication
;
64 virtual ~DolphinMainWindow();
67 * Returns the currently active view.
68 * All menu actions are applied to this view. When
69 * having a split view setup, the nonactive view
70 * is usually shown in darker colors.
72 DolphinViewContainer
* activeViewContainer() const;
75 * Returns true, if the main window contains two instances
76 * of a view container. The active view constainer can be
77 * accessed by DolphinMainWindow::activeViewContainer().
82 * If the main window contains two instances of a view container
83 * (DolphinMainWindow::isSplit() returns true), then the
84 * two views get toggled (the right view is on the left, the left
89 /** Renames the item represented by \a oldUrl to \a newUrl. */
90 void rename(const KUrl
& oldUrl
, const KUrl
& newUrl
);
93 * Refreshes the views of the main window by recreating them dependent from
94 * the given Dolphin settings.
99 * Returns the 'Create New...' sub menu which also can be shared
100 * with other menus (e. g. a context menu).
102 KNewMenu
* newMenu() const;
105 * Returns the 'Show Menubar' action which can be shared with
106 * other menus (e. g. a context menu).
108 KAction
* showMenuBarAction() const;
112 * Pastes the clipboard data into the currently selected folder
113 * of the active view. If not exactly one folder is selected,
114 * no pasting is done at all.
116 void pasteIntoFolder();
119 * Returns the main window ID used through DBus.
124 * Inform all affected dolphin components (panels, views) of an URL
127 void changeUrl(const KUrl
& url
);
130 * Inform all affected dolphin components that a selection change is
133 void changeSelection(const KFileItemList
& selection
);
135 /** Stores all settings and quits Dolphin. */
140 * Is sent if the selection of the currently active view has
143 void selectionChanged(const KFileItemList
& selection
);
146 * Is sent if the url of the currently active view has
149 void urlChanged(const KUrl
& url
);
152 * Is emitted if information of an item is requested to be shown e. g. in the panel.
153 * If item is null, no item information request is pending.
155 void requestItemInfo(const KFileItem
& item
);
158 /** @see QMainWindow::closeEvent() */
159 virtual void closeEvent(QCloseEvent
* event
);
161 /** @see KMainWindow::saveProperties() */
162 virtual void saveProperties(KConfigGroup
& group
);
164 /** @see KMainWindow::readProperties() */
165 virtual void readProperties(const KConfigGroup
& group
);
168 void clearStatusBar();
170 /** Updates the 'Create New...' sub menu. */
171 void updateNewMenu();
173 /** Shows the error message in the status bar of the active view. */
174 void showErrorMessage(const QString
& message
);
177 * Updates the state of the 'Undo' menu action dependent
178 * from the parameter \a available.
180 void slotUndoAvailable(bool available
);
182 /** Sets the text of the 'Undo' menu action to \a text. */
183 void slotUndoTextChanged(const QString
& text
);
185 /** Performs the current undo operation. */
189 * Copies all selected items to the clipboard and marks
190 * the items as cutted.
194 /** Copies all selected items to the clipboard. */
197 /** Pastes the clipboard data to the active view. */
201 * Updates the text of the paste action dependent from
202 * the number of items which are in the clipboard.
204 void updatePasteAction();
206 /** Selects all items from the active view. */
210 * Inverts the selection of all items of the active view:
211 * Selected items get nonselected and nonselected items get
214 void invertSelection();
217 * Switches between one and two views:
218 * If one view is visible, it will get split into two views.
219 * If already two views are visible, the nonactivated view gets closed.
221 void toggleSplitView();
223 /** Reloads the current active view. */
226 /** Stops the loading process for the current active view. */
230 * Toggles between showing and hiding of the filter bar
232 void toggleFilterBarVisibility(bool show
);
235 * Toggles between edit and browse mode of the navigation bar.
237 void toggleEditLocation();
240 * Switches to the edit mode of the navigation bar and selects
241 * the whole URL, so that it can be replaced by the user. If the edit mode is
242 * already active, it is assured that the navigation bar get focused.
244 void replaceLocation();
246 /** Goes back on step of the URL history. */
249 /** Goes forward one step of the URL history. */
252 /** Goes up one hierarchy of the current URL. */
255 /** Goes to the home URL. */
258 /** Opens Kompare for 2 selected files. */
262 * Initiates a preview of the selected files
263 * on the desktop by the Previewer plasmoid.
268 * Hides the menu bar if it is visible, makes the menu bar
269 * visible if it is hidden.
271 void toggleShowMenuBar();
273 /** Opens the settings dialog for Dolphin. */
276 /** Updates the state of the 'Show Full Location' action. */
277 void slotEditableStateChanged(bool editable
);
280 * Updates the state of the 'Edit' menu actions and emits
281 * the signal selectionChanged().
283 void slotSelectionChanged(const KFileItemList
& selection
);
285 /** Emits the signal requestItemInfo(). */
286 void slotRequestItemInfo(const KFileItem
&);
289 * Updates the state of the 'Back' and 'Forward' menu
290 * actions corresponding to the current history.
292 void updateHistory();
294 /** Updates the state of the 'Show filter bar' menu action. */
295 void updateFilterBarAction(bool show
);
297 /** Open a new main window. */
298 void openNewMainWindow();
300 /** Opens a new view with the current URL that is part of a tab. */
304 * Opens a new tab showing the URL \a url.
306 void openNewTab(const KUrl
& url
);
308 void activateNextTab();
310 void activatePrevTab();
313 * Opens the selected folder in a new tab.
318 * Opens the selected folder in a new window.
320 void openInNewWindow();
322 /** Toggles the active view if two views are shown within the main window. */
323 void toggleActiveView();
326 * Indicates in the statusbar that the execution of the command \a command
329 void showCommand(CommandType command
);
332 * Activates the tab with the index \a index, which means that the current view
333 * is replaced by the view of the given tab.
335 void setActiveTab(int index
);
337 /** Closes the currently active tab. */
341 * Closes the tab with the index \index and activates the tab with index - 1.
343 void closeTab(int index
);
346 * Opens a context menu for the tab with the index \a index
347 * on the position \a pos.
349 void openTabContextMenu(int index
, const QPoint
& pos
);
352 * Handles a click on a places item: if the middle mouse button is
353 * clicked, a new tab is opened for \a url, otherwise the current
354 * view is replaced by \a url.
356 void handlePlacesClick(const KUrl
& url
, Qt::MouseButtons buttons
);
359 * Is connected to the KTabBar signal testCanDecode() and adjusts
360 * the output parameter \a accept.
362 void slotTestCanDecode(const QDragMoveEvent
* event
, bool& accept
);
365 * Searchs items that match to the text entered in the search bar.
370 DolphinMainWindow(int id
);
374 * Activates the given view, which means that
375 * all menu actions are applied to this view. When
376 * having a split view setup, the nonactive view
377 * is usually shown in darker colors.
379 void setActiveViewContainer(DolphinViewContainer
* view
);
382 void setupDockWidgets();
383 void updateEditActions();
384 void updateViewActions();
385 void updateGoActions();
388 * Connects the signals from the created DolphinView with
389 * the DolphinViewContainer \a container with the corresponding slots of
390 * the DolphinMainWindow. This method must be invoked each
391 * time a DolphinView has been created.
393 void connectViewSignals(DolphinViewContainer
* container
);
396 * Updates the text of the split action:
397 * If two views are shown, the text is set to "Split",
398 * otherwise the text is set to "Join". The icon
399 * is updated to match with the text and the currently active view.
401 void updateSplitAction();
403 /** Returns the name of the tab for the URL \a url. */
404 QString
tabName(const KUrl
& url
) const;
406 bool isKompareInstalled() const;
408 void createSecondaryView(int tabIndex
);
412 * Implements a custom error handling for the undo manager. This
413 * assures that all errors are shown in the status bar of Dolphin
414 * instead as modal error dialog with an OK button.
416 class UndoUiInterface
: public KIO::FileUndoManager::UiInterface
420 virtual ~UndoUiInterface();
421 virtual void jobError(KIO::Job
* job
);
425 KAction
* m_showMenuBar
;
427 DolphinViewContainer
* m_activeViewContainer
;
428 QVBoxLayout
* m_centralWidgetLayout
;
429 KLineEdit
* m_searchBar
;
434 ViewTab() : isPrimaryViewActive(true), primaryView(0), secondaryView(0), splitter(0) {}
435 bool isPrimaryViewActive
;
436 DolphinViewContainer
* primaryView
;
437 DolphinViewContainer
* secondaryView
;
442 QList
<ViewTab
> m_viewTab
;
444 DolphinViewActionHandler
* m_actionHandler
;
445 QPointer
<DolphinSettingsDialog
> m_settingsDialog
;
448 inline DolphinViewContainer
* DolphinMainWindow::activeViewContainer() const
450 return m_activeViewContainer
;
453 inline bool DolphinMainWindow::isSplit() const
455 return m_viewTab
[m_tabIndex
].secondaryView
!= 0;
458 inline KNewMenu
* DolphinMainWindow::newMenu() const
463 inline KAction
* DolphinMainWindow::showMenuBarAction() const
465 return m_showMenuBar
;
468 inline int DolphinMainWindow::getId() const
473 #endif // DOLPHIN_MAINWINDOW_H