LibrePCB Developers Documentation
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/lengthunit.h"
27 #include "../units/point.h"
28 
29 #include <QtCore>
30 #include <QtWidgets>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 /*******************************************************************************
38  * Class StatusBar
39  ******************************************************************************/
40 
44 class StatusBar final : public QStatusBar {
45  Q_OBJECT
46 
47 public:
48  // Types
49  enum Field {
50  AbsolutePosition = 1 << 0,
51  ProgressBar = 1 << 1,
52  };
53  Q_DECLARE_FLAGS(Fields, Field);
54 
55  // Constructors / Destructor
56  explicit StatusBar(QWidget* parent = nullptr) noexcept;
57  StatusBar(const StatusBar& other) = delete;
58  ~StatusBar() noexcept;
59 
60  // Getters
61  Fields getFields() const noexcept { return mFields; }
62 
63  // Setters
64  void setFields(Fields fields) noexcept;
65  void setField(Field field, bool enable) noexcept;
66  void setLengthUnit(const LengthUnit& unit) noexcept;
67  void setAbsoluteCursorPosition(const Point& pos) noexcept;
68  void setProgressBarTextFormat(const QString& format) noexcept;
69  void setProgressBarPercent(int percent) noexcept;
70 
71  // Operator Overloadings
72  StatusBar& operator=(const StatusBar& rhs) = delete;
73 
74 private: // Methods
75  void updateAbsoluteCursorPosition() noexcept;
76 
77 private: // Data
78  Fields mFields;
81  QScopedPointer<QLabel> mAbsPosXLabel;
82  QScopedPointer<QLabel> mAbsPosYLabel;
83  QScopedPointer<QProgressBar> mProgressBar;
84  QScopedPointer<QWidget> mProgressBarPlaceHolder;
85 };
86 
87 /*******************************************************************************
88  * End of File
89  ******************************************************************************/
90 
91 } // namespace librepcb
92 
93 Q_DECLARE_OPERATORS_FOR_FLAGS(librepcb::StatusBar::Fields)
94 
95 #endif // LIBREPCB_STATUSBAR_H
QScopedPointer< QWidget > mProgressBarPlaceHolder
Definition: statusbar.h:84
Fields mFields
Definition: statusbar.h:78
Definition: airwiresbuilder.cpp:32
void setField(Field field, bool enable) noexcept
Definition: statusbar.cpp:82
QScopedPointer< QProgressBar > mProgressBar
Definition: statusbar.h:83
Definition: statusbar.h:51
void setLengthUnit(const LengthUnit &unit) noexcept
Definition: statusbar.cpp:91
void updateAbsoluteCursorPosition() noexcept
Definition: statusbar.cpp:120
Point mAbsoluteCursorPosition
Definition: statusbar.h:80
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
StatusBar(QWidget *parent=nullptr) noexcept
Definition: statusbar.cpp:37
QScopedPointer< QLabel > mAbsPosXLabel
Definition: statusbar.h:81
Field
Definition: statusbar.h:49
void setFields(Fields fields) noexcept
Definition: statusbar.cpp:77
Q_DECLARE_FLAGS(Fields, Field)
The StatusBar class extends QStatusBar for some commonly used fields.
Definition: statusbar.h:44
StatusBar & operator=(const StatusBar &rhs)=delete
void setAbsoluteCursorPosition(const Point &pos) noexcept
Definition: statusbar.cpp:96
Definition: statusbar.h:50
void setProgressBarPercent(int percent) noexcept
Definition: statusbar.cpp:105
Fields getFields() const noexcept
Definition: statusbar.h:61
The LengthUnit class represents a length unit (millimeters, inches,...) and provides some useful meth...
Definition: lengthunit.h:62
void setProgressBarTextFormat(const QString &format) noexcept
Definition: statusbar.cpp:101
LengthUnit mLengthUnit
Definition: statusbar.h:79
QScopedPointer< QLabel > mAbsPosYLabel
Definition: statusbar.h:82