mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
Shuffle Mode and Repeat mode are now stored on a playlist by playlist basis
in Tomahawk.conf
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
#include "database/databasecommand_deleteplaylist.h"
|
#include "database/databasecommand_deleteplaylist.h"
|
||||||
#include "database/databasecommand_renameplaylist.h"
|
#include "database/databasecommand_renameplaylist.h"
|
||||||
|
|
||||||
|
#include "tomahawksettings.h"
|
||||||
#include "pipeline.h"
|
#include "pipeline.h"
|
||||||
#include "source.h"
|
#include "source.h"
|
||||||
#include "sourcelist.h"
|
#include "sourcelist.h"
|
||||||
@@ -219,6 +220,9 @@ Playlist::load( const QString& guid )
|
|||||||
bool
|
bool
|
||||||
Playlist::remove( const playlist_ptr& playlist )
|
Playlist::remove( const playlist_ptr& playlist )
|
||||||
{
|
{
|
||||||
|
TomahawkSettings *s = TomahawkSettings::instance();
|
||||||
|
s->removePlaylistSettings( playlist->guid() );
|
||||||
|
|
||||||
DatabaseCommand_DeletePlaylist* cmd = new DatabaseCommand_DeletePlaylist( playlist->author(), playlist->guid() );
|
DatabaseCommand_DeletePlaylist* cmd = new DatabaseCommand_DeletePlaylist( playlist->author(), playlist->guid() );
|
||||||
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
Database::instance()->enqueue( QSharedPointer<DatabaseCommand>(cmd) );
|
||||||
|
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "sip/SipHandler.h"
|
#include "sip/SipHandler.h"
|
||||||
|
#include "playlistinterface.h"
|
||||||
|
|
||||||
#define VERSION 3
|
#define VERSION 3
|
||||||
|
|
||||||
@@ -187,7 +188,6 @@ TomahawkSettings::setWatchForChanges( bool watch )
|
|||||||
setValue( "watchForChanges", watch );
|
setValue( "watchForChanges", watch );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkSettings::setAcceptedLegalWarning( bool accept )
|
TomahawkSettings::setAcceptedLegalWarning( bool accept )
|
||||||
{
|
{
|
||||||
@@ -381,6 +381,36 @@ TomahawkSettings::setPlaylistColumnSizes( const QString& playlistid, const QByte
|
|||||||
setValue( QString( "ui/playlist/%1/columnSizes" ).arg( playlistid ), state );
|
setValue( QString( "ui/playlist/%1/columnSizes" ).arg( playlistid ), state );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
TomahawkSettings::shuffleState( const QString& playlistid ) const
|
||||||
|
{
|
||||||
|
return value( QString( "ui/playlist/%1/shuffleState" ).arg( playlistid )).toBool();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkSettings::setShuffleState( const QString& playlistid, bool state)
|
||||||
|
{
|
||||||
|
setValue( QString( "ui/playlist/%1/shuffleState" ).arg( playlistid ), state );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkSettings::removePlaylistSettings( const QString& playlistid )
|
||||||
|
{
|
||||||
|
remove( QString( "ui/playlist/%1/shuffleState" ).arg( playlistid ) );
|
||||||
|
remove( QString( "ui/playlist/%1/repeatMode" ).arg( playlistid ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkSettings::setRepeatMode( const QString& playlistid, PlaylistInterface::RepeatMode mode )
|
||||||
|
{
|
||||||
|
setValue( QString( "ui/playlist/%1/repeatMode" ).arg( playlistid ), (int)mode );
|
||||||
|
}
|
||||||
|
|
||||||
|
PlaylistInterface::RepeatMode
|
||||||
|
TomahawkSettings::repeatMode( const QString& playlistid )
|
||||||
|
{
|
||||||
|
return (PlaylistInterface::RepeatMode)value( QString( "ui/playlist/%1/repeatMode" ).arg( playlistid )).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
QList<Tomahawk::playlist_ptr>
|
QList<Tomahawk::playlist_ptr>
|
||||||
TomahawkSettings::recentlyPlayedPlaylists() const
|
TomahawkSettings::recentlyPlayedPlaylists() const
|
||||||
|
@@ -68,6 +68,14 @@ public:
|
|||||||
QList<Tomahawk::playlist_ptr> recentlyPlayedPlaylists() const;
|
QList<Tomahawk::playlist_ptr> recentlyPlayedPlaylists() const;
|
||||||
QStringList recentlyPlayedPlaylistGuids( unsigned int amount = 0 ) const;
|
QStringList recentlyPlayedPlaylistGuids( unsigned int amount = 0 ) const;
|
||||||
void appendRecentlyPlayedPlaylist( const Tomahawk::playlist_ptr& playlist );
|
void appendRecentlyPlayedPlaylist( const Tomahawk::playlist_ptr& playlist );
|
||||||
|
|
||||||
|
bool shuffleState( const QString& playlistid ) const;
|
||||||
|
void setShuffleState( const QString& playlistid, bool state );
|
||||||
|
PlaylistInterface::RepeatMode repeatMode( const QString& playlistid );
|
||||||
|
void setRepeatMode( const QString& playlistid, PlaylistInterface::RepeatMode mode);
|
||||||
|
|
||||||
|
// remove shuffle state and repeat state
|
||||||
|
void removePlaylistSettings( const QString& playlistid );
|
||||||
|
|
||||||
/// SIP plugins
|
/// SIP plugins
|
||||||
// all plugins we know about. loaded, unloaded, enabled, disabled.
|
// all plugins we know about. loaded, unloaded, enabled, disabled.
|
||||||
|
@@ -142,6 +142,7 @@ ViewManager::ViewManager( QObject* parent )
|
|||||||
|
|
||||||
ViewManager::~ViewManager()
|
ViewManager::~ViewManager()
|
||||||
{
|
{
|
||||||
|
saveCurrentPlaylistSettings();
|
||||||
delete m_widget;
|
delete m_widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -581,6 +582,9 @@ ViewManager::setPage( ViewPage* page, bool trackHistory )
|
|||||||
if ( !page )
|
if ( !page )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// save the old playlist shuffle state in config before we change playlists
|
||||||
|
saveCurrentPlaylistSettings();
|
||||||
|
|
||||||
unlinkPlaylist();
|
unlinkPlaylist();
|
||||||
|
|
||||||
if ( !m_pageHistory.contains( page ) )
|
if ( !m_pageHistory.contains( page ) )
|
||||||
@@ -652,6 +656,24 @@ ViewManager::unlinkPlaylist()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ViewManager::saveCurrentPlaylistSettings()
|
||||||
|
{
|
||||||
|
TomahawkSettings* s = TomahawkSettings::instance();
|
||||||
|
Tomahawk::playlist_ptr pl = playlistForInterface( currentPlaylistInterface() );
|
||||||
|
|
||||||
|
if ( !pl.isNull() ) {
|
||||||
|
s->setShuffleState( pl->guid(), currentPlaylistInterface()->shuffled() );
|
||||||
|
s->setRepeatMode( pl->guid(), currentPlaylistInterface()->repeatMode() );
|
||||||
|
} else {
|
||||||
|
Tomahawk::dynplaylist_ptr dynPl = dynamicPlaylistForInterface( currentPlaylistInterface() );
|
||||||
|
if ( !dynPl.isNull() ) {
|
||||||
|
s->setShuffleState( dynPl->guid(), currentPlaylistInterface()->shuffled() );
|
||||||
|
s->setRepeatMode( dynPl->guid(), currentPlaylistInterface()->repeatMode() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ViewManager::updateView()
|
ViewManager::updateView()
|
||||||
@@ -704,8 +726,26 @@ ViewManager::updateView()
|
|||||||
m_infobar->setCaption( currentPage()->title() );
|
m_infobar->setCaption( currentPage()->title() );
|
||||||
m_infobar->setDescription( currentPage()->description() );
|
m_infobar->setDescription( currentPage()->description() );
|
||||||
m_infobar->setPixmap( currentPage()->pixmap() );
|
m_infobar->setPixmap( currentPage()->pixmap() );
|
||||||
|
|
||||||
|
// turn on shuffle/repeat mode for the new playlist view if specified in config
|
||||||
|
loadCurrentPlaylistSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ViewManager::loadCurrentPlaylistSettings()
|
||||||
|
{
|
||||||
|
TomahawkSettings* s = TomahawkSettings::instance();
|
||||||
|
Tomahawk::playlist_ptr pl = playlistForInterface( currentPlaylistInterface() );
|
||||||
|
if ( !pl.isNull() ) {
|
||||||
|
currentPlaylistInterface()->setShuffled( s->shuffleState( pl->guid() ));
|
||||||
|
currentPlaylistInterface()->setRepeatMode( s->repeatMode( pl->guid() ));
|
||||||
|
} else {
|
||||||
|
Tomahawk::dynplaylist_ptr dynPl = dynamicPlaylistForInterface( currentPlaylistInterface() );
|
||||||
|
if ( !dynPl.isNull() ) {
|
||||||
|
currentPlaylistInterface()->setShuffled( s->shuffleState( dynPl->guid() ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ViewManager::onWidgetDestroyed( QWidget* widget )
|
ViewManager::onWidgetDestroyed( QWidget* widget )
|
||||||
|
@@ -162,7 +162,9 @@ private:
|
|||||||
void setPage( Tomahawk::ViewPage* page, bool trackHistory = true );
|
void setPage( Tomahawk::ViewPage* page, bool trackHistory = true );
|
||||||
void updateView();
|
void updateView();
|
||||||
void unlinkPlaylist();
|
void unlinkPlaylist();
|
||||||
|
void saveCurrentPlaylistSettings();
|
||||||
|
void loadCurrentPlaylistSettings();
|
||||||
|
|
||||||
Tomahawk::playlist_ptr playlistForInterface( PlaylistInterface* interface ) const;
|
Tomahawk::playlist_ptr playlistForInterface( PlaylistInterface* interface ) const;
|
||||||
Tomahawk::dynplaylist_ptr dynamicPlaylistForInterface( PlaylistInterface* interface ) const;
|
Tomahawk::dynplaylist_ptr dynamicPlaylistForInterface( PlaylistInterface* interface ) const;
|
||||||
Tomahawk::collection_ptr collectionForInterface( PlaylistInterface* interface ) const;
|
Tomahawk::collection_ptr collectionForInterface( PlaylistInterface* interface ) const;
|
||||||
|
@@ -233,7 +233,6 @@ TomahawkWindow::loadSettings()
|
|||||||
restoreState( s->mainWindowState() );
|
restoreState( s->mainWindowState() );
|
||||||
if ( !s->mainWindowSplitterState().isEmpty() )
|
if ( !s->mainWindowSplitterState().isEmpty() )
|
||||||
ui->splitter->restoreState( s->mainWindowSplitterState() );
|
ui->splitter->restoreState( s->mainWindowSplitterState() );
|
||||||
|
|
||||||
#ifdef QT_MAC_USE_COCOA
|
#ifdef QT_MAC_USE_COCOA
|
||||||
if( workaround ) {
|
if( workaround ) {
|
||||||
// Make it visible again
|
// Make it visible again
|
||||||
|
Reference in New Issue
Block a user