mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
* Try simpler OverlayWidget layout.
This commit is contained in:
@@ -48,13 +48,7 @@ OverlayWidget::OverlayWidget( QAbstractItemView* parent )
|
|||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
if ( m_itemView->model() )
|
onViewModelChanged();
|
||||||
{
|
|
||||||
connect( m_itemView->model(), SIGNAL( rowsInserted( QModelIndex, int, int ) ), SLOT( onViewChanged() ), Qt::UniqueConnection );
|
|
||||||
connect( m_itemView->model(), SIGNAL( rowsRemoved( QModelIndex, int, int ) ), SLOT( onViewChanged() ), Qt::UniqueConnection );
|
|
||||||
connect( m_itemView->model(), SIGNAL( loadingStarted() ), SLOT( onViewChanged() ), Qt::UniqueConnection );
|
|
||||||
connect( m_itemView->model(), SIGNAL( loadingFinished() ), SLOT( onViewChanged() ), Qt::UniqueConnection );
|
|
||||||
}
|
|
||||||
connect( m_itemView, SIGNAL( modelChanged() ), SLOT( onViewModelChanged() ) );
|
connect( m_itemView, SIGNAL( modelChanged() ), SLOT( onViewModelChanged() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +197,6 @@ OverlayWidget::paintEvent( QPaintEvent* event )
|
|||||||
if ( center != pos() )
|
if ( center != pos() )
|
||||||
{
|
{
|
||||||
move( center );
|
move( center );
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainter p( this );
|
QPainter p( this );
|
||||||
@@ -213,12 +206,11 @@ OverlayWidget::paintEvent( QPaintEvent* event )
|
|||||||
p.setRenderHint( QPainter::Antialiasing );
|
p.setRenderHint( QPainter::Antialiasing );
|
||||||
p.setOpacity( m_opacity );
|
p.setOpacity( m_opacity );
|
||||||
|
|
||||||
QPen pen( palette().dark().color(), .5 );
|
/* QPen pen( palette().dark().color(), .5 );
|
||||||
p.setPen( pen );
|
p.setPen( pen );
|
||||||
//FIXME const color
|
//FIXME const color
|
||||||
p.setBrush( QColor( 30, 30, 30, 255.0 * OPACITY ) );
|
p.setBrush( QColor( 30, 30, 30, 255.0 * OPACITY ) );
|
||||||
|
p.drawRoundedRect( r, CORNER_ROUNDNESS, CORNER_ROUNDNESS );*/
|
||||||
p.drawRoundedRect( r, CORNER_ROUNDNESS, CORNER_ROUNDNESS );
|
|
||||||
|
|
||||||
QTextOption to( Qt::AlignCenter );
|
QTextOption to( Qt::AlignCenter );
|
||||||
to.setWrapMode( QTextOption::WrapAtWordBoundaryOrAnywhere );
|
to.setWrapMode( QTextOption::WrapAtWordBoundaryOrAnywhere );
|
||||||
@@ -233,9 +225,9 @@ OverlayWidget::paintEvent( QPaintEvent* event )
|
|||||||
|
|
||||||
QFontMetricsF fm( f );
|
QFontMetricsF fm( f );
|
||||||
qreal textHeight = fm.boundingRect( textRect, Qt::AlignCenter | Qt::TextWordWrap, text() ).height();
|
qreal textHeight = fm.boundingRect( textRect, Qt::AlignCenter | Qt::TextWordWrap, text() ).height();
|
||||||
while( textHeight > availHeight )
|
while ( textHeight > availHeight )
|
||||||
{
|
{
|
||||||
if( f.pointSize() <= 4 ) // don't try harder
|
if ( f.pointSize() <= 4 ) // don't try harder
|
||||||
break;
|
break;
|
||||||
|
|
||||||
f.setPointSize( f.pointSize() - 1 );
|
f.setPointSize( f.pointSize() - 1 );
|
||||||
@@ -244,7 +236,10 @@ OverlayWidget::paintEvent( QPaintEvent* event )
|
|||||||
}
|
}
|
||||||
|
|
||||||
p.setFont( f );
|
p.setFont( f );
|
||||||
// p.setPen( palette().highlightedText().color() );
|
#ifdef Q_OS_MAC
|
||||||
p.setPen( Qt::white );
|
p.setPen( Qt::gray );
|
||||||
|
#else
|
||||||
|
p.setPen( palette().text().color().lighter( 100 ) );
|
||||||
|
#endif
|
||||||
p.drawText( r.adjusted( 8, 8, -8, -8 ), text(), to );
|
p.drawText( r.adjusted( 8, 8, -8, -8 ), text(), to );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user