diff --git a/src/libtomahawk/utils/TomahawkUtilsGui.cpp b/src/libtomahawk/utils/TomahawkUtilsGui.cpp index f2f08a458..b57197c95 100644 --- a/src/libtomahawk/utils/TomahawkUtilsGui.cpp +++ b/src/libtomahawk/utils/TomahawkUtilsGui.cpp @@ -22,6 +22,7 @@ #include "playlist/PlayableItem.h" #include "config.h" +#include "DpiScaler.h" #include "Query.h" #include "Result.h" #include "Source.h" @@ -230,6 +231,42 @@ unmarginLayout( QLayout* layout ) } +void +fixLayoutMargins( QLayout* layout, QWidget* parent ) +{ + DpiScaler scaler( parent ); + layout->setContentsMargins( scaler.scaled( layout->contentsMargins() ) ); + layout->setMargin( scaler.scaledX( layout->margin() ) ); + layout->setSpacing( scaler.scaledX( layout->spacing() ) ); + + for ( int i = 0; i < layout->count(); i++ ) + { + QLayout* childLayout = layout->itemAt( i )->layout(); + if ( childLayout ) + fixLayoutMargins( childLayout, parent ); + } +} + + +void +fixMargins( QWidget* widget ) +{ + if ( widget->layout() ) + { + fixLayoutMargins( widget->layout(), widget ); + } + + foreach ( QObject* c, widget->children() ) + { + QWidget* w = qobject_cast(c); + if ( w ) + { + fixMargins( w ); + } + } +} + + QWidget* tomahawkWindow() { diff --git a/src/libtomahawk/utils/TomahawkUtilsGui.h b/src/libtomahawk/utils/TomahawkUtilsGui.h index c9232d073..36a925fad 100644 --- a/src/libtomahawk/utils/TomahawkUtilsGui.h +++ b/src/libtomahawk/utils/TomahawkUtilsGui.h @@ -59,6 +59,8 @@ namespace TomahawkUtils DLLEXPORT void drawBackgroundAndNumbers( QPainter* p, const QString& text, const QRect& rect ); DLLEXPORT void unmarginLayout( QLayout* layout ); + DLLEXPORT void fixLayoutMargins( QLayout* layout ); + DLLEXPORT void fixMargins( QWidget* widget ); DLLEXPORT void setDefaultFontSize( int points ); DLLEXPORT int defaultFontSize(); diff --git a/src/tomahawk/AudioControls.cpp b/src/tomahawk/AudioControls.cpp index 2ee6b8865..80ea101b5 100644 --- a/src/tomahawk/AudioControls.cpp +++ b/src/tomahawk/AudioControls.cpp @@ -176,6 +176,8 @@ AudioControls::AudioControls( QWidget* parent ) SLOT( onInfoSystemPushTypesUpdated( Tomahawk::InfoSystem::InfoTypeSet ) ) ); onInfoSystemPushTypesUpdated( InfoSystem::InfoSystem::instance()->supportedPushTypes() ); + TomahawkUtils::fixMargins( this ); + onPlaybackStopped(); // initial state }