Added a DCOP interface that can be used to go to the next/prev song,

change the volume, seek, pause, etc.

svn path=/trunk/kdemultimedia/juk/; revision=216604
parent 4185aa27
...@@ -9,7 +9,7 @@ juk_SOURCES = directorylistbase.ui genrelisteditorbase.ui \ ...@@ -9,7 +9,7 @@ juk_SOURCES = directorylistbase.ui genrelisteditorbase.ui \
playlistbox.cpp tageditor.cpp cache.cpp genrelistreader.cpp \ playlistbox.cpp tageditor.cpp cache.cpp genrelistreader.cpp \
genrelistlist.cpp genrelist.cpp genre.cpp player.cpp tag.cpp customaction.cpp \ genrelistlist.cpp genrelist.cpp genre.cpp player.cpp tag.cpp customaction.cpp \
slideraction.cpp keydialog.cpp juk.cpp main.cpp tagguesser.cpp \ slideraction.cpp keydialog.cpp juk.cpp main.cpp tagguesser.cpp \
tagguesserconfigdlgwidget.ui tagguesserconfigdlg.cpp tagguesserconfigdlgwidget.ui tagguesserconfigdlg.cpp jukIface.skel
tagguessertest_SOURCES = tagguessertest.cpp tagguesser.cpp tagguessertest_SOURCES = tagguessertest.cpp tagguesser.cpp
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
JuK::JuK(QWidget *parent, const char *name) : KMainWindow(parent, name, WDestructiveClose), JuK::JuK(QWidget *parent, const char *name) : KMainWindow(parent, name, WDestructiveClose),
DCOPObject ( "Player" ),
m_shuttingDown(false) m_shuttingDown(false)
{ {
// Expect segfaults if you change this order. // Expect segfaults if you change this order.
...@@ -86,7 +87,7 @@ void JuK::setupLayout() ...@@ -86,7 +87,7 @@ void JuK::setupLayout()
// playlist item activation connection // playlist item activation connection
connect(m_splitter, SIGNAL(signalDoubleClicked()), this, SLOT(slotPlaySelectedFile())); connect(m_splitter, SIGNAL(signalDoubleClicked()), this, SLOT(slotPlaySelectedFile()));
connect(m_splitter, SIGNAL(signalListBoxDoubleClicked()), this, SLOT(slotPlayFirstFile())); connect(m_splitter, SIGNAL(signalListBoxDoubleClicked()), this, SLOT(playFirstFile()));
// create status bar // create status bar
m_statusLabel = new StatusLabel(statusBar()); m_statusLabel = new StatusLabel(statusBar());
...@@ -133,11 +134,11 @@ void JuK::setupActions() ...@@ -133,11 +134,11 @@ void JuK::setupActions()
// play menu // play menu
m_randomPlayAction = new KToggleAction(i18n("&Random Play"), 0, actionCollection(), "randomPlay"); m_randomPlayAction = new KToggleAction(i18n("&Random Play"), 0, actionCollection(), "randomPlay");
m_playAction = new KAction(i18n("&Play"), "player_play", 0, this, SLOT(slotPlay()), actionCollection(), "play"); m_playAction = new KAction(i18n("&Play"), "player_play", 0, this, SLOT(play()), actionCollection(), "play");
m_pauseAction = new KAction(i18n("P&ause"), "player_pause", 0, this, SLOT(slotPause()), actionCollection(), "pause"); m_pauseAction = new KAction(i18n("P&ause"), "player_pause", 0, this, SLOT(pause()), actionCollection(), "pause");
m_stopAction = new KAction(i18n("&Stop"), "player_stop", 0, this, SLOT(slotStop()), actionCollection(), "stop"); m_stopAction = new KAction(i18n("&Stop"), "player_stop", 0, this, SLOT(stop()), actionCollection(), "stop");
m_backAction = new KAction(i18n("Skip &Back"), "player_start", 0, this, SLOT(slotBack()), actionCollection(), "back"); m_backAction = new KAction(i18n("Skip &Back"), "player_start", 0, this, SLOT(back()), actionCollection(), "back");
m_forwardAction = new KAction(i18n("Skip &Forward"), "player_end", 0, this, SLOT(slotForward()), actionCollection(), "forward"); m_forwardAction = new KAction(i18n("Skip &Forward"), "player_end", 0, this, SLOT(forward()), actionCollection(), "forward");
m_loopPlaylistAction = new KToggleAction(i18n("&Loop Playlist"), "reload", 0, actionCollection(), "loopPlaylist"); m_loopPlaylistAction = new KToggleAction(i18n("&Loop Playlist"), "reload", 0, actionCollection(), "loopPlaylist");
// tagger menu // tagger menu
...@@ -226,7 +227,7 @@ void JuK::setupPlayer() ...@@ -226,7 +227,7 @@ void JuK::setupPlayer()
connect(m_sliderAction->getTrackPositionSlider(), SIGNAL(sliderReleased()), this, SLOT(slotTrackPositionSliderReleased())); connect(m_sliderAction->getTrackPositionSlider(), SIGNAL(sliderReleased()), this, SLOT(slotTrackPositionSliderReleased()));
m_sliderAction->getTrackPositionSlider()->setEnabled(false); m_sliderAction->getTrackPositionSlider()->setEnabled(false);
connect(m_sliderAction->getVolumeSlider(), SIGNAL(valueChanged(int)), this, SLOT(slotSetVolume(int))); connect(m_sliderAction->getVolumeSlider(), SIGNAL(valueChanged(int)), this, SLOT(setVolume(int)));
} }
int playerType = 0; int playerType = 0;
...@@ -242,15 +243,15 @@ void JuK::setupPlayer() ...@@ -242,15 +243,15 @@ void JuK::setupPlayer()
void JuK::setupGlobalAccels() void JuK::setupGlobalAccels()
{ {
m_accel = new KGlobalAccel(this); m_accel = new KGlobalAccel(this);
KeyDialog::insert(m_accel, "PlayPause", i18n("Play/Pause"), this, SLOT(slotPlayPause())); KeyDialog::insert(m_accel, "PlayPause", i18n("Play/Pause"), this, SLOT(playPause()));
KeyDialog::insert(m_accel, "Stop", i18n("Stop Playing"), this, SLOT(slotStop())); KeyDialog::insert(m_accel, "Stop", i18n("Stop Playing"), this, SLOT(stop()));
KeyDialog::insert(m_accel, "Back", i18n("Back"), this, SLOT(slotBack())); KeyDialog::insert(m_accel, "Back", i18n("Back"), this, SLOT(back()));
KeyDialog::insert(m_accel, "Forward", i18n("Forward"), this, SLOT(slotForward())); KeyDialog::insert(m_accel, "Forward", i18n("Forward"), this, SLOT(forward()));
KeyDialog::insert(m_accel, "SeekBack", i18n("Seek Back"), this, SLOT(slotSeekBack())); KeyDialog::insert(m_accel, "SeekBack", i18n("Seek Back"), this, SLOT(seekBack()));
KeyDialog::insert(m_accel, "SeekForward",i18n("Seek Forward"), this, SLOT(slotSeekForward())); KeyDialog::insert(m_accel, "SeekForward",i18n("Seek Forward"), this, SLOT(seekForward()));
KeyDialog::insert(m_accel, "VolumeUp", i18n("Volume Up"), this, SLOT(slotVolumeUp())); KeyDialog::insert(m_accel, "VolumeUp", i18n("Volume Up"), this, SLOT(volumeUp()));
KeyDialog::insert(m_accel, "VolumeDown", i18n("Volume Down"), this, SLOT(slotVolumeDown())); KeyDialog::insert(m_accel, "VolumeDown", i18n("Volume Down"), this, SLOT(volumeDown()));
KeyDialog::insert(m_accel, "Mute", i18n("Mute"), this, SLOT(slotVolumeMute())); KeyDialog::insert(m_accel, "Mute", i18n("Mute"), this, SLOT(volumeMute()));
m_accel->setConfigGroup("Shortcuts"); m_accel->setConfigGroup("Shortcuts");
m_accel->readSettings(); m_accel->readSettings();
...@@ -364,7 +365,7 @@ void JuK::saveConfig() ...@@ -364,7 +365,7 @@ void JuK::saveConfig()
bool JuK::queryExit() bool JuK::queryExit()
{ {
slotStop(); stop();
delete m_player; delete m_player;
Cache::instance()->save(); Cache::instance()->save();
saveConfig(); saveConfig();
...@@ -454,7 +455,7 @@ void JuK::play(const QString &file) ...@@ -454,7 +455,7 @@ void JuK::play(const QString &file)
m_systemTray->slotPlay(); m_systemTray->slotPlay();
} }
else else
slotStop(); stop();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
...@@ -512,7 +513,7 @@ void JuK::selectAll() ...@@ -512,7 +513,7 @@ void JuK::selectAll()
// player menu // player menu
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void JuK::slotPlay() void JuK::play()
{ {
if(!m_player) if(!m_player)
return; return;
...@@ -537,7 +538,7 @@ void JuK::slotPlay() ...@@ -537,7 +538,7 @@ void JuK::slotPlay()
play(m_splitter->playNextFile(m_randomPlayAction->isChecked(), m_loopPlaylistAction->isChecked())); play(m_splitter->playNextFile(m_randomPlayAction->isChecked(), m_loopPlaylistAction->isChecked()));
} }
void JuK::slotPause() void JuK::pause()
{ {
if(!m_player) if(!m_player)
return; return;
...@@ -549,7 +550,7 @@ void JuK::slotPause() ...@@ -549,7 +550,7 @@ void JuK::slotPause()
m_systemTray->slotPause(); m_systemTray->slotPause();
} }
void JuK::slotStop() void JuK::stop()
{ {
if(!m_player) if(!m_player)
return; return;
...@@ -573,24 +574,24 @@ void JuK::slotStop() ...@@ -573,24 +574,24 @@ void JuK::slotStop()
m_systemTray->slotStop(); m_systemTray->slotStop();
} }
void JuK::slotBack() void JuK::back()
{ {
play(m_splitter->playPreviousFile(m_randomPlayAction->isChecked())); play(m_splitter->playPreviousFile(m_randomPlayAction->isChecked()));
} }
void JuK::slotForward() void JuK::forward()
{ {
play(m_splitter->playNextFile(m_randomPlayAction->isChecked(), m_loopPlaylistAction->isChecked())); play(m_splitter->playNextFile(m_randomPlayAction->isChecked(), m_loopPlaylistAction->isChecked()));
} }
void JuK::slotSeekBack() void JuK::seekBack()
{ {
int position = m_sliderAction->getTrackPositionSlider()->value(); int position = m_sliderAction->getTrackPositionSlider()->value();
position = QMAX(m_sliderAction->getTrackPositionSlider()->minValue(), position - 10); position = QMAX(m_sliderAction->getTrackPositionSlider()->minValue(), position - 10);
emit m_sliderAction->getTrackPositionSlider()->setValue(position); emit m_sliderAction->getTrackPositionSlider()->setValue(position);
} }
void JuK::slotSeekForward() void JuK::seekForward()
{ {
int position = m_sliderAction->getTrackPositionSlider()->value(); int position = m_sliderAction->getTrackPositionSlider()->value();
position = QMIN(m_sliderAction->getTrackPositionSlider()->maxValue(), position + 10); position = QMIN(m_sliderAction->getTrackPositionSlider()->maxValue(), position + 10);
...@@ -620,7 +621,7 @@ void JuK::slotToggleSystemTray(bool enabled) ...@@ -620,7 +621,7 @@ void JuK::slotToggleSystemTray(bool enabled)
void JuK::slotSetOutput(int output) void JuK::slotSetOutput(int output)
{ {
slotStop(); stop();
delete m_player; delete m_player;
m_player = Player::createPlayer(output); m_player = Player::createPlayer(output);
} }
...@@ -657,45 +658,45 @@ void JuK::slotTrackPositionSliderUpdate(int position) ...@@ -657,45 +658,45 @@ void JuK::slotTrackPositionSliderUpdate(int position)
m_player->seekPosition(position); m_player->seekPosition(position);
} }
void JuK::slotPlayPause() void JuK::playPause()
{ {
if(!m_player) if(!m_player)
return; return;
if(m_player->playing()) if(m_player->playing())
slotPause(); pause();
else else
slotPlay(); play();
} }
void JuK::slotVolumeUp() void JuK::volumeUp()
{ {
if(m_sliderAction && m_sliderAction->getVolumeSlider()) { if(m_sliderAction && m_sliderAction->getVolumeSlider()) {
int volume = m_sliderAction->getVolumeSlider()->value() + int volume = m_sliderAction->getVolumeSlider()->value() +
m_sliderAction->getVolumeSlider()->maxValue() / 25; // 4% up m_sliderAction->getVolumeSlider()->maxValue() / 25; // 4% up
slotSetVolume(volume); setVolume(volume);
m_sliderAction->getVolumeSlider()->setValue(volume); m_sliderAction->getVolumeSlider()->setValue(volume);
} }
} }
void JuK::slotVolumeDown() void JuK::volumeDown()
{ {
if(m_sliderAction && m_sliderAction->getVolumeSlider()) { if(m_sliderAction && m_sliderAction->getVolumeSlider()) {
int volume = m_sliderAction->getVolumeSlider()->value() - int volume = m_sliderAction->getVolumeSlider()->value() -
m_sliderAction->getVolumeSlider()->maxValue() / 25; // 4% down m_sliderAction->getVolumeSlider()->maxValue() / 25; // 4% down
slotSetVolume(volume); setVolume(volume);
m_sliderAction->getVolumeSlider()->setValue(volume); m_sliderAction->getVolumeSlider()->setValue(volume);
} }
} }
void JuK::slotVolumeMute() void JuK::volumeMute()
{ {
if(m_sliderAction && m_sliderAction->getVolumeSlider()) { if(m_sliderAction && m_sliderAction->getVolumeSlider()) {
if(m_muted) if(m_muted)
slotSetVolume(m_sliderAction->getVolumeSlider()->value()); setVolume(m_sliderAction->getVolumeSlider()->value());
else else
slotSetVolume(0); setVolume(0);
m_muted = !m_muted; m_muted = !m_muted;
} }
} }
...@@ -733,7 +734,7 @@ void JuK::slotPollPlay() ...@@ -733,7 +734,7 @@ void JuK::slotPollPlay()
m_noSeek = false; m_noSeek = false;
} }
void JuK::slotSetVolume(int volume) void JuK::setVolume(int volume)
{ {
if(m_player && m_sliderAction && m_sliderAction->getVolumeSlider() && if(m_player && m_sliderAction && m_sliderAction->getVolumeSlider() &&
m_sliderAction->getVolumeSlider()->maxValue() > 0 && m_sliderAction->getVolumeSlider()->maxValue() > 0 &&
...@@ -749,4 +750,9 @@ void JuK::slotConfigureTagGuesser() ...@@ -749,4 +750,9 @@ void JuK::slotConfigureTagGuesser()
dlg.exec(); dlg.exec();
} }
void JuK::openFile(const QString &file)
{
m_splitter->open(file);
}
#include "juk.moc" #include "juk.moc"
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "player.h" #include "player.h"
#include "playlistsplitter.h" #include "playlistsplitter.h"
#include "jukIface.h"
class QTimer; class QTimer;
class QListViewItem; class QListViewItem;
...@@ -40,7 +41,7 @@ class SliderAction; ...@@ -40,7 +41,7 @@ class SliderAction;
class StatusLabel; class StatusLabel;
class SystemTray; class SystemTray;
class JuK : public KMainWindow class JuK : public KMainWindow, virtual public JuKIface
{ {
Q_OBJECT Q_OBJECT
...@@ -85,6 +86,8 @@ private: ...@@ -85,6 +86,8 @@ private:
*/ */
void play(const QString &file); void play(const QString &file);
void openFile(const QString &file);
private slots: private slots:
void slotPlaylistChanged(); void slotPlaylistChanged();
...@@ -99,13 +102,13 @@ private slots: ...@@ -99,13 +102,13 @@ private slots:
void selectAll(); void selectAll();
// player menu // player menu
void slotPlay(); void play();
void slotPause(); void pause();
void slotStop(); void stop();
void slotBack(); void back();
void slotForward(); void forward();
void slotSeekBack(); void seekBack();
void slotSeekForward(); void seekForward();
// settings menu // settings menu
void slotShowGenreListEditor(); void slotShowGenreListEditor();
...@@ -118,10 +121,10 @@ private slots: ...@@ -118,10 +121,10 @@ private slots:
void slotTrackPositionSliderClicked(); void slotTrackPositionSliderClicked();
void slotTrackPositionSliderReleased(); void slotTrackPositionSliderReleased();
void slotTrackPositionSliderUpdate(int position); void slotTrackPositionSliderUpdate(int position);
void slotPlayPause(); void playPause();
void slotVolumeUp(); void volumeUp();
void slotVolumeDown(); void volumeDown();
void slotVolumeMute(); void volumeMute();
/** /**
* This method is called to check our progress in the playing file. It uses * This method is called to check our progress in the playing file. It uses
...@@ -133,10 +136,10 @@ private slots: ...@@ -133,10 +136,10 @@ private slots:
* This method is called by the slider to set the volume of the player. Its * This method is called by the slider to set the volume of the player. Its
* value is relative to the maxValue() of the volume slider. * value is relative to the maxValue() of the volume slider.
*/ */
void slotSetVolume(int volume); void setVolume(int volume);
void slotPlaySelectedFile() { play(m_splitter->playSelectedFile()); } void slotPlaySelectedFile() { play(m_splitter->playSelectedFile()); }
void slotPlayFirstFile() { play(m_splitter->playFirstFile()); } void playFirstFile() { play(m_splitter->playFirstFile()); }
void slotToggleMenuBar() { menuBar()->isVisible() ? menuBar()->hide() : menuBar()->show(); } void slotToggleMenuBar() { menuBar()->isVisible() ? menuBar()->hide() : menuBar()->show(); }
void slotToggleToolBar() { toolBar()->isVisible() ? toolBar()->hide() : toolBar()->show(); } void slotToggleToolBar() { toolBar()->isVisible() ? toolBar()->hide() : toolBar()->show(); }
......
#include <dcopobject.h>
class JuKIface : virtual public DCOPObject
{
K_DCOP
k_dcop:
virtual void openFile( const QString &s )=0;
virtual void play()=0;
virtual void pause()=0;
virtual void stop()=0;
virtual void playPause()=0;
virtual void back()=0;
virtual void forward()=0;
virtual void seekBack()=0;
virtual void seekForward()=0;
virtual void volumeUp()=0;
virtual void volumeDown()=0;
virtual void volumeMute()=0;
virtual void setVolume(int volume)=0;
virtual void playFirstFile()=0;
};
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