Added support for adding files from the command-line.

This commit is contained in:
LoRd_MuldeR 2012-02-05 04:41:42 +01:00
parent a4d8e6e8bc
commit 48991004ff
5 changed files with 75 additions and 39 deletions

View File

@ -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)
{

View File

@ -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)

View File

@ -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<QMouseEvent*>(e);
if(mouseEvent)
{
if(qApp->widgetAt(mouseEvent->globalPos()) == labelRunNextJob)
{
checkRunNextJob->click();
}
}
}
if(o == labelUse64BitAvs2YUV && e->type() == QEvent::MouseButtonRelease)
{
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(e);
if(mouseEvent)
{
if(qApp->widgetAt(mouseEvent->globalPos()) == labelUse64BitAvs2YUV)
{
checkUse64BitAvs2YUV->click();
}
}
}
if(o == labelShutdownComputer && e->type() == QEvent::MouseButtonRelease)
{
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent*>(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<QMouseEvent*>(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();

View File

@ -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;
};

View File

@ -53,8 +53,8 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;QT_DEBUG;QT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)tmp\uic;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;QT_DEBUG;QT_DLL;QT_GUI_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtTest;$(SolutionDir)tmp\uic;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -62,6 +62,15 @@
<AdditionalLibraryDirectories>$(QTDIR)\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>QtMaind.lib;QtCored4.lib;QtGuid4.lib;Winmm.lib;psapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>rmdir /S /Q "$(SolutionDir)bin\$(Configuration)\toolset"
mkdir "$(SolutionDir)bin\$(Configuration)\toolset"
copy "$(SolutionDir)res\toolset\*.exe" "$(SolutionDir)bin\$(Configuration)\toolset"
</Command>
</PostBuildEvent>
<PostBuildEvent>
<Message>Copy Toolset</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
@ -70,8 +79,8 @@
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;QT_NO_DEBUG;QT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(SolutionDir)tmp\uic;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;QT_NO_DEBUG;QT_DLL;QT_GUI_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtTest;$(SolutionDir)tmp\uic;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<WholeProgramOptimization>true</WholeProgramOptimization>