]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.h
Merge remote-tracking branch 'fork/work/zakharafoniam/useful-groups'
[dolphin.git] / src / dolphinmainwindow.h
index 5bb17e79adb25aa0509399184edae3268e262f56..8b9c4a211be7762a8cfff8c23bff71f18937706a 100644 (file)
 #define DOLPHIN_MAINWINDOW_H
 
 #include "config-dolphin.h"
+#include "disabledactionnotifier.h"
 #include "dolphintabwidget.h"
 #include "selectionmode/bottombar.h"
+#include <KActionMenu>
 #include <KFileItemActions>
 #include <kio/fileundomanager.h>
 #include <kxmlguiwindow.h>
@@ -20,6 +22,7 @@
 #include "panels/information/informationpanel.h"
 #endif
 
+#include <QFutureWatcher>
 #include <QIcon>
 #include <QList>
 #include <QMenu>
@@ -29,6 +32,7 @@
 
 typedef KIO::FileUndoManager::CommandType CommandType;
 
+class DiskSpaceUsageMenu;
 class DolphinBookmarkHandler;
 class DolphinViewActionHandler;
 class DolphinSettingsDialog;
@@ -39,14 +43,19 @@ class KFileItem;
 class KFileItemList;
 class KJob;
 class KNewFileMenu;
+class KRecentFilesAction;
 class KToolBarPopupAction;
 class QToolButton;
 class PlacesPanel;
 class TerminalPanel;
 
+/** Used to identify that a custom command should be triggered on a view background double-click.*/
+constexpr QLatin1String customCommand{"CUSTOM_COMMAND"};
+
 namespace KIO
 {
 class OpenUrlJob;
+class CommandLauncherJob;
 }
 namespace SelectionMode
 {
@@ -116,10 +125,23 @@ public:
      */
     void setViewsToHomeIfMountPathOpen(const QString &mountPath);
 
+    /**
+     * Enables or disables the session autosaving feature.
+     *
+     * @param enable If true, saves the session automatically after a fixed
+     *               time interval from the last state change.
+     */
+    void setSessionAutoSaveEnabled(bool enable);
+
     bool isFoldersPanelEnabled() const;
     bool isInformationPanelEnabled() const;
     bool isSplitViewEnabledInCurrentTab() const;
 
+    /**
+     * Activates a user set action when double clicking the view's background.
+     */
+    void slotDoubleClickViewBackground(Qt::MouseButton button);
+
 public Q_SLOTS:
     /**
      * Opens each directory in \p dirs in a separate tab. If \a splitView is set,
@@ -188,8 +210,9 @@ public Q_SLOTS:
 
     /**
      * Opens a new tab in the background showing the URL \a url.
+     * @return A pointer to the opened DolphinTabPage.
      */
-    void openNewTab(const QUrl &url);
+    DolphinTabPage *openNewTab(const QUrl &url);
 
     /**
      * Opens a new tab  showing the URL \a url and activate it.
@@ -274,6 +297,7 @@ private Q_SLOTS:
     void updateNewMenu();
 
     void createDirectory();
+    void createFile();
 
     /** Shows the error message in the status bar of the active view. */
     void showErrorMessage(const QString &message);
@@ -334,6 +358,13 @@ private Q_SLOTS:
      */
     void toggleSplitView();
 
+    /**
+     * Pops out a split view.
+     * The active view will be popped out, unless the view is not split,
+     * in which case nothing will happen.
+     */
+    void popoutSplitView();
+
     /** Dedicated action to open the stash:/ ioslave in split view. */
     void toggleSplitStash();
 
@@ -375,10 +406,21 @@ private Q_SLOTS:
     void togglePanelLockState();
 
     /**
-     * Is invoked if the Terminal panel got visible/invisible and takes care
-     * that the active view has the focus if the Terminal panel is invisible.
+     * Is invoked whenever the Terminal panel visibility is changed by the user and then moves the focus
+     * to the active view if the panel was hidden.
+     * @note The opposite action (putting focus to the Terminal) is not handled
+     *       here but in TerminalPanel::showEvent().
+     * @param visible the new visibility state of the terminal panel
+     */
+    void slotTerminalPanelVisibilityChanged(bool visible);
+
+    /**
+     * Is invoked whenever the Places panel visibility is changed by the user and then either moves the focus
+     * - to the Places panel if it was made visible, or
+     * - to the active view if the panel was hidden.
+     * @param visible the new visibility state of the Places panel
      */
-    void slotTerminalPanelVisibilityChanged();
+    void slotPlacesPanelVisibilityChanged(bool visible);
 
     /** Goes back one step of the URL history. */
     void goBack();
@@ -428,8 +470,11 @@ private Q_SLOTS:
     /** Opens a terminal window for the URL. */
     void openTerminalJob(const QUrl &url);
 
-    /** Focus a Terminal Panel. */
-    void focusTerminalPanel();
+    /** Toggles focus to/from a Terminal Panel. */
+    void toggleTerminalPanelFocus();
+
+    /** Toggles focus to/from the Places Panel. */
+    void togglePlacesPanelFocus();
 
     /** Opens the settings dialog for Dolphin. */
     void editSettings();
@@ -476,6 +521,11 @@ private Q_SLOTS:
      */
     void openInNewWindow();
 
+    /**
+     * Opens the selected folder in the other inactive split view, enables split view if necessary.
+     */
+    void openInSplitView(const QUrl &url);
+
     /**
      * Show the target of the selected symlink
      */
@@ -614,6 +664,11 @@ private Q_SLOTS:
      */
     void slotKeyBindings();
 
+    /**
+     * Saves the session.
+     */
+    void slotSaveSession();
+
 private:
     /**
      * Sets up the various menus and actions and connects them.
@@ -643,22 +698,26 @@ private:
      * otherwise the text is set to "Join". The icon
      * is updated to match with the text and the currently active view.
      */
-    void updateSplitAction();
+    void updateSplitActions();
 
     /**
      * Sets the window sides the toolbar may be moved to based on toolbar contents.
      */
     void updateAllowedToolbarAreas();
 
+    /**
+     * Sets the background of the location bar(s) on if they are inside the toolbar,
+     * or off if they are outside the toolbar.
+     */
+    void updateNavigatorsBackground();
+
     bool isKompareInstalled() const;
 
     /**
      * Creates an action for showing/hiding a panel, that is accessible
-     * in "Configure toolbars..." and "Configure shortcuts...". This is necessary
-     * as the action for toggling the dock visibility is done by Qt which
-     * is no KAction instance.
+     * in "Configure toolbars..." and "Configure shortcuts...".
      */
-    void createPanelAction(const QIcon &icon, const QKeySequence &shortcut, QAction *dockAction, const QString &actionName);
+    void createPanelAction(const QIcon &icon, const QKeySequence &shortcut, QDockWidget *dockAction, const QString &actionName);
 
     /** Adds "What's This?" texts to many widgets and StandardActions. */
     void setupWhatsThis();
@@ -702,6 +761,7 @@ private:
     QPointer<DolphinSettingsDialog> m_settingsDialog;
     DolphinBookmarkHandler *m_bookmarkHandler;
     SelectionMode::ActionTextHelper *m_actionTextHelper;
+    DisabledActionNotifier *m_disabledActionNotifier;
 
     KIO::OpenUrlJob *m_lastHandleUrlOpenJob;
 
@@ -711,10 +771,21 @@ private:
 
     KToolBarPopupAction *m_backAction;
     KToolBarPopupAction *m_forwardAction;
+    KActionMenu *m_splitViewAction;
+    QAction *m_splitViewMenuAction;
+    DiskSpaceUsageMenu *m_diskSpaceUsageMenu;
 
     QMenu m_searchTools;
     KFileItemActions m_fileItemActions;
 
+    QTimer *m_sessionSaveTimer;
+    QFutureWatcher<void> *m_sessionSaveWatcher;
+    bool m_sessionSaveScheduled;
+
+    KIO::CommandLauncherJob *m_job;
+
+    KRecentFilesAction *m_recentFiles = nullptr;
+
     friend class DolphinMainWindowTest;
 };