43 Q_PROPERTY(SwitchType switchType READ switchType WRITE setSwitchType NOTIFY appearanceChanged)
44 Q_PROPERTY(
int positionCount READ positionCount WRITE setPositionCount NOTIFY appearanceChanged)
45 Q_PROPERTY(
int position READ position WRITE setPosition NOTIFY positionChanged)
46 Q_PROPERTY(
bool checked READ isChecked WRITE setChecked NOTIFY toggled)
47 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY appearanceChanged)
48 Q_PROPERTY(
bool hasSafetyGuard READ hasSafetyGuard WRITE setHasSafetyGuard NOTIFY appearanceChanged)
49 Q_PROPERTY(
bool isGuardOpen READ isGuardOpen WRITE setGuardOpen NOTIFY guardToggled)
50 Q_PROPERTY(
bool animated READ isAnimated WRITE setAnimated NOTIFY appearanceChanged)
51 Q_PROPERTY(
bool hasLed READ hasLed WRITE setHasLed NOTIFY appearanceChanged)
52 Q_PROPERTY(QString label READ label WRITE setLabel NOTIFY appearanceChanged)
53 Q_PROPERTY(QString labelOff READ labelOff WRITE setLabelOff NOTIFY appearanceChanged)
54 Q_PROPERTY(QString labelOn READ labelOn WRITE setLabelOn NOTIFY appearanceChanged)
55 Q_PROPERTY(QString labelCenter READ labelCenter WRITE setLabelCenter NOTIFY appearanceChanged)
56 Q_PROPERTY(QColor plateColor READ plateColor WRITE setPlateColor NOTIFY appearanceChanged)
57 Q_PROPERTY(QColor leverColor READ leverColor WRITE setLeverColor NOTIFY appearanceChanged)
58 Q_PROPERTY(QColor ledColor READ ledColor WRITE setLedColor NOTIFY appearanceChanged)
59 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor NOTIFY appearanceChanged)
60 Q_PROPERTY(QColor guardColor READ guardColor WRITE setGuardColor NOTIFY appearanceChanged)
64 enum class SwitchType {
78 [[nodiscard]] SwitchType switchType()
const;
80 [[nodiscard]]
int positionCount()
const;
82 [[nodiscard]]
int position()
const;
84 [[nodiscard]]
bool isChecked()
const;
86 [[nodiscard]] Qt::Orientation orientation()
const;
88 [[nodiscard]]
bool hasSafetyGuard()
const;
90 [[nodiscard]]
bool isGuardOpen()
const;
92 [[nodiscard]]
bool isAnimated()
const;
94 [[nodiscard]]
bool hasLed()
const;
96 [[nodiscard]] QString label()
const;
98 [[nodiscard]] QString labelOff()
const;
100 [[nodiscard]] QString labelOn()
const;
102 [[nodiscard]] QString labelCenter()
const;
105 [[nodiscard]] QColor plateColor()
const;
107 [[nodiscard]] QColor leverColor()
const;
109 [[nodiscard]] QColor ledColor()
const;
111 [[nodiscard]] QColor textColor()
const;
113 [[nodiscard]] QColor guardColor()
const;
120 [[nodiscard]] QSize sizeHint()
const override;
128 [[nodiscard]] QSize minimumSizeHint()
const override;
132 void setSwitchType(SwitchType type);
134 void setPositionCount(
int count);
136 void setPosition(
int position);
138 void setChecked(
bool checked);
142 void setOrientation(Qt::Orientation orientation);
144 void setHasSafetyGuard(
bool guard);
146 void setGuardOpen(
bool open);
148 void setAnimated(
bool animated);
150 void setHasLed(
bool hasLed);
152 void setLabel(
const QString &label);
154 void setLabelOff(
const QString &label);
156 void setLabelOn(
const QString &label);
158 void setLabelCenter(
const QString &label);
160 void setPlateColor(
const QColor &color);
162 void setLeverColor(
const QColor &color);
164 void setLedColor(
const QColor &color);
166 void setTextColor(
const QColor &color);
168 void setGuardColor(
const QColor &color);
172 void positionChanged(
int position);
174 void toggled(
bool checked);
176 void guardToggled(
bool isOpen);
178 void appearanceChanged();
181 void paintEvent(QPaintEvent *event)
override;
182 void resizeEvent(QResizeEvent *event)
override;
183 void changeEvent(QEvent *event)
override;
184 void mousePressEvent(QMouseEvent *event)
override;
185 void mouseMoveEvent(QMouseEvent *event)
override;
186 void mouseReleaseEvent(QMouseEvent *event)
override;
187 void keyPressEvent(QKeyEvent *event)
override;
188 void wheelEvent(QWheelEvent *event)
override;
191 void renderStaticBackground();
192 void drawToggleLever(QPainter &painter,
const QRectF &switchArea,
double currentPos);
193 void drawRocker(QPainter &painter,
const QRectF &switchArea,
double currentPos);
194 void drawSafetyGuard(QPainter &painter,
const QRectF &switchArea);
195 void drawLed(QPainter &painter,
const QPointF ¢er,
double radius,
bool active);
196 void drawScrew(QPainter &painter,
const QPointF ¢er,
double radius);
197 QRectF calculateSwitchRect()
const;
198 QRectF calculateGuardRect()
const;
200 std::unique_ptr<IndustrialSwitchPrivate> d_ptr;