From 43cb962ae157f1eac2275fa8bcdb73a4321c7eea Mon Sep 17 00:00:00 2001 From: Vesa Date: Thu, 10 Apr 2014 10:51:06 +0300 Subject: [PATCH 1/4] Initial implementation of LmmsPalette (doesn't work yet) --- data/themes/default/style.css | 26 ++++++++--------- include/LmmsStyle.h | 55 ++++++++++++++++++++++++++++++++--- src/gui/LmmsStyle.cpp | 41 ++++++++++++++------------ 3 files changed, 87 insertions(+), 35 deletions(-) diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 572139dfc..6f7e07d7d 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -677,17 +677,17 @@ MonstroView knob { qproperty-lineWidth: 2.5; } -/* palette information - each colour definition must be on a single line, and the line must begin with "palette:", with no leading whitespace - * colour codes MUST be of the form #RRGGBB */ - -palette:background {color: #5b6571} -palette:windowtext {color: #f0f0f0} -palette:base {color: #808080} -palette:text {color: #e0e0e0} -palette:button {color: #c9c9c9} -palette:shadow {color: #000000} -palette:buttontext {color: #000000} -palette:brighttext {color: #4afd85} -palette:highlight {color: #202020} -palette:highlightedtext {color: #ffffff} +/* palette information */ +LmmsPalette { + qproperty-background: #5b6571; + qproperty-windowText: #f0f0f0; + qproperty-base: #808080; + qproperty-text: #e0e0e0; + qproperty-button: #c9c9c9; + qproperty-shadow: #000; + qproperty-buttonText: #000; + qproperty-brightText: #4afd85; + qproperty-highlight: #202020; + qproperty-highlightedText: #ffffff; +} diff --git a/include/LmmsStyle.h b/include/LmmsStyle.h index 7b74a06f7..75c1b8612 100644 --- a/include/LmmsStyle.h +++ b/include/LmmsStyle.h @@ -3,7 +3,7 @@ * interface * * Copyright (c) 2007-2014 Tobias Doerffel - * + * * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net * * This program is free software; you can redistribute it and/or @@ -24,11 +24,58 @@ */ -#ifndef _LMMS_STYLE_H -#define _LMMS_STYLE_H +#ifndef LMMS_STYLE_H +#define LMMS_STYLE_H #include +#define ACCESSMET( read, write ) \ + QColor read () \ + { return m_##read ; } \ + void write ( const QColor & _c ) \ + { m_##read = QColor( _c ); } + +class LmmsPalette: public QWidget +{ + Q_OBJECT + Q_PROPERTY( QColor background READ background WRITE setBackground ) + Q_PROPERTY( QColor windowText READ windowText WRITE setWindowText ) + Q_PROPERTY( QColor base READ base WRITE setBase ) + Q_PROPERTY( QColor text READ text WRITE setText ) + Q_PROPERTY( QColor button READ button WRITE setButton ) + Q_PROPERTY( QColor shadow READ shadow WRITE setShadow ) + Q_PROPERTY( QColor buttonText READ buttonText WRITE setButtonText ) + Q_PROPERTY( QColor brightText READ brightText WRITE setBrightText ) + Q_PROPERTY( QColor highlight READ highlight WRITE setHighlight ) + Q_PROPERTY( QColor highlightedText READ highlightedText WRITE setHighlightedText ) + +public: + LmmsPalette( QWidget * _parent ); + virtual ~LmmsPalette() {}; + + 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 ) + +private: + QColor m_background; + QColor m_windowText; + QColor m_base; + QColor m_text; + QColor m_button; + QColor m_shadow; + QColor m_buttonText; + QColor m_brightText; + QColor m_highlight; + QColor m_highlightedText; +}; class LmmsStyle : public QPlastiqueStyle { @@ -81,7 +128,7 @@ public: const QWidget *widget = 0 ) const; virtual int pixelMetric( PixelMetric metric, - const QStyleOption * option = 0, + const QStyleOption * option = 0, const QWidget * widget = 0 ) const; // QSize sizeFromContents( ContentsType type, const QStyleOption* option, const QSize& size, const QWidget* widget ) const; diff --git a/src/gui/LmmsStyle.cpp b/src/gui/LmmsStyle.cpp index cc57470d6..58c5aafee 100644 --- a/src/gui/LmmsStyle.cpp +++ b/src/gui/LmmsStyle.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include "LmmsStyle.h" @@ -195,6 +196,14 @@ void drawPath( QPainter *p, const QPainterPath &path, } + +LmmsPalette::LmmsPalette( QWidget * _parent ) : QWidget( _parent ) +{ + setStyle( QApplication::style() ); +} + + + LmmsStyle::LmmsStyle() : QPlastiqueStyle() { @@ -210,11 +219,11 @@ LmmsStyle::LmmsStyle() : QPalette LmmsStyle::standardPalette( void ) const { - + LmmsPalette * lmmspal = new LmmsPalette( NULL ); 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 ) ); @@ -225,23 +234,19 @@ QPalette LmmsStyle::standardPalette( void ) const pal.setColor( QPalette::BrightText, QColor( 74, 253, 133 ) ); pal.setColor( QPalette::Highlight, QColor( 100, 100, 100 ) ); pal.setColor( QPalette::HighlightedText, QColor( 255, 255, 255 ) ); +*/ +/* fetch from stylesheet using LmmsPalette */ -/* fetch from stylesheet using regexp */ - - QStringList paletteData = qApp->styleSheet().split( '\n' ).filter( QRegExp( "^palette:*" ) ); - foreach( QString s, paletteData ) - { - if (s.contains(":background")) { pal.setColor( QPalette::Background, QColor( s.mid( s.indexOf("#"), 7 ) ) ); } - else if (s.contains(":windowtext")) { pal.setColor( QPalette::WindowText, QColor( s.mid( s.indexOf("#"), 7 ) ) ); } - else if (s.contains(":base")) { pal.setColor( QPalette::Base, QColor( s.mid( s.indexOf("#"), 7 ) ) ); } - else if (s.contains(":buttontext")) { pal.setColor( QPalette::ButtonText, QColor( s.mid( s.indexOf("#"), 7 ) ) ); } - else if (s.contains(":brighttext")) { pal.setColor( QPalette::BrightText, QColor( s.mid( s.indexOf("#"), 7 ) ) ); } - else if (s.contains(":text")) { pal.setColor( QPalette::Text, QColor( s.mid( s.indexOf("#"), 7 ) ) ); } - else if (s.contains(":button")) { pal.setColor( QPalette::Button, QColor( s.mid( s.indexOf("#"), 7 ) ) ); } - else if (s.contains(":shadow")) { pal.setColor( QPalette::Shadow, QColor( s.mid( s.indexOf("#"), 7 ) ) ); } - else if (s.contains(":highlightedtext")) { pal.setColor( QPalette::HighlightedText, QColor( s.mid( s.indexOf("#"), 7 ) ) ); } - else if (s.contains(":highlight")) { pal.setColor( QPalette::Highlight, QColor( s.mid( s.indexOf("#"), 7 ) ) ); }; - } + pal.setColor( QPalette::Background, lmmspal->background() ); + pal.setColor( QPalette::WindowText, lmmspal->windowText() ); + pal.setColor( QPalette::Base, lmmspal->base() ); + pal.setColor( QPalette::ButtonText, lmmspal->buttonText() ); + pal.setColor( QPalette::BrightText, lmmspal->brightText() ); + pal.setColor( QPalette::Text, lmmspal->text() ); + pal.setColor( QPalette::Button, lmmspal->button() ); + pal.setColor( QPalette::Shadow, lmmspal->shadow() ); + pal.setColor( QPalette::Highlight, lmmspal->highlight() ); + pal.setColor( QPalette::HighlightedText, lmmspal->highlightedText() ); return( pal ); } From ec69c48e5f7873449a03ef497d244e10a7450193 Mon Sep 17 00:00:00 2001 From: Vesa Date: Fri, 11 Apr 2014 07:14:37 +0300 Subject: [PATCH 2/4] LmmsPalette - continuing... still not working yet --- include/LmmsPalette.h | 84 +++++++++++++++++++++++++++++++++++++++++ include/LmmsStyle.h | 50 ++---------------------- src/core/main.cpp | 7 ++++ src/gui/LmmsPalette.cpp | 71 ++++++++++++++++++++++++++++++++++ src/gui/LmmsStyle.cpp | 27 +++---------- 5 files changed, 170 insertions(+), 69 deletions(-) create mode 100644 include/LmmsPalette.h create mode 100644 src/gui/LmmsPalette.cpp diff --git a/include/LmmsPalette.h b/include/LmmsPalette.h new file mode 100644 index 000000000..0e38750d7 --- /dev/null +++ b/include/LmmsPalette.h @@ -0,0 +1,84 @@ +/* + * LmmsPalette.h - dummy class for fetching palette qproperties from CSS + * + * + * Copyright (c) 2007-2014 Vesa Kivimäki + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#include + +#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 +{ + Q_OBJECT + Q_PROPERTY( QColor background READ background WRITE setBackground ) + Q_PROPERTY( QColor windowText READ windowText WRITE setWindowText ) + Q_PROPERTY( QColor base READ base WRITE setBase ) + Q_PROPERTY( QColor text READ text WRITE setText ) + Q_PROPERTY( QColor button READ button WRITE setButton ) + Q_PROPERTY( QColor shadow READ shadow WRITE setShadow ) + Q_PROPERTY( QColor buttonText READ buttonText WRITE setButtonText ) + Q_PROPERTY( QColor brightText READ brightText WRITE setBrightText ) + Q_PROPERTY( QColor highlight READ highlight WRITE setHighlight ) + Q_PROPERTY( QColor highlightedText READ highlightedText WRITE setHighlightedText ) + +public: + LmmsPalette( QWidget * parent ); + virtual ~LmmsPalette(); + + 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 palette() const; + +private: + QColor m_background; + QColor m_windowText; + QColor m_base; + QColor m_text; + QColor m_button; + QColor m_shadow; + QColor m_buttonText; + QColor m_brightText; + QColor m_highlight; + QColor m_highlightedText; +}; + + + + +#endif diff --git a/include/LmmsStyle.h b/include/LmmsStyle.h index 75c1b8612..539c9041b 100644 --- a/include/LmmsStyle.h +++ b/include/LmmsStyle.h @@ -29,53 +29,7 @@ #include -#define ACCESSMET( read, write ) \ - QColor read () \ - { return m_##read ; } \ - void write ( const QColor & _c ) \ - { m_##read = QColor( _c ); } -class LmmsPalette: public QWidget -{ - Q_OBJECT - Q_PROPERTY( QColor background READ background WRITE setBackground ) - Q_PROPERTY( QColor windowText READ windowText WRITE setWindowText ) - Q_PROPERTY( QColor base READ base WRITE setBase ) - Q_PROPERTY( QColor text READ text WRITE setText ) - Q_PROPERTY( QColor button READ button WRITE setButton ) - Q_PROPERTY( QColor shadow READ shadow WRITE setShadow ) - Q_PROPERTY( QColor buttonText READ buttonText WRITE setButtonText ) - Q_PROPERTY( QColor brightText READ brightText WRITE setBrightText ) - Q_PROPERTY( QColor highlight READ highlight WRITE setHighlight ) - Q_PROPERTY( QColor highlightedText READ highlightedText WRITE setHighlightedText ) - -public: - LmmsPalette( QWidget * _parent ); - virtual ~LmmsPalette() {}; - - 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 ) - -private: - QColor m_background; - QColor m_windowText; - QColor m_base; - QColor m_text; - QColor m_button; - QColor m_shadow; - QColor m_buttonText; - QColor m_brightText; - QColor m_highlight; - QColor m_highlightedText; -}; class LmmsStyle : public QPlastiqueStyle { @@ -134,11 +88,13 @@ public: // QSize sizeFromContents( ContentsType type, const QStyleOption* option, const QSize& size, const QWidget* widget ) const; // QRect subControlRect( ComplexControl control, const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget ) const; + static QPalette * s_palette; + private: QImage colorizeXpm( const char * const * xpm, const QBrush& fill ) const; void hoverColors( bool sunken, bool hover, bool active, QColor& color, QColor& blend ) const; QColor m_colors[ LmmsStyle::NumColorRoles ]; -} ; +}; #endif diff --git a/src/core/main.cpp b/src/core/main.cpp index fbf7f9507..16161ef05 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -65,6 +65,7 @@ #include "ProjectRenderer.h" #include "DataFile.h" #include "song.h" +#include "LmmsPalette.h" static inline QString baseName( const QString & _file ) { @@ -390,6 +391,12 @@ int main( int argc, char * * argv ) { // init style and palette QApplication::setStyle( new LmmsStyle() ); + + LmmsPalette * lmmspal = new LmmsPalette( NULL ); + QPalette lpal = lmmspal->palette(); + QApplication::setPalette( lpal ); + LmmsStyle::s_palette = &lpal; + // show splash screen QSplashScreen splashScreen( embed::getIconPixmap( "splash" ) ); diff --git a/src/gui/LmmsPalette.cpp b/src/gui/LmmsPalette.cpp new file mode 100644 index 000000000..c18f4d99c --- /dev/null +++ b/src/gui/LmmsPalette.cpp @@ -0,0 +1,71 @@ +/* + * LmmsPalette.h - dummy class for fetching palette qproperties from CSS + * + * + * Copyright (c) 2007-2014 Vesa Kivimäki + * + * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program (see COPYING); if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#include +#include +#include "LmmsPalette.h" +#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 ), + 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 ) +{ + setStyle( QApplication::style() ); +} + +LmmsPalette::~LmmsPalette() +{ +} + + +QPalette LmmsPalette::palette() const +{ + QPalette pal = style()->standardPalette(); + + pal.setColor( QPalette::Background, background() ); + pal.setColor( QPalette::WindowText, windowText() ); + pal.setColor( QPalette::Base, base() ); + pal.setColor( QPalette::ButtonText, buttonText() ); + pal.setColor( QPalette::BrightText, brightText() ); + pal.setColor( QPalette::Text, text() ); + pal.setColor( QPalette::Button, button() ); + pal.setColor( QPalette::Shadow, shadow() ); + pal.setColor( QPalette::Highlight, highlight() ); + pal.setColor( QPalette::HighlightedText, highlightedText() ); + + return pal; +} + + +#include "moc_LmmsPalette.cxx" diff --git a/src/gui/LmmsStyle.cpp b/src/gui/LmmsStyle.cpp index 58c5aafee..1e2f557b9 100644 --- a/src/gui/LmmsStyle.cpp +++ b/src/gui/LmmsStyle.cpp @@ -33,7 +33,7 @@ #include #include "LmmsStyle.h" - +#include "LmmsPalette.h" const int BUTTON_LENGTH = 24; @@ -107,7 +107,7 @@ static const char * const s_scrollbarArrowLeftXpm[] = { "..#$$%", "...+@@"}; - +QPalette * LmmsStyle::s_palette = NULL; QLinearGradient getGradient( const QColor & _col, const QRectF & _rect ) { @@ -197,13 +197,6 @@ void drawPath( QPainter *p, const QPainterPath &path, -LmmsPalette::LmmsPalette( QWidget * _parent ) : QWidget( _parent ) -{ - setStyle( QApplication::style() ); -} - - - LmmsStyle::LmmsStyle() : QPlastiqueStyle() { @@ -219,9 +212,11 @@ LmmsStyle::LmmsStyle() : QPalette LmmsStyle::standardPalette( void ) const { - LmmsPalette * lmmspal = new LmmsPalette( NULL ); + 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 ) ); @@ -235,18 +230,6 @@ QPalette LmmsStyle::standardPalette( void ) const pal.setColor( QPalette::Highlight, QColor( 100, 100, 100 ) ); pal.setColor( QPalette::HighlightedText, QColor( 255, 255, 255 ) ); */ -/* fetch from stylesheet using LmmsPalette */ - - pal.setColor( QPalette::Background, lmmspal->background() ); - pal.setColor( QPalette::WindowText, lmmspal->windowText() ); - pal.setColor( QPalette::Base, lmmspal->base() ); - pal.setColor( QPalette::ButtonText, lmmspal->buttonText() ); - pal.setColor( QPalette::BrightText, lmmspal->brightText() ); - pal.setColor( QPalette::Text, lmmspal->text() ); - pal.setColor( QPalette::Button, lmmspal->button() ); - pal.setColor( QPalette::Shadow, lmmspal->shadow() ); - pal.setColor( QPalette::Highlight, lmmspal->highlight() ); - pal.setColor( QPalette::HighlightedText, lmmspal->highlightedText() ); return( pal ); } From 43d503003eff5c2ec699b63f6818c4125bc8991f Mon Sep 17 00:00:00 2001 From: Vesa Date: Fri, 11 Apr 2014 11:07:49 +0300 Subject: [PATCH 3/4] LmmsPalette: finally a working implementation --- data/themes/default/style.css | 1 + include/LmmsPalette.h | 17 +++++++------ src/core/main.cpp | 8 ++++-- src/gui/LmmsPalette.cpp | 46 ++++++++++++++++++++++++++--------- src/gui/LmmsStyle.cpp | 20 +++------------ 5 files changed, 55 insertions(+), 37 deletions(-) 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 ); } From 4b9f8c070f3860d338c7df1408c59fc1d2c47569 Mon Sep 17 00:00:00 2001 From: Vesa Date: Fri, 11 Apr 2014 11:20:04 +0300 Subject: [PATCH 4/4] Forgot some cleanup --- src/gui/LmmsPalette.cpp | 2 +- src/gui/LmmsStyle.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gui/LmmsPalette.cpp b/src/gui/LmmsPalette.cpp index c2238d0a4..28e33bc0e 100644 --- a/src/gui/LmmsPalette.cpp +++ b/src/gui/LmmsPalette.cpp @@ -1,5 +1,5 @@ /* - * LmmsPalette.h - dummy class for fetching palette qproperties from CSS + * LmmsPalette.cpp - dummy class for fetching palette qproperties from CSS * * * Copyright (c) 2007-2014 Vesa Kivimäki diff --git a/src/gui/LmmsStyle.cpp b/src/gui/LmmsStyle.cpp index 600e290be..6041b389a 100644 --- a/src/gui/LmmsStyle.cpp +++ b/src/gui/LmmsStyle.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include "LmmsStyle.h" #include "LmmsPalette.h" @@ -204,7 +203,6 @@ LmmsStyle::LmmsStyle() : file.open( QIODevice::ReadOnly ); qApp->setStyleSheet( file.readAll() ); - //qApp->setPalette( standardPalette() ); if( s_palette != NULL ) { qApp->setPalette( *s_palette ); } }