Commit 8cecd422 authored by Scott Wheeler's avatar Scott Wheeler

Hopefully the last in the big round of API cleanups.

All slots now start with slotFoo()
All signals now start with signalBar()
All member variable are prefixed with m_quux

svn path=/trunk/kdemultimedia/juk/; revision=209966
parent 34c906c5
......@@ -29,8 +29,8 @@ DirectoryList::DirectoryList(QStringList &directories, QWidget* parent, const ch
m_dirList(directories)
{
directoryListView->setFullWidth(true);
connect(addDirectoryButton, SIGNAL(clicked()), this, SLOT(addDirectory()));
connect(removeDirectoryButton, SIGNAL(clicked()), this, SLOT(removeDirectory()));
connect(addDirectoryButton, SIGNAL(clicked()), this, SLOT(slotAddDirectory()));
connect(removeDirectoryButton, SIGNAL(clicked()), this, SLOT(slotRemoveDirectory()));
for(QStringList::ConstIterator it = directories.begin(); it != directories.end(); ++it)
new KListViewItem(directoryListView, *it);
......@@ -45,24 +45,24 @@ DirectoryList::~DirectoryList()
// private slots
////////////////////////////////////////////////////////////////////////////////
void DirectoryList::addDirectory()
void DirectoryList::slotAddDirectory()
{
QString dir = KFileDialog::getExistingDirectory();
if(!dir.isEmpty() && m_dirList.find(dir) == m_dirList.end()) {
m_dirList.append(dir);
new KListViewItem(directoryListView, dir);
emit(directoryAdded(dir));
emit signalDirectoryAdded(dir);
}
}
void DirectoryList::removeDirectory()
void DirectoryList::slotRemoveDirectory()
{
if(!directoryListView->selectedItem())
return;
QString dir = directoryListView->selectedItem()->text(0);
m_dirList.remove(dir);
emit(directoryRemoved(dir));
emit signalDirectoryRemoved(dir);
delete directoryListView->selectedItem();
}
......
......@@ -31,12 +31,12 @@ public:
virtual ~DirectoryList();
signals:
void directoryAdded(const QString &directory);
void directoryRemoved(const QString &directory);
void signalDirectoryAdded(const QString &directory);
void signalDirectoryRemoved(const QString &directory);
private slots:
void addDirectory();
void removeDirectory();
void slotAddDirectory();
void slotRemoveDirectory();
private:
QStringList m_dirList;
......
......@@ -78,7 +78,7 @@ void GenreListEditor::updateGenreList()
// private slots
////////////////////////////////////////////////////////////////////////////////
void GenreListEditor::updateGenreBoxes(QListViewItem *item)
void GenreListEditor::slotUpdateGenreBoxes(QListViewItem *item)
{
if(item) {
genreNameBox->setText(item->text(0));
......@@ -86,7 +86,7 @@ void GenreListEditor::updateGenreBoxes(QListViewItem *item)
}
}
void GenreListEditor::updateGenreName(const QString &name)
void GenreListEditor::slotUpdateGenreName(const QString &name)
{
QListViewItem *current = genreList->currentItem();
if(!name.isEmpty() && current)
......
......@@ -38,8 +38,8 @@ private:
void updateGenreList();
private slots:
virtual void updateGenreBoxes(QListViewItem *item);
virtual void updateGenreName(const QString &name);
virtual void slotUpdateGenreBoxes(QListViewItem *item);
virtual void slotUpdateGenreName(const QString &name);
private:
QDict<GenreList> m_listDict;
......
......@@ -285,18 +285,18 @@
<sender>genreList</sender>
<signal>executed(QListViewItem*)</signal>
<receiver>listEditor</receiver>
<slot>updateGenreBoxes(QListViewItem*)</slot>
<slot>slotUpdateGenreBoxes(QListViewItem*)</slot>
</connection>
<connection>
<sender>genreNameBox</sender>
<signal>textChanged(const QString&amp;)</signal>
<receiver>listEditor</receiver>
<slot>updateGenreName(const QString&amp;)</slot>
<slot>slotUpdateGenreName(const QString&amp;)</slot>
</connection>
</connections>
<slots>
<slot access="protected" specifier="pure virtual">updateGenreBoxes(QListViewItem *)</slot>
<slot access="protected" specifier="pure virtual">updateGenreName(const QString &amp;name)</slot>
<slot access="protected" specifier="pure virtual">slotUpdateGenreBoxes(QListViewItem *)</slot>
<slot access="protected" specifier="pure virtual">slotUpdateGenreName(const QString &amp;name)</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
<includehints>
......
......@@ -35,12 +35,9 @@ using namespace QGstPlay;
// public methods
////////////////////////////////////////////////////////////////////////////////
GStreamerPlayer::GStreamerPlayer() : QObject(0), Player()
GStreamerPlayer::GStreamerPlayer() : QObject(0), Player(),
m_positionNs(0), m_durationNs(0), m_currentVolume(1.0)
{
m_currentVolume = 1.0;
positionNs = 0;
durationNs = 0;
setupPlayer();
}
......@@ -61,8 +58,8 @@ void GStreamerPlayer::play(const QString &fileName, float volume)
void GStreamerPlayer::play(float volume)
{
// 1.0 is full volume
positionNs = 0;
durationNs = 0;
m_positionNs = 0;
m_durationNs = 0;
if (m_player->getState() != Element::STATE_PLAYING) {
m_player->setState(Element::STATE_PLAYING);
m_player->setVolume(volume);
......@@ -112,18 +109,18 @@ bool GStreamerPlayer::paused() const
long GStreamerPlayer::totalTime() const
{
return durationNs / 1000000000L;
return m_durationNs / 1000000000L;
}
long GStreamerPlayer::currentTime() const
{
return positionNs / 1000000000L;
return m_positionNs / 1000000000L;
}
int GStreamerPlayer::position() const
{
if (durationNs > 0)
return (int)((positionNs * 1000.0) / durationNs);
if (m_durationNs > 0)
return (int)((m_positionNs * 1000.0) / m_durationNs);
else
return 0;
}
......@@ -141,8 +138,8 @@ void GStreamerPlayer::seek(long seekTime)
void GStreamerPlayer::seekPosition(int position)
{
// position unit is 1/1000th
if(durationNs > 0)
m_player->seekToTime(position * durationNs / 1000L);
if(m_durationNs > 0)
m_player->seekToTime(position * m_durationNs / 1000L);
else
m_player->seekToTime(0);
......@@ -152,23 +149,13 @@ void GStreamerPlayer::seekPosition(int position)
// private
/////////////////////////////////////////////////////////////////////////////////
void GStreamerPlayer::setDuration(long long d)
{
durationNs = d;
}
void GStreamerPlayer::setPosition(long long d)
{
positionNs = d;
}
void GStreamerPlayer::setupPlayer()
{
m_player = new Play(Play::PIPE_AUDIO_BUFFER_THREADED, this, "Play");
connect(m_player, SIGNAL(timeTick(long long)),
SLOT(setPosition(long long)));
SLOT(slotSetPosition(long long)));
connect(m_player, SIGNAL(streamLength(long long)),
SLOT(setDuration(long long)));
SLOT(slotSetDuration(long long)));
connect(m_player, SIGNAL(streamEnd()), SLOT(stop()));
}
......
......@@ -59,17 +59,17 @@ public slots:
void stop();
private slots:
void setPosition(long long d);
void setDuration(long long d);
void slotSetPosition(long long d) { m_positionNs = d; }
void slotSetDuration(long long d) { m_durationNs = d; }
private:
void setupPlayer();
QGstPlay::Play *m_player;
unsigned long long duration;
unsigned long long m_duration;
long long positionNs; // in ns
long long durationNs; // in ns
long long m_positionNs; // in ns
long long m_durationNs; // in ns
QString m_currentFile;
float m_currentVolume;
......
......@@ -52,7 +52,7 @@ JuK::JuK(QWidget *parent, const char *name) : KMainWindow(parent, name, WDestruc
readSettings();
setupLayout();
setupActions();
playlistChanged();
slotPlaylistChanged();
readConfig();
setupPlayer();
setupSystemTray();
......@@ -76,8 +76,8 @@ void JuK::setupLayout()
setCentralWidget(m_splitter);
// playlist item activation connection
connect(m_splitter, SIGNAL(signalDoubleClicked()), this, SLOT(playSelectedFile()));
connect(m_splitter, SIGNAL(signalListBoxDoubleClicked()), this, SLOT(playFirstFile()));
connect(m_splitter, SIGNAL(signalDoubleClicked()), this, SLOT(slotPlaySelectedFile()));
connect(m_splitter, SIGNAL(signalListBoxDoubleClicked()), this, SLOT(slotPlayFirstFile()));
// create status bar
m_statusLabel = new StatusLabel(statusBar());
......@@ -124,11 +124,11 @@ void JuK::setupActions()
// play menu
m_randomPlayAction = new KToggleAction(i18n("Random Play"), 0, actionCollection(), "randomPlay");
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(pause()), actionCollection(), "pause");
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(back()), actionCollection(), "back");
m_forwardAction = new KAction(i18n("Skip &Forward"), "player_end", 0, this, SLOT(forward()), actionCollection(), "forward");
m_playAction = new KAction(i18n("&Play"), "player_play", 0, this, SLOT(slotPlay()), actionCollection(), "play");
m_pauseAction = new KAction(i18n("P&ause"), "player_pause", 0, this, SLOT(slotPause()), actionCollection(), "pause");
m_stopAction = new KAction(i18n("&Stop"), "player_stop", 0, this, SLOT(slotStop()), actionCollection(), "stop");
m_backAction = new KAction(i18n("Skip &Back"), "player_start", 0, this, SLOT(slotBack()), actionCollection(), "back");
m_forwardAction = new KAction(i18n("Skip &Forward"), "player_end", 0, this, SLOT(slotForward()), actionCollection(), "forward");
// tagger menu
new KAction(i18n("Save"), "filesave", "CTRL+t", m_splitter, SLOT(slotSaveTag()), actionCollection(), "saveItem");
......@@ -142,15 +142,15 @@ void JuK::setupActions()
m_restoreOnLoadAction = new KToggleAction(i18n("Restore Playlists on Load"), 0, actionCollection(), "restoreOnLoad");
m_toggleSystemTrayAction = new KToggleAction(i18n("Dock in System Tray"), 0, actionCollection(), "toggleSystemTray");
connect(m_toggleSystemTrayAction, SIGNAL(toggled(bool)), this, SLOT(toggleSystemTray(bool)));
connect(m_toggleSystemTrayAction, SIGNAL(toggled(bool)), this, SLOT(slotToggleSystemTray(bool)));
new KAction(i18n("Genre List Editor..."), 0, this, SLOT(showGenreListEditor()), actionCollection(), "showGenreListEditor");
new KAction(i18n("Genre List Editor..."), 0, this, SLOT(slotShowGenreListEditor()), actionCollection(), "showGenreListEditor");
m_outputSelectAction = Player::playerSelectAction(actionCollection());
if(m_outputSelectAction) {
m_outputSelectAction->setCurrentItem(0);
connect(m_outputSelectAction, SIGNAL(activated(int)), this, SLOT(setOutput(int)));
connect(m_outputSelectAction, SIGNAL(activated(int)), this, SLOT(slotSetOutput(int)));
}
// just in the toolbar
......@@ -159,10 +159,10 @@ void JuK::setupActions()
createGUI();
// set the slider to the proper orientation and make it stay that way
m_sliderAction->updateOrientation();
connect(this, SIGNAL(dockWindowPositionChanged(QDockWindow *)), m_sliderAction, SLOT(updateOrientation(QDockWindow *)));
m_sliderAction->slotUpdateOrientation();
connect(this, SIGNAL(dockWindowPositionChanged(QDockWindow *)), m_sliderAction, SLOT(slotUpdateOrientation(QDockWindow *)));
connect(m_splitter, SIGNAL(signalPlaylistChanged()), this, SLOT(playlistChanged()));
connect(m_splitter, SIGNAL(signalPlaylistChanged()), this, SLOT(slotPlaylistChanged()));
}
void JuK::setupSystemTray()
......@@ -171,13 +171,13 @@ void JuK::setupSystemTray()
m_systemTray = new SystemTray(this, "systemTray");
m_systemTray->show();
connect(m_systemTray, SIGNAL(play()), this, SLOT(play()));
connect(m_systemTray, SIGNAL(stop()), this, SLOT(stop()));
connect(m_systemTray, SIGNAL(pause()), this, SLOT(pause()));
connect(m_systemTray, SIGNAL(back()), this, SLOT(back()));
connect(m_systemTray, SIGNAL(forward()), this, SLOT(forward()));
connect(m_systemTray, SIGNAL(signalPlay()), this, SLOT(slotPlay()));
connect(m_systemTray, SIGNAL(signalStop()), this, SLOT(slotStop()));
connect(m_systemTray, SIGNAL(signalPause()), this, SLOT(slotPause()));
connect(m_systemTray, SIGNAL(signalBack()), this, SLOT(slotBack()));
connect(m_systemTray, SIGNAL(signalForward()), this, SLOT(slotForward()));
connect(this, SIGNAL(newSongSignal(const QString&)), m_systemTray, SLOT(slotNewSong(const QString&)));
connect(this, SIGNAL(signalNewSong(const QString&)), m_systemTray, SLOT(slotNewSong(const QString&)));
if(m_player && m_player->paused())
m_systemTray->slotPause();
......@@ -198,21 +198,21 @@ void JuK::setupPlayer()
m_forwardAction->setEnabled(false);
m_playTimer = new QTimer(this);
connect(m_playTimer, SIGNAL(timeout()), this, SLOT(pollPlay()));
connect(m_playTimer, SIGNAL(timeout()), this, SLOT(slotPollPlay()));
if(m_sliderAction && m_sliderAction->getTrackPositionSlider() && m_sliderAction->getVolumeSlider()) {
connect(m_sliderAction->getTrackPositionSlider(), SIGNAL(valueChanged(int)), this, SLOT(trackPositionSliderUpdate(int)));
connect(m_sliderAction->getTrackPositionSlider(), SIGNAL(sliderPressed()), this, SLOT(trackPositionSliderClick()));
connect(m_sliderAction->getTrackPositionSlider(), SIGNAL(sliderReleased()), this, SLOT(trackPositionSliderRelease()));
connect(m_sliderAction->getTrackPositionSlider(), SIGNAL(valueChanged(int)), this, SLOT(slotTrackPositionSliderUpdate(int)));
connect(m_sliderAction->getTrackPositionSlider(), SIGNAL(sliderPressed()), this, SLOT(slotTrackPositionSliderClicked()));
connect(m_sliderAction->getTrackPositionSlider(), SIGNAL(sliderReleased()), this, SLOT(slotTrackPositionSliderReleased()));
m_sliderAction->getTrackPositionSlider()->setEnabled(false);
connect(m_sliderAction->getVolumeSlider(), SIGNAL(valueChanged(int)), this, SLOT(setVolume(int)));
connect(m_sliderAction->getVolumeSlider(), SIGNAL(valueChanged(int)), this, SLOT(slotSetVolume(int)));
}
int playerType = 0;
if(m_outputSelectAction) {
playerType = m_outputSelectAction->currentItem();
connect(m_outputSelectAction, SIGNAL(activated(int)), this, SLOT(setOutput(int)));
connect(m_outputSelectAction, SIGNAL(activated(int)), this, SLOT(slotSetOutput(int)));
}
m_player = Player::createPlayer(playerType);
......@@ -308,7 +308,7 @@ void JuK::saveConfig()
bool JuK::queryClose()
{
stop();
slotStop();
delete m_player;
Cache::instance()->save();
saveConfig();
......@@ -329,9 +329,9 @@ void JuK::invokeEditSlot( const char *slotName, const char *slot )
if(l.find(slotName) == -1)
return;
connect(this, SIGNAL( editSignal() ), object, slot);
emit editSignal();
disconnect(this, SIGNAL(editSignal()), object, slot);
connect(this, SIGNAL(signalEdit()), object, slot);
emit signalEdit();
disconnect(this, SIGNAL(signalEdit()), object, slot);
}
QString JuK::playingString() const
......@@ -346,11 +346,52 @@ QString JuK::playingString() const
return s;
}
void JuK::updatePlaylistInfo()
{
m_statusLabel->setPlaylistInfo(m_splitter->selectedPlaylistName(), m_splitter->selectedPlaylistCount());
}
void JuK::play(const QString &file)
{
if(!m_player)
return;
float volume = float(m_sliderAction->getVolumeSlider()->value()) / float(m_sliderAction->getVolumeSlider()->maxValue());
if(m_player->paused())
m_player->stop();
m_player->play(file, volume);
// Make sure that the m_player actually starts before doing anything.
if(m_player->playing()) {
m_pauseAction->setEnabled(true);
m_stopAction->setEnabled(true);
m_backAction->setEnabled(true);
m_forwardAction->setEnabled(true);
m_sliderAction->getTrackPositionSlider()->setValue(0);
m_sliderAction->getTrackPositionSlider()->setEnabled(true);
m_playTimer->start(m_pollInterval);
m_statusLabel->setPlayingItemInfo(playingString(), m_splitter->playingList());
emit signalNewSong(playingString());
if(m_systemTray)
m_systemTray->slotPlay();
}
else
slotStop();
}
////////////////////////////////////////////////////////////////////////////////
// private slot definitions
////////////////////////////////////////////////////////////////////////////////
void JuK::playlistChanged()
void JuK::slotPlaylistChanged()
{
if(m_splitter->collectionListSelected()) {
m_savePlaylistAction->setEnabled(false);
......@@ -368,11 +409,6 @@ void JuK::playlistChanged()
updatePlaylistInfo();
}
void JuK::updatePlaylistInfo()
{
m_statusLabel->setPlaylistInfo(m_splitter->selectedPlaylistName(), m_splitter->selectedPlaylistCount());
}
////////////////////////////////////////////////////////////////////////////////
// edit menu
////////////////////////////////////////////////////////////////////////////////
......@@ -403,10 +439,10 @@ void JuK::selectAll()
}
////////////////////////////////////////////////////////////////////////////////
// m_player menu
// player menu
////////////////////////////////////////////////////////////////////////////////
void JuK::play()
void JuK::slotPlay()
{
if(!m_player)
return;
......@@ -420,7 +456,7 @@ void JuK::play()
if(m_player->playing()) {
m_pauseAction->setEnabled(true);
m_stopAction->setEnabled(true);
m_playTimer->start(pollInterval);
m_playTimer->start(m_pollInterval);
if(m_systemTray)
m_systemTray->slotPlay();
}
......@@ -431,7 +467,7 @@ void JuK::play()
play(m_splitter->playNextFile(m_randomPlayAction->isChecked()));
}
void JuK::pause()
void JuK::slotPause()
{
if(!m_player)
return;
......@@ -443,7 +479,7 @@ void JuK::pause()
m_systemTray->slotPause();
}
void JuK::stop()
void JuK::slotStop()
{
if(!m_player)
return;
......@@ -467,12 +503,12 @@ void JuK::stop()
m_systemTray->slotStop();
}
void JuK::back()
void JuK::slotBack()
{
play(m_splitter->playPreviousFile(m_randomPlayAction->isChecked()));
}
void JuK::forward()
void JuK::slotForward()
{
play(m_splitter->playNextFile(m_randomPlayAction->isChecked()));
}
......@@ -481,13 +517,13 @@ void JuK::forward()
// settings menu
////////////////////////////////////////////////////////////////////////////////
void JuK::showGenreListEditor()
void JuK::slotShowGenreListEditor()
{
GenreListEditor * editor = new GenreListEditor();
editor->exec();
}
void JuK::toggleSystemTray(bool enabled)
void JuK::slotToggleSystemTray(bool enabled)
{
if(enabled && !m_systemTray)
setupSystemTray();
......@@ -497,23 +533,23 @@ void JuK::toggleSystemTray(bool enabled)
}
}
void JuK::setOutput(int output)
void JuK::slotSetOutput(int output)
{
stop();
slotStop();
delete m_player;
m_player = Player::createPlayer(output);
}
////////////////////////////////////////////////////////////////////////////////
// additional m_player slots
// additional player slots
////////////////////////////////////////////////////////////////////////////////
void JuK::trackPositionSliderClick()
void JuK::slotTrackPositionSliderClicked()
{
m_trackPositionDragging = true;
}
void JuK::trackPositionSliderRelease()
void JuK::slotTrackPositionSliderReleased()
{
if(!m_player)
return;
......@@ -522,7 +558,7 @@ void JuK::trackPositionSliderRelease()
m_player->seekPosition(m_sliderAction->getTrackPositionSlider()->value());
}
void JuK::trackPositionSliderUpdate(int position)
void JuK::slotTrackPositionSliderUpdate(int position)
{
if(!m_player)
return;
......@@ -533,7 +569,7 @@ void JuK::trackPositionSliderUpdate(int position)
// This method is called when the play timer has expired.
void JuK::pollPlay()
void JuK::slotPollPlay()
{
if(!m_player)
return;
......@@ -561,13 +597,13 @@ void JuK::pollPlay()
// last interval, we want to check a lot -- to figure out that we've hit the
// end of the song as soon as possible.
if(m_player->playing() && m_player->totalTime() > 0 && float(m_player->totalTime() - m_player->currentTime()) < pollInterval * 2)
if(m_player->playing() && m_player->totalTime() > 0 && float(m_player->totalTime() - m_player->currentTime()) < m_pollInterval * 2)
m_playTimer->changeInterval(50);
m_noSeek = false;
}
void JuK::setVolume(int volume)
void JuK::slotSetVolume(int volume)
{
if(m_player && m_sliderAction && m_sliderAction->getVolumeSlider() &&
m_sliderAction->getVolumeSlider()->maxValue() > 0 &&
......@@ -577,40 +613,4 @@ void JuK::setVolume(int volume)
}
}
void JuK::play(const QString &file)
{
if(!m_player)
return;
float volume = float(m_sliderAction->getVolumeSlider()->value()) / float(m_sliderAction->getVolumeSlider()->maxValue());
if(m_player->paused())
m_player->stop();
m_player->play(file, volume);
// Make sure that the m_player actually starts before doing anything.
if(m_player->playing()) {
m_pauseAction->setEnabled(true);
m_stopAction->setEnabled(true);
m_backAction->setEnabled(true);
m_forwardAction->setEnabled(true);
m_sliderAction->getTrackPositionSlider()->setValue(0);
m_sliderAction->getTrackPositionSlider()->setEnabled(true);
m_playTimer->start(pollInterval);
m_statusLabel->setPlayingItemInfo(playingString(), m_splitter->playingList());
emit newSongSignal(playingString());
if(m_systemTray)
m_systemTray->slotPlay();
}
else
stop();
}
#include "juk.moc"
......@@ -48,8 +48,8 @@ public:
virtual ~JuK();
signals:
void editSignal();
void newSongSignal(const QString& songTitle);
void signalEdit();
void signalNewSong(const QString& songTitle);
private:
// private methods
......@@ -72,10 +72,16 @@ private:
void invokeEditSlot(const char *slotName, const char *slot);
QString playingString() const;
void updatePlaylistInfo();
/**
* This is the main method to play stuff. Everything else is just a wrapper
* around this.
*/
void play(const QString &file);
private slots:
void playlistChanged();
void updatePlaylistInfo();
void slotPlaylistChanged();
// edit menu
void cut();
......@@ -84,44 +90,37 @@ private slots:
void clear();
void selectAll();
// m_player menu
void play();
void pause();
void stop();
void back();
void forward();
// player menu
void slotPlay();
void slotPause();
void slotStop();
void slotBack();
void slotForward();
// settings menu
void showGenreListEditor();
void toggleSystemTray(bool enabled);
void setOutput(int output);
void slotShowGenreListEditor();
void slotToggleSystemTray(bool enabled);
void slotSetOutput(int output);
// additional m_player slots