1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 06:07:37 +02:00

* Try a generic margin & spacing fix-helper. Applied on AudioControls only so far.

This commit is contained in:
Christian Muehlhaeuser
2014-09-08 16:54:39 +02:00
parent 336bccaf40
commit b12d0fde3d
3 changed files with 41 additions and 0 deletions

View File

@@ -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<QWidget*>(c);
if ( w )
{
fixMargins( w );
}
}
}
QWidget*
tomahawkWindow()
{

View File

@@ -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();

View File

@@ -176,6 +176,8 @@ AudioControls::AudioControls( QWidget* parent )
SLOT( onInfoSystemPushTypesUpdated( Tomahawk::InfoSystem::InfoTypeSet ) ) );
onInfoSystemPushTypesUpdated( InfoSystem::InfoSystem::instance()->supportedPushTypes() );
TomahawkUtils::fixMargins( this );
onPlaybackStopped(); // initial state
}