Use QProxyStyle support in DefaultStyle
The specializations to utilize different styles is a nice idea, but it is hard to discover which styles a user may have installed. Additionally, it would be impossible to override a system style. This patch implemnts ClassicStyle as a QProxyStyle. This additionally fixes the missing dependency on toolbar_bg. Utilize CSS now.
This commit is contained in:
@@ -128,10 +128,8 @@ nameLabel, effectLabel, sf2InstrumentView > QLabel, QComboBox {
|
||||
}
|
||||
|
||||
|
||||
QWidget#mainToolbar {
|
||||
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop: 0 #66728c, stop: 1.0 #38404e);
|
||||
}
|
||||
|
||||
QWidget#mainToolbar,
|
||||
QWidget#toolbar,
|
||||
QToolBar {
|
||||
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop: 0 #66728c, stop: 1.0 #38404e);
|
||||
}
|
||||
@@ -145,21 +143,21 @@ QToolButton, toolButton {
|
||||
color: white;
|
||||
}
|
||||
|
||||
QToolButton:hover {
|
||||
QToolButton:hover, toolButton:hover {
|
||||
background: rgba(255,255,255,96);
|
||||
border-radius: 3px;
|
||||
border: 1px solid rgba(0,0,0,255);
|
||||
color: black;
|
||||
}
|
||||
|
||||
QToolButton:pressed {
|
||||
QToolButton:pressed, toolButton:pressed {
|
||||
background: rgba(192,192,192,96);
|
||||
padding: 3px 0px 0px 3px;
|
||||
border-radius: 3px;
|
||||
border: 1px solid rgba(255,255,255,64);
|
||||
}
|
||||
|
||||
QToolButton:checked {
|
||||
QToolButton:checked, toolButton:checked {
|
||||
background: rgba(233,239,255,96);
|
||||
border-radius: 3px;
|
||||
border: 1px solid black;
|
||||
|
||||
@@ -26,16 +26,14 @@
|
||||
#ifndef _CLASSIC_STYLE_H
|
||||
#define _CLASSIC_STYLE_H
|
||||
|
||||
#include <QtGui/QStyle>
|
||||
#include <QtGui/QProxyStyle>
|
||||
|
||||
#include "lmms_style.h"
|
||||
|
||||
|
||||
template<class BaseStyle>
|
||||
class ClassicStyle : public BaseStyle, public LmmsStyle
|
||||
class ClassicStyle : public QProxyStyle, public LmmsStyle
|
||||
{
|
||||
public:
|
||||
ClassicStyle();
|
||||
ClassicStyle( QStyle *style = 0 );
|
||||
virtual ~ClassicStyle()
|
||||
{
|
||||
}
|
||||
@@ -81,6 +79,4 @@ private:
|
||||
};
|
||||
|
||||
|
||||
QPair<QStyle *, LmmsStyle *> classicStyleSpecializationForBaseStyle( QStyle * baseStyle );
|
||||
|
||||
#endif
|
||||
|
||||
@@ -411,11 +411,9 @@ int main( int argc, char * * argv )
|
||||
engine::setLmmsStyle( style );
|
||||
}
|
||||
else {
|
||||
QPair<QStyle *, LmmsStyle *> style =
|
||||
classicStyleSpecializationForBaseStyle(
|
||||
QApplication::style() );
|
||||
QApplication::setStyle( style.first );
|
||||
engine::setLmmsStyle( style.second );
|
||||
ClassicStyle * style = new ClassicStyle();
|
||||
QApplication::setStyle( style );
|
||||
engine::setLmmsStyle( style );
|
||||
}
|
||||
|
||||
// END TODO
|
||||
|
||||
@@ -133,13 +133,10 @@ automationEditor::automationEditor() :
|
||||
|
||||
|
||||
m_toolBar = new QWidget( this );
|
||||
m_toolBar->setObjectName( "toolbar" );
|
||||
m_toolBar->setFixedHeight( 32 );
|
||||
m_toolBar->move( 0, 0 );
|
||||
m_toolBar->setAutoFillBackground( true );
|
||||
QPalette pal;
|
||||
pal.setBrush( m_toolBar->backgroundRole(),
|
||||
embed::getIconPixmap( "toolbar_bg" ) );
|
||||
m_toolBar->setPalette( pal );
|
||||
|
||||
QHBoxLayout * tb_layout = new QHBoxLayout( m_toolBar );
|
||||
tb_layout->setMargin( 0 );
|
||||
|
||||
@@ -43,13 +43,10 @@ bbEditor::bbEditor( bbTrackContainer * _tc ) :
|
||||
{
|
||||
// create toolbar
|
||||
m_toolBar = new QWidget;
|
||||
m_toolBar->setObjectName( "toolbar" );
|
||||
m_toolBar->setFixedHeight( 32 );
|
||||
m_toolBar->move( 0, 0 );
|
||||
m_toolBar->setAutoFillBackground( true );
|
||||
QPalette pal;
|
||||
pal.setBrush( m_toolBar->backgroundRole(),
|
||||
embed::getIconPixmap( "toolbar_bg" ) );
|
||||
m_toolBar->setPalette( pal );
|
||||
static_cast<QVBoxLayout *>( layout() )->insertWidget( 0, m_toolBar );
|
||||
|
||||
QHBoxLayout * tb_layout = new QHBoxLayout( m_toolBar );
|
||||
|
||||
@@ -41,9 +41,8 @@
|
||||
|
||||
|
||||
|
||||
template<class BaseStyle>
|
||||
ClassicStyle<BaseStyle>::ClassicStyle() :
|
||||
BaseStyle(),
|
||||
ClassicStyle::ClassicStyle(QStyle *style) :
|
||||
QProxyStyle(style),
|
||||
LmmsStyle()
|
||||
{
|
||||
QFile file( "resources:style.css" );
|
||||
@@ -83,18 +82,16 @@ ClassicStyle<BaseStyle>::ClassicStyle() :
|
||||
|
||||
|
||||
|
||||
template<class BaseStyle>
|
||||
QColor ClassicStyle<BaseStyle>::color( LmmsStyle::ColorRole _role ) const
|
||||
QColor ClassicStyle::color( LmmsStyle::ColorRole _role ) const
|
||||
{
|
||||
return colors[_role];
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class BaseStyle>
|
||||
QPalette ClassicStyle<BaseStyle>::standardPalette() const
|
||||
QPalette ClassicStyle::standardPalette() const
|
||||
{
|
||||
QPalette pal = BaseStyle::standardPalette();
|
||||
QPalette pal = QProxyStyle::standardPalette();
|
||||
pal.setColor( QPalette::Background, QColor( 72, 76, 88 ) );
|
||||
pal.setColor( QPalette::WindowText, QColor( 240, 240, 240 ) );
|
||||
pal.setColor( QPalette::Base, QColor( 128, 128, 128 ) );
|
||||
@@ -111,8 +108,7 @@ QPalette ClassicStyle<BaseStyle>::standardPalette() const
|
||||
|
||||
|
||||
|
||||
template<class BaseStyle>
|
||||
void ClassicStyle<BaseStyle>::drawComplexControl(
|
||||
void ClassicStyle::drawComplexControl(
|
||||
QStyle::ComplexControl control,
|
||||
const QStyleOptionComplex * option,
|
||||
QPainter *painter,
|
||||
@@ -133,19 +129,17 @@ void ClassicStyle<BaseStyle>::drawComplexControl(
|
||||
QColor( 192, 192, 192 ) );
|
||||
so.palette.setColor( QPalette::Text,
|
||||
QColor( 64, 64, 64 ) );
|
||||
BaseStyle::drawComplexControl( control, &so,
|
||||
QProxyStyle::drawComplexControl( control, &so,
|
||||
painter, widget );
|
||||
return;
|
||||
}
|
||||
}
|
||||
BaseStyle::drawComplexControl( control, option, painter, widget );
|
||||
QProxyStyle::drawComplexControl( control, option, painter, widget );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template<class BaseStyle>
|
||||
void ClassicStyle<BaseStyle>::drawPrimitive(
|
||||
void ClassicStyle::drawPrimitive(
|
||||
QStyle::PrimitiveElement element,
|
||||
const QStyleOption *option,
|
||||
QPainter *painter,
|
||||
@@ -252,14 +246,14 @@ void ClassicStyle<BaseStyle>::drawPrimitive(
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseStyle::drawPrimitive( element, option, painter, widget );
|
||||
QProxyStyle::drawPrimitive( element, option, painter, widget );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
template<class BaseStyle>
|
||||
int ClassicStyle<BaseStyle>::pixelMetric(
|
||||
|
||||
int ClassicStyle::pixelMetric(
|
||||
QStyle::PixelMetric _metric,
|
||||
const QStyleOption * _option,
|
||||
const QWidget * _widget ) const
|
||||
@@ -282,14 +276,13 @@ int ClassicStyle<BaseStyle>::pixelMetric(
|
||||
return 24;
|
||||
|
||||
default:
|
||||
return BaseStyle::pixelMetric(
|
||||
return QProxyStyle::pixelMetric(
|
||||
_metric, _option, _widget );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class BaseStyle>
|
||||
void ClassicStyle<BaseStyle>::drawFxLine( QPainter * _painter, const QWidget *_fxLine,
|
||||
void ClassicStyle::drawFxLine( QPainter * _painter, const QWidget *_fxLine,
|
||||
const QString & _name, bool _active, bool _sendToThis )
|
||||
{
|
||||
int width = _fxLine->rect().width();
|
||||
@@ -320,8 +313,7 @@ void ClassicStyle<BaseStyle>::drawFxLine( QPainter * _painter, const QWidget *_f
|
||||
|
||||
|
||||
|
||||
template<class BaseStyle>
|
||||
void ClassicStyle<BaseStyle>::drawTrackContentBackground(QPainter * _painter,
|
||||
void ClassicStyle::drawTrackContentBackground(QPainter * _painter,
|
||||
const QSize & _size, const int _pixelsPerTact)
|
||||
{
|
||||
const int w = _size.width();
|
||||
@@ -362,8 +354,7 @@ void ClassicStyle<BaseStyle>::drawTrackContentBackground(QPainter * _painter,
|
||||
|
||||
|
||||
|
||||
template<class BaseStyle>
|
||||
void ClassicStyle<BaseStyle>::drawTrackContentObject( QPainter * _painter,
|
||||
void ClassicStyle::drawTrackContentObject( QPainter * _painter,
|
||||
const trackContentObject * _model, const LmmsStyleOptionTCO * _option )
|
||||
{
|
||||
QRectF rc = _option->rect.adjusted( 0, 2, 0, -2 );
|
||||
@@ -626,47 +617,3 @@ void ClassicStyle<BaseStyle>::drawTrackContentObject( QPainter * _painter,
|
||||
_painter->setRenderHint( QPainter::Antialiasing, true );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include <QtGui/QPlastiqueStyle>
|
||||
#ifdef LMMS_BUILD_LINUX
|
||||
#include <QtGui/QCleanlooksStyle>
|
||||
#include <QtGui/QGtkStyle>
|
||||
#endif
|
||||
#ifdef LMMS_BUILD_APPLE
|
||||
#include <QtGui/QMacStyle>
|
||||
#endif
|
||||
#ifdef LMMS_BUILD_WIN32
|
||||
#include <QtGui/QWindowsXPStyle>
|
||||
#include <QtGui/QWindowsVistaStyle>
|
||||
#endif
|
||||
|
||||
|
||||
QPair<QStyle *, LmmsStyle *> classicStyleSpecializationForBaseStyle( QStyle * baseStyle )
|
||||
{
|
||||
#define CHECK_AND_INSTANTIATE_STYLE(s) \
|
||||
if( qobject_cast<s *>( baseStyle ) ) \
|
||||
{ \
|
||||
ClassicStyle<s> * style = new ClassicStyle<s>; \
|
||||
return qMakePair<QStyle *, LmmsStyle *>( style, style );\
|
||||
}
|
||||
|
||||
#ifdef LMMS_BUILD_LINUX
|
||||
CHECK_AND_INSTANTIATE_STYLE(QCleanlooksStyle);
|
||||
CHECK_AND_INSTANTIATE_STYLE(QGtkStyle);
|
||||
#endif
|
||||
#ifdef LMMS_BUILD_APPLE
|
||||
CHECK_AND_INSTANTIATE_STYLE(QMacStyle);
|
||||
#endif
|
||||
#ifdef LMMS_BUILD_WIN32
|
||||
CHECK_AND_INSTANTIATE_STYLE(QWindowsXPStyle);
|
||||
CHECK_AND_INSTANTIATE_STYLE(QWindowsVistaStyle);
|
||||
#endif
|
||||
|
||||
typedef QPlastiqueStyle DefaultBaseStyle;
|
||||
ClassicStyle<DefaultBaseStyle> * style = new ClassicStyle<DefaultBaseStyle>;
|
||||
return qMakePair<QStyle *, LmmsStyle *>( style, style );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -254,13 +254,10 @@ pianoRoll::pianoRoll() :
|
||||
|
||||
|
||||
m_toolBar = new QWidget( this );
|
||||
m_toolBar->setObjectName( "toolbar" );
|
||||
m_toolBar->setFixedHeight( 32 );
|
||||
m_toolBar->move( 0, 0 );
|
||||
m_toolBar->setAutoFillBackground( true );
|
||||
QPalette pal;
|
||||
pal.setBrush( m_toolBar->backgroundRole(),
|
||||
embed::getIconPixmap( "toolbar_bg" ) );
|
||||
m_toolBar->setPalette( pal );
|
||||
|
||||
QHBoxLayout * tb_layout = new QHBoxLayout( m_toolBar );
|
||||
tb_layout->setMargin( 0 );
|
||||
|
||||
@@ -98,12 +98,9 @@ songEditor::songEditor( song * _song, songEditor * & _engine_ptr ) :
|
||||
|
||||
// create own toolbar
|
||||
m_toolBar = new QWidget( this );
|
||||
m_toolBar->setObjectName( "toolbar" );
|
||||
m_toolBar->setFixedHeight( 32 );
|
||||
m_toolBar->setAutoFillBackground( true );
|
||||
QPalette pal;
|
||||
pal.setBrush( m_toolBar->backgroundRole(),
|
||||
embed::getIconPixmap( "toolbar_bg" ) );
|
||||
m_toolBar->setPalette( pal );
|
||||
|
||||
static_cast<QVBoxLayout *>( layout() )->insertWidget( 0, m_toolBar );
|
||||
static_cast<QVBoxLayout *>( layout() )->insertWidget( 1, m_timeLine );
|
||||
|
||||
Reference in New Issue
Block a user