LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
statusbar.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_STATUSBAR_H
21 #define LIBREPCB_STATUSBAR_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../units/point.h"
27 
28 #include <QtCore>
29 #include <QtWidgets>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 
36 /*******************************************************************************
37  * Class StatusBar
38  ******************************************************************************/
39 
46 class StatusBar final : public QStatusBar {
47  Q_OBJECT
48 
49 public:
50  // Types
51  enum Field {
52  AbsolutePosition = 1 << 0,
53  ProgressBar = 1 << 1,
54  };
55  Q_DECLARE_FLAGS(Fields, Field);
56 
57  // Constructors / Destructor
58  explicit StatusBar(QWidget* parent = nullptr) noexcept;
59  StatusBar(const StatusBar& other) = delete;
60  ~StatusBar() noexcept;
61 
62  // Getters
63  Fields getFields() const noexcept { return mFields; }
64 
65  // Setters
66  void setFields(Fields fields) noexcept;
67  void setField(Field field, bool enable) noexcept;
68  void setAbsoluteCursorPosition(const Point& pos) noexcept;
69  void setProgressBarVisible(bool visible) noexcept;
70  void setProgressBarTextFormat(const QString& format) noexcept;
71  void setProgressBarPercent(int percent) noexcept;
72 
73  // General Methods
74  void showProgressBar() noexcept { setProgressBarVisible(true); }
75  void hideProgressBar() noexcept { setProgressBarVisible(false); }
76 
77  // Operator Overloadings
78  StatusBar& operator=(const StatusBar& rhs) = delete;
79 
80 private: // Data
81  Fields mFields;
82  QScopedPointer<QLabel> mAbsPosXLabel;
83  QScopedPointer<QLabel> mAbsPosYLabel;
84  QScopedPointer<QProgressBar> mProgressBar;
85  QScopedPointer<QWidget> mProgressBarPlaceHolder;
86 };
87 
88 /*******************************************************************************
89  * End of File
90  ******************************************************************************/
91 
92 } // namespace librepcb
93 
94 Q_DECLARE_OPERATORS_FOR_FLAGS(librepcb::StatusBar::Fields)
95 
96 #endif // LIBREPCB_STATUSBAR_H
QScopedPointer< QWidget > mProgressBarPlaceHolder
Definition: statusbar.h:85
Fields mFields
Definition: statusbar.h:81
void setField(Field field, bool enable) noexcept
Definition: statusbar.cpp:83
QScopedPointer< QProgressBar > mProgressBar
Definition: statusbar.h:84
void setProgressBarVisible(bool visible) noexcept
Definition: statusbar.cpp:97
Definition: statusbar.h:53
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:81
void hideProgressBar() noexcept
Definition: statusbar.h:75
StatusBar(QWidget *parent=nullptr) noexcept
Definition: statusbar.cpp:37
QScopedPointer< QLabel > mAbsPosXLabel
Definition: statusbar.h:82
Field
Definition: statusbar.h:51
void setFields(Fields fields) noexcept
Definition: statusbar.cpp:78
Q_DECLARE_FLAGS(Fields, Field)
The StatusBar class extends QStatusBar for some commonly used fields.
Definition: statusbar.h:46
StatusBar & operator=(const StatusBar &rhs)=delete
void setAbsoluteCursorPosition(const Point &pos) noexcept
Definition: statusbar.cpp:92
Definition: statusbar.h:52
void setProgressBarPercent(int percent) noexcept
Definition: statusbar.cpp:106
Fields getFields() const noexcept
Definition: statusbar.h:63
void showProgressBar() noexcept
Definition: statusbar.h:74
void setProgressBarTextFormat(const QString &format) noexcept
Definition: statusbar.cpp:102
QScopedPointer< QLabel > mAbsPosYLabel
Definition: statusbar.h:83