mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-22 21:54:00 +02:00
Hook up "delete tomahawk playlist when stopping sync" option
This commit is contained in:
@@ -257,8 +257,6 @@ SpotifyAccount::configurationWidget()
|
|||||||
m_configWidget = QWeakPointer< SpotifyAccountConfig >( new SpotifyAccountConfig( this ) );
|
m_configWidget = QWeakPointer< SpotifyAccountConfig >( new SpotifyAccountConfig( this ) );
|
||||||
m_configWidget.data()->setPlaylists( m_allSpotifyPlaylists );
|
m_configWidget.data()->setPlaylists( m_allSpotifyPlaylists );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
m_configWidget.data()->loadFromConfig();
|
|
||||||
|
|
||||||
return static_cast< QWidget* >( m_configWidget.data() );
|
return static_cast< QWidget* >( m_configWidget.data() );
|
||||||
}
|
}
|
||||||
@@ -280,7 +278,6 @@ SpotifyAccount::saveConfig()
|
|||||||
creds[ "password" ] = m_configWidget.data()->password();
|
creds[ "password" ] = m_configWidget.data()->password();
|
||||||
creds[ "highQuality" ] = m_configWidget.data()->highQuality();
|
creds[ "highQuality" ] = m_configWidget.data()->highQuality();
|
||||||
setCredentials( creds );
|
setCredentials( creds );
|
||||||
sync();
|
|
||||||
|
|
||||||
// Send the result to the resolver
|
// Send the result to the resolver
|
||||||
QVariantMap msg;
|
QVariantMap msg;
|
||||||
@@ -292,6 +289,11 @@ SpotifyAccount::saveConfig()
|
|||||||
m_spotifyResolver.data()->sendMessage( msg );
|
m_spotifyResolver.data()->sendMessage( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantHash config = configuration();
|
||||||
|
config[ "deleteOnUnsync" ] = m_configWidget.data()->deleteOnUnsync();
|
||||||
|
qDebug() << "Saved deleteOnUnsync to:" << m_configWidget.data()->deleteOnUnsync();
|
||||||
|
setConfiguration( config );
|
||||||
|
|
||||||
m_configWidget.data()->saveSettings();
|
m_configWidget.data()->saveSettings();
|
||||||
foreach ( SpotifyPlaylistInfo* pl, m_allSpotifyPlaylists )
|
foreach ( SpotifyPlaylistInfo* pl, m_allSpotifyPlaylists )
|
||||||
{
|
{
|
||||||
@@ -313,6 +315,7 @@ SpotifyAccount::saveConfig()
|
|||||||
stopPlaylistSync( pl );
|
stopPlaylistSync( pl );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -389,6 +392,13 @@ SpotifyAccount::fetchFullPlaylist( SpotifyPlaylistInfo* playlist )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
SpotifyAccount::deleteOnUnsync() const
|
||||||
|
{
|
||||||
|
qDebug() << "READ deleteOnUnsync:" << configuration().value( "deleteOnUnsync", false ).toBool();
|
||||||
|
return configuration().value( "deleteOnUnsync", false ).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyAccount::stopPlaylistSync( SpotifyPlaylistInfo* playlist )
|
SpotifyAccount::stopPlaylistSync( SpotifyPlaylistInfo* playlist )
|
||||||
{
|
{
|
||||||
@@ -397,6 +407,18 @@ SpotifyAccount::stopPlaylistSync( SpotifyPlaylistInfo* playlist )
|
|||||||
msg[ "playlistid" ] = playlist->plid;
|
msg[ "playlistid" ] = playlist->plid;
|
||||||
|
|
||||||
m_spotifyResolver.data()->sendMessage( msg );
|
m_spotifyResolver.data()->sendMessage( msg );
|
||||||
|
|
||||||
|
if ( deleteOnUnsync() )
|
||||||
|
{
|
||||||
|
SpotifyPlaylistUpdater* updater = m_updaters.take( playlist->plid );
|
||||||
|
playlist_ptr tomahawkPl = updater->playlist();
|
||||||
|
|
||||||
|
if ( !tomahawkPl.isNull() )
|
||||||
|
Playlist::remove( tomahawkPl );
|
||||||
|
|
||||||
|
updater->deleteLater();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -84,16 +84,11 @@ public:
|
|||||||
virtual QWidget* aclWidget() { return 0; }
|
virtual QWidget* aclWidget() { return 0; }
|
||||||
virtual InfoSystem::InfoPlugin* infoPlugin() { return 0; }
|
virtual InfoSystem::InfoPlugin* infoPlugin() { return 0; }
|
||||||
virtual SipPlugin* sipPlugin() { return 0; }
|
virtual SipPlugin* sipPlugin() { return 0; }
|
||||||
/*
|
|
||||||
struct Sync {
|
|
||||||
QString id_;
|
|
||||||
QString uuid;
|
|
||||||
Tomahawk::playlist_ptr playlist;
|
|
||||||
};*/
|
|
||||||
|
|
||||||
void sendMessage( const QVariantMap& msg, QObject* receiver, const QString& slot );
|
void sendMessage( const QVariantMap& msg, QObject* receiver, const QString& slot );
|
||||||
void registerUpdaterForPlaylist( const QString& plId, SpotifyPlaylistUpdater* updater );
|
void registerUpdaterForPlaylist( const QString& plId, SpotifyPlaylistUpdater* updater );
|
||||||
|
|
||||||
|
bool deleteOnUnsync() const;
|
||||||
private slots:
|
private slots:
|
||||||
void resolverMessage( const QString& msgType, const QVariantMap& msg );
|
void resolverMessage( const QString& msgType, const QVariantMap& msg );
|
||||||
|
|
||||||
@@ -106,10 +101,9 @@ private:
|
|||||||
void loadPlaylists();
|
void loadPlaylists();
|
||||||
|
|
||||||
void stopPlaylistSync( SpotifyPlaylistInfo* playlist );
|
void stopPlaylistSync( SpotifyPlaylistInfo* playlist );
|
||||||
|
|
||||||
void fetchFullPlaylist( SpotifyPlaylistInfo* playlist );
|
void fetchFullPlaylist( SpotifyPlaylistInfo* playlist );
|
||||||
|
|
||||||
// QList<Sync> m_syncPlaylists;
|
|
||||||
QWeakPointer<SpotifyAccountConfig> m_configWidget;
|
QWeakPointer<SpotifyAccountConfig> m_configWidget;
|
||||||
QWeakPointer<ScriptResolver> m_spotifyResolver;
|
QWeakPointer<ScriptResolver> m_spotifyResolver;
|
||||||
|
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
|
#include <QShowEvent>
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
using namespace Accounts;
|
using namespace Accounts;
|
||||||
@@ -42,7 +43,13 @@ SpotifyAccountConfig::SpotifyAccountConfig( SpotifyAccount *account )
|
|||||||
connect( &m_resetTimer, SIGNAL( timeout() ), this, SLOT( resetVerifyButton() ) );
|
connect( &m_resetTimer, SIGNAL( timeout() ), this, SLOT( resetVerifyButton() ) );
|
||||||
connect( m_ui->usernameEdit, SIGNAL( textChanged( QString ) ), this, SLOT( clearVerifyButton() ) );
|
connect( m_ui->usernameEdit, SIGNAL( textChanged( QString ) ), this, SLOT( clearVerifyButton() ) );
|
||||||
connect( m_ui->passwordEdit, SIGNAL( textChanged( QString ) ), this, SLOT( clearVerifyButton() ) );
|
connect( m_ui->passwordEdit, SIGNAL( textChanged( QString ) ), this, SLOT( clearVerifyButton() ) );
|
||||||
|
loadFromConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SpotifyAccountConfig::showEvent( QShowEvent *event )
|
||||||
|
{
|
||||||
loadFromConfig();
|
loadFromConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,6 +60,9 @@ SpotifyAccountConfig::loadFromConfig()
|
|||||||
m_ui->usernameEdit->setText( m_account->credentials().value( "username" ).toString() );
|
m_ui->usernameEdit->setText( m_account->credentials().value( "username" ).toString() );
|
||||||
m_ui->passwordEdit->setText( m_account->credentials().value( "password" ).toString() );
|
m_ui->passwordEdit->setText( m_account->credentials().value( "password" ).toString() );
|
||||||
m_ui->streamingCheckbox->setChecked( m_account->credentials().value( "highQuality" ).toBool() );
|
m_ui->streamingCheckbox->setChecked( m_account->credentials().value( "highQuality" ).toBool() );
|
||||||
|
|
||||||
|
qDebug() << "Loaded deleteOnUnsync:" << m_account->deleteOnUnsync();
|
||||||
|
m_ui->deleteOnUnsync->setChecked( m_account->deleteOnUnsync() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -92,6 +102,13 @@ SpotifyAccountConfig::highQuality() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
SpotifyAccountConfig::deleteOnUnsync() const
|
||||||
|
{
|
||||||
|
return m_ui->deleteOnUnsync->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyAccountConfig::setPlaylists( const QList<SpotifyPlaylistInfo *>& playlists )
|
SpotifyAccountConfig::setPlaylists( const QList<SpotifyPlaylistInfo *>& playlists )
|
||||||
{
|
{
|
||||||
|
@@ -23,6 +23,8 @@
|
|||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
class QShowEvent;
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
class SpotifyConfig;
|
class SpotifyConfig;
|
||||||
@@ -45,6 +47,7 @@ public:
|
|||||||
QString username() const;
|
QString username() const;
|
||||||
QString password() const;
|
QString password() const;
|
||||||
bool highQuality() const;
|
bool highQuality() const;
|
||||||
|
bool deleteOnUnsync() const;
|
||||||
|
|
||||||
void setPlaylists( const QList< SpotifyPlaylistInfo* >& playlists );
|
void setPlaylists( const QList< SpotifyPlaylistInfo* >& playlists );
|
||||||
|
|
||||||
@@ -54,6 +57,9 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void verifyResult( const QString& msgType, const QVariantMap& msg );
|
void verifyResult( const QString& msgType, const QVariantMap& msg );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void showEvent( QShowEvent* event );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void verifyLogin();
|
void verifyLogin();
|
||||||
void resetVerifyButton();
|
void resetVerifyButton();
|
||||||
|
@@ -174,7 +174,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="deleteOnUnsync">
|
<widget class="QCheckBox" name="deleteOnUnsync">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Delete Tomahawk playlist when removing Spotify sync</string>
|
<string>Delete Tomahawk playlist when removing synchronization</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Reference in New Issue
Block a user