Debian Codegraph @

src/Gui/Dialogs/DlgToolbarsImp.h

raw
1 /***************************************************************************
2 * Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
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_DIALOG_DLGTOOLBARS_IMP_H
25 #define GUI_DIALOG_DLGTOOLBARS_IMP_H
26
27 #include <boost/signals2/connection.hpp>
28 #include "PropertyPage.h"
29 #include <memory>
30
31 class QTreeWidgetItem;
32
33 namespace Gui
34 {
35 namespace Dialog
36 {
37 class Ui_DlgCustomToolbars;
38
39 /** This class implements the creation of user defined toolbars.
40 * In the left panel are shown all command groups with their command objects.
41 * If any changeable toolbar was created in the left panel are shown all commands
42 * of the currently edited toolbar, otherwise it is empty.
43 * All changes to a toolbar is done immediately.
44 *
45 * \author Werner Mayer
46 */
47 class DlgCustomToolbars: public CustomizeActionPage
48 {
49 Q_OBJECT
50
51 protected:
52 enum Type
53 {
54 Toolbar,
55 Toolboxbar
56 };
57
58 explicit DlgCustomToolbars(Type, QWidget* parent = nullptr);
59 ~DlgCustomToolbars() override;
60
61 public:
62 void activateWorkbenchBox(int index); // Public accessor for DlgMacroExecuteImp
63
64 protected:
65 void setupConnections();
66 void onWorkbenchBoxActivated(int index);
67 void onMoveActionRightButtonClicked();
68 void onMoveActionLeftButtonClicked();
69 void onMoveActionUpButtonClicked();
70 void onMoveActionDownButtonClicked();
71 void onNewButtonClicked();
72 void onRenameButtonClicked();
73 void onDeleteButtonClicked();
74
75 protected Q_SLOTS:
76 void onAddMacroAction(const QByteArray&) override;
77 void onRemoveMacroAction(const QByteArray&) override;
78 void onModifyMacroAction(const QByteArray&) override;
79
80 protected:
81 void changeEvent(QEvent* e) override;
82 void hideEvent(QHideEvent* event) override;
83 virtual void addCustomToolbar(const QString&);
84 virtual void removeCustomToolbar(const QString&);
85 virtual void renameCustomToolbar(const QString&, const QString&);
86 virtual void addCustomCommand(const QString&, const QByteArray&);
87 virtual void removeCustomCommand(const QString&, const QByteArray&);
88 virtual void moveUpCustomCommand(const QString&, const QByteArray&);
89 virtual void moveDownCustomCommand(const QString&, const QByteArray&);
90 void onActivateCategoryBox();
91
92 private:
93 void importCustomToolbars(const QByteArray&);
94 void exportCustomToolbars(const QByteArray&);
95
96 protected:
97 std::unique_ptr<Ui_DlgCustomToolbars> ui;
98
99 private:
100 Type type;
101 boost::signals2::scoped_connection conn;
102 };
103
104 /** This class implements the creation of user defined toolbars.
105 * @see DlgCustomToolbars
106 * @see DlgCustomCmdbarsImp
107 * \author Werner Mayer
108 */
109 class DlgCustomToolbarsImp: public DlgCustomToolbars
110 {
111 Q_OBJECT
112
113 public:
114 explicit DlgCustomToolbarsImp(QWidget* parent = nullptr);
115 ~DlgCustomToolbarsImp() override;
116
117 protected:
118 void showEvent(QShowEvent* e) override;
119 void changeEvent(QEvent* e) override;
120 void addCustomToolbar(const QString&) override;
121 void removeCustomToolbar(const QString&) override;
122 void renameCustomToolbar(const QString&, const QString&) override;
123 void addCustomCommand(const QString&, const QByteArray&) override;
124 void removeCustomCommand(const QString&, const QByteArray&) override;
125 void moveUpCustomCommand(const QString&, const QByteArray&) override;
126 void moveDownCustomCommand(const QString&, const QByteArray&) override;
127
128 private:
129 QList<QAction*> getActionGroup(QAction*);
130 void setActionGroup(QAction*, const QList<QAction*>& group);
131 bool firstShow = true;
132 };
133
134 /** This class implements the creation of user defined toolbox bars.
135 * A toolbox bar is the same as a toolbar - a collection of several
136 * action objects - unless a toolbox bar is placed in a toolbox,
137 * while a toolbar is placed in the dock areas of the main window.
138 * So toolbox bars are predestinated to save place on your desktop.
139 * @see DlgCustomToolbars
140 * @see DlgCustomToolbarsImp
141 * \author Werner Mayer
142 */
143 class DlgCustomToolBoxbarsImp: public DlgCustomToolbars
144 {
145 Q_OBJECT
146
147 public:
148 explicit DlgCustomToolBoxbarsImp(QWidget* parent = nullptr);
149 ~DlgCustomToolBoxbarsImp() override;
150
151 protected:
152 void changeEvent(QEvent* e) override;
153 };
154
155 } // namespace Dialog
156 } // namespace Gui
157
158 #endif // GUI_DIALOG_DLGTOOLBARS_IMP_H