Skip to content

Commit

Permalink
Added code for ubuntu color style
Browse files Browse the repository at this point in the history
  • Loading branch information
fourtf committed Aug 17, 2017
1 parent a4533ae commit ca65e54
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ Session.vim
*~
# Vim Auto-generated tag files
tags

# rapidjson directory
rapidjson/*
44 changes: 25 additions & 19 deletions src/colorscheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void ColorScheme::setColors(double hue, double multiplier)
SystemMessageColor = QColor(140, 127, 127);

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);
Expand All @@ -71,34 +71,39 @@ void ColorScheme::setColors(double hue, double multiplier)
TextLink = lightTheme ? QColor(66, 134, 244) : QColor(66, 134, 244);

// tab
if (hasDarkBorder) {
// TabPanelBackground = getColor(hue, 0, 0.8);
// TabBackground = getColor(hue, 0, 0.8);
// TabHoverBackground = getColor(hue, 0, 0.8);
} else {
TabPanelBackground = QColor(255, 255, 255);
if (true) {
TabText = QColor(0, 0, 0);
TabBackground = QColor(255, 255, 255);

TabHoverText = QColor(0, 0, 0);
TabHoverBackground = getColor(hue, 0, 0.05);
} else {
// 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);
}

TabSelectedText = QColor(255, 255, 255);
TabSelectedBackground = getColor(hue, 0.5, 0.5);

TabHighlightedText = QColor(0, 0, 0);
TabHighlightedBackground = getColor(hue, 0.5, 0.2);

TabNewMessageBackground = QBrush(getColor(hue, 0.5, 0.2), Qt::DiagCrossPattern);
if (hasDarkBorder) {
// TabText = QColor(210, 210, 210);
// TabHoverText = QColor(210, 210, 210);
TabText = QColor(0, 0, 0);
}
TabHoverText = QColor(0, 0, 0);
TabSelectedText = QColor(255, 255, 255);
TabHighlightedText = QColor(0, 0, 0);

// Chat
ChatBackground = getColor(0, 0.1, 1);
ChatHeaderBackground = getColor(0, 0.1, 0.9);
ChatHeaderBorder = getColor(0, 0.1, 0.85);
ChatInputBackground = getColor(0, 0.1, 0.95);
ChatInputBorder = getColor(0, 0.1, 0.9);
ChatSeperator = lightTheme ? QColor(127, 127, 127) : QColor(80, 80, 80);

// Scrollbar
ScrollbarBG = ChatBackground;
ScrollbarThumb = getColor(0, 0.1, 0.85);
ScrollbarThumbSelected = getColor(0, 0.1, 0.7);
Expand All @@ -115,16 +120,17 @@ void ColorScheme::setColors(double hue, double multiplier)
void ColorScheme::normalizeColor(QColor &color)
{
if (this->lightTheme) {
// TODO: write some codes
} else {
if (color.lightnessF() < 0.5f) {
color.setHslF(color.hueF(), color.saturationF(), 0.5f);
}

if (color.lightnessF() < 0.6f && color.hueF() > 0.54444 && color.hueF() < 0.83333) {
color.setHslF(
color.hueF(), color.saturationF(),
color.lightnessF() + sin((color.hueF() - 0.54444) / (0.8333 - 0.54444) * 3.14159) *
color.saturationF() * 0.2);
color.setHslF(color.hueF(), color.saturationF(),
color.lightnessF() +
sin((color.hueF() - 0.54444) / (0.8333 - 0.54444) * 3.14159) *
color.saturationF() * 0.2);
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions src/colorscheme.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ColorScheme

QColor TooltipBackground;
QColor TooltipText;

QColor ChatSeperator;
QColor ChatBackground;
QColor ChatBackgroundHighlighted;
Expand Down Expand Up @@ -55,16 +56,19 @@ class ColorScheme
QColor ScrollbarThumbSelected;
QColor ScrollbarArrow;

QColor TabPanelBackground;
QColor TabText;
QColor TabBackground;

QColor TabHoverText;
QColor TabHoverBackground;

QColor TabSelectedText;
QColor TabSelectedBackground;

QColor TabHighlightedText;
QColor TabHighlightedBackground;

QBrush TabNewMessageBackground;
QColor TabText;
QColor TabHoverText;
QColor TabSelectedText;
QColor TabHighlightedText;

const int HighlightColorCount = 3;
QColor HighlightColors[3];
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void MainWindow::closeEvent(QCloseEvent *)
void MainWindow::refreshTheme()
{
QPalette palette;
palette.setColor(QPalette::Background, this->colorScheme.TabPanelBackground);
palette.setColor(QPalette::Background, this->colorScheme.TabBackground);
this->setPalette(palette);
}

Expand Down
2 changes: 1 addition & 1 deletion src/widgets/notebookbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void NotebookButton::paintEvent(QPaintEvent *)
QColor background;
QColor foreground;

background = this->colorScheme.TabPanelBackground;
background = this->colorScheme.TabBackground;

if (mouseDown) {
// background = this->colorScheme.TabSelectedBackground;
Expand Down
3 changes: 1 addition & 2 deletions src/widgets/notebookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,7 @@ void NotebookPage::paintEvent(QPaintEvent *)
painter.setPen(this->colorScheme.Text);
painter.drawText(rect(), "Add Chat", QTextOption(Qt::AlignCenter));
} else {
// painter.fillRect(rect(), this->colorScheme.TabSelectedBackground);
painter.fillRect(rect(), QColor(127, 127, 127));
painter.fillRect(rect(), this->colorScheme.ChatSeperator);

painter.fillRect(0, 0, width(), 2, this->colorScheme.TabSelectedBackground);
}
Expand Down

0 comments on commit ca65e54

Please sign in to comment.