2019-07-23 22:18:36 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <boost/optional.hpp>
|
|
|
|
#include <pajlada/signals/signal.hpp>
|
|
|
|
#include <pajlada/signals/signalholder.hpp>
|
|
|
|
|
2019-10-07 15:46:08 +02:00
|
|
|
namespace chatterino {
|
2019-07-23 22:18:36 +02:00
|
|
|
|
|
|
|
class Theme;
|
|
|
|
class BaseWindow;
|
|
|
|
|
|
|
|
class BaseWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-09-25 23:41:18 +02:00
|
|
|
explicit BaseWidget(QWidget *parent = nullptr,
|
|
|
|
Qt::WindowFlags f = Qt::WindowFlags());
|
2019-07-23 22:18:36 +02:00
|
|
|
|
|
|
|
virtual float scale() const;
|
|
|
|
pajlada::Signals::Signal<float> scaleChanged;
|
|
|
|
|
|
|
|
boost::optional<float> overrideScale() const;
|
|
|
|
void setOverrideScale(boost::optional<float>);
|
|
|
|
|
|
|
|
QSize scaleIndependantSize() const;
|
|
|
|
int scaleIndependantWidth() const;
|
|
|
|
int scaleIndependantHeight() const;
|
|
|
|
void setScaleIndependantSize(int width, int height);
|
|
|
|
void setScaleIndependantSize(QSize);
|
|
|
|
void setScaleIndependantWidth(int value);
|
|
|
|
void setScaleIndependantHeight(int value);
|
|
|
|
|
|
|
|
float qtFontScale() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void childEvent(QChildEvent *) override;
|
|
|
|
virtual void showEvent(QShowEvent *) override;
|
|
|
|
|
|
|
|
virtual void scaleChangedEvent(float newScale);
|
|
|
|
virtual void themeChangedEvent();
|
|
|
|
|
|
|
|
void setScale(float value);
|
|
|
|
|
|
|
|
Theme *theme;
|
|
|
|
|
|
|
|
private:
|
|
|
|
float scale_{1.f};
|
|
|
|
boost::optional<float> overrideScale_;
|
|
|
|
QSize scaleIndependantSize_;
|
|
|
|
|
|
|
|
std::vector<BaseWidget *> widgets_;
|
|
|
|
|
|
|
|
pajlada::Signals::SignalHolder signalHolder_;
|
|
|
|
|
|
|
|
friend class BaseWindow;
|
|
|
|
};
|
|
|
|
|
2019-10-07 15:46:08 +02:00
|
|
|
} // namespace chatterino
|