|
From: Tapio V. <aa...@us...> - 2011-01-21 09:26:28
|
Module: editor
Branch: master
Commit: 46a4a6784b0058c1c8a23a8bed13135bf1b5ec42
Author: Tapio Vierros <tap...@gm...>
Date: Fri Jan 21 11:25:27 2011 +0200
Simplify playback buttons handling --> less buggy.
---
editor.ui | 3 ---
editorapp.cc | 28 +++++++++++++++++-----------
editorapp.hh | 3 ++-
3 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/editor.ui b/editor.ui
index 43fb2ea..b7872c6 100644
--- a/editor.ui
+++ b/editor.ui
@@ -328,9 +328,6 @@
<property name="text">
<string>Play</string>
</property>
- <property name="checkable">
- <bool>true</bool>
- </property>
</widget>
</item>
<item row="0" column="1">
diff --git a/editorapp.cc b/editorapp.cc
index c15ac3a..85fa44f 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -257,6 +257,7 @@ void EditorApp::on_actionSaveAs_triggered()
bool EditorApp::promptSaving()
{
+ updateSongMeta(); // Make sure the stuff in textboxes is updated
if (hasUnsavedChanges) {
QMessageBox::StandardButton b = QMessageBox::question(this, tr("Unsaved changes"),
tr("There are unsaved changes, which would be lost. Save now?"),
@@ -376,6 +377,7 @@ void EditorApp::on_actionMusicFile_triggered()
ui.valMusicFile->setText(fileName);
// Metadata is updated when it becomes available (signal)
player->setCurrentSource(Phonon::MediaSource(QUrl::fromLocalFile(fileName)));
+ noteGraph->updateMusicPos(0, false);
// Fire up analyzer
noteGraph->analyzeMusic(fileName);
}
@@ -474,22 +476,26 @@ void EditorApp::metaDataChanged()
}
}
-void EditorApp::on_cmdPlay_toggled(bool checked)
+void EditorApp::playButton()
+{
+ if (player && player->state() == Phonon::PlayingState) {
+ ui.cmdPlay->setText(tr("Pause"));
+ ui.cmdPlay->setIcon(QIcon::fromTheme("media-playback-pause"));
+ } else {
+ ui.cmdPlay->setText(tr("Play"));
+ ui.cmdPlay->setIcon(QIcon::fromTheme("media-playback-start"));
+ }
+}
+
+void EditorApp::on_cmdPlay_clicked()
{
if (player) {
if (player->currentSource().type() == Phonon::MediaSource::Empty
|| player->currentSource().type() == Phonon::MediaSource::Invalid) {
on_actionMusicFile_triggered();
} else {
- if (checked) {
- player->play();
- ui.cmdPlay->setText(tr("Playing..."));
- ui.cmdPlay->setIcon(QIcon::fromTheme("media-playback-pause"));
- } else {
- player->pause();
- ui.cmdPlay->setText(tr("Play"));
- ui.cmdPlay->setIcon(QIcon::fromTheme("media-playback-start"));
- }
+ if (player && player->state() == Phonon::PlayingState) player->pause();
+ else player->play();
}
}
}
@@ -498,7 +504,6 @@ void EditorApp::on_cmdStop_clicked()
{
if (player) player->stop();
if (noteGraph) noteGraph->updateMusicPos(0, false);
- ui.cmdPlay->setChecked(false);
}
void EditorApp::audioTick(qint64 time)
@@ -510,6 +515,7 @@ void EditorApp::audioTick(qint64 time)
void EditorApp::playerStateChanged(Phonon::State newstate, Phonon::State oldstate)
{
(void)oldstate;
+ playButton();
if (newstate != Phonon::PlayingState) {
noteGraph->stopMusic();
if (newstate == Phonon::ErrorState) {
diff --git a/editorapp.hh b/editorapp.hh
index df07a97..2b2172a 100644
--- a/editorapp.hh
+++ b/editorapp.hh
@@ -27,6 +27,7 @@ private:
bool promptSaving();
void saveProject(QString fileName);
void doOpStack();
+ void playButton();
public slots:
void operationDone(const Operation &op);
@@ -38,7 +39,7 @@ public slots:
// Automatic slots
- void on_cmdPlay_toggled(bool checked);
+ void on_cmdPlay_clicked();
void on_cmdStop_clicked();
// File menu
|