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:
parent
a074af2c22
commit
859e2e4a7b
@ -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 );
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user