Commit a107dc10 authored by Scott Wheeler's avatar Scott Wheeler

Allow switching between aRts and GStreamer if they're both available

svn path=/trunk/kdemultimedia/juk/; revision=206415
parent 806b7834
...@@ -50,8 +50,8 @@ JuK::JuK(QWidget *parent, const char *name) : KMainWindow(parent, name, WDestruc ...@@ -50,8 +50,8 @@ JuK::JuK(QWidget *parent, const char *name) : KMainWindow(parent, name, WDestruc
readSettings(); readSettings();
setupLayout(); setupLayout();
setupActions(); setupActions();
setupPlayer();
readConfig(); readConfig();
setupPlayer();
setupSystemTray(); setupSystemTray();
processArgs(); processArgs();
...@@ -98,7 +98,7 @@ void JuK::setupActions() ...@@ -98,7 +98,7 @@ void JuK::setupActions()
renamePlaylistAction = new KAction(i18n("Rename..."), 0, splitter, SLOT(renamePlaylist()), renamePlaylistAction = new KAction(i18n("Rename..."), 0, splitter, SLOT(renamePlaylist()),
actionCollection(), "renamePlaylist"); actionCollection(), "renamePlaylist");
new KAction(i18n("Duplicate..."), "editcopy", 0, splitter, SLOT(duplicatePlaylist()), actionCollection(), "duplicatePlaylist"); new KAction(i18n("Duplicate..."), "editcopy", 0, splitter, SLOT(duplicatePlaylist()), actionCollection(), "duplicatePlaylist");
savePlaylistAction = KStdAction::save(splitter, SLOT(savePlaylist()), actionCollection()); savePlaylistAction = KStdAction::save(splitter, SLOT(savePlaylist()), actionCollection());
saveAsPlaylistAction = KStdAction::saveAs(splitter, SLOT(saveAsPlaylist()), actionCollection()); saveAsPlaylistAction = KStdAction::saveAs(splitter, SLOT(saveAsPlaylist()), actionCollection());
deleteItemPlaylistAction = new KAction(i18n("Delete"), "editdelete", 0, splitter, SLOT(deleteItemPlaylist()), deleteItemPlaylistAction = new KAction(i18n("Delete"), "editdelete", 0, splitter, SLOT(deleteItemPlaylist()),
...@@ -131,12 +131,18 @@ void JuK::setupActions() ...@@ -131,12 +131,18 @@ void JuK::setupActions()
// settings menu // settings menu
restoreOnLoadAction = new KToggleAction(i18n("Restore Playlists on Load"), 0, actionCollection(), "restoreOnLoad"); restoreOnLoadAction = new KToggleAction(i18n("Restore Playlists on Load"), 0, actionCollection(), "restoreOnLoad");
toggleSystemTrayAction = new KToggleAction(i18n("Dock in System Tray"), 0, actionCollection(), "toggleSystemTray"); toggleSystemTrayAction = new KToggleAction(i18n("Dock in System Tray"), 0, actionCollection(), "toggleSystemTray");
connect(toggleSystemTrayAction, SIGNAL(toggled(bool)), this, SLOT(toggleSystemTray(bool))); connect(toggleSystemTrayAction, SIGNAL(toggled(bool)), this, SLOT(toggleSystemTray(bool)));
new KAction(i18n("Genre List Editor..."), 0, this, SLOT(showGenreListEditor()), actionCollection(), "showGenreListEditor"); new KAction(i18n("Genre List Editor..."), 0, this, SLOT(showGenreListEditor()), actionCollection(), "showGenreListEditor");
connect(splitter, SIGNAL(playlistChanged()), this, SLOT(playlistChanged()));
outputSelectAction = Player::playerSelectAction(actionCollection());
if(outputSelectAction) {
outputSelectAction->setCurrentItem(0);
connect(outputSelectAction, SIGNAL(activated(int)), this, SLOT(setOutput(int)));
}
// just in the toolbar // just in the toolbar
sliderAction = new SliderAction(i18n("Track Position"), actionCollection(), "trackPositionAction"); sliderAction = new SliderAction(i18n("Track Position"), actionCollection(), "trackPositionAction");
...@@ -146,6 +152,8 @@ void JuK::setupActions() ...@@ -146,6 +152,8 @@ void JuK::setupActions()
// set the slider to the proper orientation and make it stay that way // set the slider to the proper orientation and make it stay that way
sliderAction->updateOrientation(); sliderAction->updateOrientation();
connect(this, SIGNAL(dockWindowPositionChanged(QDockWindow *)), sliderAction, SLOT(updateOrientation(QDockWindow *))); connect(this, SIGNAL(dockWindowPositionChanged(QDockWindow *)), sliderAction, SLOT(updateOrientation(QDockWindow *)));
connect(splitter, SIGNAL(playlistChanged()), this, SLOT(playlistChanged()));
} }
void JuK::setupSystemTray() void JuK::setupSystemTray()
...@@ -405,6 +413,13 @@ void JuK::toggleSystemTray(bool enabled) ...@@ -405,6 +413,13 @@ void JuK::toggleSystemTray(bool enabled)
} }
} }
void JuK::setOutput(int output)
{
stopFile();
delete(player);
player = Player::createPlayer(output);
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// additional player slots // additional player slots
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
......
...@@ -82,6 +82,7 @@ private slots: ...@@ -82,6 +82,7 @@ private slots:
// settings menu // settings menu
void showGenreListEditor(); void showGenreListEditor();
void toggleSystemTray(bool enabled); void toggleSystemTray(bool enabled);
void setOutput(int output);
// additional player slots // additional player slots
void trackPositionSliderClick(); void trackPositionSliderClick();
...@@ -109,7 +110,6 @@ private slots: ...@@ -109,7 +110,6 @@ private slots:
void playSelectedFile() { playFile(splitter->playSelectedFile()); } void playSelectedFile() { playFile(splitter->playSelectedFile()); }
void playFirstFile() { playFile(splitter->playFirstFile()); } void playFirstFile() { playFile(splitter->playFirstFile()); }
private: private:
// layout objects // layout objects
PlaylistSplitter *splitter; PlaylistSplitter *splitter;
...@@ -122,6 +122,7 @@ private: ...@@ -122,6 +122,7 @@ private:
SliderAction *sliderAction; SliderAction *sliderAction;
KToggleAction *randomPlayAction; KToggleAction *randomPlayAction;
KToggleAction *toggleSystemTrayAction; KToggleAction *toggleSystemTrayAction;
KSelectAction *outputSelectAction;
KAction *playAction; KAction *playAction;
KAction *pauseAction; KAction *pauseAction;
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
<Action name="showGenreListEditor"/> <Action name="showGenreListEditor"/>
<Action name="restoreOnLoad"/> <Action name="restoreOnLoad"/>
<Action name="toggleSystemTray"/> <Action name="toggleSystemTray"/>
<Action name="outputSelect"/>
</Menu> </Menu>
</MenuBar> </MenuBar>
......
...@@ -15,28 +15,50 @@ ...@@ -15,28 +15,50 @@
* * * *
***************************************************************************/ ***************************************************************************/
#include <kaction.h>
#include <klocale.h>
#include "player.h" #include "player.h"
#include "artsplayer.h" #include "artsplayer.h"
#include "gstreamerplayer.h" #include "gstreamerplayer.h"
#include "../config.h" #include "../config.h"
Player *Player::createPlayer(SoundSystem s) /*
* The goal here is to contain all of the #if'ed ugliness in this file.
*/
Player *Player::createPlayer(int system)
{ {
Player *p = 0; Player *p = 0;
#if HAVE_GSTREAMER #if HAVE_GSTREAMER
switch(system) {
if(s == Arts) case Arts:
p = new ArtsPlayer(); p = new ArtsPlayer();
else if(s == GStreamer) break;
case GStreamer:
p = new GStreamerPlayer(); p = new GStreamerPlayer();
break;
}
#else #else
Q_UNUSED(s);
p = new ArtsPlayer(); p = new ArtsPlayer();
#endif #endif
return p; return p;
} }
KSelectAction *Player::playerSelectAction(QObject *parent)
{
KSelectAction *action = 0;
#if HAVE_GSTREAMER
action = new KSelectAction(i18n("Ouput To"), 0, parent, "outputSelect");
QStringList l;
l << "aRts" << "GStreamer";
action->setItems(l);
#else
Q_UNUSED(parent);
#endif
return action;
}
...@@ -22,13 +22,15 @@ ...@@ -22,13 +22,15 @@
* Just an interface for concrete player implementations * Just an interface for concrete player implementations
*/ */
class QObject;
class QString; class QString;
class KSelectAction;
class Player class Player
{ {
public: public:
enum SoundSystem { Arts, GStreamer }; enum SoundSystem { Arts = 0, GStreamer = 1 };
virtual ~Player() {} virtual ~Player() {}
...@@ -51,10 +53,10 @@ public: ...@@ -51,10 +53,10 @@ public:
virtual void seekPosition(int position) = 0; virtual void seekPosition(int position) = 0;
/** /**
* Returns a pointer to a Player object. * Returns a pointer to a Player object. The user is responcible
*/ */
static Player *createPlayer(int system = Arts);
static Player *createPlayer(SoundSystem s = Arts); static KSelectAction *playerSelectAction(QObject *parent);
protected: protected:
Player() {} Player() {}
......
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