mirror-chatterino2/src/widgets/Label.hpp

50 lines
1.2 KiB
C++
Raw Normal View History

2018-06-11 15:04:54 +02:00
#pragma once
2018-06-28 19:46:45 +02:00
#include "singletons/Fonts.hpp"
2018-06-26 14:09:39 +02:00
#include "widgets/BaseWidget.hpp"
2018-06-11 15:04:54 +02:00
2018-06-24 13:32:56 +02:00
#include <pajlada/signals/signalholder.hpp>
2018-06-11 15:04:54 +02:00
namespace chatterino {
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);
const QString &getText() const;
void setText(const QString &text);
FontStyle getFontStyle() const;
void setFontStyle(FontStyle style);
bool getCentered() const;
void setCentered(bool centered);
bool getHasOffset() const;
2018-06-19 18:55:45 +02:00
void setHasOffset(bool hasOffset);
2018-06-11 15:04:54 +02:00
protected:
2018-07-06 17:11:37 +02:00
virtual void scaleChangedEvent(float scale_) override;
2018-06-11 15:04:54 +02:00
virtual void paintEvent(QPaintEvent *) override;
virtual QSize sizeHint() const override;
virtual QSize minimumSizeHint() const override;
private:
2018-07-06 19:23:47 +02:00
void updateSize();
int getOffset();
2018-06-24 13:32:56 +02:00
2018-06-11 15:04:54 +02:00
QString text_;
FontStyle fontStyle_;
QSize preferedSize_;
bool centered_ = false;
bool hasOffset_ = true;
2018-07-06 19:23:47 +02:00
pajlada::Signals::SignalHolder connections_;
2018-06-11 15:04:54 +02:00
};
} // namespace chatterino