2021-08-22 20:41:52 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QSize>
|
|
|
|
|
|
2022-05-03 20:00:52 +01:00
|
|
|
#include "Label.hpp"
|
|
|
|
|
|
2021-08-22 20:41:52 +01:00
|
|
|
namespace Bloom::Widgets
|
|
|
|
|
{
|
2022-05-03 20:00:52 +01:00
|
|
|
class RotatableLabel: public Label
|
2021-08-22 20:41:52 +01:00
|
|
|
{
|
2021-10-06 21:12:31 +01:00
|
|
|
Q_OBJECT
|
2023-03-11 21:09:36 +00:00
|
|
|
Q_PROPERTY(int leftMargin READ getLeftMargin WRITE setLeftMargin DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(int rightMargin READ getRightMargin WRITE setRightMargin DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(int topMargin READ getTopMargin WRITE setTopMargin DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(int bottomMargin READ getBottomMargin WRITE setBottomMargin DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(int angle READ getAngle WRITE setAngle DESIGNABLE true)
|
2021-08-22 20:41:52 +01:00
|
|
|
|
2021-10-06 21:12:31 +01:00
|
|
|
public:
|
2022-05-03 20:00:52 +01:00
|
|
|
RotatableLabel(const QString& text, QWidget* parent)
|
|
|
|
|
: Label(text, parent)
|
|
|
|
|
{};
|
|
|
|
|
|
2021-10-06 21:12:31 +01:00
|
|
|
RotatableLabel(int angleDegrees, const QString& text, QWidget* parent)
|
2022-05-03 20:00:52 +01:00
|
|
|
: Label(text, parent)
|
|
|
|
|
, angle(angleDegrees)
|
2022-04-28 21:08:55 +01:00
|
|
|
{};
|
2021-10-06 21:12:31 +01:00
|
|
|
|
2023-03-11 21:09:36 +00:00
|
|
|
int getLeftMargin() {
|
|
|
|
|
return this->contentsMargins().left();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setLeftMargin(int leftMargin) {
|
|
|
|
|
auto margins = this->contentsMargins();
|
|
|
|
|
margins.setLeft(leftMargin);
|
|
|
|
|
this->setContentsMargins(margins);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int getRightMargin() {
|
|
|
|
|
return this->contentsMargins().right();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setRightMargin(int rightMargin) {
|
|
|
|
|
auto margins = this->contentsMargins();
|
|
|
|
|
margins.setRight(rightMargin);
|
|
|
|
|
this->setContentsMargins(margins);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int getTopMargin() {
|
|
|
|
|
return this->contentsMargins().top();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setTopMargin(int topMargin) {
|
|
|
|
|
auto margins = this->contentsMargins();
|
|
|
|
|
margins.setTop(topMargin);
|
|
|
|
|
this->setContentsMargins(margins);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int getBottomMargin() {
|
|
|
|
|
return this->contentsMargins().bottom();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setBottomMargin(int bottomMargin) {
|
|
|
|
|
auto margins = this->contentsMargins();
|
|
|
|
|
margins.setBottom(bottomMargin);
|
|
|
|
|
this->setContentsMargins(margins);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int getAngle() {
|
|
|
|
|
return this->angle;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-06 21:12:31 +01:00
|
|
|
void setAngle(int angleDegrees) {
|
|
|
|
|
this->angle = angleDegrees;
|
|
|
|
|
}
|
2021-08-22 20:41:52 +01:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void paintEvent(QPaintEvent* event) override;
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] QSize sizeHint() const override {
|
|
|
|
|
return this->getContainerSize();
|
2022-04-28 21:08:55 +01:00
|
|
|
}
|
2021-08-22 20:41:52 +01:00
|
|
|
|
|
|
|
|
[[nodiscard]] QSize minimumSizeHint() const override {
|
|
|
|
|
return this->getContainerSize();
|
2022-04-28 21:08:55 +01:00
|
|
|
}
|
2021-08-22 20:41:52 +01:00
|
|
|
|
2021-10-06 21:12:31 +01:00
|
|
|
private:
|
|
|
|
|
int angle = 90;
|
2021-08-22 20:41:52 +01:00
|
|
|
|
2021-10-06 21:12:31 +01:00
|
|
|
[[nodiscard]] QSize getContainerSize() const;
|
2021-08-22 20:41:52 +01:00
|
|
|
};
|
|
|
|
|
}
|