From 513ffdc18229a44c4e89a866f68976383fb85908 Mon Sep 17 00:00:00 2001 From: APTX Date: Fri, 30 Oct 2009 13:50:05 +0100 Subject: [PATCH] Fix opening files with single application. --- src/aniplayer.cpp | 2 +- src/videowindow.cpp | 15 +++++++++------ src/videowindow.h | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/aniplayer.cpp b/src/aniplayer.cpp index 65635de..f7d18b3 100644 --- a/src/aniplayer.cpp +++ b/src/aniplayer.cpp @@ -34,7 +34,7 @@ qDebug() << "handleMessage" << message; int pos = -1; if ((pos = message.indexOf(' ')) != -1) - w->play(message.mid(pos)); + w->play(message.mid(pos + 1)); } AniPlayer *AniPlayer::m_instance = 0; diff --git a/src/videowindow.cpp b/src/videowindow.cpp index 38b5ed1..d9353d2 100644 --- a/src/videowindow.cpp +++ b/src/videowindow.cpp @@ -212,7 +212,7 @@ void VideoWindow::setMenuVisible(bool visible) menu->setVisible(visible); } -void VideoWindow::open(bool closeOnStop) +bool VideoWindow::open(bool closeOnStop) { QString dir; @@ -238,22 +238,23 @@ void VideoWindow::open(bool closeOnStop) ); if (file == "") - return; + return false; // open(file, closeOnStop); play(file, closeOnStop); + return true; } -void VideoWindow::open(const QString &file, bool closeOnStop) +bool VideoWindow::open(const QString &file, bool closeOnStop) { if (file == "") - return; + return false; QFileInfo fileInfo(file); if (!fileInfo.exists()) { menu->showMessage(tr("File %1 does not exist").arg(file)); - return; + return false; } playlist->setDirectory(fileInfo.absoluteDir()); @@ -271,6 +272,7 @@ void VideoWindow::open(const QString &file, bool closeOnStop) m_closeOnStop = closeOnStop; updateWindowTitle(fileInfo); + return true; } void VideoWindow::openUrl(const QString &urlstr) @@ -291,7 +293,8 @@ void VideoWindow::play(bool closeOnStop) { if (videoPlayer->currentSource().type() == Phonon::MediaSource::Invalid) { - open(closeOnStop); + if (!open(closeOnStop)) + return; } videoPlayer->play(); diff --git a/src/videowindow.h b/src/videowindow.h index 0a5e03e..f835645 100644 --- a/src/videowindow.h +++ b/src/videowindow.h @@ -68,8 +68,8 @@ public slots: void toggleMenu(); void setMenuVisible(bool visible); - void open(bool closeOnStop = false); - void open(const QString &file, bool closeOnStop = false); + bool open(bool closeOnStop = false); + bool open(const QString &file, bool closeOnStop = false); void openUrl(const QString &url); void play(bool closeOnStop = false); void play(const QString &file, bool closeOnStop = false); -- 2.52.0