aboutsummaryrefslogtreecommitdiff
path: root/mainwindow.cc
diff options
context:
space:
mode:
Diffstat (limited to 'mainwindow.cc')
-rw-r--r--mainwindow.cc69
1 files changed, 68 insertions, 1 deletions
diff --git a/mainwindow.cc b/mainwindow.cc
index c509d4e..e269c61 100644
--- a/mainwindow.cc
+++ b/mainwindow.cc
@@ -6,7 +6,9 @@ MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
_notebooks(new NotebookModel(this)),
- _manager(new SmartpenManager(this))
+ _manager(new SmartpenManager(this)),
+ _media(new Phonon::MediaObject(this)),
+ _mediaOutput(new Phonon::AudioOutput(this))
{
ui->setupUi(this);
ui->notebookTree->setModel(_notebooks);
@@ -14,6 +16,11 @@ MainWindow::MainWindow(QWidget *parent) :
ui->notebookTree->header()->setResizeMode(1, QHeaderView::Fixed);
ui->notebookTree->header()->setResizeMode(2, QHeaderView::Fixed);
ui->notebookTree->expandAll();
+ Phonon::createPath(_media, _mediaOutput);
+ ui->replaySlider->setMediaObject(_media);
+ ui->pauseButton->setVisible(false);
+ connect(_media, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
+ this, SLOT(handleMediaStateChange(Phonon::State)));
}
MainWindow::~MainWindow()
@@ -65,3 +72,63 @@ void MainWindow::handleCurPageChanged()
{
ui->pageEdit->setText(QString::number(ui->notebookView->curPage() + 1));
}
+
+void MainWindow::handlePaperReplayRequested(const QString &file, qint64 time)
+{
+ QFileInfo finfo(file);
+ if (!finfo.exists()) {
+ qWarning() << "Cannot open paper replay media file:" << finfo.canonicalFilePath();
+ }
+
+ QString filePath = finfo.canonicalFilePath();
+
+ if (_media->currentSource().fileName() != filePath) {
+ _media->setCurrentSource(filePath);
+ }
+
+ switch (_media->state()) {
+ case Phonon::PlayingState:
+ case Phonon::BufferingState:
+ case Phonon::PausedState:
+ _pendingSeek = 0;
+ _media->seek(time);
+ break;
+ default:
+ _pendingSeek = time;
+ break;
+ }
+
+ _media->play();
+}
+
+void MainWindow::handlePaperReplayPlay()
+{
+ _media->play();
+}
+
+void MainWindow::handlePaperReplayPause()
+{
+ _media->pause();
+}
+
+void MainWindow::handleMediaStateChange(Phonon::State state)
+{
+ qDebug() << "Media state change:" << state;
+ switch (state) {
+ case Phonon::PlayingState:
+ ui->playButton->setVisible(false);
+ ui->pauseButton->setVisible(true);
+ if (_pendingSeek) {
+ _media->seek(_pendingSeek);
+ _pendingSeek = 0;
+ }
+ break;
+ case Phonon::PausedState:
+ ui->playButton->setVisible(true);
+ ui->pauseButton->setVisible(false);
+ break;
+ default:
+ ui->playButton->setVisible(true);
+ ui->pauseButton->setVisible(false);
+ }
+}