Commit e93fee0e authored by Scott Wheeler's avatar Scott Wheeler

Added the option to *not* restore playlists and items on load up.

svn path=/trunk/kdemultimedia/juk/; revision=185373
parent 544b47a3
......@@ -34,12 +34,13 @@ CollectionList *CollectionList::instance()
return(list);
}
void CollectionList::initialize(PlaylistSplitter *s, QWidget *parent)
void CollectionList::initialize(PlaylistSplitter *s, QWidget *parent, bool restoreOnLoad)
{
list = new CollectionList(s, parent);
for(QDictIterator<Tag>it(*Cache::instance()); it.current(); ++it)
new CollectionListItem(it.current()->fileInfo());
if(restoreOnLoad)
for(QDictIterator<Tag>it(*Cache::instance()); it.current(); ++it)
new CollectionListItem(it.current()->fileInfo());
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -23,15 +23,16 @@
#include "playlist.h"
#include "playlistitem.h"
/** This is the "collection", or all of the music files that have been opened
in any playlist and not explicitly removed from the collection.
It is being implemented as a "semi-singleton" because I need universal access
to just one instance. However, because the collection needs initialization
parameters (that will not always be available when an instance is needed).
Hence there will be the familiar singleton "instance()" method allong with an
"initialize()" method.
*/
/**
* This is the "collection", or all of the music files that have been opened
* in any playlist and not explicitly removed from the collection.
*
* It is being implemented as a "semi-singleton" because I need universal access
* to just one instance. However, because the collection needs initialization
* parameters (that will not always be available when an instance is needed).
* Hence there will be the familiar singleton "instance()" method allong with an
* "initialize()" method.
*/
class PlaylistSplitter;
class CollectionListItem;
......@@ -43,7 +44,7 @@ class CollectionList : public Playlist
Q_OBJECT
public:
static CollectionList *instance();
static void initialize(PlaylistSplitter *s, QWidget *parent);
static void initialize(PlaylistSplitter *s, QWidget *parent, bool restoreOnLoad = true);
QStringList artists() const;
QStringList albums() const;
......
......@@ -39,6 +39,7 @@ JuK::JuK(QWidget *parent, const char *name) : KMainWindow(parent, name, WDestruc
{
// Expect segfaults if you change this order.
readSettings();
setupLayout();
setupActions();
setupPlayer();
......@@ -57,7 +58,7 @@ JuK::~JuK()
void JuK::setupLayout()
{
splitter = new PlaylistSplitter(this, "playlistSplitter");
splitter = new PlaylistSplitter(this, restore, "playlistSplitter");
setCentralWidget(splitter);
// playlist item activation connection
......@@ -106,8 +107,12 @@ void JuK::setupActions()
renamePlaylistAction = new KAction(i18n("Rename..."), 0, splitter, SLOT(renamePlaylist()),
actionCollection(), "renamePlaylist");
new KAction(i18n("Duplicate..."), "editcopy", 0, splitter, SLOT(duplicatePlaylist()), actionCollection(), "duplicatePlaylist");
deleteItemPlaylistAction = new KAction(i18n("Delete"), "editdelete", 0, splitter, SLOT(deleteItemPlaylist()), actionCollection(), "deleteItemPlaylist");
deleteItemPlaylistAction = new KAction(i18n("Delete"), "editdelete", 0, splitter, SLOT(deleteItemPlaylist()),
actionCollection(), "deleteItemPlaylist");
// settings menu
restoreOnLoadAction = new KToggleAction(i18n("Restored Playlists on Load"), 0, actionCollection(), "restoreOnLoad");
playlistChanged(0);
connect(splitter, SIGNAL(playlistChanged(Playlist *)), this, SLOT(playlistChanged(Playlist *)));
......@@ -171,12 +176,24 @@ void JuK::readConfig()
randomPlayAction->setChecked(randomPlay);
}
}
{ // view Settings
{ // view settings
KConfigGroupSaver saver(config, "View");
bool showEditor = config->readBoolEntry("ShowEditor", true);
showEditorAction->setChecked(showEditor);
splitter->setEditorVisible(showEditor);
}
if(restoreOnLoadAction)
restoreOnLoadAction->setChecked(restore);
}
void JuK::readSettings()
{
KConfig *config = KGlobal::config();
{ // general settings
KConfigGroupSaver saver(config, "Settings");
restore = config->readBoolEntry("RestoreOnLoad", true);
}
}
void JuK::saveConfig()
......@@ -193,6 +210,11 @@ void JuK::saveConfig()
KConfigGroupSaver saver(config, "View");
config->writeEntry("ShowEditor", showEditorAction->isChecked());
}
{ // general settings
KConfigGroupSaver saver(config, "Settings");
if(restoreOnLoadAction)
config->writeEntry("RestoreOnLoad", restoreOnLoadAction->isChecked());
}
}
bool JuK::queryClose()
......
......@@ -54,6 +54,11 @@ private:
void setupPlayer();
void processArgs();
void readConfig();
/**
* This is only separate from readConfig() because it is useful to call it
* before we construct the splitter.
*/
void readSettings();
void saveConfig();
virtual bool queryClose();
......@@ -64,6 +69,7 @@ private:
// actions
KToggleAction *showEditorAction;
KToggleAction *restoreOnLoadAction;
SliderAction *sliderAction;
KToggleAction *randomPlayAction;
KAction *playAction;
......@@ -80,6 +86,7 @@ private:
PlaylistItem *playingItem;
bool trackPositionDragging;
bool noSeek;
bool restore;
static const int pollInterval = 800;
......
......@@ -32,6 +32,9 @@
<Action name="duplicatePlaylist"/>
<Action name="deleteItemPlaylist"/>
</Menu>
<Menu name="settings" noMerge="1"><text>&amp;Settings</text>
<Action name="restoreOnLoad"/>
</Menu>
</MenuBar>
<ToolBar name="mainToolBar" noMerge="1"><text>Main Toolbar</text>
......
......@@ -43,8 +43,10 @@ void processEvents()
// public methods
////////////////////////////////////////////////////////////////////////////////
PlaylistSplitter::PlaylistSplitter(QWidget *parent, const char *name) : QSplitter(Qt::Horizontal, parent, name)
PlaylistSplitter::PlaylistSplitter(QWidget *parent, bool restoreOnLoad, const char *name) : QSplitter(Qt::Horizontal, parent, name)
{
restore = restoreOnLoad;
setupLayout();
readConfig();
mediaExtensions.append("mp3");
......@@ -343,7 +345,7 @@ void PlaylistSplitter::setupLayout()
// fact is a subclass) so it is created here rather than by using
// createPlaylist().
CollectionList::initialize(this, playlistStack);
CollectionList::initialize(this, playlistStack, restore);
collection = CollectionList::instance();
PlaylistBoxItem *collectionBoxItem = new PlaylistBoxItem(playlistBox, SmallIcon("folder_sound", 32),
......@@ -365,15 +367,17 @@ void PlaylistSplitter::readConfig()
{ // block for Playlists group
KConfigGroupSaver saver(config, "Playlists");
QStringList external = config->readListEntry("ExternalPlaylists");
for(QStringList::Iterator it = external.begin(); it != external.end(); ++it)
openPlaylist(*it);
QStringList internal = config->readListEntry("InternalPlaylists");
for(QStringList::Iterator it = internal.begin(); it != internal.end(); ++it) {
Playlist *p = openPlaylist(*it);
if(p)
p->setInternal(true);
if(restore) {
QStringList external = config->readListEntry("ExternalPlaylists");
for(QStringList::Iterator it = external.begin(); it != external.end(); ++it)
openPlaylist(*it);
QStringList internal = config->readListEntry("InternalPlaylists");
for(QStringList::Iterator it = internal.begin(); it != internal.end(); ++it) {
Playlist *p = openPlaylist(*it);
if(p)
p->setInternal(true);
}
}
}
}
......@@ -385,7 +389,7 @@ void PlaylistSplitter::saveConfig()
// Save the list of open playlists.
if(playlistBox) {
if(restore && playlistBox) {
QStringList internalPlaylists;
QStringList externalPlaylists;
......
......@@ -42,7 +42,7 @@ class PlaylistSplitter : public QSplitter
Q_OBJECT
public:
PlaylistSplitter(QWidget *parent, const char *name = 0);
PlaylistSplitter(QWidget *parent, bool restoreOnLoad = true, const char *name = 0);
virtual ~PlaylistSplitter();
/**
......@@ -137,6 +137,7 @@ private:
QStringList listExtensions;
bool showEditor;
bool restore;
private slots:
// playlist box slots
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment