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
readSettings();
setupLayout();
setupActions();
setupPlayer();
readConfig();
setupPlayer();
setupSystemTray();
processArgs();
......@@ -98,7 +98,7 @@ 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");
savePlaylistAction = KStdAction::save(splitter, SLOT(savePlaylist()), actionCollection());
saveAsPlaylistAction = KStdAction::saveAs(splitter, SLOT(saveAsPlaylist()), actionCollection());
deleteItemPlaylistAction = new KAction(i18n("Delete"), "editdelete", 0, splitter, SLOT(deleteItemPlaylist()),
......@@ -131,12 +131,18 @@ void JuK::setupActions()
// settings menu
restoreOnLoadAction = new KToggleAction(i18n("Restore Playlists on Load"), 0, actionCollection(), "restoreOnLoad");
toggleSystemTrayAction = new KToggleAction(i18n("Dock in System Tray"), 0, actionCollection(), "toggleSystemTray");
connect(toggleSystemTrayAction, SIGNAL(toggled(bool)), this, SLOT(toggleSystemTray(bool)));
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
sliderAction = new SliderAction(i18n("Track Position"), actionCollection(), "trackPositionAction");
......@@ -146,6 +152,8 @@ void JuK::setupActions()
// set the slider to the proper orientation and make it stay that way
sliderAction->updateOrientation();
connect(this, SIGNAL(dockWindowPositionChanged(QDockWindow *)), sliderAction, SLOT(updateOrientation(QDockWindow *)));
connect(splitter, SIGNAL(playlistChanged()), this, SLOT(playlistChanged()));
}
void JuK::setupSystemTray()
......@@ -405,6 +413,13 @@ void JuK::toggleSystemTray(bool enabled)
}
}
void JuK::setOutput(int output)
{
stopFile();
delete(player);
player = Player::createPlayer(output);
}
////////////////////////////////////////////////////////////////////////////////
// additional player slots
////////////////////////////////////////////////////////////////////////////////
......
......@@ -82,6 +82,7 @@ private slots:
// settings menu
void showGenreListEditor();
void toggleSystemTray(bool enabled);
void setOutput(int output);
// additional player slots
void trackPositionSliderClick();
......@@ -109,7 +110,6 @@ private slots:
void playSelectedFile() { playFile(splitter->playSelectedFile()); }
void playFirstFile() { playFile(splitter->playFirstFile()); }
private:
// layout objects
PlaylistSplitter *splitter;
......@@ -122,6 +122,7 @@ private:
SliderAction *sliderAction;
KToggleAction *randomPlayAction;
KToggleAction *toggleSystemTrayAction;
KSelectAction *outputSelectAction;
KAction *playAction;
KAction *pauseAction;
......
......@@ -47,6 +47,7 @@
<Action name="showGenreListEditor"/>
<Action name="restoreOnLoad"/>
<Action name="toggleSystemTray"/>
<Action name="outputSelect"/>
</Menu>
</MenuBar>
......
......@@ -15,28 +15,50 @@
* *
***************************************************************************/
#include <kaction.h>
#include <klocale.h>
#include "player.h"
#include "artsplayer.h"
#include "gstreamerplayer.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;
#if HAVE_GSTREAMER
if(s == Arts)
switch(system) {
case Arts:
p = new ArtsPlayer();
else if(s == GStreamer)
break;
case GStreamer:
p = new GStreamerPlayer();
break;
}
#else
Q_UNUSED(s);
p = new ArtsPlayer();
#endif
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 @@
* Just an interface for concrete player implementations
*/
class QObject;
class QString;
class KSelectAction;
class Player
{
public:
enum SoundSystem { Arts, GStreamer };
enum SoundSystem { Arts = 0, GStreamer = 1 };
virtual ~Player() {}
......@@ -51,10 +53,10 @@ public:
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(SoundSystem s = Arts);
static Player *createPlayer(int system = Arts);
static KSelectAction *playerSelectAction(QObject *parent);
protected:
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