mirror-chatterino2/src/widgets/basewidget.cpp

69 lines
1.6 KiB
C++
Raw Normal View History

#include "widgets/basewidget.hpp"
2017-12-31 00:50:07 +01:00
#include "singletons/settingsmanager.hpp"
#include "singletons/thememanager.hpp"
#include <QDebug>
2018-01-05 03:30:43 +01:00
#include <QIcon>
#include <QLayout>
#include <QtGlobal>
#include <boost/signals2.hpp>
namespace chatterino {
namespace widgets {
BaseWidget::BaseWidget(singletons::ThemeManager &_themeManager, QWidget *parent, Qt::WindowFlags f)
: QWidget(parent, f)
2017-12-31 00:50:07 +01:00
, themeManager(_themeManager)
{
this->init();
}
BaseWidget::BaseWidget(BaseWidget *parent, Qt::WindowFlags f)
: QWidget(parent, f)
2017-12-31 22:58:35 +01:00
, themeManager(singletons::ThemeManager::getInstance())
{
this->init();
}
BaseWidget::BaseWidget(QWidget *parent, Qt::WindowFlags f)
: QWidget(parent, f)
2017-12-31 22:58:35 +01:00
, themeManager(singletons::ThemeManager::getInstance())
2017-12-17 16:45:15 +01:00
{
}
2017-09-22 00:50:43 +02:00
float BaseWidget::getDpiMultiplier()
{
// return 1.f;
2017-09-22 00:50:43 +02:00
BaseWidget *baseWidget = dynamic_cast<BaseWidget *>(this->window());
if (baseWidget == nullptr) {
return 1.f;
} else {
return baseWidget->dpiMultiplier;
// int screenNr = QApplication::desktop()->screenNumber(this);
// QScreen *screen = QApplication::screens().at(screenNr);
// return screen->logicalDotsPerInch() / 96.f;
}
}
void BaseWidget::init()
{
2017-12-31 00:50:07 +01:00
auto connection = this->themeManager.updated.connect([this]() {
this->refreshTheme();
this->update();
});
QObject::connect(this, &QObject::destroyed, [connection] {
connection.disconnect(); //
});
}
void BaseWidget::refreshTheme()
{
// Do any color scheme updates here
}
} // namespace widgets
} // namespace chatterino