Improved UI status handling.
This commit is contained in:
parent
c76bac6f35
commit
1f41a535d4
@ -26,7 +26,7 @@
|
|||||||
#define VER_X264_MAJOR 2
|
#define VER_X264_MAJOR 2
|
||||||
#define VER_X264_MINOR 3
|
#define VER_X264_MINOR 3
|
||||||
#define VER_X264_PATCH 0
|
#define VER_X264_PATCH 0
|
||||||
#define VER_X264_BUILD 730
|
#define VER_X264_BUILD 732
|
||||||
|
|
||||||
#define VER_X264_MINIMUM_REV 2363
|
#define VER_X264_MINIMUM_REV 2363
|
||||||
#define VER_X264_CURRENT_API 140
|
#define VER_X264_CURRENT_API 140
|
||||||
|
185
src/win_main.cpp
185
src/win_main.cpp
@ -62,7 +62,8 @@ const char *tpl_last = "<LAST_USED>";
|
|||||||
#define SET_FONT_BOLD(WIDGET,BOLD) do { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); } while(0)
|
#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 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 LINK(URL) "<a href=\"" URL "\">" URL "</a>"
|
||||||
#define INIT_ERROR_EXIT() do { m_initialized = true; close(); qApp->exit(-1); return; } while(0)
|
#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; }
|
//static int exceptionFilter(_EXCEPTION_RECORD *dst, _EXCEPTION_POINTERS *src) { memcpy(dst, src->ExceptionRecord, sizeof(_EXCEPTION_RECORD)); return EXCEPTION_EXECUTE_HANDLER; }
|
||||||
|
|
||||||
@ -80,13 +81,13 @@ MainWindow::MainWindow(const x264_cpu_t *const cpuFeatures, IPC *ipc)
|
|||||||
m_appDir(QApplication::applicationDirPath()),
|
m_appDir(QApplication::applicationDirPath()),
|
||||||
m_options(NULL),
|
m_options(NULL),
|
||||||
m_jobList(NULL),
|
m_jobList(NULL),
|
||||||
m_droppedFiles(NULL),
|
m_pendingFiles(new QStringList()),
|
||||||
m_preferences(NULL),
|
m_preferences(NULL),
|
||||||
m_recentlyUsed(NULL),
|
m_recentlyUsed(NULL),
|
||||||
m_skipVersionTest(false),
|
m_skipVersionTest(false),
|
||||||
m_abortOnTimeout(true),
|
m_abortOnTimeout(true),
|
||||||
|
m_status(STATUS_PRE_INIT),
|
||||||
m_firstShow(true),
|
m_firstShow(true),
|
||||||
m_initialized(false),
|
|
||||||
ui(new Ui::MainWindow())
|
ui(new Ui::MainWindow())
|
||||||
{
|
{
|
||||||
//Init the dialog, from the .ui file
|
//Init the dialog, from the .ui file
|
||||||
@ -201,7 +202,7 @@ MainWindow::~MainWindow(void)
|
|||||||
|
|
||||||
X264_DELETE(m_jobList);
|
X264_DELETE(m_jobList);
|
||||||
X264_DELETE(m_options);
|
X264_DELETE(m_options);
|
||||||
X264_DELETE(m_droppedFiles);
|
X264_DELETE(m_pendingFiles);
|
||||||
X264_DELETE(m_label);
|
X264_DELETE(m_label);
|
||||||
|
|
||||||
while(!m_toolsList.isEmpty())
|
while(!m_toolsList.isEmpty())
|
||||||
@ -239,6 +240,9 @@ MainWindow::~MainWindow(void)
|
|||||||
*/
|
*/
|
||||||
void MainWindow::addButtonPressed()
|
void MainWindow::addButtonPressed()
|
||||||
{
|
{
|
||||||
|
ENSURE_APP_IS_IDLE();
|
||||||
|
m_status = STATUS_BLOCKED;
|
||||||
|
|
||||||
qDebug("MainWindow::addButtonPressed");
|
qDebug("MainWindow::addButtonPressed");
|
||||||
bool runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
|
bool runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
|
||||||
QString sourceFileName, outputFileName;
|
QString sourceFileName, outputFileName;
|
||||||
@ -247,6 +251,8 @@ void MainWindow::addButtonPressed()
|
|||||||
{
|
{
|
||||||
appendJob(sourceFileName, outputFileName, m_options, runImmediately);
|
appendJob(sourceFileName, outputFileName, m_options, runImmediately);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_status = STATUS_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -254,6 +260,9 @@ void MainWindow::addButtonPressed()
|
|||||||
*/
|
*/
|
||||||
void MainWindow::openActionTriggered()
|
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);
|
QStringList fileList = QFileDialog::getOpenFileNames(this, tr("Open Source File(s)"), m_recentlyUsed->sourceDirectory(), AddJobDialog::getInputFilterLst(), NULL, QFileDialog::DontUseNativeDialog);
|
||||||
if(!fileList.empty())
|
if(!fileList.empty())
|
||||||
{
|
{
|
||||||
@ -272,6 +281,8 @@ void MainWindow::openActionTriggered()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_status = STATUS_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -279,6 +290,7 @@ void MainWindow::openActionTriggered()
|
|||||||
*/
|
*/
|
||||||
void MainWindow::startButtonPressed(void)
|
void MainWindow::startButtonPressed(void)
|
||||||
{
|
{
|
||||||
|
ENSURE_APP_IS_IDLE();
|
||||||
m_jobList->startJob(ui->jobsView->currentIndex());
|
m_jobList->startJob(ui->jobsView->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,6 +299,7 @@ void MainWindow::startButtonPressed(void)
|
|||||||
*/
|
*/
|
||||||
void MainWindow::abortButtonPressed(void)
|
void MainWindow::abortButtonPressed(void)
|
||||||
{
|
{
|
||||||
|
ENSURE_APP_IS_IDLE();
|
||||||
m_jobList->abortJob(ui->jobsView->currentIndex());
|
m_jobList->abortJob(ui->jobsView->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,6 +308,7 @@ void MainWindow::abortButtonPressed(void)
|
|||||||
*/
|
*/
|
||||||
void MainWindow::deleteButtonPressed(void)
|
void MainWindow::deleteButtonPressed(void)
|
||||||
{
|
{
|
||||||
|
ENSURE_APP_IS_IDLE();
|
||||||
m_jobList->deleteJob(ui->jobsView->currentIndex());
|
m_jobList->deleteJob(ui->jobsView->currentIndex());
|
||||||
m_label->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
|
m_label->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
|
||||||
}
|
}
|
||||||
@ -304,6 +318,9 @@ void MainWindow::deleteButtonPressed(void)
|
|||||||
*/
|
*/
|
||||||
void MainWindow::browseButtonPressed(void)
|
void MainWindow::browseButtonPressed(void)
|
||||||
{
|
{
|
||||||
|
ENSURE_APP_IS_IDLE();
|
||||||
|
m_status = STATUS_BLOCKED;
|
||||||
|
|
||||||
QString outputFile = m_jobList->getJobOutputFile(ui->jobsView->currentIndex());
|
QString outputFile = m_jobList->getJobOutputFile(ui->jobsView->currentIndex());
|
||||||
if((!outputFile.isEmpty()) && QFileInfo(outputFile).exists() && QFileInfo(outputFile).isFile())
|
if((!outputFile.isEmpty()) && QFileInfo(outputFile).exists() && QFileInfo(outputFile).isFile())
|
||||||
{
|
{
|
||||||
@ -313,6 +330,8 @@ void MainWindow::browseButtonPressed(void)
|
|||||||
{
|
{
|
||||||
QMessageBox::warning(this, tr("Not Found"), tr("Sorry, the output file could not be found!"));
|
QMessageBox::warning(this, tr("Not Found"), tr("Sorry, the output file could not be found!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_status = STATUS_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -335,6 +354,8 @@ void MainWindow::pauseButtonPressed(bool checked)
|
|||||||
*/
|
*/
|
||||||
void MainWindow::restartButtonPressed(void)
|
void MainWindow::restartButtonPressed(void)
|
||||||
{
|
{
|
||||||
|
ENSURE_APP_IS_IDLE();
|
||||||
|
|
||||||
const QModelIndex index = ui->jobsView->currentIndex();
|
const QModelIndex index = ui->jobsView->currentIndex();
|
||||||
const OptionsModel *options = m_jobList->getJobOptions(index);
|
const OptionsModel *options = m_jobList->getJobOptions(index);
|
||||||
QString sourceFileName = m_jobList->getJobSourceFile(index);
|
QString sourceFileName = m_jobList->getJobSourceFile(index);
|
||||||
@ -453,8 +474,10 @@ void MainWindow::jobLogExtended(const QModelIndex & parent, int start, int end)
|
|||||||
*/
|
*/
|
||||||
void MainWindow::showAbout(void)
|
void MainWindow::showAbout(void)
|
||||||
{
|
{
|
||||||
QString text;
|
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("<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("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());
|
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());
|
||||||
@ -536,6 +559,7 @@ void MainWindow::showAbout(void)
|
|||||||
QMessageBox::aboutQt(this);
|
QMessageBox::aboutQt(this);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
m_status = STATUS_IDLE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -567,9 +591,14 @@ void MainWindow::showWebLink(void)
|
|||||||
*/
|
*/
|
||||||
void MainWindow::showPreferences(void)
|
void MainWindow::showPreferences(void)
|
||||||
{
|
{
|
||||||
|
ENSURE_APP_IS_IDLE();
|
||||||
|
m_status = STATUS_BLOCKED;
|
||||||
|
|
||||||
PreferencesDialog *preferences = new PreferencesDialog(this, m_preferences, m_cpuFeatures->x64);
|
PreferencesDialog *preferences = new PreferencesDialog(this, m_preferences, m_cpuFeatures->x64);
|
||||||
preferences->exec();
|
preferences->exec();
|
||||||
|
|
||||||
X264_DELETE(preferences);
|
X264_DELETE(preferences);
|
||||||
|
m_status = STATUS_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -710,6 +739,12 @@ void MainWindow::shutdownComputer(void)
|
|||||||
*/
|
*/
|
||||||
void MainWindow::init(void)
|
void MainWindow::init(void)
|
||||||
{
|
{
|
||||||
|
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";
|
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);
|
QStringList binaries = QString::fromLatin1(binFiles).split(":", QString::SkipEmptyParts);
|
||||||
|
|
||||||
@ -856,9 +891,6 @@ void MainWindow::init(void)
|
|||||||
qDebug(" ");
|
qDebug(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update initialized flag (must do this before update check!)
|
|
||||||
m_initialized = true;
|
|
||||||
|
|
||||||
//Enable drag&drop support for this window, required for Qt v4.8.4+
|
//Enable drag&drop support for this window, required for Qt v4.8.4+
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
@ -883,21 +915,28 @@ void MainWindow::init(void)
|
|||||||
QTimer::singleShot(7500, btn3, SLOT(show()));
|
QTimer::singleShot(7500, btn3, SLOT(show()));
|
||||||
if(msgBox.exec() == 0)
|
if(msgBox.exec() == 0)
|
||||||
{
|
{
|
||||||
QTimer::singleShot(0, this, SLOT(checkUpdates()));
|
m_status = STATUS_IDLE;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if((!m_preferences->noUpdateReminder()) && (m_recentlyUsed->lastUpdateCheck() + 14 < x264_current_date_safe().toJulianDay()))
|
|
||||||
{
|
|
||||||
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()));
|
QTimer::singleShot(0, this, SLOT(checkUpdates()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add files from command-line
|
//Update app staus
|
||||||
parseCommandLineArgs();
|
m_status = STATUS_IDLE;
|
||||||
|
|
||||||
|
//Try adding files from command-line
|
||||||
|
if(!parseCommandLineArgs())
|
||||||
|
{
|
||||||
|
//Update reminder
|
||||||
|
if((!m_preferences->noUpdateReminder()) && (m_recentlyUsed->lastUpdateCheck() + 14 < x264_current_date_safe().toJulianDay()))
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -926,32 +965,40 @@ void MainWindow::copyLogToClipboard(bool checked)
|
|||||||
/*
|
/*
|
||||||
* Process the dropped files
|
* Process the dropped files
|
||||||
*/
|
*/
|
||||||
void MainWindow::handleDroppedFiles(void)
|
void MainWindow::handlePendingFiles(void)
|
||||||
{
|
{
|
||||||
qDebug("MainWindow::handleDroppedFiles");
|
if((m_status == STATUS_IDLE) || (m_status == STATUS_AWAITING))
|
||||||
if(m_droppedFiles)
|
|
||||||
{
|
{
|
||||||
QStringList droppedFiles(*m_droppedFiles);
|
qDebug("MainWindow::handlePendingFiles");
|
||||||
m_droppedFiles->clear();
|
if(!m_pendingFiles->isEmpty())
|
||||||
createJobMultiple(droppedFiles);
|
{
|
||||||
|
QStringList pendingFiles(*m_pendingFiles);
|
||||||
|
m_pendingFiles->clear();
|
||||||
|
createJobMultiple(pendingFiles);
|
||||||
|
}
|
||||||
|
qDebug("Leave from MainWindow::handlePendingFiles!");
|
||||||
|
m_status = STATUS_IDLE;
|
||||||
}
|
}
|
||||||
qDebug("Leave from MainWindow::handleDroppedFiles!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::handleCommand(const int &command, const QStringList &args)
|
void MainWindow::handleCommand(const int &command, const QStringList &args)
|
||||||
{
|
{
|
||||||
|
if((m_status != STATUS_IDLE) && (m_status != STATUS_AWAITING))
|
||||||
|
{
|
||||||
|
qWarning("Cannot accapt commands at this time -> discarding!");
|
||||||
|
}
|
||||||
|
|
||||||
x264_bring_to_front(this);
|
x264_bring_to_front(this);
|
||||||
|
|
||||||
if(true)
|
#ifdef IPC_LOGGING
|
||||||
|
qDebug("\n---------- IPC ----------");
|
||||||
|
qDebug("CommandId: %d", command);
|
||||||
|
for(QStringList::ConstIterator iter = args.constBegin(); iter != args.constEnd(); iter++)
|
||||||
{
|
{
|
||||||
qDebug("\n---------- IPC ----------");
|
qDebug("Arguments: %s", iter->toUtf8().constData());
|
||||||
qDebug("CommandId: %d", command);
|
|
||||||
for(QStringList::ConstIterator iter = args.constBegin(); iter != args.constEnd(); iter++)
|
|
||||||
{
|
|
||||||
qDebug("Arguments: %s", iter->toUtf8().constData());
|
|
||||||
}
|
|
||||||
qDebug("---------- IPC ----------\n");
|
|
||||||
}
|
}
|
||||||
|
qDebug("---------- IPC ----------\n");
|
||||||
|
#endif //IPC_LOGGING
|
||||||
|
|
||||||
switch(command)
|
switch(command)
|
||||||
{
|
{
|
||||||
@ -964,7 +1011,12 @@ void MainWindow::handleCommand(const int &command, const QStringList &args)
|
|||||||
{
|
{
|
||||||
if(QFileInfo(args[0]).exists() && QFileInfo(args[0]).isFile())
|
if(QFileInfo(args[0]).exists() && QFileInfo(args[0]).isFile())
|
||||||
{
|
{
|
||||||
createJobMultiple(QStringList() << QFileInfo(args[0]).canonicalFilePath());
|
*m_pendingFiles << QFileInfo(args[0]).canonicalFilePath();
|
||||||
|
if(m_status != STATUS_AWAITING)
|
||||||
|
{
|
||||||
|
m_status = STATUS_AWAITING;
|
||||||
|
QTimer::singleShot(3333, this, SLOT(handlePendingFiles()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1000,14 +1052,13 @@ void MainWindow::handleCommand(const int &command, const QStringList &args)
|
|||||||
|
|
||||||
void MainWindow::checkUpdates(void)
|
void MainWindow::checkUpdates(void)
|
||||||
{
|
{
|
||||||
if(!m_initialized)
|
ENSURE_APP_IS_IDLE();
|
||||||
{
|
m_status = STATUS_BLOCKED;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(countRunningJobs() > 0)
|
if(countRunningJobs() > 0)
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this, tr("Jobs Are Running"), tr("Sorry, can not update while there still are running jobs!"));
|
QMessageBox::warning(this, tr("Jobs Are Running"), tr("Sorry, can not update while there still are running jobs!"));
|
||||||
|
m_status = STATUS_IDLE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1022,12 +1073,18 @@ void MainWindow::checkUpdates(void)
|
|||||||
|
|
||||||
if(ret == UpdaterDialog::READY_TO_INSTALL_UPDATE)
|
if(ret == UpdaterDialog::READY_TO_INSTALL_UPDATE)
|
||||||
{
|
{
|
||||||
|
m_status = STATUS_EXITTING;
|
||||||
qWarning("Exitting program to install update...");
|
qWarning("Exitting program to install update...");
|
||||||
close();
|
close();
|
||||||
QApplication::quit();
|
QApplication::quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
X264_DELETE(updater);
|
X264_DELETE(updater);
|
||||||
|
|
||||||
|
if(m_status != STATUS_EXITTING)
|
||||||
|
{
|
||||||
|
m_status = STATUS_IDLE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -1053,27 +1110,34 @@ void MainWindow::showEvent(QShowEvent *e)
|
|||||||
*/
|
*/
|
||||||
void MainWindow::closeEvent(QCloseEvent *e)
|
void MainWindow::closeEvent(QCloseEvent *e)
|
||||||
{
|
{
|
||||||
if(!m_initialized)
|
if((m_status != STATUS_IDLE) && (m_status != STATUS_EXITTING))
|
||||||
{
|
{
|
||||||
e->ignore();
|
qWarning("Cannot close window at this time!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(countRunningJobs() > 0)
|
if(m_status != STATUS_EXITTING)
|
||||||
{
|
{
|
||||||
e->ignore();
|
if(countRunningJobs() > 0)
|
||||||
QMessageBox::warning(this, tr("Jobs Are Running"), tr("Sorry, can not exit while there still are running jobs!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(countPendingJobs() > 0)
|
|
||||||
{
|
|
||||||
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();
|
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;
|
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)
|
while(m_jobList->rowCount(QModelIndex()) > 0)
|
||||||
@ -1082,7 +1146,9 @@ void MainWindow::closeEvent(QCloseEvent *e)
|
|||||||
if(!m_jobList->deleteJob(m_jobList->index(0, 0, QModelIndex())))
|
if(!m_jobList->deleteJob(m_jobList->index(0, 0, QModelIndex())))
|
||||||
{
|
{
|
||||||
e->ignore();
|
e->ignore();
|
||||||
|
m_status = STATUS_BLOCKED;
|
||||||
QMessageBox::warning(this, tr("Failed To Exit"), tr("Sorry, at least one job could not be deleted!"));
|
QMessageBox::warning(this, tr("Failed To Exit"), tr("Sorry, at least one job could not be deleted!"));
|
||||||
|
m_status = STATUS_IDLE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1161,13 +1227,9 @@ void MainWindow::dropEvent(QDropEvent *event)
|
|||||||
|
|
||||||
if(droppedFiles.count() > 0)
|
if(droppedFiles.count() > 0)
|
||||||
{
|
{
|
||||||
if(!m_droppedFiles)
|
m_pendingFiles->append(droppedFiles);
|
||||||
{
|
m_pendingFiles->sort();
|
||||||
m_droppedFiles = new QStringList();
|
QTimer::singleShot(0, this, SLOT(handlePendingFiles()));
|
||||||
}
|
|
||||||
m_droppedFiles->append(droppedFiles);
|
|
||||||
m_droppedFiles->sort();
|
|
||||||
QTimer::singleShot(0, this, SLOT(handleDroppedFiles()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1405,10 +1467,13 @@ void MainWindow::updateTaskbar(JobStatus status, const QIcon &icon)
|
|||||||
/*
|
/*
|
||||||
* Parse command-line arguments
|
* Parse command-line arguments
|
||||||
*/
|
*/
|
||||||
void MainWindow::parseCommandLineArgs(void)
|
bool MainWindow::parseCommandLineArgs(void)
|
||||||
{
|
{
|
||||||
|
bool bCommandAccepted = false;
|
||||||
|
|
||||||
QStringList files;
|
QStringList files;
|
||||||
QStringList args = x264_arguments();
|
QStringList args = x264_arguments();
|
||||||
|
|
||||||
args.takeFirst(); //Pop argv[0]
|
args.takeFirst(); //Pop argv[0]
|
||||||
|
|
||||||
while(!args.isEmpty())
|
while(!args.isEmpty())
|
||||||
@ -1416,6 +1481,7 @@ void MainWindow::parseCommandLineArgs(void)
|
|||||||
QString current = args.takeFirst();
|
QString current = args.takeFirst();
|
||||||
if(X264_STRCMP(current, "--add") || X264_STRCMP(current, "--add-file"))
|
if(X264_STRCMP(current, "--add") || X264_STRCMP(current, "--add-file"))
|
||||||
{
|
{
|
||||||
|
bCommandAccepted = true;
|
||||||
if(!args.isEmpty())
|
if(!args.isEmpty())
|
||||||
{
|
{
|
||||||
handleCommand(IPC::IPC_OPCODE_ADD_FILE, QStringList() << args.takeFirst());
|
handleCommand(IPC::IPC_OPCODE_ADD_FILE, QStringList() << args.takeFirst());
|
||||||
@ -1427,6 +1493,7 @@ void MainWindow::parseCommandLineArgs(void)
|
|||||||
}
|
}
|
||||||
else if(X264_STRCMP(current, "--add-job"))
|
else if(X264_STRCMP(current, "--add-job"))
|
||||||
{
|
{
|
||||||
|
bCommandAccepted = true;
|
||||||
if(args.size() >= 3)
|
if(args.size() >= 3)
|
||||||
{
|
{
|
||||||
QStringList lst;
|
QStringList lst;
|
||||||
@ -1451,4 +1518,6 @@ void MainWindow::parseCommandLineArgs(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return bCommandAccepted;
|
||||||
}
|
}
|
||||||
|
@ -57,20 +57,31 @@ protected:
|
|||||||
virtual void dropEvent(QDropEvent *event);
|
virtual void dropEvent(QDropEvent *event);
|
||||||
virtual bool winEvent(MSG *message, long *result);
|
virtual bool winEvent(MSG *message, long *result);
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
STATUS_PRE_INIT = 0,
|
||||||
|
STATUS_IDLE = 1,
|
||||||
|
STATUS_AWAITING = 2,
|
||||||
|
STATUS_BLOCKED = 3,
|
||||||
|
STATUS_EXITTING = 4
|
||||||
|
}
|
||||||
|
x264_status_t;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *const ui;
|
Ui::MainWindow *const ui;
|
||||||
|
|
||||||
bool m_firstShow;
|
bool m_firstShow;
|
||||||
bool m_skipVersionTest;
|
bool m_skipVersionTest;
|
||||||
bool m_abortOnTimeout;
|
bool m_abortOnTimeout;
|
||||||
bool m_initialized;
|
|
||||||
|
x264_status_t m_status;
|
||||||
|
|
||||||
QLabel *m_label;
|
QLabel *m_label;
|
||||||
IPC *const m_ipc;
|
IPC *const m_ipc;
|
||||||
|
|
||||||
JobListModel *m_jobList;
|
JobListModel *m_jobList;
|
||||||
OptionsModel *m_options;
|
OptionsModel *m_options;
|
||||||
QStringList *m_droppedFiles;
|
QStringList *m_pendingFiles;
|
||||||
QList<QFile*> m_toolsList;
|
QList<QFile*> m_toolsList;
|
||||||
|
|
||||||
PreferencesModel *m_preferences;
|
PreferencesModel *m_preferences;
|
||||||
@ -90,7 +101,7 @@ private:
|
|||||||
unsigned int countPendingJobs(void);
|
unsigned int countPendingJobs(void);
|
||||||
unsigned int countRunningJobs(void);
|
unsigned int countRunningJobs(void);
|
||||||
|
|
||||||
void parseCommandLineArgs(void);
|
bool parseCommandLineArgs(void);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void addButtonPressed();
|
void addButtonPressed();
|
||||||
@ -100,7 +111,7 @@ private slots:
|
|||||||
void deleteButtonPressed(void);
|
void deleteButtonPressed(void);
|
||||||
void copyLogToClipboard(bool checked);
|
void copyLogToClipboard(bool checked);
|
||||||
void checkUpdates(void);
|
void checkUpdates(void);
|
||||||
void handleDroppedFiles(void);
|
void handlePendingFiles(void);
|
||||||
void init(void);
|
void init(void);
|
||||||
void handleCommand(const int &command, const QStringList &args);
|
void handleCommand(const int &command, const QStringList &args);
|
||||||
void jobSelected(const QModelIndex ¤t, const QModelIndex &previous);
|
void jobSelected(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
|
Loading…
Reference in New Issue
Block a user