mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
more crash fixes.....
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -49,18 +49,18 @@ DynamicView::DynamicView( QWidget* parent )
|
|||||||
setContentsMargins( 0, 0, 0, 0 );
|
setContentsMargins( 0, 0, 0, 0 );
|
||||||
setFrameShape( QFrame::NoFrame );
|
setFrameShape( QFrame::NoFrame );
|
||||||
setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
setAttribute( Qt::WA_MacShowFocusRect, 0 );
|
||||||
|
|
||||||
m_fadeOutAnim.setDuration( FADE_LENGTH );
|
m_fadeOutAnim.setDuration( FADE_LENGTH );
|
||||||
m_fadeOutAnim.setCurveShape( QTimeLine::LinearCurve );
|
m_fadeOutAnim.setCurveShape( QTimeLine::LinearCurve );
|
||||||
m_fadeOutAnim.setFrameRange( 100, 0 );
|
m_fadeOutAnim.setFrameRange( 100, 0 );
|
||||||
m_fadeOutAnim.setUpdateInterval( 5 );
|
m_fadeOutAnim.setUpdateInterval( 5 );
|
||||||
|
|
||||||
QEasingCurve curve( QEasingCurve::OutBounce );
|
QEasingCurve curve( QEasingCurve::OutBounce );
|
||||||
curve.setAmplitude( .25 );
|
curve.setAmplitude( .25 );
|
||||||
m_slideAnim.setEasingCurve( curve );
|
m_slideAnim.setEasingCurve( curve );
|
||||||
m_slideAnim.setDirection( QTimeLine::Forward );
|
m_slideAnim.setDirection( QTimeLine::Forward );
|
||||||
m_fadeOutAnim.setUpdateInterval( 5 );
|
m_fadeOutAnim.setUpdateInterval( 5 );
|
||||||
|
|
||||||
connect( &m_fadeOutAnim, SIGNAL( frameChanged( int ) ), viewport(), SLOT( update() ) );
|
connect( &m_fadeOutAnim, SIGNAL( frameChanged( int ) ), viewport(), SLOT( update() ) );
|
||||||
connect( &m_fadeOutAnim, SIGNAL( finished() ), this, SLOT( animFinished() ) );
|
connect( &m_fadeOutAnim, SIGNAL( finished() ), this, SLOT( animFinished() ) );
|
||||||
}
|
}
|
||||||
@@ -70,12 +70,12 @@ DynamicView::~DynamicView()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicView::setDynamicModel( DynamicModel* model)
|
DynamicView::setDynamicModel( DynamicModel* model)
|
||||||
{
|
{
|
||||||
m_model = model;
|
m_model = model;
|
||||||
PlaylistView::setModel( m_model );
|
PlaylistView::setPlaylistModel( m_model );
|
||||||
|
|
||||||
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
connect( m_model, SIGNAL( trackCountChanged( unsigned int ) ), SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||||
connect( m_model, SIGNAL( checkForOverflow() ), this, SLOT( checkForOverflow() ) );
|
connect( m_model, SIGNAL( checkForOverflow() ), this, SLOT( checkForOverflow() ) );
|
||||||
}
|
}
|
||||||
@@ -84,37 +84,37 @@ void
|
|||||||
DynamicView::setOnDemand( bool onDemand )
|
DynamicView::setOnDemand( bool onDemand )
|
||||||
{
|
{
|
||||||
m_onDemand = onDemand;
|
m_onDemand = onDemand;
|
||||||
|
|
||||||
if( m_onDemand )
|
if( m_onDemand )
|
||||||
setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
||||||
else
|
else
|
||||||
setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
|
setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicView::setReadOnly( bool readOnly )
|
DynamicView::setReadOnly( bool readOnly )
|
||||||
{
|
{
|
||||||
m_readOnly = readOnly;
|
m_readOnly = readOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicView::showMessageTimeout( const QString& title, const QString& body )
|
DynamicView::showMessageTimeout( const QString& title, const QString& body )
|
||||||
{
|
{
|
||||||
m_title = title;
|
m_title = title;
|
||||||
m_body = body;
|
m_body = body;
|
||||||
|
|
||||||
overlay()->setText( QString( "%1:\n\n%2" ).arg( m_title, m_body ) );
|
overlay()->setText( QString( "%1:\n\n%2" ).arg( m_title, m_body ) );
|
||||||
overlay()->show( 10 );
|
overlay()->show( 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicView::showMessage(const QString& message)
|
DynamicView::showMessage(const QString& message)
|
||||||
{
|
{
|
||||||
overlay()->setText( message );
|
overlay()->setText( message );
|
||||||
overlay()->show();
|
overlay()->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicView::setDynamicWorking(bool working)
|
DynamicView::setDynamicWorking(bool working)
|
||||||
{
|
{
|
||||||
m_working = working;
|
m_working = working;
|
||||||
@@ -125,7 +125,7 @@ DynamicView::setDynamicWorking(bool working)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicView::onTrackCountChanged( unsigned int tracks )
|
DynamicView::onTrackCountChanged( unsigned int tracks )
|
||||||
{
|
{
|
||||||
if ( tracks == 0 && !m_working )
|
if ( tracks == 0 && !m_working )
|
||||||
@@ -173,7 +173,7 @@ DynamicView::checkForOverflow()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicView::collapseEntries( int startRow, int num, int numToKeep )
|
DynamicView::collapseEntries( int startRow, int num, int numToKeep )
|
||||||
{
|
{
|
||||||
qDebug() << "BEGINNING TO COLLAPSE FROM" << startRow << num << numToKeep;
|
qDebug() << "BEGINNING TO COLLAPSE FROM" << startRow << num << numToKeep;
|
||||||
@@ -192,7 +192,7 @@ DynamicView::collapseEntries( int startRow, int num, int numToKeep )
|
|||||||
} else {
|
} else {
|
||||||
m_fadeOnly = false;
|
m_fadeOnly = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we capture the image of the rows we're going to collapse
|
// we capture the image of the rows we're going to collapse
|
||||||
// then we capture the image of the target row we're going to animate downwards
|
// then we capture the image of the target row we're going to animate downwards
|
||||||
// then we fade the first image out while sliding the second image up.
|
// then we fade the first image out while sliding the second image up.
|
||||||
@@ -204,7 +204,7 @@ DynamicView::collapseEntries( int startRow, int num, int numToKeep )
|
|||||||
QRect fadingRectViewport = fadingRect; // all values that we use in paintEvent() have to be in viewport coords
|
QRect fadingRectViewport = fadingRect; // all values that we use in paintEvent() have to be in viewport coords
|
||||||
fadingRect.moveTo( viewport()->mapTo( this, fadingRect.topLeft() ) );
|
fadingRect.moveTo( viewport()->mapTo( this, fadingRect.topLeft() ) );
|
||||||
//fadingRect.setBottom( qMin( fadingRect.bottom(), viewport()->mapTo( this, viewport()->rect().bottomLeft() ).y() ) ); // limit what we capture to the viewport rect, if the last item is partially obscured
|
//fadingRect.setBottom( qMin( fadingRect.bottom(), viewport()->mapTo( this, viewport()->rect().bottomLeft() ).y() ) ); // limit what we capture to the viewport rect, if the last item is partially obscured
|
||||||
|
|
||||||
m_fadingIndexes = QPixmap::grabWidget( this, fadingRect ); // but all values we use to grab the widgetr have to be in scrollarea coords :(
|
m_fadingIndexes = QPixmap::grabWidget( this, fadingRect ); // but all values we use to grab the widgetr have to be in scrollarea coords :(
|
||||||
m_fadingPointAnchor = QPoint( 0, fadingRectViewport.topLeft().y() );
|
m_fadingPointAnchor = QPoint( 0, fadingRectViewport.topLeft().y() );
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ DynamicView::collapseEntries( int startRow, int num, int numToKeep )
|
|||||||
m_bg = backgroundBetween( m_fadingIndexes.rect(), startRow );
|
m_bg = backgroundBetween( m_fadingIndexes.rect(), startRow );
|
||||||
|
|
||||||
m_fadeOutAnim.start();
|
m_fadeOutAnim.start();
|
||||||
|
|
||||||
qDebug() << "Grabbed fading indexes from rect:" << fadingRect << m_fadingIndexes.size() << "ANCHORED:" << m_fadingPointAnchor;
|
qDebug() << "Grabbed fading indexes from rect:" << fadingRect << m_fadingIndexes.size() << "ANCHORED:" << m_fadingPointAnchor;
|
||||||
|
|
||||||
if( !m_fadeOnly ) {
|
if( !m_fadeOnly ) {
|
||||||
@@ -233,7 +233,7 @@ DynamicView::collapseEntries( int startRow, int num, int numToKeep )
|
|||||||
QRect slidingRectViewport = slidingRect;
|
QRect slidingRectViewport = slidingRect;
|
||||||
// map internal view coord to external qscrollarea
|
// map internal view coord to external qscrollarea
|
||||||
slidingRect.moveTo( viewport()->mapTo( this, slidingRect.topLeft() ) );
|
slidingRect.moveTo( viewport()->mapTo( this, slidingRect.topLeft() ) );
|
||||||
|
|
||||||
m_slidingIndex = QPixmap::grabWidget( this, slidingRect );
|
m_slidingIndex = QPixmap::grabWidget( this, slidingRect );
|
||||||
m_bottomAnchor = QPoint( 0, slidingRectViewport.topLeft().y() );
|
m_bottomAnchor = QPoint( 0, slidingRectViewport.topLeft().y() );
|
||||||
m_bottomOfAnim = QPoint( 0, slidingRectViewport.bottomLeft().y() );
|
m_bottomOfAnim = QPoint( 0, slidingRectViewport.bottomLeft().y() );
|
||||||
@@ -246,7 +246,7 @@ DynamicView::collapseEntries( int startRow, int num, int numToKeep )
|
|||||||
|
|
||||||
QTimer::singleShot( SLIDE_OFFSET, &m_slideAnim, SLOT( start() ) );
|
QTimer::singleShot( SLIDE_OFFSET, &m_slideAnim, SLOT( start() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete the actual indices
|
// delete the actual indices
|
||||||
QModelIndexList todel;
|
QModelIndexList todel;
|
||||||
for( int i = 0; i < num; i++ ) {
|
for( int i = 0; i < num; i++ ) {
|
||||||
@@ -294,11 +294,11 @@ DynamicView::animFinished()
|
|||||||
m_checkOnCollapse = false;
|
m_checkOnCollapse = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DynamicView::paintEvent( QPaintEvent* event )
|
DynamicView::paintEvent( QPaintEvent* event )
|
||||||
{
|
{
|
||||||
TrackView::paintEvent(event);
|
TrackView::paintEvent(event);
|
||||||
|
|
||||||
QPainter p( viewport() );
|
QPainter p( viewport() );
|
||||||
if( m_fadeOutAnim.state() == QTimeLine::Running ) { // both run together
|
if( m_fadeOutAnim.state() == QTimeLine::Running ) { // both run together
|
||||||
p.save();
|
p.save();
|
||||||
@@ -316,8 +316,8 @@ DynamicView::paintEvent( QPaintEvent* event )
|
|||||||
// qDebug() << "FAST SETOPACITY:" << p.paintEngine()->hasFeature(QPaintEngine::ConstantOpacity);
|
// qDebug() << "FAST SETOPACITY:" << p.paintEngine()->hasFeature(QPaintEngine::ConstantOpacity);
|
||||||
p.setOpacity( 1 - m_fadeOutAnim.currentValue() );
|
p.setOpacity( 1 - m_fadeOutAnim.currentValue() );
|
||||||
p.drawPixmap( m_fadingPointAnchor, m_fadingIndexes );
|
p.drawPixmap( m_fadingPointAnchor, m_fadingIndexes );
|
||||||
p.restore();
|
p.restore();
|
||||||
|
|
||||||
if( m_slideAnim.state() == QTimeLine::Running ) {
|
if( m_slideAnim.state() == QTimeLine::Running ) {
|
||||||
// draw the collapsing entry
|
// draw the collapsing entry
|
||||||
p.drawPixmap( 0, m_slideAnim.currentFrame(), m_slidingIndex );
|
p.drawPixmap( 0, m_slideAnim.currentFrame(), m_slidingIndex );
|
||||||
|
@@ -65,7 +65,7 @@ DynamicWidget::DynamicWidget( const Tomahawk::dynplaylist_ptr& playlist, QWidget
|
|||||||
|
|
||||||
m_model = new DynamicModel( this );
|
m_model = new DynamicModel( this );
|
||||||
m_view = new DynamicView( this );
|
m_view = new DynamicView( this );
|
||||||
m_view->setModel( m_model );
|
m_view->setDynamicModel( m_model );
|
||||||
m_view->setContentsMargins( 0, 0, 0, 0 );
|
m_view->setContentsMargins( 0, 0, 0, 0 );
|
||||||
m_layout->addWidget( m_view, 1 );
|
m_layout->addWidget( m_view, 1 );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user