]>
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 "sidebarpage.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 DolphinViewContainer
;
50 * @short Main window for Dolphin.
52 * Handles the menus, toolbars and Dolphin views.
54 class DolphinMainWindow
: public KXmlGuiWindow
57 Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
58 Q_PROPERTY(int id READ getId SCRIPTABLE
true)
59 friend class DolphinApplication
;
62 virtual ~DolphinMainWindow();
65 * Returns the currently active view.
66 * All menu actions are applied to this view. When
67 * having a split view setup, the nonactive view
68 * is usually shown in darker colors.
70 DolphinViewContainer
* activeViewContainer() const;
73 * Returns true, if the main window contains two instances
74 * of a view container. The active view constainer can be
75 * accessed by DolphinMainWindow::activeViewContainer().
80 * If the main window contains two instances of a view container
81 * (DolphinMainWindow::isSplit() returns true), then the
82 * two views get toggled (the right view is on the left, the left
87 /** Renames the item represented by \a oldUrl to \a newUrl. */
88 void rename(const KUrl
& oldUrl
, const KUrl
& newUrl
);
91 * Refreshes the views of the main window by recreating them dependent from
92 * the given Dolphin settings.
97 * Returns the 'Create New...' sub menu which also can be shared
98 * with other menus (e. g. a context menu).
100 KNewMenu
* newMenu() const;
103 * Returns the 'Show Menubar' action which can be shared with
104 * other menus (e. g. a context menu).
106 KAction
* showMenuBarAction() const;
110 * Pastes the clipboard data into the currently selected folder
111 * of the active view. If not exactly one folder is selected,
112 * no pasting is done at all.
114 void pasteIntoFolder();
117 * Returns the main window ID used through DBus.
122 * Inform all affected dolphin components (sidebars, views) of an URL
125 void changeUrl(const KUrl
& url
);
128 * Inform all affected dolphin components that a selection change is
131 void changeSelection(const KFileItemList
& selection
);
133 /** Stores all settings and quits Dolphin. */
138 * Is sent if the selection of the currently active view has
141 void selectionChanged(const KFileItemList
& selection
);
144 * Is sent if the url of the currently active view has
147 void urlChanged(const KUrl
& url
);
150 * Is emitted if information of an item is requested to be shown e. g. in the sidebar.
151 * If item is null, no item information request is pending.
153 void requestItemInfo(const KFileItem
& item
);
156 /** @see QMainWindow::closeEvent() */
157 virtual void closeEvent(QCloseEvent
* event
);
159 /** @see KMainWindow::saveProperties() */
160 virtual void saveProperties(KConfigGroup
& group
);
162 /** @see KMainWindow::readProperties() */
163 virtual void readProperties(const KConfigGroup
& group
);
166 void clearStatusBar();
168 /** Updates the 'Create New...' sub menu. */
169 void updateNewMenu();
172 * Shows the error information from the places model
175 void slotHandlePlacesError(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 /** Sets the text of the 'Undo' menu action to \a text. */
184 void slotUndoTextChanged(const QString
& text
);
186 /** Performs the current undo operation. */
190 * Copies all selected items to the clipboard and marks
191 * the items as cutted.
195 /** Copies all selected items to the clipboard. */
198 /** Pastes the clipboard data to the active view. */
202 * Updates the text of the paste action dependent from
203 * the number of items which are in the clipboard.
205 void updatePasteAction();
207 /** Selects all items from the active view. */
211 * Inverts the selection of all items of the active view:
212 * Selected items get nonselected and nonselected items get
215 void invertSelection();
218 * Switches between one and two views:
219 * If one view is visible, it will get split into two views.
220 * If already two views are visible, the nonactivated view gets closed.
222 void toggleSplitView();
224 /** Reloads the current active view. */
227 /** Stops the loading process for the current active view. */
231 * Toggles between showing and hiding of the filter bar
233 void toggleFilterBarVisibility(bool show
);
236 * Toggles between edit and browse mode of the navigation bar.
238 void toggleEditLocation();
241 * Switches to the edit mode of the navigation bar and selects
242 * the whole URL, so that it can be replaced by the user. If the edit mode is
243 * already active, it is assured that the navigation bar get focused.
245 void replaceLocation();
247 /** Goes back on step of the URL history. */
250 /** Goes forward one step of the URL history. */
253 /** Goes up one hierarchy of the current URL. */
256 /** Goes to the home URL. */
259 /** Opens Kompare for 2 selected files. */
263 * Initiates a preview of the selected files
264 * on the desktop by the Previewer plasmoid.
269 * Hides the menu bar if it is visible, makes the menu bar
270 * visible if it is hidden.
272 void toggleShowMenuBar();
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 /** Emits the signal requestItemInfo(). */
287 void slotRequestItemInfo(const KFileItem
&);
290 * Updates the state of the 'Back' and 'Forward' menu
291 * actions corresponding to the current history.
293 void updateHistory();
295 /** Updates the state of the 'Show filter bar' menu action. */
296 void updateFilterBarAction(bool show
);
298 /** Open a new main window. */
299 void openNewMainWindow();
301 /** Opens a new view with the current URL that is part of a tab. */
305 * Opens a new tab showing the URL \a url.
307 void openNewTab(const KUrl
& url
);
309 void activateNextTab();
311 void activatePrevTab();
313 /** Toggles the active view if two views are shown within the main window. */
314 void toggleActiveView();
317 * Indicates in the statusbar that the execution of the command \a command
320 void showCommand(CommandType command
);
323 * Activates the tab with the index \a index, which means that the current view
324 * is replaced by the view of the given tab.
326 void setActiveTab(int index
);
328 /** Closes the currently active tab. */
332 * Closes the tab with the index \index and activates the tab with index - 1.
334 void closeTab(int index
);
337 * Opens a context menu for the tab with the index \a index
338 * on the position \a pos.
340 void openTabContextMenu(int index
, const QPoint
& pos
);
343 * Handles a click on a places item: if the middle mouse button is
344 * clicked, a new tab is opened for \a url, otherwise the current
345 * view is replaced by \a url.
347 void handlePlacesClick(const KUrl
& url
, Qt::MouseButtons buttons
);
350 * Is connected to the KTabBar signal testCanDecode() and adjusts
351 * the output parameter \a accept.
353 void slotTestCanDecode(const QDragMoveEvent
* event
, bool& accept
);
356 DolphinMainWindow(int id
);
360 * Activates the given view, which means that
361 * all menu actions are applied to this view. When
362 * having a split view setup, the nonactive view
363 * is usually shown in darker colors.
365 void setActiveViewContainer(DolphinViewContainer
* view
);
368 void setupDockWidgets();
369 void updateEditActions();
370 void updateViewActions();
371 void updateGoActions();
374 * Connects the signals from the created DolphinView with
375 * the DolphinViewContainer \a container with the corresponding slots of
376 * the DolphinMainWindow. This method must be invoked each
377 * time a DolphinView has been created.
379 void connectViewSignals(DolphinViewContainer
* container
);
382 * Updates the text of the split action:
383 * If two views are shown, the text is set to "Split",
384 * otherwise the text is set to "Join". The icon
385 * is updated to match with the text and the currently active view.
387 void updateSplitAction();
389 /** Returns the name of the tab for the URL \a url. */
390 QString
tabName(const KUrl
& url
) const;
392 bool isKompareInstalled() const;
396 * Implements a custom error handling for the undo manager. This
397 * assures that all errors are shown in the status bar of Dolphin
398 * instead as modal error dialog with an OK button.
400 class UndoUiInterface
: public KIO::FileUndoManager::UiInterface
404 virtual ~UndoUiInterface();
405 virtual void jobError(KIO::Job
* job
);
409 KAction
* m_showMenuBar
;
411 DolphinViewContainer
* m_activeViewContainer
;
412 QVBoxLayout
* m_centralWidgetLayout
;
417 ViewTab() : isPrimaryViewActive(true), primaryView(0), secondaryView(0), splitter(0) {}
418 bool isPrimaryViewActive
;
419 DolphinViewContainer
* primaryView
;
420 DolphinViewContainer
* secondaryView
;
425 QList
<ViewTab
> m_viewTab
;
427 DolphinViewActionHandler
* m_actionHandler
;
430 inline DolphinViewContainer
* DolphinMainWindow::activeViewContainer() const
432 return m_activeViewContainer
;
435 inline bool DolphinMainWindow::isSplit() const
437 return m_viewTab
[m_tabIndex
].secondaryView
!= 0;
440 inline KNewMenu
* DolphinMainWindow::newMenu() const
445 inline KAction
* DolphinMainWindow::showMenuBarAction() const
447 return m_showMenuBar
;
450 inline int DolphinMainWindow::getId() const
455 #endif // DOLPHIN_MAINWINDOW_H