put singletons into their namespace

This commit is contained in:
2017-12-31 22:58:35 +01:00
parent ad001431f2
commit 5a26d5f17f
72 changed files with 357 additions and 288 deletions
+11 -8
View File
@@ -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);
+6 -6
View File
@@ -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) {
-2
View File
@@ -10,8 +10,6 @@
namespace chatterino {
class ThemeManager;
namespace widgets {
class Notebook;
+1 -1
View File
@@ -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();
-3
View File
@@ -10,9 +10,6 @@
#include <QWidget>
namespace chatterino {
class ThemeManager;
namespace widgets {
class RippleEffectLabel : public RippleEffectButton
+3 -2
View File
@@ -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()
{
-2
View File
@@ -16,8 +16,6 @@
namespace chatterino {
class ThemeManager;
namespace widgets {
class Split;
+7 -7
View File
@@ -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);