LmmsPalette - continuing... still not working yet
This commit is contained in:
84
include/LmmsPalette.h
Normal file
84
include/LmmsPalette.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* LmmsPalette.h - dummy class for fetching palette qproperties from CSS
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2007-2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
|
||||
*
|
||||
* 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 <QtGui/QWidget>
|
||||
|
||||
#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
|
||||
@@ -29,53 +29,7 @@
|
||||
|
||||
#include <QtGui/QPlastiqueStyle>
|
||||
|
||||
#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
|
||||
|
||||
@@ -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" ) );
|
||||
|
||||
71
src/gui/LmmsPalette.cpp
Normal file
71
src/gui/LmmsPalette.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* LmmsPalette.h - dummy class for fetching palette qproperties from CSS
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2007-2014 Vesa Kivimäki <contact/dot/diizy/at/nbl/dot/fi>
|
||||
*
|
||||
* 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 <QApplication>
|
||||
#include <QStyle>
|
||||
#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"
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <QWidget>
|
||||
|
||||
#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 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user