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