Debian Codegraph @

src/Gui/Control.h

raw
1 /***************************************************************************
2 * Copyright (c) 2011 Jürgen Riegel <[email protected]> *
3 * *
4 * This file is part of the FreeCAD CAx development system. *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Library General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2 of the License, or (at your option) any later version. *
10 * *
11 * This library 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 Library General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Library General Public *
17 * License along with this library; see the file COPYING.LIB. If not, *
18 * write to the Free Software Foundation, Inc., 59 Temple Place, *
19 * Suite 330, Boston, MA 02111-1307, USA *
20 * *
21 ***************************************************************************/
22
23
24 #ifndef GUI_CONTROL_H
25 #define GUI_CONTROL_H
26
27 // Std. configurations
28
29 #include <QObject>
30 #include <bitset>
31 #include <stack>
32
33 #include <Gui/TaskView/TaskDialog.h>
34
35 class QDockWidget;
36 class QTabBar;
37
38 namespace App
39 {
40 class DocumentObject;
41 class Document;
42 } // namespace App
43
44 namespace Gui
45 {
46 namespace TaskView
47 {
48 class TaskDialog;
49 class TaskView;
50 } // namespace TaskView
51
52
53 /** The control class
54 */
55 class GuiExport ControlSingleton: public QObject
56 {
57 Q_OBJECT
58
59 public:
60 static ControlSingleton& instance();
61 static void destruct();
62
63 /** @name dialog handling
64 * These methods are used to control the TaskDialog stuff.
65 */
66 //@{
67 /// This method starts a task dialog in the task view
68 void showDialog(Gui::TaskView::TaskDialog* dlg);
69 Gui::TaskView::TaskDialog* activeDialog() const;
70 // void closeDialog();
71 //@}
72
73 /** @name task view handling
74 */
75 //@{
76 Gui::TaskView::TaskView* taskPanel() const;
77 /// raising the model view
78 void showModelView();
79 //@}
80
81 /*!
82 If a task dialog is open then it indicates whether this task dialog allows other commands to
83 modify the document while it is open. If no task dialog is open true is returned.
84 */
85 bool isAllowedAlterDocument() const;
86 /*!
87 If a task dialog is open then it indicates whether this task dialog allows other commands to
88 modify the 3d view while it is open. If no task dialog is open true is returned.
89 */
90 bool isAllowedAlterView() const;
91 /*!
92 If a task dialog is open then it indicates whether this task dialog allows other commands to
93 modify the selection while it is open. If no task dialog is open true is returned.
94 */
95 bool isAllowedAlterSelection() const;
96
97 public Q_SLOTS:
98 void accept();
99 void reject();
100 void closeDialog();
101 /// raises the task view panel
102 void showTaskView();
103
104 private Q_SLOTS:
105 /// This get called by the TaskView when the Dialog is finished
106 void closedDialog();
107
108 private:
109 struct status
110 {
111 std::bitset<32> StatusBits;
112 } CurrentStatus;
113
114 std::stack<status> StatusStack;
115
116 Gui::TaskView::TaskDialog* ActiveDialog;
117 int oldTabIndex;
118
119 private:
120 /// Construction
121 ControlSingleton();
122 /// Destruction
123 ~ControlSingleton() override;
124 void showDockWidget(QWidget*);
125 QTabBar* findTabBar(QDockWidget*) const;
126 void aboutToShowDialog(QDockWidget* widget);
127 void aboutToHideDialog(QDockWidget* widget);
128
129 static ControlSingleton* _pcSingleton;
130 };
131
132 /// Get the global instance
133 inline ControlSingleton& Control()
134 {
135 return ControlSingleton::instance();
136 }
137
138 } // namespace Gui
139
140 #endif // GUI_CONTROL_H