diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 6f7e07d7d..778e4686a 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -691,3 +691,4 @@ LmmsPalette { qproperty-highlight: #202020; qproperty-highlightedText: #ffffff; } + diff --git a/include/LmmsPalette.h b/include/LmmsPalette.h index 0e38750d7..4ce41d514 100644 --- a/include/LmmsPalette.h +++ b/include/LmmsPalette.h @@ -24,17 +24,13 @@ */ #include +#include "export.h" #ifndef LMMSPALETTE_H #define LMMSPALETTE_H -#define ACCESSMET( read, write ) \ - QColor read () const \ - { return m_##read ; } \ - void write ( const QColor & c ) \ - { m_##read = QColor( c ); } -class LmmsPalette : public QWidget +class EXPORT LmmsPalette : public QWidget { Q_OBJECT Q_PROPERTY( QColor background READ background WRITE setBackground ) @@ -49,9 +45,14 @@ class LmmsPalette : public QWidget Q_PROPERTY( QColor highlightedText READ highlightedText WRITE setHighlightedText ) public: - LmmsPalette( QWidget * parent ); + LmmsPalette( QWidget * parent, QStyle * stylearg ); virtual ~LmmsPalette(); +#define ACCESSMET( read, write ) \ + QColor read () const; \ + void write ( const QColor & c ); \ + + ACCESSMET( background, setBackground ) ACCESSMET( windowText, setWindowText ) ACCESSMET( base, setBase ) @@ -63,6 +64,8 @@ public: ACCESSMET( highlight, setHighlight ) ACCESSMET( highlightedText, setHighlightedText ) +#undef ACCESSMET + QPalette palette() const; private: diff --git a/src/core/main.cpp b/src/core/main.cpp index 16161ef05..e3416cbd3 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -390,10 +390,14 @@ int main( int argc, char * * argv ) if( render_out.isEmpty() ) { // init style and palette - QApplication::setStyle( new LmmsStyle() ); + LmmsStyle * lmmsstyle = new LmmsStyle(); + QApplication::setStyle( lmmsstyle ); - LmmsPalette * lmmspal = new LmmsPalette( NULL ); + LmmsPalette * lmmspal = new LmmsPalette( NULL, lmmsstyle ); + lmmspal->show(); // necessary to get properties + lmmspal->hide(); QPalette lpal = lmmspal->palette(); + QApplication::setPalette( lpal ); LmmsStyle::s_palette = &lpal; diff --git a/src/gui/LmmsPalette.cpp b/src/gui/LmmsPalette.cpp index c18f4d99c..c2238d0a4 100644 --- a/src/gui/LmmsPalette.cpp +++ b/src/gui/LmmsPalette.cpp @@ -29,29 +29,53 @@ #include "LmmsStyle.h" -LmmsPalette::LmmsPalette( QWidget * parent ) : QWidget( parent ), - m_background( 0,0,0 ), - m_windowText( 0,0,0 ), - m_base( 0,0,0 ), - m_text( 0,0,0 ), - m_button( 0,0,0 ), +LmmsPalette::LmmsPalette( QWidget * parent, QStyle * stylearg ) : + QWidget( parent ), + +/* sane defaults in case fetching from stylesheet fails*/ + + m_background( 91, 101, 113 ), + m_windowText( 240, 240, 240 ), + m_base( 128, 128, 128 ), + m_text( 224, 224, 224 ), + m_button( 201, 201, 201 ), m_shadow( 0,0,0 ), m_buttonText( 0,0,0 ), - m_brightText( 0,0,0 ), - m_highlight( 0,0,0 ), - m_highlightedText( 0,0,0 ) + m_brightText( 74, 253, 133 ), + m_highlight( 100, 100, 100 ), + m_highlightedText( 255, 255, 255 ) { - setStyle( QApplication::style() ); + setStyle( stylearg ); + stylearg->polish( this ); } LmmsPalette::~LmmsPalette() { } +#define ACCESSMET( read, write ) \ + QColor LmmsPalette:: read () const \ + { return m_##read ; } \ + void LmmsPalette:: write ( const QColor & c ) \ + { m_##read = QColor( c ); } + + + ACCESSMET( background, setBackground ) + ACCESSMET( windowText, setWindowText ) + ACCESSMET( base, setBase ) + ACCESSMET( text, setText ) + ACCESSMET( button, setButton ) + ACCESSMET( shadow, setShadow ) + ACCESSMET( buttonText, setButtonText ) + ACCESSMET( brightText, setBrightText ) + ACCESSMET( highlight, setHighlight ) + ACCESSMET( highlightedText, setHighlightedText ) + + QPalette LmmsPalette::palette() const { - QPalette pal = style()->standardPalette(); + QPalette pal = QApplication::style()->standardPalette(); pal.setColor( QPalette::Background, background() ); pal.setColor( QPalette::WindowText, windowText() ); diff --git a/src/gui/LmmsStyle.cpp b/src/gui/LmmsStyle.cpp index 1e2f557b9..600e290be 100644 --- a/src/gui/LmmsStyle.cpp +++ b/src/gui/LmmsStyle.cpp @@ -204,7 +204,8 @@ LmmsStyle::LmmsStyle() : file.open( QIODevice::ReadOnly ); qApp->setStyleSheet( file.readAll() ); - qApp->setPalette( standardPalette() ); + //qApp->setPalette( standardPalette() ); + if( s_palette != NULL ) { qApp->setPalette( *s_palette ); } } @@ -212,25 +213,10 @@ LmmsStyle::LmmsStyle() : QPalette LmmsStyle::standardPalette( void ) const { - if( s_palette != NULL) return * s_palette; + if( s_palette != NULL) { return * s_palette; } QPalette pal = QPlastiqueStyle::standardPalette(); - -/* sane defaults in case fetching from stylesheet fails*/ -/* - pal.setColor( QPalette::Background, QColor( 91, 101, 113 ) ); - pal.setColor( QPalette::WindowText, QColor( 240, 240, 240 ) ); - pal.setColor( QPalette::Base, QColor( 128, 128, 128 ) ); - pal.setColor( QPalette::Text, QColor( 224, 224, 224 ) ); - pal.setColor( QPalette::Button, QColor( 201, 201, 201 ) ); - pal.setColor( QPalette::Shadow, QColor( 0, 0, 0 ) ); - pal.setColor( QPalette::ButtonText, QColor( 0, 0, 0 ) ); - pal.setColor( QPalette::BrightText, QColor( 74, 253, 133 ) ); - pal.setColor( QPalette::Highlight, QColor( 100, 100, 100 ) ); - pal.setColor( QPalette::HighlightedText, QColor( 255, 255, 255 ) ); -*/ - return( pal ); }