2019-07-23 22:18:36 +02:00
|
|
|
#pragma once
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-07-23 22:18:36 +02:00
|
|
|
#include "singletons/Fonts.hpp"
|
|
|
|
#include "widgets/BaseWidget.hpp"
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-07-23 22:18:36 +02:00
|
|
|
#include <pajlada/signals/signalholder.hpp>
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-10-07 15:46:08 +02:00
|
|
|
namespace chatterino {
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-07-23 22:18:36 +02:00
|
|
|
class Label : public BaseWidget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit Label(QString text = QString(),
|
|
|
|
FontStyle style = FontStyle::UiMedium);
|
|
|
|
explicit Label(BaseWidget *parent, QString text = QString(),
|
|
|
|
FontStyle style = FontStyle::UiMedium);
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-07-23 22:18:36 +02:00
|
|
|
const QString &getText() const;
|
|
|
|
void setText(const QString &text);
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-07-23 22:18:36 +02:00
|
|
|
FontStyle getFontStyle() const;
|
|
|
|
void setFontStyle(FontStyle style);
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-07-23 22:18:36 +02:00
|
|
|
bool getCentered() const;
|
|
|
|
void setCentered(bool centered);
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-07-23 22:18:36 +02:00
|
|
|
bool getHasOffset() const;
|
|
|
|
void setHasOffset(bool hasOffset);
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-07-23 22:18:36 +02:00
|
|
|
protected:
|
|
|
|
virtual void scaleChangedEvent(float scale_) override;
|
|
|
|
virtual void paintEvent(QPaintEvent *) override;
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-07-23 22:18:36 +02:00
|
|
|
virtual QSize sizeHint() const override;
|
|
|
|
virtual QSize minimumSizeHint() const override;
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-07-23 22:18:36 +02:00
|
|
|
private:
|
|
|
|
void updateSize();
|
|
|
|
int getOffset();
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-07-23 22:18:36 +02:00
|
|
|
QString text_;
|
|
|
|
FontStyle fontStyle_;
|
|
|
|
QSize preferedSize_;
|
|
|
|
bool centered_ = false;
|
|
|
|
bool hasOffset_ = true;
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-07-23 22:18:36 +02:00
|
|
|
pajlada::Signals::SignalHolder connections_;
|
|
|
|
};
|
2019-09-08 22:27:57 +02:00
|
|
|
|
2019-10-07 15:46:08 +02:00
|
|
|
} // namespace chatterino
|