mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-30 17:20:26 +02:00
Try a different QtCurve hack that intercepts QProxyStyle::polish to
avoid infinite loop.
This commit is contained in:
@@ -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 );
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user