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
+2 -2
View File
@@ -1,8 +1,8 @@
#include "widgets/accountpopup.hpp"
#include "accountmanager.hpp"
#include "singletons/accountmanager.hpp"
#include "channel.hpp"
#include "credentials.hpp"
#include "settingsmanager.hpp"
#include "singletons/settingsmanager.hpp"
#include "ui_accountpopupform.h"
#include "util/urlfetch.hpp"
+1 -1
View File
@@ -1,5 +1,5 @@
#include "accountswitchwidget.hpp"
#include "accountmanager.hpp"
#include "singletons/accountmanager.hpp"
#include "const.hpp"
namespace chatterino {
+7 -7
View File
@@ -1,6 +1,6 @@
#include "widgets/basewidget.hpp"
#include "colorscheme.hpp"
#include "settingsmanager.hpp"
#include "singletons/settingsmanager.hpp"
#include "singletons/thememanager.hpp"
#include "widgets/tooltipwidget.hpp"
#include <QDebug>
@@ -12,23 +12,23 @@
namespace chatterino {
namespace widgets {
BaseWidget::BaseWidget(ColorScheme &_colorScheme, QWidget *parent)
BaseWidget::BaseWidget(ThemeManager &_themeManager, QWidget *parent)
: QWidget(parent)
, colorScheme(_colorScheme)
, themeManager(_themeManager)
{
this->init();
}
BaseWidget::BaseWidget(BaseWidget *parent)
: QWidget(parent)
, colorScheme(*ColorScheme::instance)
, themeManager(ThemeManager::getInstance())
{
this->init();
}
BaseWidget::BaseWidget(QWidget *parent)
: QWidget(parent)
, colorScheme(*ColorScheme::instance)
, themeManager(ThemeManager::getInstance())
{
}
@@ -49,7 +49,7 @@ float BaseWidget::getDpiMultiplier()
void BaseWidget::init()
{
auto connection = this->colorScheme.updated.connect([this]() {
auto connection = this->themeManager.updated.connect([this]() {
this->refreshTheme();
this->update();
+3 -3
View File
@@ -4,7 +4,7 @@
namespace chatterino {
class ColorScheme;
class ThemeManager;
namespace widgets {
@@ -13,13 +13,13 @@ class BaseWidget : public QWidget
Q_OBJECT
public:
explicit BaseWidget(ColorScheme &_colorScheme, QWidget *parent);
explicit BaseWidget(ThemeManager &_themeManager, QWidget *parent);
explicit BaseWidget(BaseWidget *parent);
explicit BaseWidget(QWidget *parent = nullptr);
ColorScheme &colorScheme;
ThemeManager &themeManager;
float getDpiMultiplier();
+2 -2
View File
@@ -12,8 +12,8 @@ using namespace chatterino::messages;
namespace chatterino {
namespace widgets {
EmotePopup::EmotePopup(ColorScheme &colorScheme)
: BaseWidget(colorScheme, 0)
EmotePopup::EmotePopup(ThemeManager &themeManager)
: BaseWidget(themeManager, 0)
{
this->initAsWindow();
+1 -1
View File
@@ -10,7 +10,7 @@ namespace widgets {
class EmotePopup : public BaseWidget
{
public:
explicit EmotePopup(ColorScheme &);
explicit EmotePopup(ThemeManager &);
void loadChannel(std::shared_ptr<Channel> channel);
void loadEmojis();
+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);
+3 -5
View File
@@ -1,6 +1,6 @@
#include "widgets/notebook.hpp"
#include "colorscheme.hpp"
#include "debug/log.hpp"
#include "singletons/thememanager.hpp"
#include "widgets/accountswitchpopupwidget.hpp"
#include "widgets/helper/notebookbutton.hpp"
#include "widgets/helper/notebooktab.hpp"
@@ -22,11 +22,9 @@
namespace chatterino {
namespace widgets {
Notebook::Notebook(ChannelManager &_channelManager, Window *parent, bool _showButtons,
const std::string &settingPrefix)
Notebook::Notebook(Window *parent, bool _showButtons, const std::string &settingPrefix)
: BaseWidget(parent)
, settingRoot(fS("{}/notebook", settingPrefix))
, channelManager(_channelManager)
, addButton(this)
, settingsButton(this)
, userButton(this)
@@ -58,7 +56,7 @@ SplitContainer *Notebook::addNewPage()
SplitContainer *Notebook::addPage(const std::string &uuid, bool select)
{
auto tab = new NotebookTab(this, uuid);
auto page = new SplitContainer(this->channelManager, this, tab, uuid);
auto page = new SplitContainer(this, tab, uuid);
tab->show();
+1 -5
View File
@@ -25,8 +25,7 @@ class Notebook : public BaseWidget
public:
enum HighlightType { none, highlighted, newMessage };
explicit Notebook(ChannelManager &_channelManager, Window *parent, bool _showButtons,
const std::string &settingPrefix);
explicit Notebook(Window *parent, bool _showButtons, const std::string &settingPrefix);
SplitContainer *addNewPage();
SplitContainer *addPage(const std::string &uuid, bool select = false);
@@ -58,9 +57,6 @@ public slots:
void usersButtonClicked();
void addPageButtonClicked();
public:
ChannelManager &channelManager;
private:
QList<SplitContainer *> pages;
+6 -6
View File
@@ -1,5 +1,5 @@
#include "widgets/scrollbar.hpp"
#include "colorscheme.hpp"
#include "singletons/thememanager.hpp"
#include "widgets/helper/channelview.hpp"
#include <QDebug>
@@ -234,22 +234,22 @@ void ScrollBar::paintEvent(QPaintEvent *)
int xOffset = mouseOver ? 0 : width() - (int)(4 * this->getDpiMultiplier());
QPainter painter(this);
// painter.fillRect(rect(), this->colorScheme.ScrollbarBG);
// painter.fillRect(rect(), this->themeManager.ScrollbarBG);
painter.fillRect(QRect(xOffset, 0, width(), this->buttonHeight),
this->colorScheme.ScrollbarArrow);
this->themeManager.ScrollbarArrow);
painter.fillRect(QRect(xOffset, height() - this->buttonHeight, width(), this->buttonHeight),
this->colorScheme.ScrollbarArrow);
this->themeManager.ScrollbarArrow);
this->thumbRect.setX(xOffset);
// mouse over thumb
if (this->mouseDownIndex == 2) {
painter.fillRect(this->thumbRect, this->colorScheme.ScrollbarThumbSelected);
painter.fillRect(this->thumbRect, this->themeManager.ScrollbarThumbSelected);
}
// mouse not over thumb
else {
painter.fillRect(this->thumbRect, this->colorScheme.ScrollbarThumb);
painter.fillRect(this->thumbRect, this->themeManager.ScrollbarThumb);
}
// ScrollBarHighlight *highlight = highlights;
+2 -2
View File
@@ -1,5 +1,6 @@
#pragma once
#include "singletons/settingsmanager.hpp"
#include "widgets/basewidget.hpp"
#include "widgets/helper/scrollbarhighlight.hpp"
@@ -7,11 +8,10 @@
#include <QPropertyAnimation>
#include <QWidget>
#include <boost/signals2.hpp>
#include <settingsmanager.hpp>
namespace chatterino {
class ColorScheme;
class ThemeManager;
namespace widgets {
+2 -2
View File
@@ -1,12 +1,12 @@
#include "widgets/settingsdialog.hpp"
#include "accountmanager.hpp"
#include "singletons/accountmanager.hpp"
#include "const.hpp"
#include "debug/log.hpp"
#include "twitch/twitchmessagebuilder.hpp"
#include "twitch/twitchuser.hpp"
#include "widgets/helper/settingsdialogtab.hpp"
#include "widgets/logindialog.hpp"
#include "windowmanager.hpp"
#include "singletons/windowmanager.hpp"
#include <QComboBox>
#include <QDebug>
+1 -1
View File
@@ -1,6 +1,6 @@
#pragma once
#include "settingsmanager.hpp"
#include "singletons/settingsmanager.hpp"
#include "widgets/accountswitchwidget.hpp"
#include "widgets/helper/settingsdialogtab.hpp"
+16 -17
View File
@@ -1,14 +1,14 @@
#include "widgets/split.hpp"
#include "channelmanager.hpp"
#include "colorscheme.hpp"
#include "settingsmanager.hpp"
#include "singletons/channelmanager.hpp"
#include "singletons/settingsmanager.hpp"
#include "singletons/thememanager.hpp"
#include "singletons/windowmanager.hpp"
#include "twitch/twitchmessagebuilder.hpp"
#include "util/urlfetch.hpp"
#include "widgets/qualitypopup.hpp"
#include "widgets/splitcontainer.hpp"
#include "widgets/textinputdialog.hpp"
#include "widgets/window.hpp"
#include "windowmanager.hpp"
#include <QApplication>
#include <QClipboard>
@@ -45,14 +45,13 @@ inline void ezShortcut(Split *w, const char *key, T t)
} // namespace
Split::Split(ChannelManager &_channelManager, SplitContainer *parent, const std::string &_uuid)
Split::Split(SplitContainer *parent, const std::string &_uuid)
: BaseWidget(parent)
, uuid(_uuid)
, settingRoot(fS("/splits/{}", this->uuid))
, channelName(fS("{}/channelName", this->settingRoot))
, parentPage(*parent)
, channelManager(_channelManager)
, channel(_channelManager.emptyChannel)
, channel(ChannelManager::getInstance().emptyChannel)
, vbox(this)
, header(this)
, view(this)
@@ -171,17 +170,18 @@ double Split::getFlexSizeY()
void Split::channelNameUpdated(const std::string &newChannelName)
{
auto &cman = ChannelManager::getInstance();
// remove current channel
if (!this->channel->isEmpty()) {
this->channelManager.removeTwitchChannel(this->channel->name);
cman.removeTwitchChannel(this->channel->name);
}
// update messages
if (newChannelName.empty()) {
this->setChannel(this->channelManager.emptyChannel);
this->setChannel(cman.emptyChannel);
} else {
this->setChannel(
this->channelManager.addTwitchChannel(QString::fromStdString(newChannelName)));
this->setChannel(cman.addTwitchChannel(QString::fromStdString(newChannelName)));
}
// update header
@@ -236,7 +236,7 @@ void Split::paintEvent(QPaintEvent *)
// color the background of the chat
QPainter painter(this);
painter.fillRect(this->rect(), this->colorScheme.ChatBackground);
painter.fillRect(this->rect(), this->themeManager.ChatBackground);
}
/// Slots
@@ -264,10 +264,9 @@ void Split::doChangeChannel()
void Split::doPopup()
{
Window &window = WindowManager::instance->createWindow();
Window &window = WindowManager::getInstance().createWindow();
Split *split = new Split(this->channelManager,
static_cast<SplitContainer *>(window.getNotebook().getSelectedPage()),
Split *split = new Split(static_cast<SplitContainer *>(window.getNotebook().getSelectedPage()),
this->uuid);
window.getNotebook().getSelectedPage()->addToLayout(split);
@@ -396,7 +395,7 @@ void Split::doOpenViewerList()
QList<QListWidgetItem *> labelList;
for (auto &x : labels) {
auto label = new QListWidgetItem(x);
label->setBackgroundColor(this->colorScheme.ChatHeaderBackground);
label->setBackgroundColor(this->themeManager.ChatHeaderBackground);
labelList.append(label);
}
auto loadingLabel = new QLabel("Loading...");
@@ -453,7 +452,7 @@ void Split::doOpenViewerList()
dockVbox->addWidget(resultList);
resultList->hide();
multiWidget->setStyleSheet(this->colorScheme.InputStyleSheet);
multiWidget->setStyleSheet(this->themeManager.InputStyleSheet);
multiWidget->setLayout(dockVbox);
viewerDock->setWidget(multiWidget);
viewerDock->show();
+1 -5
View File
@@ -19,9 +19,6 @@
namespace chatterino {
class ChannelManager;
class ColorScheme;
namespace widgets {
class SplitContainer;
@@ -46,10 +43,9 @@ class Split : public BaseWidget
const std::string settingRoot;
public:
Split(ChannelManager &_channelManager, SplitContainer *parent, const std::string &_uuid);
Split(SplitContainer *parent, const std::string &_uuid);
~Split();
ChannelManager &channelManager;
pajlada::Settings::Setting<std::string> channelName;
boost::signals2::signal<void()> channelChanged;
+9 -11
View File
@@ -1,6 +1,6 @@
#include "widgets/splitcontainer.hpp"
#include "colorscheme.hpp"
#include "common.hpp"
#include "singletons/thememanager.hpp"
#include "util/helpers.hpp"
#include "widgets/helper/notebooktab.hpp"
#include "widgets/notebook.hpp"
@@ -25,13 +25,11 @@ bool SplitContainer::isDraggingSplit = false;
Split *SplitContainer::draggingSplit = nullptr;
std::pair<int, int> SplitContainer::dropPosition = std::pair<int, int>(-1, -1);
SplitContainer::SplitContainer(ChannelManager &_channelManager, Notebook *parent, NotebookTab *_tab,
const std::string &_uuid)
: BaseWidget(parent->colorScheme, parent)
SplitContainer::SplitContainer(Notebook *parent, NotebookTab *_tab, const std::string &_uuid)
: BaseWidget(parent->themeManager, parent)
, uuid(_uuid)
, settingRoot(fS("/containers/{}", this->uuid))
, chats(fS("{}/chats", this->settingRoot))
, channelManager(_channelManager)
, tab(_tab)
, dropPreview(this)
, chatWidgets()
@@ -387,17 +385,17 @@ void SplitContainer::paintEvent(QPaintEvent *)
QPainter painter(this);
if (this->ui.hbox.count() == 0) {
painter.fillRect(rect(), this->colorScheme.ChatBackground);
painter.fillRect(rect(), this->themeManager.ChatBackground);
painter.setPen(this->colorScheme.Text);
painter.setPen(this->themeManager.Text);
painter.drawText(rect(), "Add Chat", QTextOption(Qt::AlignCenter));
} else {
painter.fillRect(rect(), this->colorScheme.ChatSeperator);
painter.fillRect(rect(), this->themeManager.ChatSeperator);
}
QColor accentColor = (QApplication::activeWindow() == this->window()
? this->colorScheme.TabSelectedBackground
: this->colorScheme.TabSelectedUnfocusedBackground);
? this->themeManager.TabSelectedBackground
: this->themeManager.TabSelectedUnfocusedBackground);
painter.fillRect(0, 0, width(), 2, accentColor);
}
@@ -432,7 +430,7 @@ std::pair<int, int> SplitContainer::getChatPosition(const Split *chatWidget)
Split *SplitContainer::createChatWidget(const std::string &uuid)
{
auto split = new Split(this->channelManager, this, uuid);
auto split = new Split(this, uuid);
split->getChannelView().highlightedMessageReceived.connect([this] {
this->tab->setHighlightState(HighlightState::Highlighted); //
+1 -4
View File
@@ -26,16 +26,13 @@ class SplitContainer : public BaseWidget
const std::string settingRoot;
public:
SplitContainer(ChannelManager &_channelManager, Notebook *parent, NotebookTab *_tab,
const std::string &_uuid);
SplitContainer(Notebook *parent, NotebookTab *_tab, const std::string &_uuid);
const std::string &getUUID() const
{
return this->uuid;
}
ChannelManager &channelManager;
std::pair<int, int> removeFromLayout(Split *widget);
void addToLayout(Split *widget, std::pair<int, int> position = std::pair<int, int>(-1, -1));
+2 -2
View File
@@ -1,6 +1,6 @@
#include "tooltipwidget.hpp"
#include "colorscheme.hpp"
#include "fontmanager.hpp"
#include "singletons/thememanager.hpp"
#include "singletons/fontmanager.hpp"
#include <QStyle>
#include <QVBoxLayout>
+9 -11
View File
@@ -1,8 +1,8 @@
#include "widgets/window.hpp"
#include "accountmanager.hpp"
#include "channelmanager.hpp"
#include "colorscheme.hpp"
#include "settingsmanager.hpp"
#include "singletons/accountmanager.hpp"
#include "singletons/channelmanager.hpp"
#include "singletons/settingsmanager.hpp"
#include "singletons/thememanager.hpp"
#include "widgets/notebook.hpp"
#include "widgets/settingsdialog.hpp"
#include "widgets/split.hpp"
@@ -14,15 +14,13 @@
namespace chatterino {
namespace widgets {
Window::Window(const QString &windowName, ChannelManager &_channelManager,
ColorScheme &_colorScheme, bool _isMainWindow)
: BaseWidget(_colorScheme, nullptr)
Window::Window(const QString &windowName, ThemeManager &_themeManager, bool _isMainWindow)
: BaseWidget(_themeManager, nullptr)
, settingRoot(fS("/windows/{}", windowName))
, windowGeometry(this->settingRoot)
, dpi(this->getDpiMultiplier())
, channelManager(_channelManager)
, colorScheme(_colorScheme)
, notebook(this->channelManager, this, _isMainWindow, this->settingRoot)
, themeManager(_themeManager)
, notebook(this, _isMainWindow, this->settingRoot)
{
this->initAsWindow();
@@ -110,7 +108,7 @@ void Window::closeEvent(QCloseEvent *)
void Window::refreshTheme()
{
QPalette palette;
palette.setColor(QPalette::Background, this->colorScheme.TabBackground);
palette.setColor(QPalette::Background, this->themeManager.TabBackground);
this->setPalette(palette);
}
+4 -6
View File
@@ -16,7 +16,7 @@
namespace chatterino {
class ChannelManager;
class ColorScheme;
class ThemeManager;
class CompletionManager;
namespace widgets {
@@ -45,8 +45,7 @@ class Window : public BaseWidget
WindowGeometry windowGeometry;
public:
explicit Window(const QString &windowName, ChannelManager &_channelManager,
ColorScheme &_colorScheme, bool isMainWindow);
explicit Window(const QString &windowName, ThemeManager &_themeManager, bool isMainWindow);
void repaintVisibleChatWidgets(Channel *channel = nullptr);
@@ -60,15 +59,14 @@ protected:
virtual void closeEvent(QCloseEvent *event) override;
private:
ThemeManager &themeManager;
float dpi;
virtual void refreshTheme() override;
void loadGeometry();
ChannelManager &channelManager;
ColorScheme &colorScheme;
Notebook notebook;
TitleBar titleBar;