Finish up singleton refactoring into one giant class
This commit is contained in:
@@ -75,10 +75,9 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||
this->goToBottom->getLabel().setText("More messages below");
|
||||
this->goToBottom->setVisible(false);
|
||||
|
||||
this->managedConnections.emplace_back(
|
||||
singletons::FontManager::getInstance().fontChanged.connect([this] {
|
||||
this->layoutMessages(); //
|
||||
}));
|
||||
this->managedConnections.emplace_back(app->fonts->fontChanged.connect([this] {
|
||||
this->layoutMessages(); //
|
||||
}));
|
||||
|
||||
connect(goToBottom, &RippleEffectLabel::clicked, this, [=] {
|
||||
QTimer::singleShot(180, [=] {
|
||||
@@ -514,7 +513,7 @@ messages::MessageElement::Flags ChannelView::getFlags() const
|
||||
if (split->getModerationMode()) {
|
||||
flags = (MessageElement::Flags)(flags | MessageElement::ModeratorTools);
|
||||
}
|
||||
if (this->channel == TwitchServer::getInstance().mentionsChannel) {
|
||||
if (this->channel == app->twitch.server->mentionsChannel) {
|
||||
flags = (MessageElement::Flags)(flags | MessageElement::ChannelName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "label.hpp"
|
||||
|
||||
#include "application.hpp"
|
||||
#include "singletons/fontmanager.hpp"
|
||||
|
||||
#include <QPainter>
|
||||
@@ -9,8 +11,11 @@ namespace widgets {
|
||||
Label::Label(BaseWidget *parent)
|
||||
: BaseWidget(parent)
|
||||
{
|
||||
singletons::FontManager::getInstance().fontChanged.connect(
|
||||
[this]() { this->scaleChangedEvent(this->getScale()); });
|
||||
auto app = getApp();
|
||||
|
||||
app->fonts->fontChanged.connect([=]() {
|
||||
this->scaleChangedEvent(this->getScale()); //
|
||||
});
|
||||
}
|
||||
|
||||
const QString &Label::getText() const
|
||||
@@ -37,8 +42,9 @@ void Label::setFontStyle(FontStyle style)
|
||||
|
||||
void Label::scaleChangedEvent(float scale)
|
||||
{
|
||||
QFontMetrics metrics =
|
||||
singletons::FontManager::getInstance().getFontMetrics(this->fontStyle, scale);
|
||||
auto app = getApp();
|
||||
|
||||
QFontMetrics metrics = app->fonts->getFontMetrics(this->fontStyle, scale);
|
||||
|
||||
this->preferedSize = QSize(metrics.width(this->text), metrics.height());
|
||||
|
||||
@@ -57,13 +63,13 @@ QSize Label::minimumSizeHint() const
|
||||
|
||||
void Label::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
painter.setFont(singletons::FontManager::getInstance().getFont(
|
||||
this->fontStyle, this->getScale() / painter.device()->devicePixelRatioF()));
|
||||
auto app = getApp();
|
||||
|
||||
int width = singletons::FontManager::getInstance()
|
||||
.getFontMetrics(this->fontStyle, this->getScale())
|
||||
.width(this->text);
|
||||
QPainter painter(this);
|
||||
painter.setFont(app->fonts->getFont(this->fontStyle,
|
||||
this->getScale() / painter.device()->devicePixelRatioF()));
|
||||
|
||||
int width = app->fonts->getFontMetrics(this->fontStyle, this->getScale()).width(this->text);
|
||||
|
||||
int flags = Qt::TextSingleLine;
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "widgets/helper/splitheader.hpp"
|
||||
|
||||
#include "application.hpp"
|
||||
#include "providers/twitch/twitchchannel.hpp"
|
||||
#include "providers/twitch/twitchserver.hpp"
|
||||
#include "singletons/resourcemanager.hpp"
|
||||
@@ -28,17 +30,16 @@ SplitHeader::SplitHeader(Split *_split)
|
||||
: BaseWidget(_split)
|
||||
, split(_split)
|
||||
{
|
||||
auto app = getApp();
|
||||
this->setMouseTracking(true);
|
||||
|
||||
singletons::ResourceManager &resourceManager = singletons::ResourceManager::getInstance();
|
||||
|
||||
util::LayoutCreator<SplitHeader> layoutCreator(this);
|
||||
auto layout = layoutCreator.emplace<QHBoxLayout>().withoutMargin();
|
||||
{
|
||||
// dropdown label
|
||||
auto dropdown = layout.emplace<RippleEffectButton>(this).assign(&this->dropdownButton);
|
||||
dropdown->setMouseTracking(true);
|
||||
dropdown->setPixmap(resourceManager.splitHeaderContext->getPixmap());
|
||||
dropdown->setPixmap(app->resources->splitHeaderContext->getPixmap());
|
||||
this->addDropdownItems(dropdown.getElement());
|
||||
QObject::connect(dropdown.getElement(), &RippleEffectButton::clicked, this, [this] {
|
||||
QTimer::singleShot(80, [&] {
|
||||
@@ -197,10 +198,11 @@ void SplitHeader::updateChannelText()
|
||||
|
||||
void SplitHeader::updateModerationModeIcon()
|
||||
{
|
||||
singletons::ResourceManager &resourceManager = singletons::ResourceManager::getInstance();
|
||||
auto app = getApp();
|
||||
|
||||
this->moderationButton->setPixmap(this->split->getModerationMode()
|
||||
? resourceManager.moderationmode_enabled->getPixmap()
|
||||
: resourceManager.moderationmode_disabled->getPixmap());
|
||||
? app->resources->moderationmode_enabled->getPixmap()
|
||||
: app->resources->moderationmode_disabled->getPixmap());
|
||||
|
||||
bool modButtonVisible = false;
|
||||
ChannelPtr channel = this->split->getChannel();
|
||||
@@ -285,8 +287,10 @@ void SplitHeader::menuReloadChannelEmotes()
|
||||
|
||||
void SplitHeader::menuManualReconnect()
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
// fourtf: connection
|
||||
providers::twitch::TwitchServer::getInstance().connect();
|
||||
app->twitch.server->connect();
|
||||
}
|
||||
|
||||
void SplitHeader::menuShowChangelog()
|
||||
|
||||
@@ -39,7 +39,6 @@ SplitInput::SplitInput(Split *_chatWidget)
|
||||
void SplitInput::initLayout()
|
||||
{
|
||||
auto app = getApp();
|
||||
auto &fontManager = singletons::FontManager::getInstance();
|
||||
util::LayoutCreator<SplitInput> layoutCreator(this);
|
||||
|
||||
auto layout = layoutCreator.setLayoutType<QHBoxLayout>().withoutMargin().assign(&this->ui.hbox);
|
||||
@@ -66,11 +65,11 @@ void SplitInput::initLayout()
|
||||
|
||||
// set edit font
|
||||
this->ui.textEdit->setFont(
|
||||
fontManager.getFont(singletons::FontManager::Type::Medium, this->getScale()));
|
||||
app->fonts->getFont(singletons::FontManager::Type::Medium, this->getScale()));
|
||||
|
||||
this->managedConnections.emplace_back(fontManager.fontChanged.connect([this, &fontManager]() {
|
||||
this->managedConnections.emplace_back(app->fonts->fontChanged.connect([=]() {
|
||||
this->ui.textEdit->setFont(
|
||||
fontManager.getFont(singletons::FontManager::Type::Medium, this->getScale()));
|
||||
app->fonts->getFont(singletons::FontManager::Type::Medium, this->getScale()));
|
||||
}));
|
||||
|
||||
// open emote popup
|
||||
|
||||
Reference in New Issue
Block a user