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
|
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
|
|
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
}
|