From kde-commits Thu Jul 10 08:16:40 2014 From: Casian Andrei Date: Thu, 10 Jul 2014 08:16:40 +0000 To: kde-commits Subject: [phonon/five] demos/phota: Redo phota open dialog methods Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=140498020922265 Git commit 2e9da30162e764451bafd72e0f5948066f2aad6c by Casian Andrei. Committed on 10/07/2014 at 08:11. Pushed by casianandrei into branch 'five'. Redo phota open dialog methods Replace openFile with openUrl, openUrl was previously not implemented. M +0 -1 demos/phota/mainwindow.cpp M +10 -12 demos/phota/mediacontroller.cpp M +0 -1 demos/phota/mediacontroller.h http://commits.kde.org/phonon/2e9da30162e764451bafd72e0f5948066f2aad6c diff --git a/demos/phota/mainwindow.cpp b/demos/phota/mainwindow.cpp index 77d0b1d..7621b7f 100644 --- a/demos/phota/mainwindow.cpp +++ b/demos/phota/mainwindow.cpp @@ -42,7 +42,6 @@ MainWindow::MainWindow(QWidget *parent) : void MainWindow::contextMenuEvent(QContextMenuEvent *e) { QMenu menu(tr("Control Menu"), this); - menu.addAction(tr("Open a file"), m_mediaControl, SLOT(openFile())); menu.addAction(tr("Open a URL"), m_mediaControl, SLOT(openURL())); menu.addSeparator(); menu.addAction(tr("Video Effects"), this, SLOT(effectsDialog())); diff --git a/demos/phota/mediacontroller.cpp b/demos/phota/mediacontroller.= cpp index 5f1fee0..8cb75c9 100644 --- a/demos/phota/mediacontroller.cpp +++ b/demos/phota/mediacontroller.cpp @@ -37,22 +37,20 @@ Phonon::Player *MediaController::player() const return m_player; } = -void MediaController::openFile() -{ - QString file =3D QFileDialog::getOpenFileName(0, tr("Open a new file t= o play"), ""); - if (!file.isEmpty()) { - Phonon::Source s(file); - playSource(s); - } -} - void MediaController::openURL() { - + QUrl homeDirUrl =3D QUrl::fromLocalFile(QDir::homePath()); + QUrl url =3D QFileDialog::getOpenFileUrl( + qobject_cast(parent()), + tr("Open a new file to play"), homeDirUrl); + if (!url.isEmpty()) { + Phonon::Source source(url); + playSource(source); + } } = -void MediaController::playSource(const Phonon::Source &s) +void MediaController::playSource(const Phonon::Source &source) { - m_player->setSource(s); + m_player->setSource(source); m_player->play(); } diff --git a/demos/phota/mediacontroller.h b/demos/phota/mediacontroller.h index 8f953d8..554a182 100644 --- a/demos/phota/mediacontroller.h +++ b/demos/phota/mediacontroller.h @@ -39,7 +39,6 @@ public: Phonon::Player *player() const; = public slots: - void openFile(); void openURL(); = private: