put singletons into their namespace
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "widgets/accountpopup.hpp"
|
||||
#include "singletons/accountmanager.hpp"
|
||||
#include "channel.hpp"
|
||||
#include "credentials.hpp"
|
||||
#include "singletons/accountmanager.hpp"
|
||||
#include "singletons/settingsmanager.hpp"
|
||||
#include "ui_accountpopupform.h"
|
||||
#include "util/urlfetch.hpp"
|
||||
@@ -32,7 +32,7 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> _channel)
|
||||
|
||||
this->resize(0, 0);
|
||||
|
||||
SettingsManager &settings = SettingsManager::getInstance();
|
||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||
|
||||
this->permission = permissions::User;
|
||||
for (auto button : this->ui->profileLayout->findChildren<QPushButton *>()) {
|
||||
@@ -59,7 +59,7 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> _channel)
|
||||
this->sendCommand(this->ui->mod, "/mod ");
|
||||
this->sendCommand(this->ui->unMod, "/unmod ");
|
||||
|
||||
auto &accountManager = AccountManager::getInstance();
|
||||
auto &accountManager = singletons::AccountManager::getInstance();
|
||||
QString userId;
|
||||
QString userNickname;
|
||||
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
||||
@@ -185,7 +185,8 @@ void AccountPopupWidget::loadAvatar(const QUrl &avatarUrl)
|
||||
|
||||
void AccountPopupWidget::updatePermissions()
|
||||
{
|
||||
AccountManager &accountManager = AccountManager::getInstance();
|
||||
singletons::AccountManager &accountManager = singletons::AccountManager::getInstance();
|
||||
|
||||
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
||||
if (!currentTwitchUser) {
|
||||
// No twitch user set (should never happen)
|
||||
@@ -242,7 +243,7 @@ void AccountPopupWidget::focusOutEvent(QFocusEvent *)
|
||||
|
||||
void AccountPopupWidget::showEvent(QShowEvent *)
|
||||
{
|
||||
AccountManager &accountManager = AccountManager::getInstance();
|
||||
singletons::AccountManager &accountManager = singletons::AccountManager::getInstance();
|
||||
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
||||
if (!currentTwitchUser) {
|
||||
// No twitch user set (should never happen)
|
||||
@@ -266,7 +267,8 @@ void AccountPopupWidget::showEvent(QShowEvent *)
|
||||
this->updateButtons(this->ui->ownerLayout, false);
|
||||
}
|
||||
|
||||
QString blacklisted = SettingsManager::getInstance().highlightUserBlacklist.getnonConst();
|
||||
QString blacklisted =
|
||||
singletons::SettingManager::getInstance().highlightUserBlacklist.getnonConst();
|
||||
QStringList list = blacklisted.split("\n", QString::SkipEmptyParts);
|
||||
if (list.contains(this->ui->lblUsername->text(), Qt::CaseInsensitive)) {
|
||||
this->ui->disableHighlights->hide();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "basewidget.hpp"
|
||||
#include "concurrentmap.hpp"
|
||||
#include "util/concurrentmap.hpp"
|
||||
#include "twitch/twitchchannel.hpp"
|
||||
|
||||
#include <QPushButton>
|
||||
@@ -52,7 +52,7 @@ private:
|
||||
QString userID;
|
||||
QPixmap avatar;
|
||||
|
||||
ConcurrentMap<QString, QPixmap> avatarMap;
|
||||
util::ConcurrentMap<QString, QPixmap> avatarMap;
|
||||
|
||||
protected:
|
||||
virtual void focusOutEvent(QFocusEvent *event) override;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "accountswitchwidget.hpp"
|
||||
#include "singletons/accountmanager.hpp"
|
||||
#include "const.hpp"
|
||||
#include "singletons/accountmanager.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
@@ -8,20 +8,22 @@ namespace widgets {
|
||||
AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
|
||||
: QListWidget(parent)
|
||||
{
|
||||
singletons::AccountManager &accountManager = singletons::AccountManager::getInstance();
|
||||
|
||||
this->addItem(ANONYMOUS_USERNAME_LABEL);
|
||||
|
||||
for (const auto &userName : AccountManager::getInstance().Twitch.getUsernames()) {
|
||||
for (const auto &userName : accountManager.Twitch.getUsernames()) {
|
||||
this->addItem(userName);
|
||||
}
|
||||
|
||||
AccountManager::getInstance().Twitch.userListUpdated.connect([this]() {
|
||||
accountManager.Twitch.userListUpdated.connect([this, &accountManager]() {
|
||||
this->blockSignals(true);
|
||||
|
||||
this->clear();
|
||||
|
||||
this->addItem(ANONYMOUS_USERNAME_LABEL);
|
||||
|
||||
for (const auto &userName : AccountManager::getInstance().Twitch.getUsernames()) {
|
||||
for (const auto &userName : accountManager.Twitch.getUsernames()) {
|
||||
this->addItem(userName);
|
||||
}
|
||||
|
||||
@@ -32,13 +34,13 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
|
||||
|
||||
this->refreshSelection();
|
||||
|
||||
QObject::connect(this, &QListWidget::clicked, [this] {
|
||||
QObject::connect(this, &QListWidget::clicked, [this, &accountManager] {
|
||||
if (!this->selectedItems().isEmpty()) {
|
||||
QString newUsername = this->currentItem()->text();
|
||||
if (newUsername.compare(ANONYMOUS_USERNAME_LABEL, Qt::CaseInsensitive) == 0) {
|
||||
AccountManager::getInstance().Twitch.currentUsername = "";
|
||||
accountManager.Twitch.currentUsername = "";
|
||||
} else {
|
||||
AccountManager::getInstance().Twitch.currentUsername = newUsername.toStdString();
|
||||
accountManager.Twitch.currentUsername = newUsername.toStdString();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -55,7 +57,7 @@ void AccountSwitchWidget::refreshSelection()
|
||||
|
||||
// Select the currently logged in user
|
||||
if (this->count() > 0) {
|
||||
auto currentUser = AccountManager::getInstance().Twitch.getCurrent();
|
||||
auto currentUser = singletons::AccountManager::getInstance().Twitch.getCurrent();
|
||||
|
||||
if (currentUser->isAnon()) {
|
||||
this->setCurrentRow(0);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
BaseWidget::BaseWidget(ThemeManager &_themeManager, QWidget *parent)
|
||||
BaseWidget::BaseWidget(singletons::ThemeManager &_themeManager, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, themeManager(_themeManager)
|
||||
{
|
||||
@@ -21,14 +21,14 @@ BaseWidget::BaseWidget(ThemeManager &_themeManager, QWidget *parent)
|
||||
|
||||
BaseWidget::BaseWidget(BaseWidget *parent)
|
||||
: QWidget(parent)
|
||||
, themeManager(ThemeManager::getInstance())
|
||||
, themeManager(singletons::ThemeManager::getInstance())
|
||||
{
|
||||
this->init();
|
||||
}
|
||||
|
||||
BaseWidget::BaseWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, themeManager(ThemeManager::getInstance())
|
||||
, themeManager(singletons::ThemeManager::getInstance())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ void BaseWidget::initAsWindow()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (SettingsManager::getInstance().windowTopMost.getValue()) {
|
||||
if (singletons::SettingManager::getInstance().windowTopMost.getValue()) {
|
||||
this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
#include <QWidget>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
namespace singletons {
|
||||
class ThemeManager;
|
||||
}
|
||||
|
||||
namespace widgets {
|
||||
|
||||
@@ -13,13 +14,13 @@ class BaseWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BaseWidget(ThemeManager &_themeManager, QWidget *parent);
|
||||
explicit BaseWidget(singletons::ThemeManager &_themeManager, QWidget *parent);
|
||||
|
||||
explicit BaseWidget(BaseWidget *parent);
|
||||
|
||||
explicit BaseWidget(QWidget *parent = nullptr);
|
||||
|
||||
ThemeManager &themeManager;
|
||||
singletons::ThemeManager &themeManager;
|
||||
|
||||
float getDpiMultiplier();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ using namespace chatterino::messages;
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
EmotePopup::EmotePopup(ThemeManager &themeManager)
|
||||
EmotePopup::EmotePopup(singletons::ThemeManager &themeManager)
|
||||
: BaseWidget(themeManager, 0)
|
||||
{
|
||||
this->initAsWindow();
|
||||
@@ -44,12 +44,12 @@ void EmotePopup::loadChannel(std::shared_ptr<Channel> _channel)
|
||||
|
||||
std::shared_ptr<Channel> emoteChannel(new Channel(""));
|
||||
|
||||
auto addEmotes = [&](EmoteMap &map, const QString &title, const QString &emoteDesc) {
|
||||
auto addEmotes = [&](util::EmoteMap &map, const QString &title, const QString &emoteDesc) {
|
||||
// TITLE
|
||||
messages::MessageBuilder builder1;
|
||||
|
||||
builder1.appendWord(Word(title, Word::Flags::Text, MessageColor(MessageColor::Text),
|
||||
FontManager::Medium, QString(), QString()));
|
||||
singletons::FontManager::Medium, QString(), QString()));
|
||||
|
||||
builder1.getMessage()->centered = true;
|
||||
emoteChannel->addMessage(builder1.getMessage());
|
||||
@@ -58,7 +58,7 @@ void EmotePopup::loadChannel(std::shared_ptr<Channel> _channel)
|
||||
messages::MessageBuilder builder2;
|
||||
builder2.getMessage()->centered = true;
|
||||
|
||||
map.each([&](const QString &key, const EmoteData &value) {
|
||||
map.each([&](const QString &key, const util::EmoteData &value) {
|
||||
builder2.appendWord(Word(value.image, Word::Flags::AlwaysShow, key, emoteDesc,
|
||||
Link(Link::Type::InsertText, key)));
|
||||
});
|
||||
@@ -66,7 +66,7 @@ void EmotePopup::loadChannel(std::shared_ptr<Channel> _channel)
|
||||
emoteChannel->addMessage(builder2.getMessage());
|
||||
};
|
||||
|
||||
EmoteManager &emoteManager = EmoteManager::getInstance();
|
||||
singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance();
|
||||
|
||||
addEmotes(emoteManager.bttvGlobalEmotes, "BetterTTV Global Emotes", "BetterTTV Global Emote");
|
||||
addEmotes(*channel->bttvChannelEmotes.get(), "BetterTTV Channel Emotes",
|
||||
@@ -81,7 +81,7 @@ void EmotePopup::loadChannel(std::shared_ptr<Channel> _channel)
|
||||
|
||||
void EmotePopup::loadEmojis()
|
||||
{
|
||||
EmoteMap &emojis = EmoteManager::getInstance().getEmojis();
|
||||
util::EmoteMap &emojis = singletons::EmoteManager::getInstance().getEmojis();
|
||||
|
||||
std::shared_ptr<Channel> emojiChannel(new Channel(""));
|
||||
|
||||
@@ -89,7 +89,7 @@ void EmotePopup::loadEmojis()
|
||||
messages::MessageBuilder builder1;
|
||||
|
||||
builder1.appendWord(Word("emojis", Word::Flags::Text, MessageColor(MessageColor::Text),
|
||||
FontManager::Medium, QString(), QString()));
|
||||
singletons::FontManager::Medium, QString(), QString()));
|
||||
|
||||
builder1.getMessage()->centered = true;
|
||||
emojiChannel->addMessage(builder1.getMessage());
|
||||
@@ -97,7 +97,7 @@ void EmotePopup::loadEmojis()
|
||||
// emojis
|
||||
messages::MessageBuilder builder;
|
||||
builder.getMessage()->centered = true;
|
||||
emojis.each([this, &builder](const QString &key, const EmoteData &value) {
|
||||
emojis.each([this, &builder](const QString &key, const util::EmoteData &value) {
|
||||
builder.appendWord(Word(value.image, Word::Flags::AlwaysShow, key, "emoji",
|
||||
Link(Link::Type::InsertText, key)));
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace widgets {
|
||||
class EmotePopup : public BaseWidget
|
||||
{
|
||||
public:
|
||||
explicit EmotePopup(ThemeManager &);
|
||||
explicit EmotePopup(singletons::ThemeManager &);
|
||||
|
||||
void loadChannel(std::shared_ptr<Channel> channel);
|
||||
void loadEmojis();
|
||||
|
||||
@@ -39,7 +39,8 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||
#endif
|
||||
this->setMouseTracking(true);
|
||||
|
||||
QObject::connect(&SettingsManager::getInstance(), &SettingsManager::wordTypeMaskChanged, this,
|
||||
QObject::connect(&singletons::SettingManager::getInstance(),
|
||||
&singletons::SettingManager::wordTypeMaskChanged, this,
|
||||
&ChannelView::wordTypeMaskChanged);
|
||||
|
||||
this->scrollBar.getCurrentValueChanged().connect([this] {
|
||||
@@ -51,7 +52,7 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||
this->queueUpdate();
|
||||
});
|
||||
|
||||
WindowManager &windowManager = WindowManager::getInstance();
|
||||
singletons::WindowManager &windowManager = singletons::WindowManager::getInstance();
|
||||
|
||||
this->repaintGifsConnection =
|
||||
windowManager.repaintGifs.connect([&] { this->updateGifEmotes(); });
|
||||
@@ -62,9 +63,10 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||
this->goToBottom->getLabel().setText("Jump to bottom");
|
||||
this->goToBottom->setVisible(false);
|
||||
|
||||
this->managedConnections.emplace_back(FontManager::getInstance().fontChanged.connect([this] {
|
||||
this->layoutMessages(); //
|
||||
}));
|
||||
this->managedConnections.emplace_back(
|
||||
singletons::FontManager::getInstance().fontChanged.connect([this] {
|
||||
this->layoutMessages(); //
|
||||
}));
|
||||
|
||||
connect(goToBottom, &RippleEffectLabel::clicked, this,
|
||||
[this] { QTimer::singleShot(180, [this] { this->scrollBar.scrollToBottom(); }); });
|
||||
@@ -82,8 +84,9 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||
|
||||
ChannelView::~ChannelView()
|
||||
{
|
||||
QObject::disconnect(&SettingsManager::getInstance(), &SettingsManager::wordTypeMaskChanged,
|
||||
this, &ChannelView::wordTypeMaskChanged);
|
||||
QObject::disconnect(&singletons::SettingManager::getInstance(),
|
||||
&singletons::SettingManager::wordTypeMaskChanged, this,
|
||||
&ChannelView::wordTypeMaskChanged);
|
||||
this->messageAppendedConnection.disconnect();
|
||||
this->messageRemovedConnection.disconnect();
|
||||
this->repaintGifsConnection.disconnect();
|
||||
@@ -776,7 +779,7 @@ void ChannelView::drawMessageSelection(QPainter &painter, messages::MessageRef *
|
||||
void ChannelView::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (this->scrollBar.isVisible()) {
|
||||
float mouseMultiplier = SettingsManager::getInstance().mouseScrollMultiplier;
|
||||
float mouseMultiplier = singletons::SettingManager::getInstance().mouseScrollMultiplier;
|
||||
|
||||
this->scrollBar.setDesiredValue(
|
||||
this->scrollBar.getDesiredValue() - event->delta() / 10.0 * mouseMultiplier, true);
|
||||
|
||||
@@ -29,7 +29,7 @@ NotebookTab::NotebookTab(Notebook *_notebook, const std::string &_uuid)
|
||||
|
||||
this->positionChangedAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic));
|
||||
|
||||
SettingsManager::getInstance().hideTabX.connect(
|
||||
singletons::SettingManager::getInstance().hideTabX.connect(
|
||||
boost::bind(&NotebookTab::hideTabXChanged, this, _1), this->managedConnections);
|
||||
|
||||
this->setMouseTracking(true);
|
||||
@@ -74,7 +74,7 @@ void NotebookTab::calcSize()
|
||||
float scale = getDpiMultiplier();
|
||||
QString qTitle(qS(this->title));
|
||||
|
||||
if (SettingsManager::getInstance().hideTabX) {
|
||||
if (singletons::SettingManager::getInstance().hideTabX) {
|
||||
this->resize(static_cast<int>((fontMetrics().width(qTitle) + 16) * scale),
|
||||
static_cast<int>(24 * scale));
|
||||
} else {
|
||||
@@ -190,12 +190,12 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||
painter.setPen(fg);
|
||||
|
||||
float scale = this->getDpiMultiplier();
|
||||
int rectW = (SettingsManager::getInstance().hideTabX ? 0 : static_cast<int>(16) * scale);
|
||||
int rectW = (singletons::SettingManager::getInstance().hideTabX ? 0 : static_cast<int>(16) * scale);
|
||||
QRect rect(0, 0, this->width() - rectW, this->height());
|
||||
|
||||
painter.drawText(rect, this->getTitle(), QTextOption(Qt::AlignCenter));
|
||||
|
||||
if (!SettingsManager::getInstance().hideTabX && (mouseOver || selected)) {
|
||||
if (!singletons::SettingManager::getInstance().hideTabX && (mouseOver || selected)) {
|
||||
QRect xRect = this->getXRect();
|
||||
if (mouseOverX) {
|
||||
painter.fillRect(xRect, QColor(0, 0, 0, 64));
|
||||
@@ -237,7 +237,7 @@ void NotebookTab::mouseReleaseEvent(QMouseEvent *event)
|
||||
this->notebook->removePage(this->page);
|
||||
}
|
||||
} else {
|
||||
if (!SettingsManager::getInstance().hideTabX && this->mouseDownX &&
|
||||
if (!singletons::SettingManager::getInstance().hideTabX && this->mouseDownX &&
|
||||
this->getXRect().contains(event->pos())) {
|
||||
this->mouseDownX = false;
|
||||
|
||||
@@ -270,7 +270,7 @@ void NotebookTab::dragEnterEvent(QDragEnterEvent *)
|
||||
|
||||
void NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!SettingsManager::getInstance().hideTabX) {
|
||||
if (!singletons::SettingManager::getInstance().hideTabX) {
|
||||
bool overX = this->getXRect().contains(event->pos());
|
||||
|
||||
if (overX != this->mouseOverX) {
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class ThemeManager;
|
||||
|
||||
namespace widgets {
|
||||
|
||||
class Notebook;
|
||||
|
||||
@@ -88,7 +88,7 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
|
||||
}
|
||||
|
||||
auto *completionModel =
|
||||
static_cast<chatterino::CompletionModel *>(this->completer->model());
|
||||
static_cast<chatterino::singletons::CompletionModel *>(this->completer->model());
|
||||
|
||||
if (!this->nextCompletion) {
|
||||
completionModel->refresh();
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
#include <QWidget>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class ThemeManager;
|
||||
|
||||
namespace widgets {
|
||||
|
||||
class RippleEffectLabel : public RippleEffectButton
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
#include "QString"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
namespace singletons {
|
||||
class ThemeManager;
|
||||
}
|
||||
|
||||
namespace widgets {
|
||||
|
||||
@@ -18,7 +19,7 @@ public:
|
||||
ScrollBarHighlight(double _position, int _colorIndex, ScrollBar *parent, Style _style = Default,
|
||||
QString _tag = "");
|
||||
|
||||
ThemeManager &themeManager;
|
||||
singletons::ThemeManager &themeManager;
|
||||
|
||||
double getPosition()
|
||||
{
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class ThemeManager;
|
||||
|
||||
namespace widgets {
|
||||
|
||||
class Split;
|
||||
|
||||
@@ -27,13 +27,13 @@ SplitInput::SplitInput(Split *_chatWidget)
|
||||
this->hbox.addLayout(&this->editContainer);
|
||||
this->hbox.addLayout(&this->vbox);
|
||||
|
||||
auto &fontManager = FontManager::getInstance();
|
||||
auto &fontManager = singletons::FontManager::getInstance();
|
||||
|
||||
this->textInput.setFont(
|
||||
fontManager.getFont(FontManager::Type::Medium, this->getDpiMultiplier()));
|
||||
fontManager.getFont(singletons::FontManager::Type::Medium, this->getDpiMultiplier()));
|
||||
this->managedConnections.emplace_back(fontManager.fontChanged.connect([this, &fontManager]() {
|
||||
this->textInput.setFont(
|
||||
fontManager.getFont(FontManager::Type::Medium, this->getDpiMultiplier()));
|
||||
fontManager.getFont(singletons::FontManager::Type::Medium, this->getDpiMultiplier()));
|
||||
}));
|
||||
|
||||
this->editContainer.addWidget(&this->textInput);
|
||||
@@ -67,10 +67,10 @@ SplitInput::SplitInput(Split *_chatWidget)
|
||||
connect(&textInput, &ResizingTextEdit::textChanged, this, &SplitInput::editTextChanged);
|
||||
|
||||
this->refreshTheme();
|
||||
textLengthLabel.setHidden(!SettingsManager::getInstance().showMessageLength);
|
||||
textLengthLabel.setHidden(!singletons::SettingManager::getInstance().showMessageLength);
|
||||
|
||||
auto completer =
|
||||
new QCompleter(CompletionManager::getInstance().createModel(this->chatWidget->channelName));
|
||||
auto completer = new QCompleter(
|
||||
singletons::CompletionManager::getInstance().createModel(this->chatWidget->channelName));
|
||||
|
||||
this->textInput.setCompleter(completer);
|
||||
|
||||
@@ -180,7 +180,7 @@ SplitInput::SplitInput(Split *_chatWidget)
|
||||
}
|
||||
});
|
||||
|
||||
SettingsManager::getInstance().showMessageLength.connect(
|
||||
singletons::SettingManager::getInstance().showMessageLength.connect(
|
||||
[this](const bool &value, auto) { this->textLengthLabel.setHidden(!value); },
|
||||
this->managedConnections);
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ void LogInWithCredentials(const std::string &userID, const std::string &username
|
||||
pajlada::Settings::Setting<std::string>::set("/accounts/uid" + userID + "/oauthToken",
|
||||
oauthToken);
|
||||
|
||||
AccountManager::getInstance().Twitch.reloadUsers();
|
||||
singletons::AccountManager::getInstance().Twitch.reloadUsers();
|
||||
|
||||
messageBox.exec();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ Notebook::Notebook(Window *parent, bool _showButtons, const std::string &setting
|
||||
this->userButton.move(24, 0);
|
||||
this->userButton.icon = NotebookButton::IconUser;
|
||||
|
||||
auto &settingsManager = SettingsManager::getInstance();
|
||||
auto &settingsManager = singletons::SettingManager::getInstance();
|
||||
|
||||
settingsManager.hidePreferencesButton.connectSimple([this](auto) { this->performLayout(); });
|
||||
settingsManager.hideUserButton.connectSimple([this](auto) { this->performLayout(); });
|
||||
@@ -177,13 +177,13 @@ void Notebook::performLayout(bool animated)
|
||||
int x = 0, y = 0;
|
||||
float scale = this->getDpiMultiplier();
|
||||
|
||||
if (!showButtons || SettingsManager::getInstance().hidePreferencesButton) {
|
||||
if (!showButtons || singletons::SettingManager::getInstance().hidePreferencesButton) {
|
||||
this->settingsButton.hide();
|
||||
} else {
|
||||
this->settingsButton.show();
|
||||
x += settingsButton.width();
|
||||
}
|
||||
if (!showButtons || SettingsManager::getInstance().hideUserButton) {
|
||||
if (!showButtons || singletons::SettingManager::getInstance().hideUserButton) {
|
||||
this->userButton.hide();
|
||||
} else {
|
||||
this->userButton.move(x, 0);
|
||||
|
||||
@@ -9,9 +9,6 @@
|
||||
#include <QWidget>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class ChannelManager;
|
||||
|
||||
namespace widgets {
|
||||
|
||||
class Window;
|
||||
|
||||
@@ -17,7 +17,7 @@ ScrollBar::ScrollBar(ChannelView *parent)
|
||||
: BaseWidget(parent)
|
||||
, currentValueAnimation(this, "currentValue")
|
||||
, highlights(nullptr)
|
||||
, smoothScrollingSetting(SettingsManager::getInstance().enableSmoothScrolling)
|
||||
, smoothScrollingSetting(singletons::SettingManager::getInstance().enableSmoothScrolling)
|
||||
{
|
||||
resize((int)(16 * this->getDpiMultiplier()), 100);
|
||||
this->currentValueAnimation.setDuration(250);
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class ThemeManager;
|
||||
|
||||
namespace widgets {
|
||||
|
||||
class ChannelView;
|
||||
|
||||
@@ -106,7 +106,7 @@ void SettingsDialog::addTabs()
|
||||
QVBoxLayout *SettingsDialog::createAccountsTab()
|
||||
{
|
||||
auto layout = new QVBoxLayout();
|
||||
SettingsManager &settings = SettingsManager::getInstance();
|
||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||
|
||||
// add remove buttons
|
||||
auto buttonBox = new QDialogButtonBox(this);
|
||||
@@ -136,7 +136,7 @@ QVBoxLayout *SettingsDialog::createAccountsTab()
|
||||
return;
|
||||
}
|
||||
|
||||
AccountManager::getInstance().Twitch.removeUser(selectedUser);
|
||||
singletons::AccountManager::getInstance().Twitch.removeUser(selectedUser);
|
||||
});
|
||||
|
||||
layout->addWidget(this->ui.accountSwitchWidget);
|
||||
@@ -146,7 +146,7 @@ QVBoxLayout *SettingsDialog::createAccountsTab()
|
||||
|
||||
QVBoxLayout *SettingsDialog::createAppearanceTab()
|
||||
{
|
||||
auto &settings = SettingsManager::getInstance();
|
||||
auto &settings = singletons::SettingManager::getInstance();
|
||||
auto layout = this->createTabLayout();
|
||||
|
||||
{
|
||||
@@ -163,7 +163,7 @@ QVBoxLayout *SettingsDialog::createAppearanceTab()
|
||||
fontLayout->addWidget(fontFamilyLabel);
|
||||
|
||||
{
|
||||
auto &fontManager = FontManager::getInstance();
|
||||
auto &fontManager = singletons::FontManager::getInstance();
|
||||
|
||||
auto UpdateFontFamilyLabel = [fontFamilyLabel, &fontManager](auto) {
|
||||
fontFamilyLabel->setText(
|
||||
@@ -178,11 +178,11 @@ QVBoxLayout *SettingsDialog::createAppearanceTab()
|
||||
}
|
||||
|
||||
fontButton->connect(fontButton, &QPushButton::clicked, []() {
|
||||
auto &fontManager = FontManager::getInstance();
|
||||
QFontDialog dialog(fontManager.getFont(FontManager::Medium, 1.));
|
||||
auto &fontManager = singletons::FontManager::getInstance();
|
||||
QFontDialog dialog(fontManager.getFont(singletons::FontManager::Medium, 1.));
|
||||
|
||||
dialog.connect(&dialog, &QFontDialog::fontSelected, [](const QFont &font) {
|
||||
auto &fontManager = FontManager::getInstance();
|
||||
auto &fontManager = singletons::FontManager::getInstance();
|
||||
fontManager.currentFontFamily = font.family().toStdString();
|
||||
fontManager.currentFontSize = font.pointSize();
|
||||
});
|
||||
@@ -263,7 +263,7 @@ QVBoxLayout *SettingsDialog::createAppearanceTab()
|
||||
|
||||
QObject::connect(combo, &QComboBox::currentTextChanged, this, [](const QString &value) {
|
||||
// dirty hack
|
||||
EmoteManager::getInstance().incGeneration();
|
||||
singletons::EmoteManager::getInstance().incGeneration();
|
||||
pajlada::Settings::Setting<std::string>::set("/appearance/theme/name",
|
||||
value.toStdString());
|
||||
});
|
||||
@@ -312,7 +312,7 @@ QVBoxLayout *SettingsDialog::createAppearanceTab()
|
||||
|
||||
QVBoxLayout *SettingsDialog::createBehaviourTab()
|
||||
{
|
||||
SettingsManager &settings = SettingsManager::getInstance();
|
||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||
auto layout = this->createTabLayout();
|
||||
|
||||
auto form = new QFormLayout();
|
||||
@@ -329,14 +329,14 @@ QVBoxLayout *SettingsDialog::createBehaviourTab()
|
||||
auto scroll = new QSlider(Qt::Horizontal);
|
||||
form->addRow("Mouse scroll speed:", scroll);
|
||||
|
||||
float currentValue = SettingsManager::getInstance().mouseScrollMultiplier;
|
||||
float currentValue = singletons::SettingManager::getInstance().mouseScrollMultiplier;
|
||||
int scrollValue = ((currentValue - 0.1f) / 2.f) * 99.f;
|
||||
scroll->setValue(scrollValue);
|
||||
|
||||
connect(scroll, &QSlider::valueChanged, [](int newValue) {
|
||||
float mul = static_cast<float>(newValue) / 99.f;
|
||||
float newScrollValue = (mul * 2.1f) + 0.1f;
|
||||
SettingsManager::getInstance().mouseScrollMultiplier = newScrollValue;
|
||||
singletons::SettingManager::getInstance().mouseScrollMultiplier = newScrollValue;
|
||||
});
|
||||
|
||||
form->addRow("Streamlink path:", createLineEdit(settings.streamlinkPath));
|
||||
@@ -361,7 +361,7 @@ QVBoxLayout *SettingsDialog::createCommandsTab()
|
||||
|
||||
QVBoxLayout *SettingsDialog::createEmotesTab()
|
||||
{
|
||||
SettingsManager &settings = SettingsManager::getInstance();
|
||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||
auto layout = this->createTabLayout();
|
||||
|
||||
layout->addWidget(createCheckbox("Enable Twitch Emotes", settings.enableTwitchEmotes));
|
||||
@@ -405,7 +405,7 @@ QVBoxLayout *SettingsDialog::createLogsTab()
|
||||
|
||||
QVBoxLayout *SettingsDialog::createHighlightingTab()
|
||||
{
|
||||
SettingsManager &settings = SettingsManager::getInstance();
|
||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||
auto layout = this->createTabLayout();
|
||||
|
||||
auto highlights = new QListWidget();
|
||||
@@ -615,7 +615,7 @@ void SettingsDialog::refresh()
|
||||
{
|
||||
this->ui.accountSwitchWidget->refresh();
|
||||
|
||||
SettingsManager::getInstance().saveSnapshot();
|
||||
singletons::SettingManager::getInstance().saveSnapshot();
|
||||
}
|
||||
|
||||
void SettingsDialog::dpiMultiplierChanged(float oldDpi, float newDpi)
|
||||
@@ -754,7 +754,7 @@ void SettingsDialog::okButtonClicked()
|
||||
|
||||
void SettingsDialog::cancelButtonClicked()
|
||||
{
|
||||
auto &settings = SettingsManager::getInstance();
|
||||
auto &settings = singletons::SettingManager::getInstance();
|
||||
|
||||
settings.recallSnapshot();
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ Split::Split(SplitContainer *parent, const std::string &_uuid)
|
||||
, settingRoot(fS("/splits/{}", this->uuid))
|
||||
, channelName(fS("{}/channelName", this->settingRoot))
|
||||
, parentPage(*parent)
|
||||
, channel(ChannelManager::getInstance().emptyChannel)
|
||||
, channel(singletons::ChannelManager::getInstance().emptyChannel)
|
||||
, vbox(this)
|
||||
, header(this)
|
||||
, view(this)
|
||||
@@ -97,7 +97,7 @@ Split::Split(SplitContainer *parent, const std::string &_uuid)
|
||||
});
|
||||
|
||||
this->input.textChanged.connect([this](const QString &newText) {
|
||||
if (!SettingsManager::getInstance().hideEmptyInput) {
|
||||
if (!singletons::SettingManager::getInstance().hideEmptyInput) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ Split::Split(SplitContainer *parent, const std::string &_uuid)
|
||||
}
|
||||
});
|
||||
|
||||
SettingsManager::getInstance().hideEmptyInput.connect([this](const bool &hideEmptyInput, auto) {
|
||||
singletons::SettingManager::getInstance().hideEmptyInput.connect([this](const bool &hideEmptyInput, auto) {
|
||||
if (hideEmptyInput && this->input.getInputText().length() == 0) {
|
||||
this->input.hide();
|
||||
} else {
|
||||
@@ -170,7 +170,7 @@ double Split::getFlexSizeY()
|
||||
|
||||
void Split::channelNameUpdated(const std::string &newChannelName)
|
||||
{
|
||||
auto &cman = ChannelManager::getInstance();
|
||||
auto &cman = singletons::ChannelManager::getInstance();
|
||||
|
||||
// remove current channel
|
||||
if (!this->channel->isEmpty()) {
|
||||
@@ -264,7 +264,7 @@ void Split::doChangeChannel()
|
||||
|
||||
void Split::doPopup()
|
||||
{
|
||||
Window &window = WindowManager::getInstance().createWindow();
|
||||
Window &window = singletons::WindowManager::getInstance().createWindow();
|
||||
|
||||
Split *split = new Split(static_cast<SplitContainer *>(window.getNotebook().getSelectedPage()),
|
||||
this->uuid);
|
||||
@@ -293,7 +293,7 @@ void Split::doOpenPopupPlayer()
|
||||
|
||||
void Split::doOpenStreamlink()
|
||||
{
|
||||
SettingsManager &settings = SettingsManager::getInstance();
|
||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||
QString preferredQuality =
|
||||
QString::fromStdString(settings.preferredQuality.getValue()).toLower();
|
||||
// TODO(Confuseh): Default streamlink paths
|
||||
|
||||
@@ -13,9 +13,6 @@
|
||||
#include <QWidget>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class ChannelManager;
|
||||
|
||||
namespace widgets {
|
||||
|
||||
class SplitContainer : public BaseWidget
|
||||
|
||||
@@ -20,7 +20,7 @@ TooltipWidget::TooltipWidget(BaseWidget *parent)
|
||||
palette.setColor(QPalette::Background, black);
|
||||
this->setPalette(palette);
|
||||
this->setWindowOpacity(0.8);
|
||||
this->setFont(FontManager::getInstance().getFont(FontManager::Type::MediumSmall,
|
||||
this->setFont(singletons::FontManager::getInstance().getFont(singletons::FontManager::Type::MediumSmall,
|
||||
this->getDpiMultiplier()));
|
||||
|
||||
this->setAttribute(Qt::WA_ShowWithoutActivating);
|
||||
@@ -32,8 +32,8 @@ TooltipWidget::TooltipWidget(BaseWidget *parent)
|
||||
layout->addWidget(displayText);
|
||||
this->setLayout(layout);
|
||||
|
||||
FontManager::getInstance().fontChanged.connect([this] {
|
||||
this->setFont(FontManager::getInstance().getFont(FontManager::Type::MediumSmall,
|
||||
singletons::FontManager::getInstance().fontChanged.connect([this] {
|
||||
this->setFont(singletons::FontManager::getInstance().getFont(singletons::FontManager::Type::MediumSmall,
|
||||
this->getDpiMultiplier()));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
Window::Window(const QString &windowName, ThemeManager &_themeManager, bool _isMainWindow)
|
||||
Window::Window(const QString &windowName, singletons::ThemeManager &_themeManager, bool _isMainWindow)
|
||||
: BaseWidget(_themeManager, nullptr)
|
||||
, settingRoot(fS("/windows/{}", windowName))
|
||||
, windowGeometry(this->settingRoot)
|
||||
@@ -24,7 +24,7 @@ Window::Window(const QString &windowName, ThemeManager &_themeManager, bool _isM
|
||||
{
|
||||
this->initAsWindow();
|
||||
|
||||
AccountManager::getInstance().Twitch.currentUsername.connect(
|
||||
singletons::AccountManager::getInstance().Twitch.currentUsername.connect(
|
||||
[this](const std::string &newUsername, auto) {
|
||||
if (newUsername.empty()) {
|
||||
this->refreshWindowTitle("Not logged in");
|
||||
|
||||
@@ -14,10 +14,9 @@
|
||||
#include <pajlada/signals/signal.hpp>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class ChannelManager;
|
||||
namespace singletons {
|
||||
class ThemeManager;
|
||||
class CompletionManager;
|
||||
}
|
||||
|
||||
namespace widgets {
|
||||
|
||||
@@ -45,7 +44,7 @@ class Window : public BaseWidget
|
||||
WindowGeometry windowGeometry;
|
||||
|
||||
public:
|
||||
explicit Window(const QString &windowName, ThemeManager &_themeManager, bool isMainWindow);
|
||||
explicit Window(const QString &windowName, singletons::ThemeManager &_themeManager, bool isMainWindow);
|
||||
|
||||
void repaintVisibleChatWidgets(Channel *channel = nullptr);
|
||||
|
||||
@@ -59,7 +58,7 @@ protected:
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
ThemeManager &themeManager;
|
||||
singletons::ThemeManager &themeManager;
|
||||
|
||||
float dpi;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user