File indexing completed on 2024-04-28 04:37:32

0001 /*
0002     SPDX-FileCopyrightText: 2007 Roberto Raggi <roberto@kdevelop.org>
0003     SPDX-FileCopyrightText: 2007 Hamish Rodda <rodda@kde.org>
0004     SPDX-FileCopyrightText: 2011 Alexander Dymo <adymo@kdevelop.org>
0005 
0006     SPDX-License-Identifier: LicenseRef-MIT-KDevelop-Ideal
0007 */
0008 
0009 #ifndef SUBLIME_IDEALCONTROLLER_H
0010 #define SUBLIME_IDEALCONTROLLER_H
0011 
0012 #include <QAction>
0013 #include <QSet>
0014 #include <QPointer>
0015 
0016 #include "sublimedefs.h"
0017 
0018 class KActionMenu;
0019 
0020 namespace Sublime {
0021 
0022 class Area;
0023 class View;
0024 class MainWindow;
0025 class IdealButtonBarWidget;
0026 class IdealDockWidget;
0027 class View;
0028 
0029 class IdealController: public QObject
0030 {
0031     Q_OBJECT
0032 public:
0033     explicit IdealController(Sublime::MainWindow *mainWindow);
0034 
0035     void addView(Qt::DockWidgetArea area, View* view);
0036 
0037     enum RaiseMode { HideOtherViews, GroupWithOtherViews };
0038     void raiseView(View* view, RaiseMode mode = HideOtherViews);
0039     void showDockWidget(IdealDockWidget* dock, bool show);
0040     void focusEditor();
0041     QWidget *statusBarLocation() const;
0042     QAction* actionForView(View* view) const;
0043     void setShowDockStatus(Qt::DockWidgetArea area, bool checked);
0044 
0045     /** Remove view.  If nondestructive true, view->widget()
0046         is not deleted, as is left with NULL parent.
0047         Otherwise, it's deleted.  */
0048     void removeView(View* view, bool nondestructive = false);
0049 
0050     void moveView(View *view, Qt::DockWidgetArea area);
0051 
0052     void showLeftDock(bool show);
0053     void showRightDock(bool show);
0054     void showBottomDock(bool show);
0055     void toggleDocksShown();
0056 
0057     IdealButtonBarWidget* barForDockArea(Qt::DockWidgetArea area) const;
0058     QAction* actionForArea(Qt::DockWidgetArea area) const;
0059 
0060     enum Direction { NextDock, PrevDock };
0061     void goPrevNextDock(IdealController::Direction direction);
0062 
0063     IdealButtonBarWidget *leftBarWidget;
0064     IdealButtonBarWidget *rightBarWidget;
0065     IdealButtonBarWidget *bottomBarWidget;
0066     IdealButtonBarWidget *topBarWidget;
0067     QWidget *bottomStatusBarLocation;
0068 
0069     IdealDockWidget* currentDockWidget() const;
0070     QMap<Qt::DockWidgetArea, QPointer<IdealDockWidget> > lastDockWidget;
0071 
0072     QList<IdealDockWidget*> allDockWidgets() const;
0073 
0074 Q_SIGNALS:
0075         /// Emitted, when a context menu is requested on one of the dock bars.
0076     /// When no actions gets associated to the QMenu, it won't be shown.
0077     void dockBarContextMenuRequested(Qt::DockWidgetArea area, const QPoint& position);
0078     void dockShown(Sublime::View*, Sublime::Position pos, bool shown);
0079 
0080 private Q_SLOTS:
0081     void slotDockBarContextMenuRequested(const QPoint& position);
0082     void dockLocationChanged(Qt::DockWidgetArea);
0083     void loadSettings();
0084 
0085 private:
0086     void hideDocks(IdealButtonBarWidget *bar);
0087     void showDock(Qt::DockWidgetArea area, bool show);
0088     void toggleDocksShown(IdealButtonBarWidget *bar, bool show);
0089 
0090     Sublime::MainWindow* const m_mainWindow;
0091 
0092     QSet<IdealDockWidget*> docks;
0093 
0094     /** Map from View to an action that shows/hides
0095         the IdealDockWidget containing that view.  */
0096     QMap<View*, QAction*> m_view_to_action;
0097     /** Map from IdealDockWidget  to an action that shows/hides
0098         that IdealDockWidget.  */
0099     QMap<IdealDockWidget*, QAction*> m_dockwidget_to_action;
0100 
0101     KActionMenu* m_docks;
0102 
0103     QAction* m_showLeftDock;
0104     QAction* m_showRightDock;
0105     QAction* m_showBottomDock;
0106     QAction* m_showTopDock;
0107 
0108 };
0109 
0110 }
0111 
0112 #endif