]>
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>
38 class DolphinViewActionHandler
;
39 class DolphinApplication
;
40 class DolphinViewContainer
;
48 * @short Main window for Dolphin.
50 * Handles the menus, toolbars and Dolphin views.
52 class DolphinMainWindow
: public KXmlGuiWindow
55 Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
56 Q_PROPERTY(int id READ getId SCRIPTABLE
true)
57 friend class DolphinApplication
;
60 virtual ~DolphinMainWindow();
63 * Returns the currently active view.
64 * All menu actions are applied to this view. When
65 * having a split view setup, the nonactive view
66 * is usually shown in darker colors.
68 DolphinViewContainer
* activeViewContainer() const;
71 * Returns true, if the main window contains two instances
72 * of a view container. The active view constainer can be
73 * accessed by DolphinMainWindow::activeViewContainer().
78 * If the main window contains two instances of a view container
79 * (DolphinMainWindow::isSplit() returns true), then the
80 * two views get toggled (the right view is on the left, the left
85 /** Renames the item represented by \a oldUrl to \a newUrl. */
86 void rename(const KUrl
& oldUrl
, const KUrl
& newUrl
);
89 * Refreshes the views of the main window by recreating them dependent from
90 * the given Dolphin settings.
95 * Returns the 'Create New...' sub menu which also can be shared
96 * with other menus (e. g. a context menu).
98 KNewMenu
* newMenu() const;
101 * Returns the 'Show Menubar' action which can be shared with
102 * other menus (e. g. a context menu).
104 KAction
* showMenuBarAction() const;
108 * Handles the dropping of URLs to the given
109 * destination. This is only called by the TreeViewSidebarPage.
111 void dropUrls(const KFileItem
& destItem
,
112 const KUrl
& destPath
,
116 * Pastes the clipboard data into the currently selected folder
117 * of the active view. If not exactly one folder is selected,
118 * no pasting is done at all.
120 void pasteIntoFolder();
123 * Returns the main window ID used through DBus.
128 * Inform all affected dolphin components (sidebars, views) of an URL
131 void changeUrl(const KUrl
& url
);
134 * Inform all affected dolphin components that a selection change is
137 void changeSelection(const KFileItemList
& selection
);
139 /** Stores all settings and quits Dolphin. */
144 * Is sent if the selection of the currently active view has
147 void selectionChanged(const KFileItemList
& selection
);
150 * Is sent if the url of the currently active view has
153 void urlChanged(const KUrl
& url
);
156 * Is emitted if information of an item is requested to be shown e. g. in the sidebar.
157 * If item is null, no item information request is pending.
159 void requestItemInfo(const KFileItem
& item
);
162 /** @see QMainWindow::closeEvent() */
163 virtual void closeEvent(QCloseEvent
* event
);
165 /** @see KMainWindow::saveProperties() */
166 virtual void saveProperties(KConfigGroup
& group
);
168 /** @see KMainWindow::readProperties() */
169 virtual void readProperties(const KConfigGroup
& group
);
172 void clearStatusBar();
174 /** Updates the 'Create New...' sub menu. */
175 void updateNewMenu();
178 * Shows the error information from the places model
181 void slotHandlePlacesError(const QString
&message
);
184 * Updates the state of the 'Undo' menu action dependent
185 * from the parameter \a available.
187 void slotUndoAvailable(bool available
);
189 /** Sets the text of the 'Undo' menu action to \a text. */
190 void slotUndoTextChanged(const QString
& text
);
192 /** Performs the current undo operation. */
196 * Copies all selected items to the clipboard and marks
197 * the items as cutted.
201 /** Copies all selected items to the clipboard. */
204 /** Pastes the clipboard data to the active view. */
208 * Updates the text of the paste action dependent from
209 * the number of items which are in the clipboard.
211 void updatePasteAction();
213 /** Selects all items from the active view. */
217 * Inverts the selection of all items of the active view:
218 * Selected items get nonselected and nonselected items get
221 void invertSelection();
224 * Switches between one and two views:
225 * If one view is visible, it will get split into two views.
226 * If already two views are visible, the nonactivated view gets closed.
228 void toggleSplitView();
230 /** Reloads the current active view. */
233 /** Stops the loading process for the current active view. */
237 * Toggles between showing and hiding of the filter bar
239 void toggleFilterBarVisibility(bool show
);
242 * Toggles between edit and browse mode of the navigation bar.
244 void toggleEditLocation();
247 * Switches to the edit mode of the navigation bar. If the edit mode is
248 * already active, it is assured that the navigation bar get focused.
252 /** Goes back on step of the URL history. */
255 /** Goes forward one step of the URL history. */
258 /** Goes up one hierarchy of the current URL. */
261 /** Goes to the home URL. */
264 /** Opens Kompare for 2 selected files. */
268 * Initiates a preview of the selected files
269 * on the desktop by the Previewer plasmoid.
274 * Hides the menu bar if it is visible, makes the menu bar
275 * visible if it is hidden.
277 void toggleShowMenuBar();
279 /** Opens the settings dialog for Dolphin. */
282 /** Updates the state of the 'Show Full Location' action. */
283 void slotEditableStateChanged(bool editable
);
286 * Updates the state of the 'Edit' menu actions and emits
287 * the signal selectionChanged().
289 void slotSelectionChanged(const KFileItemList
& selection
);
291 /** Emits the signal requestItemInfo(). */
292 void slotRequestItemInfo(const KFileItem
&);
295 * Updates the state of the 'Back' and 'Forward' menu
296 * actions corresponding to the current history.
298 void updateHistory();
300 /** Updates the state of the 'Show filter bar' menu action. */
301 void updateFilterBarAction(bool show
);
303 /** Open a new main window. */
304 void openNewMainWindow();
306 /** Opens a new view with the current URL that is part of a tab. */
310 * Opens a new tab showing the URL \a url.
312 void openNewTab(const KUrl
& url
);
314 /** Toggles the active view if two views are shown within the main window. */
315 void toggleActiveView();
317 /** Called when the view is doing a file operation, like renaming, copying, moving etc. */
318 void slotDoingOperation(KIO::FileUndoManager::CommandType type
);
321 * Activates the tab with the index \a index, which means that the current view
322 * is replaced by the view of the given tab.
324 void setActiveTab(int index
);
326 /** Closes the currently active tab. */
330 * Closes the tab with the index \index and activates the tab with index - 1.
332 void closeTab(int index
);
335 * Opens a context menu for the tab with the index \a index
336 * on the position \a pos.
338 void openTabContextMenu(int index
, const QPoint
& pos
);
341 * Handles a click on a places item: if the middle mouse button is
342 * clicked, a new tab is opened for \a url, otherwise the current
343 * view is replaced by \a url.
345 void handlePlacesClick(const KUrl
& url
, Qt::MouseButtons buttons
);
348 * Is connected to the KTabBar signal testCanDecode() and adjusts
349 * the output parameter \a accept.
351 void slotTestCanDecode(const QDragMoveEvent
* event
, bool& accept
);
354 DolphinMainWindow(int id
);
358 * Activates the given view, which means that
359 * all menu actions are applied to this view. When
360 * having a split view setup, the nonactive view
361 * is usually shown in darker colors.
363 void setActiveViewContainer(DolphinViewContainer
* view
);
366 void setupDockWidgets();
367 void updateEditActions();
368 void updateViewActions();
369 void updateGoActions();
372 * Connects the signals from the created DolphinView with
373 * the DolphinViewContainer \a container with the corresponding slots of
374 * the DolphinMainWindow. This method must be invoked each
375 * time a DolphinView has been created.
377 void connectViewSignals(DolphinViewContainer
* container
);
380 * Updates the text of the split action:
381 * If two views are shown, the text is set to "Split",
382 * otherwise the text is set to "Join". The icon
383 * is updated to match with the text and the currently active view.
385 void updateSplitAction();
387 /** Returns the name of the tab for the URL \a url. */
388 QString
tabName(const KUrl
& url
) const;
390 bool isKompareInstalled() const;
394 * Implements a custom error handling for the undo manager. This
395 * assures that all errors are shown in the status bar of Dolphin
396 * instead as modal error dialog with an OK button.
398 class UndoUiInterface
: public KIO::FileUndoManager::UiInterface
402 virtual ~UndoUiInterface();
403 virtual void jobError(KIO::Job
* job
);
407 KAction
* m_showMenuBar
;
409 DolphinViewContainer
* m_activeViewContainer
;
410 QVBoxLayout
* m_centralWidgetLayout
;
415 ViewTab() : isPrimaryViewActive(true), primaryView(0), secondaryView(0), splitter(0) {}
416 bool isPrimaryViewActive
;
417 DolphinViewContainer
* primaryView
;
418 DolphinViewContainer
* secondaryView
;
423 QList
<ViewTab
> m_viewTab
;
425 DolphinViewActionHandler
* m_actionHandler
;
427 /// remember pending undo operations until they are finished
428 QList
<KIO::FileUndoManager::CommandType
> m_undoCommandTypes
;
431 inline DolphinViewContainer
* DolphinMainWindow::activeViewContainer() const
433 return m_activeViewContainer
;
436 inline bool DolphinMainWindow::isSplit() const
438 return m_viewTab
[m_tabIndex
].secondaryView
!= 0;
441 inline KNewMenu
* DolphinMainWindow::newMenu() const
446 inline KAction
* DolphinMainWindow::showMenuBarAction() const
448 return m_showMenuBar
;
451 inline int DolphinMainWindow::getId() const
456 #endif // DOLPHIN_MAINWINDOW_H