the rewrite that nobody wanted

This commit is contained in:
2018-01-02 02:15:11 +01:00
parent 0ef08378cc
commit 3e5937011a
18 changed files with 217 additions and 175 deletions

View file

@ -25,11 +25,11 @@ const QColor &MessageColor::getColor(singletons::ThemeManager &themeManager) con
case Type::Custom: case Type::Custom:
return this->color; return this->color;
case Type::Text: case Type::Text:
return themeManager.Text; return themeManager.messages.textColors.regular;
case Type::System: case Type::System:
return themeManager.SystemMessageColor; return themeManager.messages.textColors.system;
case Type::Link: case Type::Link:
return themeManager.TextLink; return themeManager.messages.textColors.link;
} }
static QColor _default; static QColor _default;

View file

@ -291,7 +291,7 @@ void IrcManager::writeConnectionMessageReceived(Communi::IrcMessage *message)
} }
// XXX: This does not fit in IrcManager // XXX: This does not fit in IrcManager
bool IrcManager::isTwitchBlockedUser(QString const &username) bool IrcManager::isTwitchUserBlocked(QString const &username)
{ {
QMutexLocker locker(&this->twitchBlockedUsersMutex); QMutexLocker locker(&this->twitchBlockedUsersMutex);

View file

@ -57,70 +57,85 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
qreal sat = 0.05; qreal sat = 0.05;
SystemMessageColor = QColor(140, 127, 127);
auto getColor = [multiplier](double h, double s, double l, double a = 1.0) { auto getColor = [multiplier](double h, double s, double l, double a = 1.0) {
return QColor::fromHslF(h, s, ((l - 0.5) * multiplier) + 0.5, a); return QColor::fromHslF(h, s, ((l - 0.5) * multiplier) + 0.5, a);
}; };
DropPreviewBackground = getColor(hue, 0.5, 0.5, 0.6); // Ubuntu style
// TODO: add setting for this
// TabText = QColor(210, 210, 210);
// TabBackground = QColor(61, 60, 56);
// TabHoverText = QColor(210, 210, 210);
// TabHoverBackground = QColor(73, 72, 68);
Text = TextCaret = lightTheme ? QColor(0, 0, 0) : QColor(255, 255, 255); // message (referenced later)
TextLink = lightTheme ? QColor(66, 134, 244) : QColor(66, 134, 244); this->messages.textColors.caret = //
this->messages.textColors.regular = lightTheme ? QColor(0, 0, 0) : QColor(255, 255, 255);
// tab // tabs
if (true) { // text, {regular, hover, unfocused}
TabText = QColor(0, 0, 0); this->tabs.regular = {QColor(0, 0, 0),
TabBackground = QColor(255, 255, 255); {QColor(255, 255, 255), QColor(200, 200, 200), QColor(255, 255, 255)}};
TabHoverText = QColor(0, 0, 0); this->tabs.selected = {QColor(255, 255, 255),
TabHoverBackground = QColor::fromHslF(hue, 0, 0.95); {QColor::fromHslF(hue, 0.5, 0.5), QColor::fromHslF(hue, 0.5, 0.5),
} else { QColor::fromHslF(hue, 0, 0.5)}};
// Ubuntu style
// TODO: add setting for this
TabText = QColor(210, 210, 210);
TabBackground = QColor(61, 60, 56);
TabHoverText = QColor(210, 210, 210); this->tabs.newMessage = {QColor(0, 0, 0),
TabHoverBackground = QColor(73, 72, 68); {QBrush(QColor::fromHslF(hue, 0.5, 0.8), Qt::DiagCrossPattern),
} QBrush(QColor::fromHslF(hue, 0.5, 0.7), Qt::DiagCrossPattern),
QBrush(QColor::fromHslF(hue, 0, 0.8), Qt::DiagCrossPattern)}};
TabSelectedText = QColor(255, 255, 255); this->tabs.highlighted = {QColor(0, 0, 0),
TabSelectedBackground = QColor::fromHslF(hue, 0.5, 0.5); {QColor::fromHslF(hue, 0.5, 0.8), QColor::fromHslF(hue, 0.5, 0.7),
QColor::fromHslF(hue, 0, 0.8)}};
TabSelectedUnfocusedText = QColor(255, 255, 255); // Split
TabSelectedUnfocusedBackground = QColor::fromHslF(hue, 0, 0.5);
TabHighlightedText = QColor(0, 0, 0);
TabHighlightedBackground = QColor::fromHslF(hue, 0.5, 0.8);
TabNewMessageBackground = QBrush(QColor::fromHslF(hue, 0.5, 0.8), Qt::DiagCrossPattern);
// Chat
bool flat = lightTheme; bool flat = lightTheme;
ChatBackground = getColor(0, sat, 1); this->splits.messageSeperator = lightTheme ? QColor(127, 127, 127) : QColor(80, 80, 80);
DisabledMessageOverlay = getColor(0, sat, 1, 0.6); this->splits.background = getColor(0, sat, 1);
ChatBackgroundHighlighted = blendColors(TabSelectedBackground, ChatBackground, 0.8); this->splits.dropPreview = getColor(hue, 0.5, 0.5, 0.6);
ChatHeaderBackground = getColor(0, sat, flat ? 1 : 0.9); // this->splits.border
ChatHeaderBorder = getColor(0, sat, flat ? 1 : 0.85); // this->splits.borderFocused
ChatInputBackground = getColor(0, sat, flat ? 0.95 : 0.95);
ChatInputBorder = getColor(0, sat, flat ? 1 : 1); this->splits.header.background = getColor(0, sat, flat ? 1 : 0.9);
ChatSeperator = lightTheme ? QColor(127, 127, 127) : QColor(80, 80, 80); this->splits.header.border = getColor(0, sat, flat ? 1 : 0.85);
this->splits.header.text = this->messages.textColors.regular;
this->splits.input.background = getColor(0, sat, flat ? 0.95 : 0.95);
this->splits.input.border = getColor(0, sat, flat ? 1 : 1);
this->splits.input.text = this->messages.textColors.regular;
this->splits.input.styleSheet =
"background:" + this->splits.input.background.name() + ";" +
"border:" + this->tabs.selected.backgrounds.regular.color().name() + ";" +
"color:" + this->messages.textColors.regular.name() + ";" +
"selection-background-color:" + this->tabs.selected.backgrounds.regular.color().name();
// Message
this->messages.textColors.link = lightTheme ? QColor(66, 134, 244) : QColor(66, 134, 244);
this->messages.textColors.system = QColor(140, 127, 127);
this->messages.backgrounds.regular = splits.background;
this->messages.backgrounds.highlighted = blendColors(
this->tabs.selected.backgrounds.regular.color(), this->messages.backgrounds.regular, 0.8);
// this->messages.backgrounds.resub
// this->messages.backgrounds.whisper
this->messages.disabled = getColor(0, sat, 1, 0.6);
// this->messages.seperator =
// this->messages.seperatorInner =
// Scrollbar // Scrollbar
ScrollbarBG = getColor(0, sat, 0.94); this->scrollbars.background = getColor(0, sat, 0.94);
ScrollbarThumb = getColor(0, sat, 0.80); this->scrollbars.thumb = getColor(0, sat, 0.80);
ScrollbarThumbSelected = getColor(0, sat, 0.7); this->scrollbars.thumbSelected = getColor(0, sat, 0.7);
ScrollbarArrow = getColor(0, sat, 0.9);
// stylesheet // tooltip
InputStyleSheet = "background:" + ChatInputBackground.name() + ";" + this->tooltip.background = QColor(0, 0, 0);
"border:" + TabSelectedBackground.name() + ";" + "color:" + Text.name() + this->tooltip.text = QColor(255, 255, 255);
";" + "selection-background-color:" + TabSelectedBackground.name();
// Selection // Selection
Selection = isLightTheme() ? QColor(0, 0, 0, 64) : QColor(255, 255, 255, 64); this->messages.selection = isLightTheme() ? QColor(0, 0, 0, 64) : QColor(255, 255, 255, 64);
this->updated(); this->updated();
} }

View file

@ -22,65 +22,79 @@ public:
return this->lightTheme; return this->lightTheme;
} }
QString InputStyleSheet; struct TabColors {
QColor text;
struct Backgrounds {
QBrush regular;
QBrush hover;
QBrush unfocused;
} backgrounds;
};
QColor SystemMessageColor; struct Tabs {
TabColors regular;
TabColors selected;
TabColors highlighted;
TabColors newMessage;
} tabs;
QColor DropPreviewBackground; struct Splits {
QColor messageSeperator;
QColor background;
QColor border;
QColor borderFocused;
QColor dropPreview;
QColor TooltipBackground; struct Header {
QColor TooltipText; QColor border;
QColor background;
QColor text;
// int margin;
} header;
QColor ChatSeperator; struct Input {
QColor ChatBackground; QColor border;
QColor ChatBackgroundHighlighted; QColor background;
QColor ChatBackgroundResub; QColor selection;
QColor ChatBackgroundWhisper; QColor text;
QColor DisabledMessageOverlay; QString styleSheet;
// int margin;
} input;
} splits;
QColor ChatHeaderBorder; struct Messages {
QColor ChatHeaderBackground; struct TextColors {
QColor regular;
QColor caret;
QColor link;
QColor system;
} textColors;
QColor ChatInputBackground; struct Backgrounds {
QColor ChatInputBorder; QColor regular;
QColor highlighted;
// QColor resub;
// QColor whisper;
} backgrounds;
QColor ChatMessageSeperatorBorder; QColor disabled;
QColor ChatMessageSeperatorBorderInner; // QColor seperator;
QColor ChatBorder; // QColor seperatorInner;
QColor ChatBorderFocused; QColor selection;
QColor Text; } messages;
QColor TextCaret;
QColor TextLink;
QColor TextFocused;
QColor Menu;
QColor MenuBorder;
QColor ScrollbarBG; struct Scrollbars {
QColor ScrollbarThumb; QColor background;
QColor ScrollbarThumbSelected; QColor thumb;
QColor ScrollbarArrow; QColor thumbSelected;
// const int highlightsCount = 3;
// QColor highlights[3];
} scrollbars;
QColor TabText; struct Tooltip {
QColor TabBackground; QColor text;
QColor background;
QColor TabHoverText; } tooltip;
QColor TabHoverBackground;
QColor TabSelectedText;
QColor TabSelectedBackground;
QColor TabHighlightedText;
QColor TabHighlightedBackground;
QColor TabSelectedUnfocusedText;
QColor TabSelectedUnfocusedBackground;
QBrush TabNewMessageBackground;
QColor Selection;
const int HighlightColorCount = 3;
QColor HighlightColors[3];
void normalizeColor(QColor &color); void normalizeColor(QColor &color);

View file

@ -25,7 +25,7 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel,
, ircMessage(_ircMessage) , ircMessage(_ircMessage)
, args(_args) , args(_args)
, tags(this->ircMessage->tags()) , tags(this->ircMessage->tags())
, usernameColor(singletons::ThemeManager::getInstance().SystemMessageColor) , usernameColor(singletons::ThemeManager::getInstance().messages.textColors.system)
{ {
} }

View file

@ -483,7 +483,7 @@ void ChannelView::paintEvent(QPaintEvent * /*event*/)
// update all messages // update all messages
this->gifEmotes.clear(); this->gifEmotes.clear();
painter.fillRect(rect(), this->themeManager.ChatBackground); painter.fillRect(rect(), this->themeManager.splits.background);
// draw messages // draw messages
this->drawMessages(painter, false); this->drawMessages(painter, false);
@ -524,7 +524,7 @@ void ChannelView::drawMessages(QPainter &painter, bool overlays)
if (overlays) { if (overlays) {
if (messageRef->isDisabled()) { if (messageRef->isDisabled()) {
painter.fillRect(0, y, this->width(), messageRef->getHeight(), painter.fillRect(0, y, this->width(), messageRef->getHeight(),
this->themeManager.DisabledMessageOverlay); this->themeManager.messages.disabled);
} }
} else { } else {
std::shared_ptr<QPixmap> buffer = messageRef->buffer; std::shared_ptr<QPixmap> buffer = messageRef->buffer;
@ -624,8 +624,8 @@ void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap
//} else { //} else {
painter.fillRect(buffer->rect(), painter.fillRect(buffer->rect(),
(messageRef->getMessage()->containsHighlightedPhrase()) (messageRef->getMessage()->containsHighlightedPhrase())
? this->themeManager.ChatBackgroundHighlighted ? this->themeManager.messages.backgrounds.highlighted
: this->themeManager.ChatBackground); : this->themeManager.messages.backgrounds.regular);
//} //}
// draw selection // draw selection
@ -672,7 +672,7 @@ void ChannelView::drawMessageSelection(QPainter &painter, messages::MessageRef *
return; return;
} }
QColor selectionColor = this->themeManager.Selection; QColor selectionColor = this->themeManager.messages.selection;
int charIndex = 0; int charIndex = 0;
size_t i = 0; size_t i = 0;

View file

@ -20,7 +20,7 @@ void NotebookPageDropPreview::paintEvent(QPaintEvent *)
QPainter painter(this); QPainter painter(this);
painter.fillRect(8, 8, this->width() - 17, this->height() - 17, painter.fillRect(8, 8, this->width() - 17, this->height() - 17,
this->themeManager.DropPreviewBackground); this->themeManager.splits.dropPreview);
} }
void NotebookPageDropPreview::hideEvent(QHideEvent *) void NotebookPageDropPreview::hideEvent(QHideEvent *)

View file

@ -23,16 +23,11 @@ void NotebookButton::paintEvent(QPaintEvent *)
QColor background; QColor background;
QColor foreground; QColor foreground;
background = this->themeManager.TabBackground; if (mouseDown || mouseOver) {
background = this->themeManager.tabs.regular.backgrounds.regular.color();
if (mouseDown) { foreground = this->themeManager.tabs.regular.text;
// background = this->themeManager.TabSelectedBackground;
foreground = this->themeManager.TabHoverText;
} else if (mouseOver) {
// background = this->themeManager.TabHoverText;
foreground = this->themeManager.TabHoverText;
} else { } else {
// background = this->themeManager.TabPanelBackground; background = this->themeManager.tabs.regular.backgrounds.regular.color();
foreground = QColor(70, 80, 80); foreground = QColor(70, 80, 80);
} }

View file

@ -1,10 +1,11 @@
#include "widgets/helper/notebooktab.hpp" #include "widgets/helper/notebooktab.hpp"
#include "singletons/thememanager.hpp"
#include "common.hpp" #include "common.hpp"
#include "debug/log.hpp" #include "debug/log.hpp"
#include "singletons/settingsmanager.hpp" #include "singletons/settingsmanager.hpp"
#include "singletons/thememanager.hpp"
#include "util/helpers.hpp" #include "util/helpers.hpp"
#include "widgets/notebook.hpp" #include "widgets/notebook.hpp"
#include "widgets/settingsdialog.hpp"
#include "widgets/textinputdialog.hpp" #include "widgets/textinputdialog.hpp"
#include <QApplication> #include <QApplication>
@ -161,41 +162,44 @@ void NotebookTab::moveAnimated(QPoint pos, bool animated)
void NotebookTab::paintEvent(QPaintEvent *) void NotebookTab::paintEvent(QPaintEvent *)
{ {
singletons::SettingManager &settingManager = singletons::SettingManager::getInstance();
QPainter painter(this); QPainter painter(this);
QColor fg = QColor(0, 0, 0); // select the right tab colors
singletons::ThemeManager::TabColors colors;
if (this->selected) { if (this->selected) {
if (this->window() == QApplication::activeWindow()) { colors = this->themeManager.tabs.selected;
painter.fillRect(rect(), this->themeManager.TabSelectedBackground);
fg = this->themeManager.TabSelectedText;
} else {
painter.fillRect(rect(), this->themeManager.TabSelectedUnfocusedBackground);
fg = this->themeManager.TabSelectedUnfocusedText;
}
} else if (this->mouseOver) {
painter.fillRect(rect(), this->themeManager.TabHoverBackground);
fg = this->themeManager.TabHoverText;
} else if (this->highlightState == HighlightState::Highlighted) { } else if (this->highlightState == HighlightState::Highlighted) {
painter.fillRect(rect(), this->themeManager.TabHighlightedBackground); colors = this->themeManager.tabs.highlighted;
fg = this->themeManager.TabHighlightedText;
} else if (this->highlightState == HighlightState::NewMessage) { } else if (this->highlightState == HighlightState::NewMessage) {
painter.fillRect(rect(), this->themeManager.TabNewMessageBackground); colors = this->themeManager.tabs.newMessage;
fg = this->themeManager.TabHighlightedText;
} else { } else {
painter.fillRect(rect(), this->themeManager.TabBackground); colors = this->themeManager.tabs.regular;
fg = this->themeManager.TabText;
} }
painter.setPen(fg); bool windowFocused = this->window() == QApplication::activeWindow();
// || SettingsDialog::getHandle() == QApplication::activeWindow();
// fill the tab background
painter.fillRect(rect(),
windowFocused
? (this->mouseOver ? colors.backgrounds.hover : colors.backgrounds.regular)
: colors.backgrounds.unfocused);
// set the pen color
painter.setPen(colors.text);
// set area for text
float scale = this->getDpiMultiplier(); float scale = this->getDpiMultiplier();
int rectW = (singletons::SettingManager::getInstance().hideTabX ? 0 : static_cast<int>(16) * scale); int rectW = (settingManager.hideTabX ? 0 : static_cast<int>(16) * scale);
QRect rect(0, 0, this->width() - rectW, this->height()); QRect rect(0, 0, this->width() - rectW, this->height());
// draw text
painter.drawText(rect, this->getTitle(), QTextOption(Qt::AlignCenter)); painter.drawText(rect, this->getTitle(), QTextOption(Qt::AlignCenter));
if (!singletons::SettingManager::getInstance().hideTabX && (mouseOver || selected)) { // draw close x
if (!settingManager.hideTabX && (mouseOver || selected)) {
QRect xRect = this->getXRect(); QRect xRect = this->getXRect();
if (mouseOverX) { if (mouseOverX) {
painter.fillRect(xRect, QColor(0, 0, 0, 64)); painter.fillRect(xRect, QColor(0, 0, 0, 64));

View file

@ -9,7 +9,8 @@ ScrollBarHighlight::ScrollBarHighlight(double _position, int _colorIndex, Scroll
Style _style, QString _tag) Style _style, QString _tag)
: themeManager(parent->themeManager) : themeManager(parent->themeManager)
, position(_position) , position(_position)
, colorIndex(std::max(0, std::min(this->themeManager.HighlightColorCount, _colorIndex))) // , colorIndex(std::max(0, std::min(this->themeManager.HighlightColorCount, _colorIndex)))
, colorIndex(0)
, style(_style) , style(_style)
, tag(_tag) , tag(_tag)
{ {

View file

@ -119,9 +119,8 @@ void SplitHeader::updateChannelText()
"<br>" "<br>"
"Live for " + "Live for " +
twitchChannel->streamUptime + " with " + twitchChannel->streamUptime + " with " +
twitchChannel->streamViewerCount + twitchChannel->streamViewerCount + " viewers"
" viewers" "</p>";
"</p>";
this->channelNameLabel.setText(QString::fromStdString(channelName) + " (live)"); this->channelNameLabel.setText(QString::fromStdString(channelName) + " (live)");
} else { } else {
this->isLive = false; this->isLive = false;
@ -135,8 +134,8 @@ void SplitHeader::paintEvent(QPaintEvent *)
{ {
QPainter painter(this); QPainter painter(this);
painter.fillRect(rect(), this->themeManager.ChatHeaderBackground); painter.fillRect(rect(), this->themeManager.splits.header.background);
painter.setPen(this->themeManager.ChatHeaderBorder); painter.setPen(this->themeManager.splits.header.border);
painter.drawRect(0, 0, width() - 1, height() - 1); painter.drawRect(0, 0, width() - 1, height() - 1);
} }
@ -217,7 +216,7 @@ void SplitHeader::rightButtonClicked()
void SplitHeader::refreshTheme() void SplitHeader::refreshTheme()
{ {
QPalette palette; QPalette palette;
palette.setColor(QPalette::Foreground, this->themeManager.Text); palette.setColor(QPalette::Foreground, this->themeManager.splits.header.text);
this->leftLabel.setPalette(palette); this->leftLabel.setPalette(palette);
this->channelNameLabel.setPalette(palette); this->channelNameLabel.setPalette(palette);

View file

@ -210,11 +210,11 @@ void SplitInput::refreshTheme()
{ {
QPalette palette; QPalette palette;
palette.setColor(QPalette::Foreground, this->themeManager.Text); palette.setColor(QPalette::Foreground, this->themeManager.splits.input.text);
this->textLengthLabel.setPalette(palette); this->textLengthLabel.setPalette(palette);
this->textInput.setStyleSheet(this->themeManager.InputStyleSheet); this->textInput.setStyleSheet(this->themeManager.splits.input.styleSheet);
this->hbox.setMargin((this->themeManager.isLightTheme() ? 4 : 2) * this->getDpiMultiplier()); this->hbox.setMargin((this->themeManager.isLightTheme() ? 4 : 2) * this->getDpiMultiplier());
} }
@ -244,9 +244,9 @@ void SplitInput::paintEvent(QPaintEvent *)
{ {
QPainter painter(this); QPainter painter(this);
painter.fillRect(this->rect(), this->themeManager.ChatInputBackground); painter.fillRect(this->rect(), this->themeManager.splits.input.background);
QPen pen(this->themeManager.ChatInputBorder); QPen pen(this->themeManager.splits.input.border);
if (this->themeManager.isLightTheme()) { if (this->themeManager.isLightTheme()) {
pen.setWidth((int)(6 * this->getDpiMultiplier())); pen.setWidth((int)(6 * this->getDpiMultiplier()));
} }

View file

@ -236,20 +236,21 @@ void ScrollBar::paintEvent(QPaintEvent *)
QPainter painter(this); QPainter painter(this);
// painter.fillRect(rect(), this->themeManager.ScrollbarBG); // painter.fillRect(rect(), this->themeManager.ScrollbarBG);
painter.fillRect(QRect(xOffset, 0, width(), this->buttonHeight), // painter.fillRect(QRect(xOffset, 0, width(), this->buttonHeight),
this->themeManager.ScrollbarArrow); // this->themeManager.ScrollbarArrow);
painter.fillRect(QRect(xOffset, height() - this->buttonHeight, width(), this->buttonHeight), // painter.fillRect(QRect(xOffset, height() - this->buttonHeight, width(),
this->themeManager.ScrollbarArrow); // this->buttonHeight),
// this->themeManager.ScrollbarArrow);
this->thumbRect.setX(xOffset); this->thumbRect.setX(xOffset);
// mouse over thumb // mouse over thumb
if (this->mouseDownIndex == 2) { if (this->mouseDownIndex == 2) {
painter.fillRect(this->thumbRect, this->themeManager.ScrollbarThumbSelected); painter.fillRect(this->thumbRect, this->themeManager.scrollbars.thumbSelected);
} }
// mouse not over thumb // mouse not over thumb
else { else {
painter.fillRect(this->thumbRect, this->themeManager.ScrollbarThumb); painter.fillRect(this->thumbRect, this->themeManager.scrollbars.thumb);
} }
// ScrollBarHighlight *highlight = highlights; // ScrollBarHighlight *highlight = highlights;

View file

@ -1,12 +1,12 @@
#include "widgets/settingsdialog.hpp" #include "widgets/settingsdialog.hpp"
#include "singletons/accountmanager.hpp"
#include "const.hpp" #include "const.hpp"
#include "debug/log.hpp" #include "debug/log.hpp"
#include "singletons/accountmanager.hpp"
#include "singletons/windowmanager.hpp"
#include "twitch/twitchmessagebuilder.hpp" #include "twitch/twitchmessagebuilder.hpp"
#include "twitch/twitchuser.hpp" #include "twitch/twitchuser.hpp"
#include "widgets/helper/settingsdialogtab.hpp" #include "widgets/helper/settingsdialogtab.hpp"
#include "widgets/logindialog.hpp" #include "widgets/logindialog.hpp"
#include "singletons/windowmanager.hpp"
#include <QComboBox> #include <QComboBox>
#include <QDebug> #include <QDebug>
@ -25,6 +25,8 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
SettingsDialog *SettingsDialog::handle = nullptr;
SettingsDialog::SettingsDialog() SettingsDialog::SettingsDialog()
: BaseWidget() : BaseWidget()
, usernameDisplayMode( , usernameDisplayMode(
@ -71,6 +73,11 @@ SettingsDialog::SettingsDialog()
this->dpiMultiplierChanged(this->getDpiMultiplier(), this->getDpiMultiplier()); this->dpiMultiplierChanged(this->getDpiMultiplier(), this->getDpiMultiplier());
} }
SettingsDialog *SettingsDialog::getHandle()
{
return SettingsDialog::handle;
}
void SettingsDialog::addTabs() void SettingsDialog::addTabs()
{ {
this->addTab(this->createAccountsTab(), "Accounts", ":/images/Message_16xLG.png"); this->addTab(this->createAccountsTab(), "Accounts", ":/images/Message_16xLG.png");

View file

@ -33,6 +33,8 @@ class SettingsDialog : public BaseWidget
friend class SettingsDialogTab; friend class SettingsDialogTab;
public: public:
static SettingsDialog *getHandle(); // may be NULL
enum class PreferredTab { enum class PreferredTab {
NoPreference, NoPreference,
Accounts, Accounts,
@ -45,6 +47,7 @@ protected:
private: private:
void refresh(); void refresh();
static SettingsDialog *handle;
std::vector<SettingsDialogTab *> tabs; std::vector<SettingsDialogTab *> tabs;

View file

@ -108,13 +108,14 @@ Split::Split(SplitContainer *parent, const std::string &_uuid)
} }
}); });
singletons::SettingManager::getInstance().hideEmptyInput.connect([this](const bool &hideEmptyInput, auto) { singletons::SettingManager::getInstance().hideEmptyInput.connect(
if (hideEmptyInput && this->input.getInputText().length() == 0) { [this](const bool &hideEmptyInput, auto) {
this->input.hide(); if (hideEmptyInput && this->input.getInputText().length() == 0) {
} else { this->input.hide();
this->input.show(); } else {
} this->input.show();
}); }
});
} }
Split::~Split() Split::~Split()
@ -236,7 +237,7 @@ void Split::paintEvent(QPaintEvent *)
// color the background of the chat // color the background of the chat
QPainter painter(this); QPainter painter(this);
painter.fillRect(this->rect(), this->themeManager.ChatBackground); painter.fillRect(this->rect(), this->themeManager.splits.background);
} }
/// Slots /// Slots
@ -395,7 +396,7 @@ void Split::doOpenViewerList()
QList<QListWidgetItem *> labelList; QList<QListWidgetItem *> labelList;
for (auto &x : labels) { for (auto &x : labels) {
auto label = new QListWidgetItem(x); auto label = new QListWidgetItem(x);
label->setBackgroundColor(this->themeManager.ChatHeaderBackground); label->setBackgroundColor(this->themeManager.splits.header.background);
labelList.append(label); labelList.append(label);
} }
auto loadingLabel = new QLabel("Loading..."); auto loadingLabel = new QLabel("Loading...");
@ -452,7 +453,7 @@ void Split::doOpenViewerList()
dockVbox->addWidget(resultList); dockVbox->addWidget(resultList);
resultList->hide(); resultList->hide();
multiWidget->setStyleSheet(this->themeManager.InputStyleSheet); multiWidget->setStyleSheet(this->themeManager.splits.input.styleSheet);
multiWidget->setLayout(dockVbox); multiWidget->setLayout(dockVbox);
viewerDock->setWidget(multiWidget); viewerDock->setWidget(multiWidget);
viewerDock->show(); viewerDock->show();

View file

@ -385,17 +385,17 @@ void SplitContainer::paintEvent(QPaintEvent *)
QPainter painter(this); QPainter painter(this);
if (this->ui.hbox.count() == 0) { if (this->ui.hbox.count() == 0) {
painter.fillRect(rect(), this->themeManager.ChatBackground); painter.fillRect(rect(), this->themeManager.splits.background);
painter.setPen(this->themeManager.Text); painter.setPen(this->themeManager.splits.header.text);
painter.drawText(rect(), "Add Chat", QTextOption(Qt::AlignCenter)); painter.drawText(rect(), "Add Chat", QTextOption(Qt::AlignCenter));
} else { } else {
painter.fillRect(rect(), this->themeManager.ChatSeperator); painter.fillRect(rect(), this->themeManager.splits.messageSeperator);
} }
QColor accentColor = (QApplication::activeWindow() == this->window() QBrush accentColor = (QApplication::activeWindow() == this->window()
? this->themeManager.TabSelectedBackground ? this->themeManager.tabs.selected.backgrounds.regular
: this->themeManager.TabSelectedUnfocusedBackground); : this->themeManager.tabs.selected.backgrounds.unfocused);
painter.fillRect(0, 0, width(), 2, accentColor); painter.fillRect(0, 0, width(), 2, accentColor);
} }

View file

@ -14,7 +14,8 @@
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
Window::Window(const QString &windowName, singletons::ThemeManager &_themeManager, bool _isMainWindow) Window::Window(const QString &windowName, singletons::ThemeManager &_themeManager,
bool _isMainWindow)
: BaseWidget(_themeManager, nullptr) : BaseWidget(_themeManager, nullptr)
, settingRoot(fS("/windows/{}", windowName)) , settingRoot(fS("/windows/{}", windowName))
, windowGeometry(this->settingRoot) , windowGeometry(this->settingRoot)
@ -108,7 +109,8 @@ void Window::closeEvent(QCloseEvent *)
void Window::refreshTheme() void Window::refreshTheme()
{ {
QPalette palette; QPalette palette;
palette.setColor(QPalette::Background, this->themeManager.TabBackground); palette.setColor(QPalette::Background,
this->themeManager.tabs.regular.backgrounds.regular.color());
this->setPalette(palette); this->setPalette(palette);
} }