From 48991004fff433e14b94e1e04bb23e73ce6685c1 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Sun, 5 Feb 2012 04:41:42 +0100 Subject: [PATCH] Added support for adding files from the command-line. --- src/global.cpp | 2 +- src/win_main.cpp | 37 ++++++++++++++++++++++++++- src/win_preferences.cpp | 56 +++++++++++++++++------------------------ src/win_preferences.h | 2 ++ x264_launcher.vcxproj | 17 ++++++++++--- 5 files changed, 75 insertions(+), 39 deletions(-) diff --git a/src/global.cpp b/src/global.cpp index 56ca5ac..95f4399 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -264,7 +264,7 @@ void x264_message_handler(QtMsgType type, const char *msg) */ void x264_init_console(int argc, char* argv[]) { - bool enableConsole = x264_is_prerelease(); + bool enableConsole = x264_is_prerelease() || X264_DEBUG; if(_environ) { diff --git a/src/win_main.cpp b/src/win_main.cpp index 14eef1f..b02f342 100644 --- a/src/win_main.cpp +++ b/src/win_main.cpp @@ -76,7 +76,15 @@ MainWindow::MainWindow(bool x64supported) labelBuildDate->setText(tr("Built on %1 at %2").arg(x264_version_date().toString(Qt::ISODate), QString::fromLatin1(x264_version_time()))); labelBuildDate->installEventFilter(this); setWindowTitle(QString("%1 (%2 Mode)").arg(windowTitle(), m_x64supported ? "64-Bit" : "32-Bit")); - if(x264_is_prerelease()) setWindowTitle(QString("%1 | PRE-RELEASE VERSION").arg(windowTitle())); + if(X264_DEBUG) + { + setWindowTitle(QString("%1 | !!! DEBUG VERSION !!!").arg(windowTitle())); + setStyleSheet("QMenuBar, QMainWindow { background-color: yellow }"); + } + else if(x264_is_prerelease()) + { + setWindowTitle(QString("%1 | PRE-RELEASE VERSION").arg(windowTitle())); + } //Create model m_jobList = new JobListModel(); @@ -540,6 +548,33 @@ void MainWindow::init(void) QTimer::singleShot(5000, btn2, SLOT(show())); msgBox.exec(); } + + //Add files from command-line + bool bAddFile = false; + QStringList files, args = qApp->arguments(); + while(!args.isEmpty()) + { + QString current = args.takeFirst(); + if(!bAddFile) + { + bAddFile = (current.compare("--add", Qt::CaseInsensitive) == 0); + continue; + } + if(QFileInfo(current).exists() && QFileInfo(current).isFile()) + { + files << QFileInfo(current).canonicalFilePath(); + } + } + if(int totalFiles = files.count()) + { + bool ok = true; int n = 0; + while((!files.isEmpty()) && ok) + { + QString currentFile = files.takeFirst(); + qDebug("Adding file: %s", currentFile.toUtf8().constData()); + addButtonPressed(currentFile, n++, totalFiles, &ok); + } + } } void MainWindow::updateLabel(void) diff --git a/src/win_preferences.cpp b/src/win_preferences.cpp index d8cb4fb..749933c 100644 --- a/src/win_preferences.cpp +++ b/src/win_preferences.cpp @@ -72,42 +72,32 @@ void PreferencesDialog::showEvent(QShowEvent *event) bool PreferencesDialog::eventFilter(QObject *o, QEvent *e) { - if(o == labelRunNextJob && e->type() == QEvent::MouseButtonRelease) - { - QMouseEvent *mouseEvent = dynamic_cast(e); - if(mouseEvent) - { - if(qApp->widgetAt(mouseEvent->globalPos()) == labelRunNextJob) - { - checkRunNextJob->click(); - } - } - } - if(o == labelUse64BitAvs2YUV && e->type() == QEvent::MouseButtonRelease) - { - QMouseEvent *mouseEvent = dynamic_cast(e); - if(mouseEvent) - { - if(qApp->widgetAt(mouseEvent->globalPos()) == labelUse64BitAvs2YUV) - { - checkUse64BitAvs2YUV->click(); - } - } - } - if(o == labelShutdownComputer && e->type() == QEvent::MouseButtonRelease) - { - QMouseEvent *mouseEvent = dynamic_cast(e); - if(mouseEvent) - { - if(qApp->widgetAt(mouseEvent->globalPos()) == labelShutdownComputer) - { - checkShutdownComputer->click(); - } - } - } + emulateMouseEvent(o, e, labelRunNextJob, checkRunNextJob); + emulateMouseEvent(o, e, labelShutdownComputer, checkShutdownComputer); + emulateMouseEvent(o, e, labelUse64BitAvs2YUV, checkUse64BitAvs2YUV); return false; } +void PreferencesDialog::emulateMouseEvent(QObject *object, QEvent *event, QWidget *source, QWidget *target) +{ + if(object == source) + { + if((event->type() == QEvent::MouseButtonPress) || (event->type() == QEvent::MouseButtonRelease)) + { + if(QMouseEvent *mouseEvent = dynamic_cast(event)) + { + qApp->postEvent(target, new QMouseEvent + ( + event->type(), + qApp->widgetAt(mouseEvent->globalPos()) == source ? QPoint(1, 1) : QPoint(INT_MAX, INT_MAX), + Qt::LeftButton, + 0, 0 + )); + } + } + } +} + void PreferencesDialog::accept(void) { m_preferences->autoRunNextJob = checkRunNextJob->isChecked(); diff --git a/src/win_preferences.h b/src/win_preferences.h index 47bc96c..8e11410 100644 --- a/src/win_preferences.h +++ b/src/win_preferences.h @@ -50,6 +50,8 @@ protected: virtual void showEvent(QShowEvent *event); virtual bool eventFilter(QObject *o, QEvent *e); + void emulateMouseEvent(QObject *object, QEvent *event, QWidget *source, QWidget *target); + private: Preferences *m_preferences; }; diff --git a/x264_launcher.vcxproj b/x264_launcher.vcxproj index c02848b..1680e7a 100644 --- a/x264_launcher.vcxproj +++ b/x264_launcher.vcxproj @@ -53,8 +53,8 @@ Level3 Disabled - WIN32;_DEBUG;QT_DEBUG;QT_DLL;%(PreprocessorDefinitions) - $(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)tmp\uic;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;QT_DEBUG;QT_DLL;QT_GUI_LIB;%(PreprocessorDefinitions) + $(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtTest;$(SolutionDir)tmp\uic;%(AdditionalIncludeDirectories) Windows @@ -62,6 +62,15 @@ $(QTDIR)\lib;%(AdditionalLibraryDirectories) QtMaind.lib;QtCored4.lib;QtGuid4.lib;Winmm.lib;psapi.lib;%(AdditionalDependencies) + + rmdir /S /Q "$(SolutionDir)bin\$(Configuration)\toolset" +mkdir "$(SolutionDir)bin\$(Configuration)\toolset" +copy "$(SolutionDir)res\toolset\*.exe" "$(SolutionDir)bin\$(Configuration)\toolset" + + + + Copy Toolset + @@ -70,8 +79,8 @@ Full true true - WIN32;NDEBUG;QT_NO_DEBUG;QT_DLL;%(PreprocessorDefinitions) - $(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)tmp\uic;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;QT_NO_DEBUG;QT_DLL;QT_GUI_LIB;%(PreprocessorDefinitions) + $(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtTest;$(SolutionDir)tmp\uic;%(AdditionalIncludeDirectories) AnySuitable Speed true