///////////////////////////////////////////////////////////////////////////////
// Simple x264 Launcher
-// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2014 LoRd_MuldeR <MuldeR2@GMX.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
///////////////////////////////////////////////////////////////////////////////
#include "win_main.h"
+#include "uic_win_main.h"
+#include "global.h"
+#include "ipc.h"
+#include "model_status.h"
#include "model_jobList.h"
#include "model_options.h"
+#include "model_preferences.h"
+#include "model_recently.h"
+#include "thread_avisynth.h"
+#include "thread_vapoursynth.h"
+#include "thread_encode.h"
+#include "taskbar7.h"
#include "win_addJob.h"
#include "win_preferences.h"
-#include "taskbar7.h"
+#include "win_updater.h"
#include "resource.h"
#include <QDate>
#include <QLibrary>
#include <QProcess>
#include <QProgressDialog>
+#include <QScrollBar>
+#include <QTextStream>
+#include <QSettings>
+#include <QFileDialog>
-#include <Mmsystem.h>
+#include <ctime>
-const char *home_url = "http://mulder.brhack.net/";
-const char *update_url = "http://code.google.com/p/mulder/downloads/list";
+const char *home_url = "http://muldersoft.com/";
+const char *update_url = "https://github.com/lordmulder/Simple-x264-Launcher/releases/latest";
const char *tpl_last = "<LAST_USED>";
-#define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); }
-#define SET_TEXT_COLOR(WIDGET,COLOR) { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, (COLOR)); _palette.setColor(QPalette::Text, (COLOR)); WIDGET->setPalette(_palette); }
+#define SET_FONT_BOLD(WIDGET,BOLD) do { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); } while(0)
+#define SET_TEXT_COLOR(WIDGET,COLOR) do { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, (COLOR)); _palette.setColor(QPalette::Text, (COLOR)); WIDGET->setPalette(_palette); } while(0)
+#define LINK(URL) "<a href=\"" URL "\">" URL "</a>"
+#define INIT_ERROR_EXIT() do { m_status = STATUS_EXITTING; close(); qApp->exit(-1); return; } while(0)
+#define ENSURE_APP_IS_IDLE() do { if(m_status != STATUS_IDLE) return; } while(0)
+
+//static int exceptionFilter(_EXCEPTION_RECORD *dst, _EXCEPTION_POINTERS *src) { memcpy(dst, src->ExceptionRecord, sizeof(_EXCEPTION_RECORD)); return EXCEPTION_EXECUTE_HANDLER; }
///////////////////////////////////////////////////////////////////////////////
// Constructor & Destructor
/*
* Constructor
*/
-MainWindow::MainWindow(const x264_cpu_t *const cpuFeatures)
+MainWindow::MainWindow(const x264_cpu_t *const cpuFeatures, IPC *ipc)
:
m_cpuFeatures(cpuFeatures),
+ m_ipc(ipc),
m_appDir(QApplication::applicationDirPath()),
m_options(NULL),
m_jobList(NULL),
- m_droppedFiles(NULL),
- m_firstShow(true)
+ m_pendingFiles(new QStringList()),
+ m_preferences(NULL),
+ m_recentlyUsed(NULL),
+ m_skipVersionTest(false),
+ m_abortOnTimeout(true),
+ m_status(STATUS_PRE_INIT),
+ m_firstShow(true),
+ ui(new Ui::MainWindow())
{
//Init the dialog, from the .ui file
- setupUi(this);
+ ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowMaximizeButtonHint));
//Register meta types
qRegisterMetaType<QUuid>("QUuid");
- qRegisterMetaType<EncodeThread::JobStatus>("EncodeThread::JobStatus");
+ qRegisterMetaType<QUuid>("DWORD");
+ qRegisterMetaType<JobStatus>("JobStatus");
//Load preferences
- PreferencesDialog::initPreferences(&m_preferences);
- PreferencesDialog::loadPreferences(&m_preferences);
+ m_preferences = new PreferencesModel();
+ PreferencesModel::loadPreferences(m_preferences);
+
+ //Load recently used
+ m_recentlyUsed = new RecentlyUsed();
+ RecentlyUsed::loadRecentlyUsed(m_recentlyUsed);
//Create options object
m_options = new OptionsModel();
//Freeze minimum size
setMinimumSize(size());
- splitter->setSizes(QList<int>() << 16 << 196);
+ ui->splitter->setSizes(QList<int>() << 16 << 196);
//Update title
- labelBuildDate->setText(tr("Built on %1 at %2").arg(x264_version_date().toString(Qt::ISODate), QString::fromLatin1(x264_version_time())));
- labelBuildDate->installEventFilter(this);
+ ui->labelBuildDate->setText(tr("Built on %1 at %2").arg(x264_version_date().toString(Qt::ISODate), QString::fromLatin1(x264_version_time())));
+ ui->labelBuildDate->installEventFilter(this);
setWindowTitle(QString("%1 (%2 Mode)").arg(windowTitle(), m_cpuFeatures->x64 ? "64-Bit" : "32-Bit"));
if(X264_DEBUG)
{
}
//Create model
- m_jobList = new JobListModel();
+ m_jobList = new JobListModel(m_preferences);
connect(m_jobList, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(jobChangedData(QModelIndex, QModelIndex)));
- jobsView->setModel(m_jobList);
+ ui->jobsView->setModel(m_jobList);
//Setup view
- jobsView->horizontalHeader()->setSectionHidden(3, true);
- jobsView->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
- jobsView->horizontalHeader()->setResizeMode(1, QHeaderView::Fixed);
- jobsView->horizontalHeader()->setResizeMode(2, QHeaderView::Fixed);
- jobsView->horizontalHeader()->resizeSection(1, 150);
- jobsView->horizontalHeader()->resizeSection(2, 90);
- jobsView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
- connect(jobsView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(jobSelected(QModelIndex, QModelIndex)));
+ ui->jobsView->horizontalHeader()->setSectionHidden(3, true);
+ ui->jobsView->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
+ ui->jobsView->horizontalHeader()->setResizeMode(1, QHeaderView::Fixed);
+ ui->jobsView->horizontalHeader()->setResizeMode(2, QHeaderView::Fixed);
+ ui->jobsView->horizontalHeader()->resizeSection(1, 150);
+ ui->jobsView->horizontalHeader()->resizeSection(2, 90);
+ ui->jobsView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
+ connect(ui->jobsView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(jobSelected(QModelIndex, QModelIndex)));
//Create context menu
- QAction *actionClipboard = new QAction(QIcon(":/buttons/page_paste.png"), tr("Copy to Clipboard"), logView);
+ QAction *actionClipboard = new QAction(QIcon(":/buttons/page_paste.png"), tr("Copy to Clipboard"), ui->logView);
actionClipboard->setEnabled(false);
- logView->addAction(actionClipboard);
+ ui->logView->addAction(actionClipboard);
connect(actionClipboard, SIGNAL(triggered(bool)), this, SLOT(copyLogToClipboard(bool)));
- jobsView->addActions(menuJob->actions());
+ ui->jobsView->addActions(ui->menuJob->actions());
//Enable buttons
- connect(buttonAddJob, SIGNAL(clicked()), this, SLOT(addButtonPressed()));
- connect(buttonStartJob, SIGNAL(clicked()), this, SLOT(startButtonPressed()));
- connect(buttonAbortJob, SIGNAL(clicked()), this, SLOT(abortButtonPressed()));
- connect(buttonPauseJob, SIGNAL(toggled(bool)), this, SLOT(pauseButtonPressed(bool)));
- connect(actionJob_Delete, SIGNAL(triggered()), this, SLOT(deleteButtonPressed()));
- connect(actionJob_Browse, SIGNAL(triggered()), this, SLOT(browseButtonPressed()));
+ connect(ui->buttonAddJob, SIGNAL(clicked()), this, SLOT(addButtonPressed()));
+ connect(ui->buttonStartJob, SIGNAL(clicked()), this, SLOT(startButtonPressed()));
+ connect(ui->buttonAbortJob, SIGNAL(clicked()), this, SLOT(abortButtonPressed()));
+ connect(ui->buttonPauseJob, SIGNAL(toggled(bool)), this, SLOT(pauseButtonPressed(bool)));
+ connect(ui->actionJob_Delete, SIGNAL(triggered()), this, SLOT(deleteButtonPressed()));
+ connect(ui->actionJob_Restart, SIGNAL(triggered()), this, SLOT(restartButtonPressed()));
+ connect(ui->actionJob_Browse, SIGNAL(triggered()), this, SLOT(browseButtonPressed()));
//Enable menu
- connect(actionAbout, SIGNAL(triggered()), this, SLOT(showAbout()));
- connect(actionWebMulder, SIGNAL(triggered()), this, SLOT(showWebLink()));
- connect(actionWebX264, SIGNAL(triggered()), this, SLOT(showWebLink()));
- connect(actionWebKomisar, SIGNAL(triggered()), this, SLOT(showWebLink()));
- connect(actionWebJarod, SIGNAL(triggered()), this, SLOT(showWebLink()));
- connect(actionWebJEEB, SIGNAL(triggered()), this, SLOT(showWebLink()));
- connect(actionWebAvisynth32, SIGNAL(triggered()), this, SLOT(showWebLink()));
- connect(actionWebAvisynth64, SIGNAL(triggered()), this, SLOT(showWebLink()));
- connect(actionWebWiki, SIGNAL(triggered()), this, SLOT(showWebLink()));
- connect(actionWebBluRay, SIGNAL(triggered()), this, SLOT(showWebLink()));
- connect(actionWebSecret, SIGNAL(triggered()), this, SLOT(showWebLink()));
- connect(actionPreferences, SIGNAL(triggered()), this, SLOT(showPreferences()));
+ connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openActionTriggered()));
+ connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAbout()));
+ connect(ui->actionWebMulder, SIGNAL(triggered()), this, SLOT(showWebLink()));
+ connect(ui->actionWebX264, SIGNAL(triggered()), this, SLOT(showWebLink()));
+ connect(ui->actionWebKomisar, SIGNAL(triggered()), this, SLOT(showWebLink()));
+ connect(ui->actionWebVideoLAN, SIGNAL(triggered()), this, SLOT(showWebLink()));
+ connect(ui->actionWebJEEB, SIGNAL(triggered()), this, SLOT(showWebLink()));
+ connect(ui->actionWebAvisynth32, SIGNAL(triggered()), this, SLOT(showWebLink()));
+ connect(ui->actionWebAvisynth64, SIGNAL(triggered()), this, SLOT(showWebLink()));
+ connect(ui->actionWebVapourSynth, SIGNAL(triggered()), this, SLOT(showWebLink()));
+ connect(ui->actionWebVapourSynthDocs, SIGNAL(triggered()), this, SLOT(showWebLink()));
+ connect(ui->actionWebWiki, SIGNAL(triggered()), this, SLOT(showWebLink()));
+ connect(ui->actionWebBluRay, SIGNAL(triggered()), this, SLOT(showWebLink()));
+ connect(ui->actionWebAvsWiki, SIGNAL(triggered()), this, SLOT(showWebLink()));
+ connect(ui->actionWebSecret, SIGNAL(triggered()), this, SLOT(showWebLink()));
+ connect(ui->actionWebSupport, SIGNAL(triggered()), this, SLOT(showWebLink()));
+ connect(ui->actionPreferences, SIGNAL(triggered()), this, SLOT(showPreferences()));
+ connect(ui->actionCheckForUpdates, SIGNAL(triggered()), this, SLOT(checkUpdates()));
//Create floating label
- m_label = new QLabel(jobsView->viewport());
+ m_label = new QLabel(ui->jobsView->viewport());
m_label->setText(tr("No job created yet. Please click the 'Add New Job' button!"));
m_label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
SET_TEXT_COLOR(m_label, Qt::darkGray);
SET_FONT_BOLD(m_label, true);
m_label->setVisible(true);
m_label->setContextMenuPolicy(Qt::ActionsContextMenu);
- m_label->addActions(jobsView->actions());
- connect(splitter, SIGNAL(splitterMoved(int, int)), this, SLOT(updateLabelPos()));
+ m_label->addActions(ui->jobsView->actions());
+ connect(ui->splitter, SIGNAL(splitterMoved(int, int)), this, SLOT(updateLabelPos()));
updateLabelPos();
}
X264_DELETE(m_jobList);
X264_DELETE(m_options);
- X264_DELETE(m_droppedFiles);
+ X264_DELETE(m_pendingFiles);
X264_DELETE(m_label);
while(!m_toolsList.isEmpty())
QFile *temp = m_toolsList.takeFirst();
X264_DELETE(temp);
}
+
+ /*
+ if(m_ipcThread->isRunning())
+ {
+ m_ipcThread->setAbort();
+ if(!m_ipcThread->wait(5000))
+ {
+ m_ipcThread->terminate();
+ m_ipcThread->wait();
+ }
+ }
+ */
+
+ X264_DELETE(m_preferences);
+ X264_DELETE(m_recentlyUsed);
+ VapourSynthCheckThread::unload();
+ AvisynthCheckThread::unload();
+
+ delete ui;
}
///////////////////////////////////////////////////////////////////////////////
/*
* The "add" button was clicked
*/
-void MainWindow::addButtonPressed(const QString &filePath, int fileNo, int fileTotal, bool *ok)
+void MainWindow::addButtonPressed()
{
+ ENSURE_APP_IS_IDLE();
+ m_status = STATUS_BLOCKED;
+
qDebug("MainWindow::addButtonPressed");
-
- if(ok) *ok = false;
-
- AddJobDialog *addDialog = new AddJobDialog(this, m_options, m_cpuFeatures->x64);
- addDialog->setRunImmediately(countRunningJobs() < (m_preferences.autoRunNextJob ? m_preferences.maxRunningJobCount : 1));
- if((fileNo >= 0) && (fileTotal > 1)) addDialog->setWindowTitle(addDialog->windowTitle().append(tr(" (File %1 of %2)").arg(QString::number(fileNo+1), QString::number(fileTotal))));
- if(!filePath.isEmpty()) addDialog->setSourceFile(filePath);
+ bool runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
+ QString sourceFileName, outputFileName;
- int result = addDialog->exec();
- if(result == QDialog::Accepted)
+ if(createJob(sourceFileName, outputFileName, m_options, runImmediately))
{
- EncodeThread *thrd = new EncodeThread
- (
- addDialog->sourceFile(),
- addDialog->outputFile(),
- m_options,
- QString("%1/toolset").arg(m_appDir),
- m_cpuFeatures->x64,
- m_cpuFeatures->x64 && m_preferences.useAvisyth64Bit
- );
+ appendJob(sourceFileName, outputFileName, m_options, runImmediately);
+ }
- QModelIndex newIndex = m_jobList->insertJob(thrd);
+ m_status = STATUS_IDLE;
+}
- if(newIndex.isValid())
+/*
+ * The "open" action was triggered
+ */
+void MainWindow::openActionTriggered()
+{
+ ENSURE_APP_IS_IDLE();
+ m_status = STATUS_BLOCKED;
+
+ QStringList fileList = QFileDialog::getOpenFileNames(this, tr("Open Source File(s)"), m_recentlyUsed->sourceDirectory(), AddJobDialog::getInputFilterLst(), NULL, QFileDialog::DontUseNativeDialog);
+ if(!fileList.empty())
+ {
+ m_recentlyUsed->setSourceDirectory(QFileInfo(fileList.last()).absolutePath());
+ if(fileList.count() > 1)
{
- if(addDialog->runImmediately())
+ createJobMultiple(fileList);
+ }
+ else
+ {
+ bool runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
+ QString sourceFileName(fileList.first()), outputFileName;
+ if(createJob(sourceFileName, outputFileName, m_options, runImmediately))
{
- jobsView->selectRow(newIndex.row());
- QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
- m_jobList->startJob(newIndex);
+ appendJob(sourceFileName, outputFileName, m_options, runImmediately);
}
-
- if(ok) *ok = true;
}
}
- m_label->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
- X264_DELETE(addDialog);
+ m_status = STATUS_IDLE;
}
/*
*/
void MainWindow::startButtonPressed(void)
{
- m_jobList->startJob(jobsView->currentIndex());
+ ENSURE_APP_IS_IDLE();
+ m_jobList->startJob(ui->jobsView->currentIndex());
}
/*
*/
void MainWindow::abortButtonPressed(void)
{
- m_jobList->abortJob(jobsView->currentIndex());
+ ENSURE_APP_IS_IDLE();
+ m_jobList->abortJob(ui->jobsView->currentIndex());
}
/*
*/
void MainWindow::deleteButtonPressed(void)
{
- m_jobList->deleteJob(jobsView->currentIndex());
+ ENSURE_APP_IS_IDLE();
+ m_jobList->deleteJob(ui->jobsView->currentIndex());
m_label->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
}
*/
void MainWindow::browseButtonPressed(void)
{
- QString outputFile = m_jobList->getJobOutputFile(jobsView->currentIndex());
+ ENSURE_APP_IS_IDLE();
+ m_status = STATUS_BLOCKED;
+
+ QString outputFile = m_jobList->getJobOutputFile(ui->jobsView->currentIndex());
if((!outputFile.isEmpty()) && QFileInfo(outputFile).exists() && QFileInfo(outputFile).isFile())
{
QProcess::startDetached(QString::fromLatin1("explorer.exe"), QStringList() << QString::fromLatin1("/select,") << QDir::toNativeSeparators(outputFile), QFileInfo(outputFile).path());
{
QMessageBox::warning(this, tr("Not Found"), tr("Sorry, the output file could not be found!"));
}
+
+ m_status = STATUS_IDLE;
}
/*
{
if(checked)
{
- m_jobList->pauseJob(jobsView->currentIndex());
+ m_jobList->pauseJob(ui->jobsView->currentIndex());
}
else
{
- m_jobList->resumeJob(jobsView->currentIndex());
+ m_jobList->resumeJob(ui->jobsView->currentIndex());
+ }
+}
+
+/*
+ * The "restart" button was clicked
+ */
+void MainWindow::restartButtonPressed(void)
+{
+ ENSURE_APP_IS_IDLE();
+
+ const QModelIndex index = ui->jobsView->currentIndex();
+ const OptionsModel *options = m_jobList->getJobOptions(index);
+ QString sourceFileName = m_jobList->getJobSourceFile(index);
+ QString outputFileName = m_jobList->getJobOutputFile(index);
+
+ if((options) && (!sourceFileName.isEmpty()) && (!outputFileName.isEmpty()))
+ {
+ bool runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1)); //bool runImmediately = true;
+ OptionsModel *tempOptions = new OptionsModel(*options);
+ if(createJob(sourceFileName, outputFileName, tempOptions, runImmediately, true))
+ {
+ appendJob(sourceFileName, outputFileName, tempOptions, runImmediately);
+ }
+ X264_DELETE(tempOptions);
}
}
{
qDebug("Job selected: %d", current.row());
- if(logView->model())
+ if(ui->logView->model())
{
- disconnect(logView->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(jobLogExtended(QModelIndex, int, int)));
+ disconnect(ui->logView->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(jobLogExtended(QModelIndex, int, int)));
}
if(current.isValid())
{
- logView->setModel(m_jobList->getLogFile(current));
- connect(logView->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(jobLogExtended(QModelIndex, int, int)));
- logView->actions().first()->setEnabled(true);
- QTimer::singleShot(0, logView, SLOT(scrollToBottom()));
+ ui->logView->setModel(m_jobList->getLogFile(current));
+ connect(ui->logView->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(jobLogExtended(QModelIndex, int, int)));
+ ui->logView->actions().first()->setEnabled(true);
+ QTimer::singleShot(0, ui->logView, SLOT(scrollToBottom()));
- progressBar->setValue(m_jobList->getJobProgress(current));
- editDetails->setText(m_jobList->data(m_jobList->index(current.row(), 3, QModelIndex()), Qt::DisplayRole).toString());
+ ui->progressBar->setValue(m_jobList->getJobProgress(current));
+ ui->editDetails->setText(m_jobList->data(m_jobList->index(current.row(), 3, QModelIndex()), Qt::DisplayRole).toString());
updateButtons(m_jobList->getJobStatus(current));
updateTaskbar(m_jobList->getJobStatus(current), m_jobList->data(m_jobList->index(current.row(), 0, QModelIndex()), Qt::DecorationRole).value<QIcon>());
}
else
{
- logView->setModel(NULL);
- logView->actions().first()->setEnabled(false);
- progressBar->setValue(0);
- editDetails->clear();
- updateButtons(EncodeThread::JobStatus_Undefined);
- updateTaskbar(EncodeThread::JobStatus_Undefined, QIcon());
+ ui->logView->setModel(NULL);
+ ui->logView->actions().first()->setEnabled(false);
+ ui->progressBar->setValue(0);
+ ui->editDetails->clear();
+ updateButtons(JobStatus_Undefined);
+ updateTaskbar(JobStatus_Undefined, QIcon());
}
- progressBar->repaint();
+ ui->progressBar->repaint();
}
/*
*/
void MainWindow::jobChangedData(const QModelIndex &topLeft, const QModelIndex &bottomRight)
{
- int selected = jobsView->currentIndex().row();
+ int selected = ui->jobsView->currentIndex().row();
if(topLeft.column() <= 1 && bottomRight.column() >= 1) /*STATUS*/
{
for(int i = topLeft.row(); i <= bottomRight.row(); i++)
{
- EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
+ JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
if(i == selected)
{
qDebug("Current job changed status!");
updateButtons(status);
updateTaskbar(status, m_jobList->data(m_jobList->index(i, 0, QModelIndex()), Qt::DecorationRole).value<QIcon>());
}
- if((status == EncodeThread::JobStatus_Completed) || (status == EncodeThread::JobStatus_Failed))
+ if((status == JobStatus_Completed) || (status == JobStatus_Failed))
{
- if(m_preferences.autoRunNextJob) QTimer::singleShot(0, this, SLOT(launchNextJob()));
- if(m_preferences.shutdownComputer) QTimer::singleShot(0, this, SLOT(shutdownComputer()));
+ if(m_preferences->autoRunNextJob()) QTimer::singleShot(0, this, SLOT(launchNextJob()));
+ if(m_preferences->shutdownComputer()) QTimer::singleShot(0, this, SLOT(shutdownComputer()));
+ if(m_preferences->saveLogFiles()) saveLogFile(m_jobList->index(i, 1, QModelIndex()));
}
}
}
{
if(i == selected)
{
- progressBar->setValue(m_jobList->getJobProgress(m_jobList->index(i, 0, QModelIndex())));
- WinSevenTaskbar::setTaskbarProgress(this, progressBar->value(), progressBar->maximum());
+ ui->progressBar->setValue(m_jobList->getJobProgress(m_jobList->index(i, 0, QModelIndex())));
+ WinSevenTaskbar::setTaskbarProgress(this, ui->progressBar->value(), ui->progressBar->maximum());
break;
}
}
{
if(i == selected)
{
- editDetails->setText(m_jobList->data(m_jobList->index(i, 3, QModelIndex()), Qt::DisplayRole).toString());
+ ui->editDetails->setText(m_jobList->data(m_jobList->index(i, 3, QModelIndex()), Qt::DisplayRole).toString());
break;
}
}
*/
void MainWindow::jobLogExtended(const QModelIndex & parent, int start, int end)
{
- QTimer::singleShot(0, logView, SLOT(scrollToBottom()));
+ QTimer::singleShot(0, ui->logView, SLOT(scrollToBottom()));
}
/*
*/
void MainWindow::showAbout(void)
{
+ ENSURE_APP_IS_IDLE();
+ m_status = STATUS_BLOCKED;
+
QString text;
-
text += QString().sprintf("<nobr><tt>Simple x264 Launcher v%u.%02u.%u - use 64-Bit x264 with 32-Bit Avisynth<br>", x264_version_major(), x264_version_minor(), x264_version_build());
text += QString().sprintf("Copyright (c) 2004-%04d LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved.<br>", qMax(x264_version_date().year(),QDate::currentDate().year()));
text += QString().sprintf("Built on %s at %s with %s for Win-%s.<br><br>", x264_version_date().toString(Qt::ISODate).toLatin1().constData(), x264_version_time(), x264_version_compiler(), x264_version_arch());
aboutBox.setWindowTitle(tr("About..."));
aboutBox.setText(text.replace("-", "−"));
aboutBox.addButton(tr("About x264"), QMessageBox::NoRole);
+ aboutBox.addButton(tr("About AVS"), QMessageBox::NoRole);
+ aboutBox.addButton(tr("About VPY"), QMessageBox::NoRole);
aboutBox.addButton(tr("About Qt"), QMessageBox::NoRole);
aboutBox.setEscapeButton(aboutBox.addButton(tr("Close"), QMessageBox::NoRole));
forever
{
- MessageBeep(MB_ICONINFORMATION);
+ x264_beep(x264_beep_info);
switch(aboutBox.exec())
{
case 0:
{
QString text2;
- text2 += tr("<nobr><tt>x264 - the best H.264/AVC encoder. Copyright (c) 2003-2012 x264 project.<br>");
+ text2 += tr("<nobr><tt>x264 - the best H.264/AVC encoder. Copyright (c) 2003-2013 x264 project.<br>");
text2 += tr("Free software library for encoding video streams into the H.264/MPEG-4 AVC format.<br>");
text2 += tr("Released under the terms of the GNU General Public License.<br><br>");
- text2 += tr("Please visit <a href=\"%1\">%1</a> for obtaining a <u>commercial</u> x264 license!<br></tt></nobr>").arg("http://x264licensing.com/");
+ text2 += tr("Please visit <a href=\"%1\">%1</a> for obtaining a commercial x264 license.<br>").arg("http://x264licensing.com/");
+ text2 += tr("Read the <a href=\"%1\">user's manual</a> to get started and use the <a href=\"%2\">support forum</a> for help!<br></tt></nobr>").arg("http://mewiki.project357.com/wiki/X264_Settings", "http://forum.doom9.org/forumdisplay.php?f=77");
QMessageBox x264Box(this);
x264Box.setIconPixmap(QIcon(":/images/x264.png").pixmap(48,48));
x264Box.setWindowTitle(tr("About x264"));
x264Box.setText(text2.replace("-", "−"));
x264Box.setEscapeButton(x264Box.addButton(tr("Close"), QMessageBox::NoRole));
- MessageBeep(MB_ICONINFORMATION);
+ x264_beep(x264_beep_info);
x264Box.exec();
}
break;
case 1:
+ {
+ QString text2;
+ text2 += tr("<nobr><tt>Avisynth - powerful video processing scripting language.<br>");
+ text2 += tr("Copyright (c) 2000 Ben Rudiak-Gould and all subsequent developers.<br>");
+ text2 += tr("Released under the terms of the GNU General Public License.<br><br>");
+ text2 += tr("Please visit the web-site <a href=\"%1\">%1</a> for more information.<br>").arg("http://avisynth.org/");
+ text2 += tr("Read the <a href=\"%1\">guide</a> to get started and use the <a href=\"%2\">support forum</a> for help!<br></tt></nobr>").arg("http://avisynth.nl/index.php/First_script", "http://forum.doom9.org/forumdisplay.php?f=33");
+
+ QMessageBox x264Box(this);
+ x264Box.setIconPixmap(QIcon(":/images/avisynth.png").pixmap(48,67));
+ x264Box.setWindowTitle(tr("About Avisynth"));
+ x264Box.setText(text2.replace("-", "−"));
+ x264Box.setEscapeButton(x264Box.addButton(tr("Close"), QMessageBox::NoRole));
+ x264_beep(x264_beep_info);
+ x264Box.exec();
+ }
+ break;
+ case 2:
+ {
+ QString text2;
+ text2 += tr("<nobr><tt>VapourSynth - application for video manipulation based on Python.<br>");
+ text2 += tr("Copyright (c) 2012 Fredrik Mellbin.<br>");
+ text2 += tr("Released under the terms of the GNU Lesser General Public.<br><br>");
+ text2 += tr("Please visit the web-site <a href=\"%1\">%1</a> for more information.<br>").arg("http://www.vapoursynth.com/");
+ text2 += tr("Read the <a href=\"%1\">documentation</a> to get started and use the <a href=\"%2\">support forum</a> for help!<br></tt></nobr>").arg("http://www.vapoursynth.com/doc/", "http://forum.doom9.org/showthread.php?t=165771");
+
+ QMessageBox x264Box(this);
+ x264Box.setIconPixmap(QIcon(":/images/python.png").pixmap(48,48));
+ x264Box.setWindowTitle(tr("About VapourSynth"));
+ x264Box.setText(text2.replace("-", "−"));
+ x264Box.setEscapeButton(x264Box.addButton(tr("Close"), QMessageBox::NoRole));
+ x264_beep(x264_beep_info);
+ x264Box.exec();
+ }
+ break;
+ case 3:
QMessageBox::aboutQt(this);
break;
default:
+ m_status = STATUS_IDLE;
return;
}
}
*/
void MainWindow::showWebLink(void)
{
- if(QObject::sender() == actionWebMulder) QDesktopServices::openUrl(QUrl(home_url));
- if(QObject::sender() == actionWebX264) QDesktopServices::openUrl(QUrl("http://www.x264.com/"));
- if(QObject::sender() == actionWebKomisar) QDesktopServices::openUrl(QUrl("http://komisar.gin.by/"));
- if(QObject::sender() == actionWebJarod) QDesktopServices::openUrl(QUrl("http://www.x264.nl/"));
- if(QObject::sender() == actionWebJEEB) QDesktopServices::openUrl(QUrl("http://x264.fushizen.eu/"));
- if(QObject::sender() == actionWebAvisynth32) QDesktopServices::openUrl(QUrl("http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/"));
- if(QObject::sender() == actionWebAvisynth64) QDesktopServices::openUrl(QUrl("http://code.google.com/p/avisynth64/downloads/list"));
- if(QObject::sender() == actionWebWiki) QDesktopServices::openUrl(QUrl("http://mewiki.project357.com/wiki/X264_Settings"));
- if(QObject::sender() == actionWebBluRay) QDesktopServices::openUrl(QUrl("http://www.x264bluray.com/"));
- if(QObject::sender() == actionWebSecret) QDesktopServices::openUrl(QUrl("http://www.youtube.com/watch_popup?v=AXIeHY-OYNI"));
+ if(QObject::sender() == ui->actionWebMulder) QDesktopServices::openUrl(QUrl(home_url));
+ if(QObject::sender() == ui->actionWebX264) QDesktopServices::openUrl(QUrl("http://www.x264.com/"));
+ if(QObject::sender() == ui->actionWebKomisar) QDesktopServices::openUrl(QUrl("http://komisar.gin.by/"));
+ if(QObject::sender() == ui->actionWebVideoLAN) QDesktopServices::openUrl(QUrl("http://download.videolan.org/pub/x264/binaries/"));
+ if(QObject::sender() == ui->actionWebJEEB) QDesktopServices::openUrl(QUrl("http://x264.fushizen.eu/"));
+ if(QObject::sender() == ui->actionWebAvisynth32) QDesktopServices::openUrl(QUrl("http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/"));
+ if(QObject::sender() == ui->actionWebAvisynth64) QDesktopServices::openUrl(QUrl("http://code.google.com/p/avisynth64/downloads/list"));
+ if(QObject::sender() == ui->actionWebVapourSynth) QDesktopServices::openUrl(QUrl("http://www.vapoursynth.com/"));
+ if(QObject::sender() == ui->actionWebVapourSynthDocs) QDesktopServices::openUrl(QUrl("http://www.vapoursynth.com/doc/"));
+ if(QObject::sender() == ui->actionWebWiki) QDesktopServices::openUrl(QUrl("http://mewiki.project357.com/wiki/X264_Settings"));
+ if(QObject::sender() == ui->actionWebBluRay) QDesktopServices::openUrl(QUrl("http://www.x264bluray.com/"));
+ if(QObject::sender() == ui->actionWebAvsWiki) QDesktopServices::openUrl(QUrl("http://avisynth.nl/index.php/Main_Page#Usage"));
+ if(QObject::sender() == ui->actionWebSupport) QDesktopServices::openUrl(QUrl("http://forum.doom9.org/showthread.php?t=144140"));
+ if(QObject::sender() == ui->actionWebSecret) QDesktopServices::openUrl(QUrl("http://www.youtube.com/watch_popup?v=AXIeHY-OYNI"));
}
/*
*/
void MainWindow::showPreferences(void)
{
- PreferencesDialog *preferences = new PreferencesDialog(this, &m_preferences, m_cpuFeatures->x64);
+ ENSURE_APP_IS_IDLE();
+ m_status = STATUS_BLOCKED;
+
+ PreferencesDialog *preferences = new PreferencesDialog(this, m_preferences, m_cpuFeatures->x64);
preferences->exec();
+
X264_DELETE(preferences);
+ m_status = STATUS_IDLE;
}
/*
void MainWindow::launchNextJob(void)
{
qDebug("launchNextJob(void)");
-
const int rows = m_jobList->rowCount(QModelIndex());
- if(countRunningJobs() >= m_preferences.maxRunningJobCount)
+ if(countRunningJobs() >= m_preferences->maxRunningJobCount())
{
qDebug("Still have too many jobs running, won't launch next one yet!");
return;
}
- int startIdx= jobsView->currentIndex().isValid() ? qBound(0, jobsView->currentIndex().row(), rows-1) : 0;
+ int startIdx= ui->jobsView->currentIndex().isValid() ? qBound(0, ui->jobsView->currentIndex().row(), rows-1) : 0;
for(int i = 0; i < rows; i++)
{
int currentIdx = (i + startIdx) % rows;
- EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(currentIdx, 0, QModelIndex()));
- if(status == EncodeThread::JobStatus_Enqueued)
+ JobStatus status = m_jobList->getJobStatus(m_jobList->index(currentIdx, 0, QModelIndex()));
+ if(status == JobStatus_Enqueued)
{
if(m_jobList->startJob(m_jobList->index(currentIdx, 0, QModelIndex())))
{
- jobsView->selectRow(currentIdx);
+ ui->jobsView->selectRow(currentIdx);
return;
}
}
}
/*
+ * Save log to text file
+ */
+void MainWindow::saveLogFile(const QModelIndex &index)
+{
+ if(index.isValid())
+ {
+ if(LogFileModel *log = m_jobList->getLogFile(index))
+ {
+ QDir(QString("%1/logs").arg(x264_data_path())).mkpath(".");
+ QString logFilePath = QString("%1/logs/LOG.%2.%3.txt").arg(x264_data_path(), QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString(Qt::ISODate).replace(':', "-"));
+ QFile outFile(logFilePath);
+ if(outFile.open(QIODevice::WriteOnly))
+ {
+ QTextStream outStream(&outFile);
+ outStream.setCodec("UTF-8");
+ outStream.setGenerateByteOrderMark(true);
+
+ const int rows = log->rowCount(QModelIndex());
+ for(int i = 0; i < rows; i++)
+ {
+ outStream << log->data(log->index(i, 0, QModelIndex()), Qt::DisplayRole).toString() << QLatin1String("\r\n");
+ }
+ outFile.close();
+ }
+ else
+ {
+ qWarning("Failed to open log file for writing:\n%s", logFilePath.toUtf8().constData());
+ }
+ }
+ }
+}
+
+/*
* Shut down the computer (with countdown)
*/
void MainWindow::shutdownComputer(void)
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
QApplication::setOverrideCursor(Qt::WaitCursor);
- PlaySound(MAKEINTRESOURCE(IDR_WAVE1), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
+ x264_play_sound(IDR_WAVE1, false);
QApplication::restoreOverrideCursor();
QTimer timer;
progressDialog.setLabelText(text.arg(iTimeout-i));
if(iTimeout-i == 3) progressDialog.setCancelButton(NULL);
QApplication::processEvents();
- PlaySound(MAKEINTRESOURCE((i < iTimeout) ? IDR_WAVE2 : IDR_WAVE3), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
+ x264_play_sound(((i < iTimeout) ? IDR_WAVE2 : IDR_WAVE3), false);
}
qWarning("Shutting down !!!");
*/
void MainWindow::init(void)
{
- static const char *binFiles = "x264.exe:x264_x64.exe:avs2yuv.exe:avs2yuv_x64.exe";
+ if(m_status != STATUS_PRE_INIT)
+ {
+ qWarning("Already initialized -> skipping!");
+ return;
+ }
+
+ static const char *binFiles = "x86/x264_8bit_x86.exe:x64/x264_8bit_x64.exe:x86/x264_10bit_x86.exe:x64/x264_10bit_x64.exe:x86/avs2yuv_x86.exe:x64/avs2yuv_x64.exe";
QStringList binaries = QString::fromLatin1(binFiles).split(":", QString::SkipEmptyParts);
updateLabelPos();
+ //Create the IPC listener thread
+ if(m_ipc->isInitialized())
+ {
+ connect(m_ipc, SIGNAL(receivedCommand(int,QStringList)), this, SLOT(handleCommand(int,QStringList)), Qt::QueuedConnection);
+ m_ipc->startListening();
+ }
+
//Check all binaries
while(!binaries.isEmpty())
{
QFile *file = new QFile(QString("%1/toolset/%2").arg(m_appDir, current));
if(file->open(QIODevice::ReadOnly))
{
- bool binaryTypeOkay = false;
- DWORD binaryType;
- if(GetBinaryType(QWCHAR(file->fileName()), &binaryType))
- {
- binaryTypeOkay = (binaryType == SCS_32BIT_BINARY || binaryType == SCS_64BIT_BINARY);
- }
- if(!binaryTypeOkay)
+ if(!x264_is_executable(file->fileName()))
{
- QMessageBox::critical(this, tr("Invalid File!"), tr("<nobr>At least on required tool is not a valid Win32 or Win64 binary:<br>%1<br><br>Please re-install the program in order to fix the problem!</nobr>").arg(QDir::toNativeSeparators(QString("%1/toolset/%2").arg(m_appDir, current))).replace("-", "−"));
+ QMessageBox::critical(this, tr("Invalid File!"), tr("<nobr>At least on required tool is not a valid Win32 or Win64 binary:<br><tt style=\"whitespace:nowrap\">%1</tt><br><br>Please re-install the program in order to fix the problem!</nobr>").arg(QDir::toNativeSeparators(QString("%1/toolset/%2").arg(m_appDir, current))).replace("-", "−"));
qFatal(QString("Binary is invalid: %1/toolset/%2").arg(m_appDir, current).toLatin1().constData());
- close(); qApp->exit(-1); return;
+ INIT_ERROR_EXIT();
}
m_toolsList << file;
}
else
{
X264_DELETE(file);
- QMessageBox::critical(this, tr("File Not Found!"), tr("<nobr>At least on required tool could not be found:<br>%1<br><br>Please re-install the program in order to fix the problem!</nobr>").arg(QDir::toNativeSeparators(QString("%1/toolset/%2").arg(m_appDir, current))).replace("-", "−"));
+ QMessageBox::critical(this, tr("File Not Found!"), tr("<nobr>At least on required tool could not be found:<br><tt style=\"whitespace:nowrap\">%1</tt><br><br>Please re-install the program in order to fix the problem!</nobr>").arg(QDir::toNativeSeparators(QString("%1/toolset/%2").arg(m_appDir, current))).replace("-", "−"));
qFatal(QString("Binary not found: %1/toolset/%2").arg(m_appDir, current).toLatin1().constData());
- close(); qApp->exit(-1); return;
+ INIT_ERROR_EXIT();
}
}
if(!ok)
{
int val = QMessageBox::warning(this, tr("Write Test Failed"), tr("<nobr>The application was launched in portable mode, but the program path is <b>not</b> writable!</nobr>"), tr("Quit"), tr("Ignore"));
- if(val != 1) { close(); qApp->exit(-1); return; }
+ if(val != 1) INIT_ERROR_EXIT();
}
}
{
qsrand(time(NULL)); int rnd = qrand() % 3;
int val = QMessageBox::information(this, tr("Pre-Release Version"), tr("Note: This is a pre-release version. Please do NOT use for production!<br>Click the button #%1 in order to continue...<br><br>(There will be no such message box in the final version of this application)").arg(QString::number(rnd + 1)), tr("(1)"), tr("(2)"), tr("(3)"), qrand() % 3);
- if(rnd != val) { close(); qApp->exit(-1); return; }
+ if(rnd != val) INIT_ERROR_EXIT();
}
//Make sure this CPU can run x264 (requires MMX + MMXEXT/iSSE to run x264 with ASM enabled, additionally requires SSE1 for most x264 builds)
{
QMessageBox::critical(this, tr("Unsupported CPU"), tr("<nobr>Sorry, but this machine is <b>not</b> physically capable of running x264 (with assembly).<br>Please get a CPU that supports at least the MMX and MMXEXT instruction sets!</nobr>"), tr("Quit"));
qFatal("System does not support MMX and MMXEXT, x264 will not work !!!");
- close(); qApp->exit(-1); return;
+ INIT_ERROR_EXIT();
}
else if(!(m_cpuFeatures->mmx && m_cpuFeatures->sse))
{
qWarning("WARNING: System does not support SSE1, most x264 builds will not work !!!\n");
int val = QMessageBox::warning(this, tr("Unsupported CPU"), tr("<nobr>It appears that this machine does <b>not</b> support the SSE1 instruction set.<br>Thus most builds of x264 will <b>not</b> run on this computer at all.<br><br>Please get a CPU that supports the MMX and SSE1 instruction sets!</nobr>"), tr("Quit"), tr("Ignore"));
- if(val != 1) { close(); qApp->exit(-1); return; }
+ if(val != 1) INIT_ERROR_EXIT();
+ }
+
+ //Skip version check (not recommended!)
+ if(qApp->arguments().contains("--skip-x264-version-check", Qt::CaseInsensitive))
+ {
+ qWarning("x264 version check disabled, you have been warned!\n");
+ m_skipVersionTest = true;
+ }
+
+ //Don't abort encoding process on timeout (not recommended!)
+ if(qApp->arguments().contains("--no-deadlock-detection", Qt::CaseInsensitive))
+ {
+ qWarning("Deadlock detection disabled, you have been warned!\n");
+ m_abortOnTimeout = false;
}
//Check for Avisynth support
- bool avsAvailable = false;
- QLibrary *avsLib = new QLibrary("avisynth.dll");
- if(avsLib->load())
+ if(!qApp->arguments().contains("--skip-avisynth-check", Qt::CaseInsensitive))
{
- avsAvailable = (avsLib->resolve("avs_create_script_environment") != NULL);
+ qDebug("[Check for Avisynth support]");
+ volatile double avisynthVersion = 0.0;
+ const int result = AvisynthCheckThread::detect(&avisynthVersion);
+ if(result < 0)
+ {
+ QString text = tr("A critical error was encountered while checking your Avisynth version.").append("<br>");
+ text += tr("This is most likely caused by an erroneous Avisynth Plugin, please try to clean your Plugins folder!").append("<br>");
+ text += tr("We suggest to move all .dll and .avsi files out of your Avisynth Plugins folder and try again.");
+ int val = QMessageBox::critical(this, tr("Avisynth Error"), QString("<nobr>%1</nobr>").arg(text).replace("-", "−"), tr("Quit"), tr("Ignore"));
+ if(val != 1) INIT_ERROR_EXIT();
+ }
+ if((!result) || (avisynthVersion < 2.5))
+ {
+ if(!m_preferences->disableWarnings())
+ {
+ QString text = tr("It appears that Avisynth is <b>not</b> currently installed on your computer.<br>Therefore Avisynth (.avs) input will <b>not</b> be working at all!").append("<br><br>");
+ text += tr("Please download and install Avisynth:").append("<br>").append(LINK("http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/"));
+ int val = QMessageBox::warning(this, tr("Avisynth Missing"), QString("<nobr>%1</nobr>").arg(text).replace("-", "−"), tr("Quit"), tr("Ignore"));
+ if(val != 1) INIT_ERROR_EXIT();
+ }
+ }
+ qDebug(" ");
}
- if(!avsAvailable)
+
+ //Check for VapourSynth support
+ if(!qApp->arguments().contains("--skip-vapoursynth-check", Qt::CaseInsensitive))
{
- avsLib->unload(); X264_DELETE(avsLib);
- int val = QMessageBox::warning(this, tr("Avisynth Missing"), tr("<nobr>It appears that Avisynth is <b>not</b> currently installed on your computer.<br>Thus Avisynth (.avs) input will <b>not</b> be working at all!<br><br>Please download and install Avisynth:<br><a href=\"http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/\">http://sourceforge.net/projects/avisynth2/files/AviSynth 2.5/</a></nobr>").replace("-", "−"), tr("Quit"), tr("Ignore"));
- if(val != 1) { close(); qApp->exit(-1); return; }
+ qDebug("[Check for VapourSynth support]");
+ volatile double avisynthVersion = 0.0;
+ const int result = VapourSynthCheckThread::detect(m_vapoursynthPath);
+ if(result < 0)
+ {
+ QString text = tr("A critical error was encountered while checking your VapourSynth installation.").append("<br>");
+ text += tr("This is most likely caused by an erroneous VapourSynth Plugin, please try to clean your Filters folder!").append("<br>");
+ text += tr("We suggest to move all .dll files out of your VapourSynth Filters folder and try again.");
+ int val = QMessageBox::critical(this, tr("VapourSynth Error"), QString("<nobr>%1</nobr>").arg(text).replace("-", "−"), tr("Quit"), tr("Ignore"));
+ if(val != 1) INIT_ERROR_EXIT();
+ }
+ if((!result) || (m_vapoursynthPath.isEmpty()))
+ {
+ if(!m_preferences->disableWarnings())
+ {
+ QString text = tr("It appears that VapourSynth is <b>not</b> currently installed on your computer.<br>Therefore VapourSynth (.vpy) input will <b>not</b> be working at all!").append("<br><br>");
+ text += tr("Please download and install VapourSynth for Windows (R19 or later):").append("<br>").append(LINK("http://www.vapoursynth.com/")).append("<br><br>");
+ text += tr("Note that Python 3.3 (x86) is a prerequisite for installing VapourSynth:").append("<br>").append(LINK("http://www.python.org/getit/")).append("<br>");
+ int val = QMessageBox::warning(this, tr("VapourSynth Missing"), QString("<nobr>%1</nobr>").arg(text).replace("-", "−"), tr("Quit"), tr("Ignore"));
+ if(val != 1) INIT_ERROR_EXIT();
+ }
+ }
+ qDebug(" ");
}
+ //Enable drag&drop support for this window, required for Qt v4.8.4+
+ setAcceptDrops(true);
+
//Check for expiration
- if(x264_version_date().addMonths(6) < QDate::currentDate())
+ if(x264_version_date().addMonths(6) < x264_current_date_safe())
{
+ QString text;
+ text += QString("<nobr><tt>%1</tt></nobr><br><br>").arg(tr("Your version of Simple x264 Launcher is more than 6 months old!").replace("-", "−"));
+ text += QString("<nobr><tt>%1<br><a href=\"%2\">%2</a><br><br>").arg(tr("You can download the most recent version from the official web-site now:").replace("-", "−"), QString::fromLatin1(update_url));
+ text += QString("<nobr><tt>%1</tt></nobr><br>").arg(tr("Alternatively, click 'Check for Updates' to run the auto-update utility.").replace("-", "−"));
QMessageBox msgBox(this);
msgBox.setIconPixmap(QIcon(":/images/update.png").pixmap(56,56));
msgBox.setWindowTitle(tr("Update Notification"));
msgBox.setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
- msgBox.setText(tr("<nobr><tt>Your version of 'Simple x264 Launcher' is more than 6 months old!<br><br>Please download the most recent version from the official web-site at:<br><a href=\"%1\">%1</a><br></tt></nobr>").replace("-", "−").arg(update_url));
- QPushButton *btn1 = msgBox.addButton(tr("Discard"), QMessageBox::NoRole);
- QPushButton *btn2 = msgBox.addButton(tr("Discard"), QMessageBox::AcceptRole);
- btn1->setEnabled(false);
- btn2->setVisible(false);
- QTimer::singleShot(5000, btn1, SLOT(hide()));
- 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((!current.startsWith("--")) && QFileInfo(current).exists() && QFileInfo(current).isFile())
+ msgBox.setText(text);
+ QPushButton *btn1 = msgBox.addButton(tr("Check for Updates"), QMessageBox::AcceptRole);
+ QPushButton *btn2 = msgBox.addButton(tr("Discard"), QMessageBox::NoRole);
+ QPushButton *btn3 = msgBox.addButton(btn2->text(), QMessageBox::RejectRole);
+ btn2->setEnabled(false);
+ btn3->setVisible(false);
+ QTimer::singleShot(7500, btn2, SLOT(hide()));
+ QTimer::singleShot(7500, btn3, SLOT(show()));
+ if(msgBox.exec() == 0)
{
- files << QFileInfo(current).canonicalFilePath();
+ m_status = STATUS_IDLE;
+ QTimer::singleShot(0, this, SLOT(checkUpdates()));
+ return;
}
}
- if(int totalFiles = files.count())
+
+ //Update app staus
+ m_status = STATUS_IDLE;
+
+ //Try adding files from command-line
+ if(!parseCommandLineArgs())
{
- bool ok = true; int n = 0;
- while((!files.isEmpty()) && ok)
+ //Update reminder
+ if((!m_preferences->noUpdateReminder()) && (m_recentlyUsed->lastUpdateCheck() + 14 < x264_current_date_safe().toJulianDay()))
{
- QString currentFile = files.takeFirst();
- qDebug("Adding file: %s", currentFile.toUtf8().constData());
- addButtonPressed(currentFile, n++, totalFiles, &ok);
+ if(QMessageBox::warning(this, tr("Update Notification"), QString("<nobr>%1</nobr>").arg(tr("Your last update check was more than 14 days ago. Check for updates now?")), tr("Check for Updates"), tr("Discard")) == 0)
+ {
+ QTimer::singleShot(0, this, SLOT(checkUpdates()));
+ return;
+ }
}
}
}
*/
void MainWindow::updateLabelPos(void)
{
- const QWidget *const viewPort = jobsView->viewport();
+ const QWidget *const viewPort = ui->jobsView->viewport();
m_label->setGeometry(0, 0, viewPort->width(), viewPort->height());
}
{
qDebug("copyLogToClipboard");
- if(LogFileModel *log = dynamic_cast<LogFileModel*>(logView->model()))
+ if(LogFileModel *log = dynamic_cast<LogFileModel*>(ui->logView->model()))
{
log->copyToClipboard();
- MessageBeep(MB_ICONINFORMATION);
+ x264_beep(x264_beep_info);
}
}
/*
* Process the dropped files
*/
-void MainWindow::handleDroppedFiles(void)
+void MainWindow::handlePendingFiles(void)
+{
+ if((m_status == STATUS_IDLE) || (m_status == STATUS_AWAITING))
+ {
+ qDebug("MainWindow::handlePendingFiles");
+ if(!m_pendingFiles->isEmpty())
+ {
+ QStringList pendingFiles(*m_pendingFiles);
+ m_pendingFiles->clear();
+ createJobMultiple(pendingFiles);
+ }
+ qDebug("Leave from MainWindow::handlePendingFiles!");
+ m_status = STATUS_IDLE;
+ }
+}
+
+void MainWindow::handleCommand(const int &command, const QStringList &args)
{
- qDebug("MainWindow::handleDroppedFiles");
- if(m_droppedFiles)
+ if((m_status != STATUS_IDLE) && (m_status != STATUS_AWAITING))
+ {
+ qWarning("Cannot accapt commands at this time -> discarding!");
+ }
+
+ x264_bring_to_front(this);
+
+#ifdef IPC_LOGGING
+ qDebug("\n---------- IPC ----------");
+ qDebug("CommandId: %d", command);
+ for(QStringList::ConstIterator iter = args.constBegin(); iter != args.constEnd(); iter++)
+ {
+ qDebug("Arguments: %s", iter->toUtf8().constData());
+ }
+ qDebug("---------- IPC ----------\n");
+#endif //IPC_LOGGING
+
+ switch(command)
{
- QStringList droppedFiles(*m_droppedFiles);
- m_droppedFiles->clear();
- int totalFiles = droppedFiles.count();
- bool ok = true; int n = 0;
- while((!droppedFiles.isEmpty()) && ok)
+ case IPC::IPC_OPCODE_PING:
+ qDebug("Received a PING request from another instance!");
+ x264_blink_window(this, 5, 125);
+ break;
+ case IPC::IPC_OPCODE_ADD_FILE:
+ if(!args.isEmpty())
{
- QString currentFile = droppedFiles.takeFirst();
- qDebug("Adding file: %s", currentFile.toUtf8().constData());
- addButtonPressed(currentFile, n++, totalFiles, &ok);
+ if(QFileInfo(args[0]).exists() && QFileInfo(args[0]).isFile())
+ {
+ *m_pendingFiles << QFileInfo(args[0]).canonicalFilePath();
+ if(m_status != STATUS_AWAITING)
+ {
+ m_status = STATUS_AWAITING;
+ QTimer::singleShot(3333, this, SLOT(handlePendingFiles()));
+ }
+ }
+ else
+ {
+ qWarning("File '%s' not found!", args[0].toUtf8().constData());
+ }
}
+ break;
+ case IPC::IPC_OPCODE_ADD_JOB:
+ if(args.size() >= 3)
+ {
+ if(QFileInfo(args[0]).exists() && QFileInfo(args[0]).isFile())
+ {
+ OptionsModel options;
+ if(!(args[2].isEmpty() || X264_STRCMP(args[2], "-")))
+ {
+ if(!OptionsModel::loadTemplate(&options, args[2].trimmed()))
+ {
+ qWarning("Template '%s' could not be found -> using defaults!", args[2].trimmed().toUtf8().constData());
+ }
+ }
+ appendJob(args[0], args[1], &options, true);
+ }
+ else
+ {
+ qWarning("Source file '%s' not found!", args[0].toUtf8().constData());
+ }
+ }
+ break;
+ default:
+ throw std::exception("Unknown command received!");
+ }
+}
+
+void MainWindow::checkUpdates(void)
+{
+ ENSURE_APP_IS_IDLE();
+ m_status = STATUS_BLOCKED;
+
+ if(countRunningJobs() > 0)
+ {
+ QMessageBox::warning(this, tr("Jobs Are Running"), tr("Sorry, can not update while there still are running jobs!"));
+ m_status = STATUS_IDLE;
+ return;
+ }
+
+ UpdaterDialog *updater = new UpdaterDialog(this, QString("%1/toolset").arg(m_appDir));
+ const int ret = updater->exec();
+
+ if(updater->getSuccess())
+ {
+ m_recentlyUsed->setLastUpdateCheck(x264_current_date_safe().toJulianDay());
+ RecentlyUsed::saveRecentlyUsed(m_recentlyUsed);
+ }
+
+ if(ret == UpdaterDialog::READY_TO_INSTALL_UPDATE)
+ {
+ m_status = STATUS_EXITTING;
+ qWarning("Exitting program to install update...");
+ close();
+ QApplication::quit();
+ }
+
+ X264_DELETE(updater);
+
+ if(m_status != STATUS_EXITTING)
+ {
+ m_status = STATUS_IDLE;
}
- qDebug("Leave from MainWindow::handleDroppedFiles!");
}
///////////////////////////////////////////////////////////////////////////////
*/
void MainWindow::closeEvent(QCloseEvent *e)
{
- if(countRunningJobs() > 0)
+ if((m_status != STATUS_IDLE) && (m_status != STATUS_EXITTING))
{
- e->ignore();
- QMessageBox::warning(this, tr("Jobs Are Running"), tr("Sorry, can not exit while there still are running jobs!"));
+ qWarning("Cannot close window at this time!");
return;
}
-
- if(countPendingJobs() > 0)
+
+ if(m_status != STATUS_EXITTING)
{
- int ret = QMessageBox::question(this, tr("Jobs Are Pending"), tr("Do you really want to quit and discard the pending jobs?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
- if(ret != QMessageBox::Yes)
+ if(countRunningJobs() > 0)
{
e->ignore();
+ m_status = STATUS_BLOCKED;
+ QMessageBox::warning(this, tr("Jobs Are Running"), tr("Sorry, can not exit while there still are running jobs!"));
+ m_status = STATUS_IDLE;
return;
}
+
+ if(countPendingJobs() > 0)
+ {
+ m_status = STATUS_BLOCKED;
+ int ret = QMessageBox::question(this, tr("Jobs Are Pending"), tr("Do you really want to quit and discard the pending jobs?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+ if(ret != QMessageBox::Yes)
+ {
+ e->ignore();
+ m_status = STATUS_IDLE;
+ return;
+ }
+ }
}
while(m_jobList->rowCount(QModelIndex()) > 0)
if(!m_jobList->deleteJob(m_jobList->index(0, 0, QModelIndex())))
{
e->ignore();
+ m_status = STATUS_BLOCKED;
QMessageBox::warning(this, tr("Failed To Exit"), tr("Sorry, at least one job could not be deleted!"));
+ m_status = STATUS_IDLE;
return;
}
}
*/
bool MainWindow::eventFilter(QObject *o, QEvent *e)
{
- if((o == labelBuildDate) && (e->type() == QEvent::MouseButtonPress))
+ if((o == ui->labelBuildDate) && (e->type() == QEvent::MouseButtonPress))
{
QTimer::singleShot(0, this, SLOT(showAbout()));
return true;
*/
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
- QStringList formats = event->mimeData()->formats();
-
- if(formats.contains("application/x-qt-windows-mime;value=\"FileNameW\"", Qt::CaseInsensitive) && formats.contains("text/uri-list", Qt::CaseInsensitive))
+ bool accept[2] = {false, false};
+
+ foreach(const QString &fmt, event->mimeData()->formats())
+ {
+ accept[0] = accept[0] || fmt.contains("text/uri-list", Qt::CaseInsensitive);
+ accept[1] = accept[1] || fmt.contains("FileNameW", Qt::CaseInsensitive);
+ }
+
+ if(accept[0] && accept[1])
{
event->acceptProposedAction();
}
if(droppedFiles.count() > 0)
{
- if(!m_droppedFiles)
- {
- m_droppedFiles = new QStringList();
- }
- m_droppedFiles->append(droppedFiles);
- m_droppedFiles->sort();
- QTimer::singleShot(0, this, SLOT(handleDroppedFiles()));
+ m_pendingFiles->append(droppedFiles);
+ m_pendingFiles->sort();
+ QTimer::singleShot(0, this, SLOT(handlePendingFiles()));
}
}
///////////////////////////////////////////////////////////////////////////////
/*
+ * Creates a new job
+ */
+bool MainWindow::createJob(QString &sourceFileName, QString &outputFileName, OptionsModel *options, bool &runImmediately, const bool restart, int fileNo, int fileTotal, bool *applyToAll)
+{
+ bool okay = false;
+ AddJobDialog *addDialog = new AddJobDialog(this, options, m_recentlyUsed, m_cpuFeatures->x64, m_preferences->use10BitEncoding(), m_preferences->saveToSourcePath());
+
+ addDialog->setRunImmediately(runImmediately);
+ if(!sourceFileName.isEmpty()) addDialog->setSourceFile(sourceFileName);
+ if(!outputFileName.isEmpty()) addDialog->setOutputFile(outputFileName);
+ if(restart) addDialog->setWindowTitle(tr("Restart Job"));
+
+ const bool multiFile = (fileNo >= 0) && (fileTotal > 1);
+ if(multiFile)
+ {
+ addDialog->setSourceEditable(false);
+ addDialog->setWindowTitle(addDialog->windowTitle().append(tr(" (File %1 of %2)").arg(QString::number(fileNo+1), QString::number(fileTotal))));
+ addDialog->setApplyToAllVisible(applyToAll);
+ }
+
+ if(addDialog->exec() == QDialog::Accepted)
+ {
+ sourceFileName = addDialog->sourceFile();
+ outputFileName = addDialog->outputFile();
+ runImmediately = addDialog->runImmediately();
+ if(applyToAll)
+ {
+ *applyToAll = addDialog->applyToAll();
+ }
+ okay = true;
+ }
+
+ X264_DELETE(addDialog);
+ return okay;
+}
+
+/*
+ * Creates a new job from *multiple* files
+ */
+bool MainWindow::createJobMultiple(const QStringList &filePathIn)
+{
+ QStringList::ConstIterator iter;
+ bool applyToAll = false, runImmediately = false;
+ int counter = 0;
+
+ //Add files individually
+ for(iter = filePathIn.constBegin(); (iter != filePathIn.constEnd()) && (!applyToAll); iter++)
+ {
+ runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
+ QString sourceFileName(*iter), outputFileName;
+ if(createJob(sourceFileName, outputFileName, m_options, runImmediately, false, counter++, filePathIn.count(), &applyToAll))
+ {
+ if(appendJob(sourceFileName, outputFileName, m_options, runImmediately))
+ {
+ continue;
+ }
+ }
+ return false;
+ }
+
+ //Add remaining files
+ while(applyToAll && (iter != filePathIn.constEnd()))
+ {
+ const bool runImmediatelyTmp = runImmediately && (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
+ const QString sourceFileName = *iter;
+ const QString outputFileName = AddJobDialog::generateOutputFileName(sourceFileName, m_recentlyUsed->outputDirectory(), m_recentlyUsed->filterIndex(), m_preferences->saveToSourcePath());
+ if(!appendJob(sourceFileName, outputFileName, m_options, runImmediatelyTmp))
+ {
+ return false;
+ }
+ iter++;
+ }
+
+ return true;
+}
+
+
+/*
+ * Append a new job
+ */
+bool MainWindow::appendJob(const QString &sourceFileName, const QString &outputFileName, OptionsModel *options, const bool runImmediately)
+{
+ bool okay = false;
+
+ EncodeThread *thrd = new EncodeThread
+ (
+ sourceFileName,
+ outputFileName,
+ options,
+ QString("%1/toolset").arg(m_appDir),
+ m_vapoursynthPath,
+ m_cpuFeatures->x64,
+ m_preferences->use10BitEncoding(),
+ m_cpuFeatures->x64 && m_preferences->useAvisyth64Bit(),
+ m_skipVersionTest,
+ m_preferences->processPriority(),
+ m_abortOnTimeout
+ );
+
+ QModelIndex newIndex = m_jobList->insertJob(thrd);
+
+ if(newIndex.isValid())
+ {
+ if(runImmediately)
+ {
+ ui->jobsView->selectRow(newIndex.row());
+ QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
+ m_jobList->startJob(newIndex);
+ }
+
+ okay = true;
+ }
+
+ m_label->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
+ return okay;
+}
+
+/*
* Jobs that are not completed (or failed, or aborted) yet
*/
unsigned int MainWindow::countPendingJobs(void)
for(int i = 0; i < rows; i++)
{
- EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
- if(status != EncodeThread::JobStatus_Completed && status != EncodeThread::JobStatus_Aborted && status != EncodeThread::JobStatus_Failed)
+ JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
+ if(status != JobStatus_Completed && status != JobStatus_Aborted && status != JobStatus_Failed)
{
count++;
}
for(int i = 0; i < rows; i++)
{
- EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
- if(status != EncodeThread::JobStatus_Completed && status != EncodeThread::JobStatus_Aborted && status != EncodeThread::JobStatus_Failed && status != EncodeThread::JobStatus_Enqueued)
+ JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
+ if(status != JobStatus_Completed && status != JobStatus_Aborted && status != JobStatus_Failed && status != JobStatus_Enqueued)
{
count++;
}
/*
* Update all buttons with respect to current job status
*/
-void MainWindow::updateButtons(EncodeThread::JobStatus status)
+void MainWindow::updateButtons(JobStatus status)
{
qDebug("MainWindow::updateButtons(void)");
- buttonStartJob->setEnabled(status == EncodeThread::JobStatus_Enqueued);
- buttonAbortJob->setEnabled(status == EncodeThread::JobStatus_Indexing || status == EncodeThread::JobStatus_Running || status == EncodeThread::JobStatus_Running_Pass1 || status == EncodeThread::JobStatus_Running_Pass2 || status == EncodeThread::JobStatus_Paused);
- buttonPauseJob->setEnabled(status == EncodeThread::JobStatus_Indexing || status == EncodeThread::JobStatus_Running || status == EncodeThread::JobStatus_Paused || status == EncodeThread::JobStatus_Running_Pass1 || status == EncodeThread::JobStatus_Running_Pass2);
- buttonPauseJob->setChecked(status == EncodeThread::JobStatus_Paused || status == EncodeThread::JobStatus_Pausing);
+ ui->buttonStartJob->setEnabled(status == JobStatus_Enqueued);
+ ui->buttonAbortJob->setEnabled(status == JobStatus_Indexing || status == JobStatus_Running || status == JobStatus_Running_Pass1 || status == JobStatus_Running_Pass2 || status == JobStatus_Paused);
+ ui->buttonPauseJob->setEnabled(status == JobStatus_Indexing || status == JobStatus_Running || status == JobStatus_Paused || status == JobStatus_Running_Pass1 || status == JobStatus_Running_Pass2);
+ ui->buttonPauseJob->setChecked(status == JobStatus_Paused || status == JobStatus_Pausing);
- actionJob_Delete->setEnabled(status == EncodeThread::JobStatus_Completed || status == EncodeThread::JobStatus_Aborted || status == EncodeThread::JobStatus_Failed || status == EncodeThread::JobStatus_Enqueued);
- actionJob_Browse->setEnabled(status == EncodeThread::JobStatus_Completed);
+ ui->actionJob_Delete->setEnabled(status == JobStatus_Completed || status == JobStatus_Aborted || status == JobStatus_Failed || status == JobStatus_Enqueued);
+ ui->actionJob_Restart->setEnabled(status == JobStatus_Completed || status == JobStatus_Aborted || status == JobStatus_Failed || status == JobStatus_Enqueued);
+ ui->actionJob_Browse->setEnabled(status == JobStatus_Completed);
- actionJob_Start->setEnabled(buttonStartJob->isEnabled());
- actionJob_Abort->setEnabled(buttonAbortJob->isEnabled());
- actionJob_Pause->setEnabled(buttonPauseJob->isEnabled());
- actionJob_Pause->setChecked(buttonPauseJob->isChecked());
+ ui->actionJob_Start->setEnabled(ui->buttonStartJob->isEnabled());
+ ui->actionJob_Abort->setEnabled(ui->buttonAbortJob->isEnabled());
+ ui->actionJob_Pause->setEnabled(ui->buttonPauseJob->isEnabled());
+ ui->actionJob_Pause->setChecked(ui->buttonPauseJob->isChecked());
- editDetails->setEnabled(status != EncodeThread::JobStatus_Paused);
+ ui->editDetails->setEnabled(status != JobStatus_Paused);
}
/*
* Update the taskbar with current job status
*/
-void MainWindow::updateTaskbar(EncodeThread::JobStatus status, const QIcon &icon)
+void MainWindow::updateTaskbar(JobStatus status, const QIcon &icon)
{
qDebug("MainWindow::updateTaskbar(void)");
switch(status)
{
- case EncodeThread::JobStatus_Undefined:
+ case JobStatus_Undefined:
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNoState);
break;
- case EncodeThread::JobStatus_Aborting:
- case EncodeThread::JobStatus_Starting:
- case EncodeThread::JobStatus_Pausing:
- case EncodeThread::JobStatus_Resuming:
+ case JobStatus_Aborting:
+ case JobStatus_Starting:
+ case JobStatus_Pausing:
+ case JobStatus_Resuming:
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarIndeterminateState);
break;
- case EncodeThread::JobStatus_Aborted:
- case EncodeThread::JobStatus_Failed:
+ case JobStatus_Aborted:
+ case JobStatus_Failed:
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState);
break;
- case EncodeThread::JobStatus_Paused:
+ case JobStatus_Paused:
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarPausedState);
break;
default:
switch(status)
{
- case EncodeThread::JobStatus_Aborting:
- case EncodeThread::JobStatus_Starting:
- case EncodeThread::JobStatus_Pausing:
- case EncodeThread::JobStatus_Resuming:
+ case JobStatus_Aborting:
+ case JobStatus_Starting:
+ case JobStatus_Pausing:
+ case JobStatus_Resuming:
break;
default:
- WinSevenTaskbar::setTaskbarProgress(this, progressBar->value(), progressBar->maximum());
+ WinSevenTaskbar::setTaskbarProgress(this, ui->progressBar->value(), ui->progressBar->maximum());
break;
}
WinSevenTaskbar::setOverlayIcon(this, icon.isNull() ? NULL : &icon);
}
+
+/*
+ * Parse command-line arguments
+ */
+bool MainWindow::parseCommandLineArgs(void)
+{
+ bool bCommandAccepted = false;
+
+ QStringList files;
+ QStringList args = x264_arguments();
+
+ args.takeFirst(); //Pop argv[0]
+
+ while(!args.isEmpty())
+ {
+ QString current = args.takeFirst();
+ if(X264_STRCMP(current, "--add") || X264_STRCMP(current, "--add-file"))
+ {
+ bCommandAccepted = true;
+ if(!args.isEmpty())
+ {
+ handleCommand(IPC::IPC_OPCODE_ADD_FILE, QStringList() << args.takeFirst());
+ }
+ else
+ {
+ qWarning("Argument for '--add-file' is missing!");
+ }
+ }
+ else if(X264_STRCMP(current, "--add-job"))
+ {
+ bCommandAccepted = true;
+ if(args.size() >= 3)
+ {
+ QStringList lst;
+ for(int i = 0; i < 3; i++)
+ {
+ lst << args.takeFirst();
+ }
+ handleCommand(IPC::IPC_OPCODE_ADD_JOB, lst);
+ }
+ else
+ {
+ qWarning("Argument(s) for '--add-job' are missing!");
+ args.clear();
+ }
+ }
+ else
+ {
+ if(!current.startsWith("--"))
+ {
+ qWarning("Unknown argument: %s", current.toUtf8().constData());
+ break;
+ }
+ }
+ }
+
+ return bCommandAccepted;
+}