mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 07:36:48 +02:00
* Save & restore queue across sessions.
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "PlaylistView.h"
|
#include "PlaylistView.h"
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
|
#include "TomahawkSettings.h"
|
||||||
#include "utils/TomahawkUtilsGui.h"
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
#include "widgets/OverlayWidget.h"
|
#include "widgets/OverlayWidget.h"
|
||||||
|
|
||||||
@@ -62,12 +63,18 @@ QueueView::QueueView( AnimatedSplitter* parent )
|
|||||||
|
|
||||||
ui->toggleButton->installEventFilter( this );
|
ui->toggleButton->installEventFilter( this );
|
||||||
ui->toggleButton->setCursor( Qt::PointingHandCursor );
|
ui->toggleButton->setCursor( Qt::PointingHandCursor );
|
||||||
|
|
||||||
|
// Set initial state
|
||||||
|
onHidden( this, false );
|
||||||
|
|
||||||
|
restoreState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QueueView::~QueueView()
|
QueueView::~QueueView()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
|
saveState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -193,3 +200,37 @@ QueueView::updateLabel()
|
|||||||
ui->toggleButton->setText( tr( "Close Queue" ) );
|
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:
|
protected:
|
||||||
void changeEvent( QEvent* e );
|
void changeEvent( QEvent* e );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateLabel();
|
void updateLabel();
|
||||||
void onAnimationFinished();
|
void onAnimationFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void saveState();
|
||||||
|
void restoreState();
|
||||||
|
|
||||||
Ui::QueueView* ui;
|
Ui::QueueView* ui;
|
||||||
QTimer* m_dragTimer;
|
QTimer* m_dragTimer;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user