1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 15:29:42 +01:00

* Save & restore queue across sessions.

This commit is contained in:
Christian Muehlhaeuser 2013-04-26 06:38:48 +02:00
parent a074af2c22
commit 859e2e4a7b
2 changed files with 46 additions and 2 deletions

View File

@ -26,6 +26,7 @@
#include "utils/Logger.h"
#include "PlaylistView.h"
#include "Source.h"
#include "TomahawkSettings.h"
#include "utils/TomahawkUtilsGui.h"
#include "widgets/OverlayWidget.h"
@ -62,12 +63,18 @@ QueueView::QueueView( AnimatedSplitter* parent )
ui->toggleButton->installEventFilter( this );
ui->toggleButton->setCursor( Qt::PointingHandCursor );
// Set initial state
onHidden( this, false );
restoreState();
}
QueueView::~QueueView()
{
qDebug() << Q_FUNC_INFO;
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
saveState();
}
@ -193,3 +200,37 @@ QueueView::updateLabel()
ui->toggleButton->setText( tr( "Close Queue" ) );
}
}
void
QueueView::restoreState()
{
QVariantList vl = TomahawkSettings::instance()->queueState().toList();
QList< query_ptr > ql;
foreach ( const QVariant& v, vl )
{
QVariantMap map = v.toMap();
query_ptr q = Query::get( map["artist"].toString(), map["track"].toString(), map["album"].toString() );
ql << q;
}
if ( !ql.isEmpty() )
{
queue()->model()->appendQueries( ql );
updateLabel();
}
}
void
QueueView::saveState()
{
QVariantList vl;
foreach ( const query_ptr& query, queue()->model()->queries() )
{
vl << query->toVariant();
}
TomahawkSettings::instance()->setQueueState( vl );
}

View File

@ -56,12 +56,15 @@ public slots:
protected:
void changeEvent( QEvent* e );
private slots:
void updateLabel();
void onAnimationFinished();
private:
void saveState();
void restoreState();
Ui::QueueView* ui;
QTimer* m_dragTimer;
};