mirror-chatterino2/src/widgets/basewidget.hpp

62 lines
1.4 KiB
C++
Raw Normal View History

#pragma once
#include <QWidget>
2018-01-25 20:49:49 +01:00
#include <pajlada/signals/signal.hpp>
namespace chatterino {
2017-12-31 22:58:35 +01:00
namespace singletons {
2017-12-31 00:50:07 +01:00
class ThemeManager;
} // namespace singletons
namespace widgets {
2018-01-25 20:49:49 +01:00
class BaseWindow;
class BaseWidget : public QWidget
{
Q_OBJECT
public:
explicit BaseWidget(singletons::ThemeManager &_themeManager, QWidget *parent,
Qt::WindowFlags f = Qt::WindowFlags());
explicit BaseWidget(BaseWidget *parent, Qt::WindowFlags f = Qt::WindowFlags());
virtual ~BaseWidget();
2017-12-17 16:45:15 +01:00
2017-12-31 22:58:35 +01:00
singletons::ThemeManager &themeManager;
2018-01-25 20:49:49 +01:00
float getScale() const;
pajlada::Signals::Signal<float> scaleChanged;
2017-09-22 00:50:43 +02:00
2018-01-25 21:11:14 +01:00
QSize getScaleIndependantSize() const;
int getScaleIndependantWidth() const;
int getScaleIndependantHeight() const;
void setScaleIndependantSize(int width, int height);
void setScaleIndependantSize(QSize);
void setScaleIndependantWidth(int value);
void setScaleIndependantHeight(int value);
2017-09-22 00:50:43 +02:00
protected:
void childEvent(QChildEvent *) override;
2017-09-22 00:50:43 +02:00
2018-01-25 20:49:49 +01:00
virtual void scaleChangedEvent(float newScale);
virtual void themeRefreshEvent();
2017-09-22 00:50:43 +02:00
2018-01-25 20:49:49 +01:00
void setScale(float value);
2018-01-24 20:35:26 +01:00
private:
void init();
2018-01-25 20:49:49 +01:00
float scale = 1.f;
2018-01-25 21:11:14 +01:00
QSize scaleIndependantSize;
2018-01-25 20:49:49 +01:00
std::vector<BaseWidget *> widgets;
pajlada::Signals::Connection themeConnection;
2018-01-25 20:49:49 +01:00
static void setScaleRecursive(float scale, QObject *object);
friend class BaseWindow;
};
} // namespace widgets
} // namespace chatterino