Initial implementation of LmmsPalette (doesn't work yet)

This commit is contained in:
Vesa
2014-04-10 10:51:06 +03:00
parent b32e602af5
commit 43cb962ae1
3 changed files with 87 additions and 35 deletions

View File

@@ -30,6 +30,7 @@
#include <QtGui/QPainter>
#include <QtGui/QPixmapCache>
#include <QtGui/QStyleOption>
#include <QWidget>
#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 );
}