added dark window to dark theme

This commit is contained in:
fourtf 2018-04-05 23:44:46 +02:00
parent 5c23be2122
commit 06c3201a1a
8 changed files with 88 additions and 71 deletions

View file

@ -54,9 +54,10 @@ void ThemeManager::update()
void ThemeManager::actuallyUpdate(double hue, double multiplier) void ThemeManager::actuallyUpdate(double hue, double multiplier)
{ {
isLight = multiplier > 0; isLight = multiplier > 0;
bool isLightTabs; bool lightWin = isLight;
QColor themeColor = QColor::fromHslF(hue, 0.5, 0.5); QColor none(0, 0, 0, 0);
QColor themeColor = QColor::fromHslF(hue, 0.43, 0.5);
QColor themeColorNoSat = QColor::fromHslF(hue, 0, 0.5); QColor themeColorNoSat = QColor::fromHslF(hue, 0, 0.5);
qreal sat = 0; qreal sat = 0;
@ -66,48 +67,40 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
return QColor::fromHslF(h, s, ((l - 0.5) * multiplier) + 0.5, a); return QColor::fromHslF(h, s, ((l - 0.5) * multiplier) + 0.5, a);
}; };
//#ifdef USEWINSDK /// WINDOW
// isLightTabs = isLight; {
// QColor tabFg = isLight ? "#000" : "#fff"; QColor bg = this->window.background = lightWin ? "#fff" : "#444";
// this->windowBg = isLight ? "#fff" : getColor(0, sat, 0.9); QColor fg = this->window.text = lightWin ? "#000" : "#eee";
//#else this->window.borderFocused = lightWin ? "#ccc" : themeColor;
isLightTabs = true; this->window.borderUnfocused = lightWin ? "#ccc" : themeColorNoSat;
QColor tabFg = isLightTabs ? "#000" : "#fff";
this->windowBg = "#fff";
//#endif
// Ubuntu style // Ubuntu style
// TODO: add setting for this // TODO: add setting for this
// TabText = QColor(210, 210, 210); // TabText = QColor(210, 210, 210);
// TabBackground = QColor(61, 60, 56); // TabBackground = QColor(61, 60, 56);
// TabHoverText = QColor(210, 210, 210); // TabHoverText = QColor(210, 210, 210);
// TabHoverBackground = QColor(73, 72, 68); // TabHoverBackground = QColor(73, 72, 68);
// message (referenced later) // message (referenced later)
this->messages.textColors.caret = // this->messages.textColors.caret = //
this->messages.textColors.regular = isLight ? "#000" : "#fff"; this->messages.textColors.regular = isLight ? "#000" : "#fff";
// tabs /// TABS
// text, {regular, hover, unfocused} // text, {regular, hover, unfocused}
// this->windowBg = "#ccc";
this->tabs.border = "#999"; if (lightWin) {
this->tabs.regular = {tabFg, {windowBg, blendColors(windowBg, "#999", 0.5), windowBg}}; this->tabs.regular = {fg, {bg, "#ccc", bg}};
this->tabs.newMessage = {fg, {bg, "#ccc", bg}};
this->tabs.selected = {"#fff", {themeColor, themeColor, QColor::fromHslF(hue, 0, 0.5)}}; this->tabs.highlighted = {fg, {bg, "#ccc", bg}};
this->tabs.selected = {"#fff", {"#333", "#333", "#666"}};
this->tabs.newMessage = { } else {
tabFg, this->tabs.regular = {fg, {bg, "#555", bg}};
{QBrush(blendColors(themeColor, windowBg, 0.7), Qt::FDiagPattern), this->tabs.newMessage = {fg, {bg, "#555", bg}};
QBrush(blendColors(themeColor, windowBg, 0.5), Qt::FDiagPattern), this->tabs.highlighted = {fg, {bg, "#555", bg}};
QBrush(blendColors(themeColorNoSat, windowBg, 0.7), Qt::FDiagPattern)}}; // this->tabs.selected = {"#000", {themeColor, themeColor, themeColorNoSat}};
this->tabs.selected = {"#000", {"#999", "#999", "#888"}};
this->tabs.highlighted = { }
tabFg, }
{blendColors(themeColor, windowBg, 0.7), blendColors(themeColor, windowBg, 0.5),
blendColors(themeColorNoSat, windowBg, 0.7)}};
// this->windowBg = "#fff";
// Split // Split
bool flat = isLight; bool flat = isLight;

View file

@ -32,6 +32,15 @@ public:
} backgrounds; } backgrounds;
}; };
/// WINDOW
struct {
QColor background;
QColor text;
QColor borderUnfocused;
QColor borderFocused;
} window;
/// TABS
struct { struct {
TabColors regular; TabColors regular;
TabColors selected; TabColors selected;
@ -40,6 +49,7 @@ public:
QColor border; QColor border;
} tabs; } tabs;
/// SPLITS
struct { struct {
QColor messageSeperator; QColor messageSeperator;
QColor background; QColor background;
@ -64,6 +74,7 @@ public:
} input; } input;
} splits; } splits;
/// MESSAGES
struct { struct {
struct { struct {
QColor regular; QColor regular;
@ -85,6 +96,7 @@ public:
QColor selection; QColor selection;
} messages; } messages;
/// SCROLLBAR
struct { struct {
QColor background; QColor background;
QColor thumb; QColor thumb;
@ -93,14 +105,12 @@ public:
// QColor highlights[3]; // QColor highlights[3];
} scrollbars; } scrollbars;
/// TOOLTIP
struct { struct {
QColor text; QColor text;
QColor background; QColor background;
} tooltip; } tooltip;
QColor windowBg;
QColor windowText;
void normalizeColor(QColor &color); void normalizeColor(QColor &color);
void update(); void update();

View file

@ -160,12 +160,12 @@ void BaseWindow::themeRefreshEvent()
{ {
if (this->enableCustomFrame) { if (this->enableCustomFrame) {
QPalette palette; QPalette palette;
palette.setColor(QPalette::Background, this->themeManager.windowBg); palette.setColor(QPalette::Background, this->themeManager.window.background);
palette.setColor(QPalette::Foreground, this->themeManager.windowText); palette.setColor(QPalette::Foreground, this->themeManager.window.text);
this->setPalette(palette); this->setPalette(palette);
for (RippleEffectButton *button : this->buttons) { for (RippleEffectButton *button : this->buttons) {
button->setMouseEffectColor(this->themeManager.windowText); button->setMouseEffectColor(this->themeManager.window.text);
} }
} }
} }
@ -408,15 +408,22 @@ void BaseWindow::paintEvent(QPaintEvent *event)
bool windowFocused = this->window() == QApplication::activeWindow(); bool windowFocused = this->window() == QApplication::activeWindow();
QLinearGradient gradient(0, 0, 10, 250); // QLinearGradient gradient(0, 0, 10, 250);
gradient.setColorAt(1, this->themeManager.tabs.selected.backgrounds.unfocused.color()); // gradient.setColorAt(1,
// this->themeManager.tabs.selected.backgrounds.unfocused.color());
if (windowFocused) { // if (windowFocused) {
gradient.setColorAt(.4, this->themeManager.tabs.selected.backgrounds.regular.color()); // gradient.setColorAt(.4,
} else { // this->themeManager.tabs.selected.backgrounds.regular.color());
gradient.setColorAt(.4, this->themeManager.tabs.selected.backgrounds.unfocused.color()); // } else {
} // gradient.setColorAt(.4,
painter.setPen(QPen(QBrush(gradient), 1)); // this->themeManager.tabs.selected.backgrounds.unfocused.color());
// }
// painter.setPen(QPen(QBrush(gradient), 1));
QColor &border = windowFocused ? this->themeManager.window.borderFocused
: this->themeManager.window.borderUnfocused;
painter.setPen(QPen(QBrush(border), 1));
painter.drawRect(0, 0, this->width() - 1, this->height() - 1); painter.drawRect(0, 0, this->width() - 1, this->height() - 1);
} }

View file

@ -17,11 +17,14 @@ namespace widgets {
NotebookButton::NotebookButton(BaseWidget *parent) NotebookButton::NotebookButton(BaseWidget *parent)
: RippleEffectButton(parent) : RippleEffectButton(parent)
{ {
setMouseEffectColor(QColor(0, 0, 0));
this->setAcceptDrops(true); this->setAcceptDrops(true);
} }
void NotebookButton::themeRefreshEvent()
{
this->setMouseEffectColor(this->themeManager.tabs.regular.text);
}
void NotebookButton::paintEvent(QPaintEvent *) void NotebookButton::paintEvent(QPaintEvent *)
{ {
QPainter painter(this); QPainter painter(this);
@ -30,15 +33,14 @@ void NotebookButton::paintEvent(QPaintEvent *)
QColor foreground; QColor foreground;
if (mouseDown || mouseOver) { if (mouseDown || mouseOver) {
background = this->themeManager.tabs.regular.backgrounds.regular.color(); background = this->themeManager.tabs.regular.backgrounds.hover.color();
foreground = this->themeManager.tabs.regular.text; foreground = this->themeManager.tabs.regular.text;
} else { } else {
background = this->themeManager.tabs.regular.backgrounds.regular.color(); background = this->themeManager.tabs.regular.backgrounds.regular.color();
foreground = QColor(70, 80, 80); foreground = this->themeManager.tabs.regular.text;
} }
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
// painter.fillRect(this->rect(), background);
float h = height(), w = width(); float h = height(), w = width();

View file

@ -21,6 +21,7 @@ public:
NotebookButton(BaseWidget *parent); NotebookButton(BaseWidget *parent);
protected: protected:
virtual void themeRefreshEvent() override;
virtual void paintEvent(QPaintEvent *) override; virtual void paintEvent(QPaintEvent *) override;
virtual void mouseReleaseEvent(QMouseEvent *) override; virtual void mouseReleaseEvent(QMouseEvent *) override;
virtual void dragEnterEvent(QDragEnterEvent *) override; virtual void dragEnterEvent(QDragEnterEvent *) override;

View file

@ -209,13 +209,13 @@ void NotebookTab::paintEvent(QPaintEvent *)
painter.fillRect(rect(), tabBackground); painter.fillRect(rect(), tabBackground);
// draw border // draw border
painter.setPen(QPen("#ccc")); // painter.setPen(QPen("#ccc"));
QPainterPath path(QPointF(0, height)); // QPainterPath path(QPointF(0, height));
path.lineTo(0, 0); // path.lineTo(0, 0);
path.lineTo(this->width() - 1, 0); // path.lineTo(this->width() - 1, 0);
path.lineTo(this->width() - 1, this->height() - 1); // path.lineTo(this->width() - 1, this->height() - 1);
path.lineTo(0, this->height() - 1); // path.lineTo(0, this->height() - 1);
painter.drawPath(path); // painter.drawPath(path);
} else { } else {
// QPainterPath path(QPointF(0, height)); // QPainterPath path(QPointF(0, height));
// path.lineTo(8 * scale, 0); // path.lineTo(8 * scale, 0);

View file

@ -1,5 +1,7 @@
#include "titlebarbutton.hpp" #include "titlebarbutton.hpp"
#include "singletons/thememanager.hpp"
namespace chatterino { namespace chatterino {
namespace widgets { namespace widgets {
@ -23,8 +25,8 @@ void TitleBarButton::paintEvent(QPaintEvent *)
{ {
QPainter painter(this); QPainter painter(this);
QColor color = "#000"; QColor color = this->themeManager.window.text;
QColor background = "#fff"; QColor background = this->themeManager.window.background;
int xD = this->height() / 3; int xD = this->height() / 3;
int centerX = this->width() / 2; int centerX = this->width() / 2;
@ -59,7 +61,8 @@ void TitleBarButton::paintEvent(QPaintEvent *)
break; break;
} }
case User: { case User: {
color = QColor("#333"); // color = QColor("#333");
color = "#999";
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::HighQualityAntialiasing); painter.setRenderHint(QPainter::HighQualityAntialiasing);
@ -85,7 +88,8 @@ void TitleBarButton::paintEvent(QPaintEvent *)
break; break;
} }
case Settings: { case Settings: {
color = QColor("#333"); // color = QColor("#333");
color = "#999";
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::HighQualityAntialiasing); painter.setRenderHint(QPainter::HighQualityAntialiasing);

View file

@ -414,7 +414,7 @@ void SplitContainer::paintEvent(QPaintEvent *)
? this->themeManager.tabs.selected.backgrounds.regular ? this->themeManager.tabs.selected.backgrounds.regular
: this->themeManager.tabs.selected.backgrounds.unfocused); : this->themeManager.tabs.selected.backgrounds.unfocused);
painter.fillRect(0, 0, width(), 2, accentColor); painter.fillRect(0, 0, width(), 1, accentColor);
} }
void SplitContainer::showEvent(QShowEvent *event) void SplitContainer::showEvent(QShowEvent *event)