]>
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>
34 #include <kactionmenu.h>
36 #include <QtCore/QList>
38 typedef KIO::FileUndoManager::CommandType CommandType
;
41 class DolphinViewActionHandler
;
42 class DolphinApplication
;
43 class DolphinSearchBox
;
44 class DolphinSettingsDialog
;
45 class DolphinViewContainer
;
53 * @short Main window for Dolphin.
55 * Handles the menus, toolbars and Dolphin views.
57 class DolphinMainWindow
: public KXmlGuiWindow
60 Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
61 Q_PROPERTY(int id READ getId SCRIPTABLE
true)
62 friend class DolphinApplication
;
65 virtual ~DolphinMainWindow();
68 * Returns the currently active view.
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 DolphinViewContainer
* activeViewContainer() const;
76 * Returns true, if the main window contains two instances
77 * of a view container. The active view constainer can be
78 * accessed by DolphinMainWindow::activeViewContainer().
83 * If the main window contains two instances of a view container
84 * (DolphinMainWindow::isSplit() returns true), then the
85 * two views get toggled (the right view is on the left, the left
90 /** Renames the item represented by \a oldUrl to \a newUrl. */
91 void rename(const KUrl
& oldUrl
, const KUrl
& newUrl
);
94 * Refreshes the views of the main window by recreating them dependent from
95 * the given Dolphin settings.
100 * Returns the 'Create New...' sub menu which also can be shared
101 * with other menus (e. g. a context menu).
103 KNewMenu
* newMenu() const;
106 * Returns the 'Show Menubar' action which can be shared with
107 * other menus (e. g. a context menu).
109 KAction
* showMenuBarAction() const;
113 * Pastes the clipboard data into the currently selected folder
114 * of the active view. If not exactly one folder is selected,
115 * no pasting is done at all.
117 void pasteIntoFolder();
120 * Returns the main window ID used through DBus.
125 * Inform all affected dolphin components (panels, views) of an URL
128 void changeUrl(const KUrl
& url
);
131 * Inform all affected dolphin components that a selection change is
134 void changeSelection(const KFileItemList
& selection
);
136 /** Stores all settings and quits Dolphin. */
141 * Is sent if the selection of the currently active view has
144 void selectionChanged(const KFileItemList
& selection
);
147 * Is sent if the url of the currently active view has
150 void urlChanged(const KUrl
& url
);
153 * Is emitted if information of an item is requested to be shown e. g. in the panel.
154 * If item is null, no item information request is pending.
156 void requestItemInfo(const KFileItem
& item
);
159 /** @see QMainWindow::closeEvent() */
160 virtual void closeEvent(QCloseEvent
* event
);
162 /** @see KMainWindow::saveProperties() */
163 virtual void saveProperties(KConfigGroup
& group
);
165 /** @see KMainWindow::readProperties() */
166 virtual void readProperties(const KConfigGroup
& group
);
169 void clearStatusBar();
171 /** Updates the 'Create New...' sub menu. */
172 void updateNewMenu();
174 /** Shows the error message in the status bar of the active view. */
175 void showErrorMessage(const QString
& message
);
178 * Updates the state of the 'Undo' menu action dependent
179 * from the parameter \a available.
181 void slotUndoAvailable(bool available
);
183 /** Invoked when an action in the recent tabs menu is clicked. */
184 void restoreClosedTab(QAction
* action
);
186 /** Sets the text of the 'Undo' menu action to \a text. */
187 void slotUndoTextChanged(const QString
& text
);
189 /** Performs the current undo operation. */
193 * Copies all selected items to the clipboard and marks
194 * the items as cutted.
198 /** Copies all selected items to the clipboard. */
201 /** Pastes the clipboard data to the active view. */
205 * Updates the text of the paste action dependent from
206 * the number of items which are in the clipboard.
208 void updatePasteAction();
210 /** Selects all items from the active view. */
214 * Inverts the selection of all items of the active view:
215 * Selected items get nonselected and nonselected items get
218 void invertSelection();
221 * Switches between one and two views:
222 * If one view is visible, it will get split into two views.
223 * If already two views are visible, the nonactivated view gets closed.
225 void toggleSplitView();
227 /** Reloads the current active view. */
230 /** Stops the loading process for the current active view. */
234 * Toggles between showing and hiding of the filter bar
236 void toggleFilterBarVisibility(bool show
);
239 * Toggles between edit and browse mode of the navigation bar.
241 void toggleEditLocation();
244 * Switches to the edit mode of the navigation bar and selects
245 * the whole URL, so that it can be replaced by the user. If the edit mode is
246 * already active, it is assured that the navigation bar get focused.
248 void replaceLocation();
250 /** Goes back on step of the URL history. */
253 /** Goes forward one step of the URL history. */
256 /** Goes up one hierarchy of the current URL. */
259 /** Goes to the home URL. */
262 /** Opens Kompare for 2 selected files. */
266 * Hides the menu bar if it is visible, makes the menu bar
267 * visible if it is hidden.
269 void toggleShowMenuBar();
271 /** Opens a terminal window for the current location. */
274 /** Opens the settings dialog for Dolphin. */
277 /** Updates the state of the 'Show Full Location' action. */
278 void slotEditableStateChanged(bool editable
);
281 * Updates the state of the 'Edit' menu actions and emits
282 * the signal selectionChanged().
284 void slotSelectionChanged(const KFileItemList
& selection
);
286 /** Enables changing of tabs via mouse wheel. */
287 void slotWheelMoved(int wheelDelta
);
289 /** Emits the signal requestItemInfo(). */
290 void slotRequestItemInfo(const KFileItem
&);
293 * Updates the state of the 'Back' and 'Forward' menu
294 * actions corresponding to the current history.
296 void updateHistory();
298 /** Updates the state of the 'Show filter bar' menu action. */
299 void updateFilterBarAction(bool show
);
301 /** Open a new main window. */
302 void openNewMainWindow();
304 /** Opens a new view with the current URL that is part of a tab. */
308 * Opens a new tab showing the URL \a url.
310 void openNewTab(const KUrl
& url
);
312 void activateNextTab();
314 void activatePrevTab();
317 * Opens the selected folder in a new tab.
322 * Opens the selected folder in a new window.
324 void openInNewWindow();
326 /** Toggles the active view if two views are shown within the main window. */
327 void toggleActiveView();
330 * Indicates in the statusbar that the execution of the command \a command
333 void showCommand(CommandType command
);
336 * Activates the tab with the index \a index, which means that the current view
337 * is replaced by the view of the given tab.
339 void setActiveTab(int index
);
341 /** Closes the currently active tab. */
345 * Closes the tab with the index \index and activates the tab with index - 1.
347 void closeTab(int index
);
351 * Opens a context menu for the tab with the index \a index
352 * on the position \a pos.
354 void openTabContextMenu(int index
, const QPoint
& pos
);
357 * Handles a click on a places item: if the middle mouse button is
358 * clicked, a new tab is opened for \a url, otherwise the current
359 * view is replaced by \a url.
361 void handlePlacesClick(const KUrl
& url
, Qt::MouseButtons buttons
);
364 * Is connected to the KTabBar signal testCanDecode() and adjusts
365 * the output parameter \a accept.
367 void slotTestCanDecode(const QDragMoveEvent
* event
, bool& accept
);
370 * Is connected with the Dolphin search box and searchs items that
371 * match to the text entered in the search bar.
373 void searchItems(const KUrl
& url
);
376 DolphinMainWindow(int id
);
380 * Activates the given view, which means that
381 * all menu actions are applied to this view. When
382 * having a split view setup, the nonactive view
383 * is usually shown in darker colors.
385 void setActiveViewContainer(DolphinViewContainer
* view
);
388 void setupDockWidgets();
389 void updateEditActions();
390 void updateViewActions();
391 void updateGoActions();
394 * Adds the tab[\a index] to the closed tab menu's list of actions.
396 void rememberClosedTab(int index
);
399 * Connects the signals from the created DolphinView with
400 * the DolphinViewContainer \a container with the corresponding slots of
401 * the DolphinMainWindow. This method must be invoked each
402 * time a DolphinView has been created.
404 void connectViewSignals(DolphinViewContainer
* container
);
407 * Updates the text of the split action:
408 * If two views are shown, the text is set to "Split",
409 * otherwise the text is set to "Join". The icon
410 * is updated to match with the text and the currently active view.
412 void updateSplitAction();
414 /** Returns the name of the tab for the URL \a url. */
415 QString
tabName(const KUrl
& url
) const;
417 bool isKompareInstalled() const;
419 void createSecondaryView(int tabIndex
);
423 * Implements a custom error handling for the undo manager. This
424 * assures that all errors are shown in the status bar of Dolphin
425 * instead as modal error dialog with an OK button.
427 class UndoUiInterface
: public KIO::FileUndoManager::UiInterface
431 virtual ~UndoUiInterface();
432 virtual void jobError(KIO::Job
* job
);
436 KActionMenu
* m_recentTabsMenu
;
437 KAction
* m_showMenuBar
;
439 DolphinViewContainer
* m_activeViewContainer
;
440 QVBoxLayout
* m_centralWidgetLayout
;
441 DolphinSearchBox
* m_searchBox
;
446 ViewTab() : isPrimaryViewActive(true), primaryView(0), secondaryView(0), splitter(0) {}
447 bool isPrimaryViewActive
;
448 DolphinViewContainer
* primaryView
;
449 DolphinViewContainer
* secondaryView
;
454 QList
<ViewTab
> m_viewTab
;
456 DolphinViewActionHandler
* m_actionHandler
;
457 QPointer
<DolphinSettingsDialog
> m_settingsDialog
;
460 inline DolphinViewContainer
* DolphinMainWindow::activeViewContainer() const
462 return m_activeViewContainer
;
465 inline bool DolphinMainWindow::isSplit() const
467 return m_viewTab
[m_tabIndex
].secondaryView
!= 0;
470 inline KNewMenu
* DolphinMainWindow::newMenu() const
475 inline KAction
* DolphinMainWindow::showMenuBarAction() const
477 return m_showMenuBar
;
480 inline int DolphinMainWindow::getId() const
485 #endif // DOLPHIN_MAINWINDOW_H