LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
toolbarproxy.h
Go to the documentation of this file.
1 /*
2  * LibrePCB - Professional EDA for everyone!
3  * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4  * https://librepcb.org/
5  *
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 3 of the License, or
9  * (at your option) any later version.
10  *
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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef LIBREPCB_TOOLBARPROXY_H
21 #define LIBREPCB_TOOLBARPROXY_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include <QtCore>
27 #include <QtWidgets>
28 
29 #include <memory>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 
36 /*******************************************************************************
37  * Class ToolBarProxy
38  ******************************************************************************/
39 
44 class ToolBarProxy final : public QObject {
45  Q_OBJECT
46 
47 public:
48  // Constructors / Destructor
49  ToolBarProxy(QObject* parent = nullptr) noexcept;
50  ToolBarProxy(const ToolBarProxy& other) = delete;
51  ~ToolBarProxy() noexcept;
52 
53  // Setters
54  void setToolBar(QToolBar* toolbar) noexcept;
55  void setEnabled(bool enabled) noexcept;
56 
57  // General Methods
58  void clear() noexcept;
59  QAction* addAction(std::unique_ptr<QAction> action) noexcept;
60  QAction* addLabel(const QString& text, int indent = 0) noexcept;
61  QAction* addWidget(std::unique_ptr<QWidget> widget) noexcept;
62  QAction* addSeparator() noexcept;
63  void removeAction(QAction* action) noexcept;
64 
65  // Operator Overloadings
66  ToolBarProxy& operator=(const ToolBarProxy& rhs) = delete;
67 
68 private: // Data
69  QToolBar* mToolBar;
70  QList<QAction*> mActions;
71 };
72 
73 /*******************************************************************************
74  * End of File
75  ******************************************************************************/
76 
77 } // namespace librepcb
78 
79 #endif // LIBREPCB_TOOLBARPROXY_H
QToolBar * mToolBar
Definition: toolbarproxy.h:69
QAction * addLabel(const QString &text, int indent=0) noexcept
Definition: toolbarproxy.cpp:102
ToolBarProxy & operator=(const ToolBarProxy &rhs)=delete
QList< QAction * > mActions
Definition: toolbarproxy.h:70
void clear() noexcept
Definition: toolbarproxy.cpp:82
~ToolBarProxy() noexcept
Definition: toolbarproxy.cpp:41
QAction * addWidget(std::unique_ptr< QWidget > widget) noexcept
Definition: toolbarproxy.cpp:108
void removeAction(QAction *action) noexcept
Definition: toolbarproxy.cpp:124
void setToolBar(QToolBar *toolbar) noexcept
Definition: toolbarproxy.cpp:49
void setEnabled(bool enabled) noexcept
Definition: toolbarproxy.cpp:71
QAction * addSeparator() noexcept
Definition: toolbarproxy.cpp:118
ToolBarProxy(QObject *parent=nullptr) noexcept
Definition: toolbarproxy.cpp:37
The ToolBarProxy class allows to map a list of QAction's to one QToolBar.
Definition: toolbarproxy.h:44
QAction * addAction(std::unique_ptr< QAction > action) noexcept
Definition: toolbarproxy.cpp:89