refactored the managers

This commit is contained in:
2017-12-31 00:50:07 +01:00
parent 258288bad9
commit bfa2f1637e
80 changed files with 1023 additions and 964 deletions
+14 -14
View File
@@ -1,17 +1,17 @@
#include "widgets/helper/channelview.hpp"
#include "channelmanager.hpp"
#include "colorscheme.hpp"
#include "channelview.hpp"
#include "debug/log.hpp"
#include "messages/limitedqueuesnapshot.hpp"
#include "messages/message.hpp"
#include "messages/messageref.hpp"
#include "settingsmanager.hpp"
#include "singletons/channelmanager.hpp"
#include "singletons/settingsmanager.hpp"
#include "singletons/thememanager.hpp"
#include "singletons/windowmanager.hpp"
#include "ui_accountpopupform.h"
#include "util/benchmark.hpp"
#include "util/distancebetweenpoints.hpp"
#include "widgets/split.hpp"
#include "widgets/tooltipwidget.hpp"
#include "windowmanager.hpp"
#include <QDebug>
#include <QDesktopServices>
@@ -51,7 +51,7 @@ ChannelView::ChannelView(BaseWidget *parent)
this->queueUpdate();
});
WindowManager &windowManager = *WindowManager::instance;
WindowManager &windowManager = WindowManager::getInstance();
this->repaintGifsConnection =
windowManager.repaintGifs.connect([&] { this->updateGifEmotes(); });
@@ -445,7 +445,7 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
// this->onlyUpdateEmotes = false;
// for (const GifEmoteData &item : this->gifEmotes) {
// painter.fillRect(item.rect, this->colorScheme.ChatBackground);
// painter.fillRect(item.rect, this->themeManager.ChatBackground);
// painter.drawPixmap(item.rect, *item.image->getPixmap());
// }
@@ -457,7 +457,7 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
// update all messages
this->gifEmotes.clear();
painter.fillRect(rect(), this->colorScheme.ChatBackground);
painter.fillRect(rect(), this->themeManager.ChatBackground);
// draw messages
this->drawMessages(painter);
@@ -466,7 +466,7 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
// draw gif emotes
for (GifEmoteData &item : this->gifEmotes) {
// painter.fillRect(item.rect, this->colorScheme.ChatBackground);
// painter.fillRect(item.rect, this->themeManager.ChatBackground);
painter.drawPixmap(item.rect, *item.image->getPixmap());
}
@@ -588,8 +588,8 @@ void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap
//} else {
painter.fillRect(buffer->rect(),
(messageRef->getMessage()->containsHighlightedPhrase())
? this->colorScheme.ChatBackgroundHighlighted
: this->colorScheme.ChatBackground);
? this->themeManager.ChatBackgroundHighlighted
: this->themeManager.ChatBackground);
//}
// draw selection
@@ -613,9 +613,9 @@ void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap
}
// text
else {
QColor color = wordPart.getWord().getTextColor().getColor(this->colorScheme);
QColor color = wordPart.getWord().getTextColor().getColor(this->themeManager);
this->colorScheme.normalizeColor(color);
this->themeManager.normalizeColor(color);
painter.setPen(color);
painter.setFont(wordPart.getWord().getFont(this->getDpiMultiplier()));
@@ -636,7 +636,7 @@ void ChannelView::drawMessageSelection(QPainter &painter, messages::MessageRef *
return;
}
QColor selectionColor = this->colorScheme.Selection;
QColor selectionColor = this->themeManager.Selection;
int charIndex = 0;
size_t i = 0;
+2 -2
View File
@@ -1,5 +1,5 @@
#include "widgets/helper/droppreview.hpp"
#include "colorscheme.hpp"
#include "singletons/thememanager.hpp"
#include <QDebug>
#include <QPainter>
@@ -20,7 +20,7 @@ void NotebookPageDropPreview::paintEvent(QPaintEvent *)
QPainter painter(this);
painter.fillRect(8, 8, this->width() - 17, this->height() - 17,
this->colorScheme.DropPreviewBackground);
this->themeManager.DropPreviewBackground);
}
void NotebookPageDropPreview::hideEvent(QHideEvent *)
+7 -7
View File
@@ -1,5 +1,5 @@
#include "widgets/helper/notebookbutton.hpp"
#include "colorscheme.hpp"
#include "singletons/thememanager.hpp"
#include "widgets/helper/rippleeffectbutton.hpp"
#include <QMouseEvent>
@@ -23,16 +23,16 @@ void NotebookButton::paintEvent(QPaintEvent *)
QColor background;
QColor foreground;
background = this->colorScheme.TabBackground;
background = this->themeManager.TabBackground;
if (mouseDown) {
// background = this->colorScheme.TabSelectedBackground;
foreground = this->colorScheme.TabHoverText;
// background = this->themeManager.TabSelectedBackground;
foreground = this->themeManager.TabHoverText;
} else if (mouseOver) {
// background = this->colorScheme.TabHoverText;
foreground = this->colorScheme.TabHoverText;
// background = this->themeManager.TabHoverText;
foreground = this->themeManager.TabHoverText;
} else {
// background = this->colorScheme.TabPanelBackground;
// background = this->themeManager.TabPanelBackground;
foreground = QColor(70, 80, 80);
}
+14 -14
View File
@@ -1,8 +1,8 @@
#include "widgets/helper/notebooktab.hpp"
#include "colorscheme.hpp"
#include "singletons/thememanager.hpp"
#include "common.hpp"
#include "debug/log.hpp"
#include "settingsmanager.hpp"
#include "singletons/settingsmanager.hpp"
#include "util/helpers.hpp"
#include "widgets/notebook.hpp"
#include "widgets/textinputdialog.hpp"
@@ -167,24 +167,24 @@ void NotebookTab::paintEvent(QPaintEvent *)
if (this->selected) {
if (this->window() == QApplication::activeWindow()) {
painter.fillRect(rect(), this->colorScheme.TabSelectedBackground);
fg = this->colorScheme.TabSelectedText;
painter.fillRect(rect(), this->themeManager.TabSelectedBackground);
fg = this->themeManager.TabSelectedText;
} else {
painter.fillRect(rect(), this->colorScheme.TabSelectedUnfocusedBackground);
fg = this->colorScheme.TabSelectedUnfocusedText;
painter.fillRect(rect(), this->themeManager.TabSelectedUnfocusedBackground);
fg = this->themeManager.TabSelectedUnfocusedText;
}
} else if (this->mouseOver) {
painter.fillRect(rect(), this->colorScheme.TabHoverBackground);
fg = this->colorScheme.TabHoverText;
painter.fillRect(rect(), this->themeManager.TabHoverBackground);
fg = this->themeManager.TabHoverText;
} else if (this->highlightState == HighlightState::Highlighted) {
painter.fillRect(rect(), this->colorScheme.TabHighlightedBackground);
fg = this->colorScheme.TabHighlightedText;
painter.fillRect(rect(), this->themeManager.TabHighlightedBackground);
fg = this->themeManager.TabHighlightedText;
} else if (this->highlightState == HighlightState::NewMessage) {
painter.fillRect(rect(), this->colorScheme.TabNewMessageBackground);
fg = this->colorScheme.TabHighlightedText;
painter.fillRect(rect(), this->themeManager.TabNewMessageBackground);
fg = this->themeManager.TabHighlightedText;
} else {
painter.fillRect(rect(), this->colorScheme.TabBackground);
fg = this->colorScheme.TabText;
painter.fillRect(rect(), this->themeManager.TabBackground);
fg = this->themeManager.TabText;
}
painter.setPen(fg);
+1 -1
View File
@@ -10,7 +10,7 @@
namespace chatterino {
class ColorScheme;
class ThemeManager;
namespace widgets {
+1 -1
View File
@@ -1,5 +1,5 @@
#include "widgets/helper/resizingtextedit.hpp"
#include "completionmanager.hpp"
#include "singletons/completionmanager.hpp"
ResizingTextEdit::ResizingTextEdit()
{
+2 -2
View File
@@ -3,7 +3,7 @@
#include <QDebug>
#include <QPainter>
#include "colorscheme.hpp"
#include "singletons/thememanager.hpp"
namespace chatterino {
namespace widgets {
@@ -37,7 +37,7 @@ void RippleEffectButton::fancyPaint(QPainter &painter)
if (this->mouseEffectColor) {
c = this->mouseEffectColor.get();
} else {
c = this->colorScheme.isLightTheme() ? QColor(0, 0, 0) : QColor(255, 255, 255);
c = this->themeManager.isLightTheme() ? QColor(0, 0, 0) : QColor(255, 255, 255);
}
if (this->hoverMultiplier > 0) {
+1 -1
View File
@@ -1,5 +1,5 @@
#include "widgets/helper/rippleeffectlabel.hpp"
#include "colorscheme.hpp"
#include "singletons/thememanager.hpp"
#include "widgets/helper/splitheader.hpp"
#include <QBrush>
+1 -1
View File
@@ -11,7 +11,7 @@
namespace chatterino {
class ColorScheme;
class ThemeManager;
namespace widgets {
+3 -3
View File
@@ -1,5 +1,5 @@
#include "widgets/helper/scrollbarhighlight.hpp"
#include "colorscheme.hpp"
#include "singletons/thememanager.hpp"
#include "widgets/scrollbar.hpp"
namespace chatterino {
@@ -7,9 +7,9 @@ namespace widgets {
ScrollBarHighlight::ScrollBarHighlight(double _position, int _colorIndex, ScrollBar *parent,
Style _style, QString _tag)
: colorScheme(parent->colorScheme)
: themeManager(parent->themeManager)
, position(_position)
, colorIndex(std::max(0, std::min(this->colorScheme.HighlightColorCount, _colorIndex)))
, colorIndex(std::max(0, std::min(this->themeManager.HighlightColorCount, _colorIndex)))
, style(_style)
, tag(_tag)
{
+2 -2
View File
@@ -4,7 +4,7 @@
namespace chatterino {
class ColorScheme;
class ThemeManager;
namespace widgets {
@@ -18,7 +18,7 @@ public:
ScrollBarHighlight(double _position, int _colorIndex, ScrollBar *parent, Style _style = Default,
QString _tag = "");
ColorScheme &colorScheme;
ThemeManager &themeManager;
double getPosition()
{
+4 -4
View File
@@ -1,5 +1,5 @@
#include "widgets/helper/splitheader.hpp"
#include "colorscheme.hpp"
#include "singletons/thememanager.hpp"
#include "twitch/twitchchannel.hpp"
#include "util/urlfetch.hpp"
#include "widgets/split.hpp"
@@ -135,8 +135,8 @@ void SplitHeader::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.fillRect(rect(), this->colorScheme.ChatHeaderBackground);
painter.setPen(this->colorScheme.ChatHeaderBorder);
painter.fillRect(rect(), this->themeManager.ChatHeaderBackground);
painter.setPen(this->themeManager.ChatHeaderBorder);
painter.drawRect(0, 0, width() - 1, height() - 1);
}
@@ -217,7 +217,7 @@ void SplitHeader::rightButtonClicked()
void SplitHeader::refreshTheme()
{
QPalette palette;
palette.setColor(QPalette::Foreground, this->colorScheme.Text);
palette.setColor(QPalette::Foreground, this->themeManager.Text);
this->leftLabel.setPalette(palette);
this->channelNameLabel.setPalette(palette);
+1 -1
View File
@@ -16,7 +16,7 @@
namespace chatterino {
class ColorScheme;
class ThemeManager;
namespace widgets {
+11 -11
View File
@@ -1,8 +1,8 @@
#include "widgets/helper/splitinput.hpp"
#include "colorscheme.hpp"
#include "completionmanager.hpp"
#include "ircmanager.hpp"
#include "settingsmanager.hpp"
#include "singletons/completionmanager.hpp"
#include "singletons/ircmanager.hpp"
#include "singletons/settingsmanager.hpp"
#include "singletons/thememanager.hpp"
#include "widgets/notebook.hpp"
#include "widgets/split.hpp"
#include "widgets/splitcontainer.hpp"
@@ -55,7 +55,7 @@ SplitInput::SplitInput(Split *_chatWidget)
connect(&this->emotesLabel, &RippleEffectLabel::clicked, [this] {
if (this->emotePopup == nullptr) {
this->emotePopup = new EmotePopup(this->colorScheme);
this->emotePopup = new EmotePopup(this->themeManager);
}
this->emotePopup->resize((int)(300 * this->emotePopup->getDpiMultiplier()),
@@ -210,13 +210,13 @@ void SplitInput::refreshTheme()
{
QPalette palette;
palette.setColor(QPalette::Foreground, this->colorScheme.Text);
palette.setColor(QPalette::Foreground, this->themeManager.Text);
this->textLengthLabel.setPalette(palette);
this->textInput.setStyleSheet(this->colorScheme.InputStyleSheet);
this->textInput.setStyleSheet(this->themeManager.InputStyleSheet);
this->hbox.setMargin((this->colorScheme.isLightTheme() ? 4 : 2) * this->getDpiMultiplier());
this->hbox.setMargin((this->themeManager.isLightTheme() ? 4 : 2) * this->getDpiMultiplier());
}
void SplitInput::editTextChanged()
@@ -244,10 +244,10 @@ void SplitInput::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.fillRect(this->rect(), this->colorScheme.ChatInputBackground);
painter.fillRect(this->rect(), this->themeManager.ChatInputBackground);
QPen pen(this->colorScheme.ChatInputBorder);
if (this->colorScheme.isLightTheme()) {
QPen pen(this->themeManager.ChatInputBorder);
if (this->themeManager.isLightTheme()) {
pen.setWidth((int)(6 * this->getDpiMultiplier()));
}
painter.setPen(pen);