Skip to content

Commit

Permalink
feat: add dark style based on windows qt style (#394) [ci release]
Browse files Browse the repository at this point in the history
  • Loading branch information
variar committed Aug 29, 2021
1 parent a75ac12 commit b9ded7d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/settings/include/styles.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
struct StyleManager {

static constexpr QLatin1String DarkStyleKey = QLatin1String( "Dark", 4 );
static constexpr QLatin1String DarkWindowsStyleKey = QLatin1String( "Windows Dark", 12 );
static constexpr QLatin1String VistaKey = QLatin1String( "WindowsVista", 12 );
static constexpr QLatin1String FusionKey = QLatin1String( "Fusion", 6 );
static constexpr QLatin1String WindowsKey = QLatin1String( "Windows", 7 );
Expand Down
15 changes: 12 additions & 3 deletions src/settings/src/styles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ QStringList StyleManager::availableStyles()

styles << DarkStyleKey;

#ifndef Q_OS_MACOS
styles << DarkWindowsStyleKey;
#endif

std::sort( styles.begin(), styles.end(), []( const auto& lhs, const auto& rhs ) {
return lhs.compare( rhs, Qt::CaseInsensitive ) < 0;
} );
Expand All @@ -68,10 +72,9 @@ void StyleManager::applyStyle( const QString& style )
{
LOG_INFO << "Setting style to " << style;

if ( style == DarkStyleKey ) {
if ( style == DarkStyleKey || style == DarkWindowsStyleKey ) {

// based on https://gist.github.com/QuantumCD/6245215

QColor darkGray( 53, 53, 53 );
QColor gray( 128, 128, 128 );
QColor black( 40, 40, 40 );
Expand All @@ -98,7 +101,13 @@ void StyleManager::applyStyle( const QString& style )
darkPalette.setColor( QPalette::Disabled, QPalette::Text, gray );
darkPalette.setColor( QPalette::Disabled, QPalette::Light, darkGray );

qApp->setStyle( QStyleFactory::create( FusionKey ) );
if ( style == DarkWindowsStyleKey ) {
qApp->setStyle( QStyleFactory::create( WindowsKey ) );
}
else {
qApp->setStyle( QStyleFactory::create( FusionKey ) );
}

qApp->setPalette( darkPalette );
}
else {
Expand Down

0 comments on commit b9ded7d

Please sign in to comment.