Skip to content

Commit

Permalink
Replace DarkPalette with custom dark QSS
Browse files Browse the repository at this point in the history
  • Loading branch information
kraxarn committed Dec 23, 2020
1 parent 4381273 commit d35555b
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 38 deletions.
2 changes: 2 additions & 0 deletions res.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,7 @@
<file>res/logo/spotify-qt-symbolic-dark.svg</file>
<file>res/logo/spotify-qt-symbolic-light.svg</file>
<file>res/logo/spotify-qt.svg</file>
<!-- QSS -->
<file>res/style/dark.qss</file>
</qresource>
</RCC>
37 changes: 37 additions & 0 deletions res/style/dark.qss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
QWidget {
selection-background-color: #282828;
color: #f5f5f5; }

QScrollBar::handle {
background-color: #4d4d4d; }

QScrollBar::add-line, QScrollBar::sub-line {
width: 0px;
height: 0px; }

MainWindow {
background-color: #000000; }
MainWindow MainToolBar {
background-color: #282828;
border: 0; }
MainWindow MainToolBar QSlider {
selection-background-color: #1db954; }
MainWindow MainToolBar QSlider::handle {
background-color: #ffffff;
width: 12px;
height: 12px;
border-radius: 6px; }

LeftSidePanel LibraryList, LeftSidePanel PlaylistList {
color: #b3b3b3;
background-color: #000000; }
LeftSidePanel LibraryList QScrollBar, LeftSidePanel PlaylistList QScrollBar {
background-color: #000000; }

TracksList {
background-color: #121212; }
TracksList QHeaderView {
background-color: #181818;
color: #b3b3b3; }
TracksList QScrollBar {
background-color: #121212; }
88 changes: 88 additions & 0 deletions res/style/dark.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Main background color
$background-color: #121212;
// Secondary background color for borders etc.
$secondary-background-color: #282828;
// Header background color for list titles etc.
$header-background-color: #181818;

// Background for handle in scrollbars
$scrollbar-handle-color: #4d4d4d;

// Sidebar background color
$sidebar-background-color: #000000;
// Sidebar font color
$sidebar-foreground-color: #b3b3b3;

// Main font color
$foreground-color: #f5f5f5;
// Color of selected items etc.
$highlight-color: #282828;
// Main Spotify green color
$theme-color: #1db954;

// Slider background (inactive)
$slider-background-color: #535353;
// Slider foreground (active)
$slider-foreground-color: $sidebar-foreground-color;
// Slider handle
$slider-handle-color: #ffffff;

QWidget {
selection-background-color: $highlight-color;
color: $foreground-color;
}

QScrollBar {
&::handle {
background-color: $scrollbar-handle-color;
}

&::add-line, &::sub-line {
width: 0px;
height: 0px;
}
}

MainWindow {
background-color: $sidebar-background-color;

MainToolBar {
background-color: $secondary-background-color;
border: 0;

QSlider {
selection-background-color: $theme-color;

&::handle {
background-color: $slider-handle-color;
width: 12px;
height: 12px;
border-radius: 6px;
}
}
}
}

LeftSidePanel {
LibraryList, PlaylistList {
color: $sidebar-foreground-color;
background-color: $sidebar-background-color;

QScrollBar {
background-color: $sidebar-background-color;
}
}
}

TracksList {
background-color: $background-color;

QHeaderView {
background-color: $header-background-color;
color: $sidebar-foreground-color;
}

QScrollBar {
background-color: $background-color;
}
}
1 change: 0 additions & 1 deletion src/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "spotify/spotify.hpp"
#include "spotify/user.hpp"
#include "trayicon.hpp"
#include "util/darkpalette.hpp"
#include "util/dateutils.hpp"
#include "util/icon.hpp"
#include "util/utils.hpp"
Expand Down
9 changes: 9 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ MainWindow::MainWindow(Settings &settings)
QApplication::setStyle(settings.general.style);
Utils::applyPalette(settings.general.stylePalette);

// Custom dark theme
if (settings.general.stylePalette == PaletteDark)
{
QFile styleFile(":/res/style/dark.qss");
styleFile.open(QFile::ReadOnly | QFile::Text);
setStyleSheet(QString::fromUtf8(styleFile.readAll()));
styleFile.close();
}

// Check for dark background
auto bg = palette().color(backgroundRole());
if (((bg.red() + bg.green() + bg.blue()) / 3) < 128)
Expand Down
25 changes: 0 additions & 25 deletions src/util/darkpalette.cpp

This file was deleted.

9 changes: 0 additions & 9 deletions src/util/darkpalette.hpp

This file was deleted.

4 changes: 2 additions & 2 deletions src/util/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ void Utils::applyPalette(Palette palette)
break;

case PaletteDark:
p = DarkPalette();
break;
// Dark palette currently gets applied manually from qss
return;
}

QApplication::setPalette(p);
Expand Down
1 change: 0 additions & 1 deletion src/util/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "../enum/linktype.hpp"
#include "../enum/maskshape.hpp"
#include "../enum/palette.hpp"
#include "darkpalette.hpp"

#include <QAction>
#include <QApplication>
Expand Down

0 comments on commit d35555b

Please sign in to comment.