diff --git a/src/TomahawkWindow.cpp b/src/TomahawkWindow.cpp index 130a8b8f0..456928094 100644 --- a/src/TomahawkWindow.cpp +++ b/src/TomahawkWindow.cpp @@ -213,7 +213,19 @@ TomahawkWindow::saveSettings() void TomahawkWindow::applyPlatformTweaks() { - qApp->setStyle( new ProxyStyle() ); + // HACK: QtCurve causes an infinite loop on startup. This is because + // setStyle calls setPalette, which calls ensureBaseStyle, which loads + // QtCurve. QtCurve calls setPalette, which creates an infinite loop. + // We could simply not use ProxyStyle under QtCurve, but that would + // make the whole UI look like crap. + // Instead, we tell ProxyStyle that it's running under QtCurve, so it + // can intercept QStyle::polish (which in the base implementation does + // nothing and in QtCurve does evil things), and avoid forwarding it + // to QtCurve. + bool isQtCurve = false; + if( QString( qApp->style()->metaObject()->className() ).toLower().contains( "qtcurve" ) ) + isQtCurve = true; + qApp->setStyle( new ProxyStyle( isQtCurve ) ); #ifdef Q_OS_MAC setUnifiedTitleAndToolBarOnMac( true ); diff --git a/src/libtomahawk/utils/ProxyStyle.cpp b/src/libtomahawk/utils/ProxyStyle.cpp index fe57817c8..9955b4bdf 100644 --- a/src/libtomahawk/utils/ProxyStyle.cpp +++ b/src/libtomahawk/utils/ProxyStyle.cpp @@ -30,6 +30,18 @@ #define ARROW_HEIGHT 7 +ProxyStyle::ProxyStyle( bool isQtCurve ) + : m_isQtCurve( isQtCurve ) +{ +} + +void +ProxyStyle::polish( QPalette& pal ) +{ + if( !m_isQtCurve ) + QProxyStyle::polish( pal ); +} + void ProxyStyle::drawPrimitive( PrimitiveElement pe, const QStyleOption* opt, QPainter* p, const QWidget* w ) const { diff --git a/src/libtomahawk/utils/ProxyStyle.h b/src/libtomahawk/utils/ProxyStyle.h index aa1dec625..7c4edca4e 100644 --- a/src/libtomahawk/utils/ProxyStyle.h +++ b/src/libtomahawk/utils/ProxyStyle.h @@ -27,11 +27,18 @@ class DLLEXPORT ProxyStyle : public QProxyStyle { public: - ProxyStyle() {} + ProxyStyle( bool isQtCurve = false ); + + virtual void polish( QApplication *a ) { QProxyStyle::polish( a ); } + virtual void polish( QPalette& pal ); + virtual void polish( QWidget *w ) { QProxyStyle::polish( w ); } virtual void drawPrimitive( PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w = 0 ) const; virtual void drawControl( ControlElement ce, const QStyleOption *opt, QPainter *p, const QWidget *w = 0 ) const; virtual QSize sizeFromContents( ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget ) const; + +private: + bool m_isQtCurve; }; #endif // PROXYSTYLE_H