mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 22:56:42 +02:00
* Try a generic margin & spacing fix-helper. Applied on AudioControls only so far.
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "playlist/PlayableItem.h"
|
#include "playlist/PlayableItem.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "DpiScaler.h"
|
||||||
#include "Query.h"
|
#include "Query.h"
|
||||||
#include "Result.h"
|
#include "Result.h"
|
||||||
#include "Source.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*
|
QWidget*
|
||||||
tomahawkWindow()
|
tomahawkWindow()
|
||||||
{
|
{
|
||||||
|
@@ -59,6 +59,8 @@ namespace TomahawkUtils
|
|||||||
DLLEXPORT void drawBackgroundAndNumbers( QPainter* p, const QString& text, const QRect& rect );
|
DLLEXPORT void drawBackgroundAndNumbers( QPainter* p, const QString& text, const QRect& rect );
|
||||||
|
|
||||||
DLLEXPORT void unmarginLayout( QLayout* layout );
|
DLLEXPORT void unmarginLayout( QLayout* layout );
|
||||||
|
DLLEXPORT void fixLayoutMargins( QLayout* layout );
|
||||||
|
DLLEXPORT void fixMargins( QWidget* widget );
|
||||||
|
|
||||||
DLLEXPORT void setDefaultFontSize( int points );
|
DLLEXPORT void setDefaultFontSize( int points );
|
||||||
DLLEXPORT int defaultFontSize();
|
DLLEXPORT int defaultFontSize();
|
||||||
|
@@ -176,6 +176,8 @@ AudioControls::AudioControls( QWidget* parent )
|
|||||||
SLOT( onInfoSystemPushTypesUpdated( Tomahawk::InfoSystem::InfoTypeSet ) ) );
|
SLOT( onInfoSystemPushTypesUpdated( Tomahawk::InfoSystem::InfoTypeSet ) ) );
|
||||||
onInfoSystemPushTypesUpdated( InfoSystem::InfoSystem::instance()->supportedPushTypes() );
|
onInfoSystemPushTypesUpdated( InfoSystem::InfoSystem::instance()->supportedPushTypes() );
|
||||||
|
|
||||||
|
TomahawkUtils::fixMargins( this );
|
||||||
|
|
||||||
onPlaybackStopped(); // initial state
|
onPlaybackStopped(); // initial state
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user