From feee78444a17d2fea053e4713352decb8b5d1e0a Mon Sep 17 00:00:00 2001 From: MuldeR Date: Sun, 19 May 2013 23:30:15 +0200 Subject: [PATCH] Added command-line support. --- src/MainWindow.cpp | 25 +++++++++++++++++++++++++ src/MainWindow.h | 1 + 2 files changed, 26 insertions(+) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index ba3ef98..e7d2189 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -58,6 +58,7 @@ CMainWindow::CMainWindow(const QString &tempFolder, QWidget *parent) : QMainWindow(parent), m_tempFolder(tempFolder), + m_firstShow(true), ui(new Ui::MainWindow) { //Init UI @@ -120,6 +121,30 @@ void CMainWindow::showEvent(QShowEvent *event) ui->versionLabel->setText(QString("v%1 (%2)").arg(QString().sprintf("%u.%02u", mixp_versionMajor, mixp_versionMinor), getBuildDate().toString(Qt::ISODate))); resizeEvent(NULL); setAcceptDrops(true); + + if(m_firstShow) + { + const QStringList arguments = qApp->arguments(); + for(QStringList::ConstIterator iter = arguments.constBegin(); iter != arguments.constEnd(); iter++) + { + if(QString::compare(*iter, "--open", Qt::CaseInsensitive) == 0) + { + if(++iter != arguments.constEnd()) + { + QFileInfo currentFile = QFileInfo(*iter); + if(currentFile.exists() && currentFile.isFile()) + { + m_droppedFile = currentFile.canonicalFilePath(); + QTimer::singleShot(0, this, SLOT(handleDroppedFile())); + break; + } + continue; + } + break; + } + } + m_firstShow = false; + } } void CMainWindow::closeEvent(QCloseEvent *event) diff --git a/src/MainWindow.h b/src/MainWindow.h index 5ac9611..2359f05 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -63,6 +63,7 @@ private: Ui::MainWindow *ui; //for Qt UIC const QString &m_tempFolder; + bool m_firstShow; QString m_mediaInfoPath; HANDLE m_mediaInfoHandle; QProcess *m_process;