1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2013 LoRd_MuldeR <MuldeR2@GMX.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
23 #include "uic_win_main.h"
26 #include "model_status.h"
27 #include "model_jobList.h"
28 #include "model_options.h"
29 #include "model_preferences.h"
30 #include "model_recently.h"
31 #include "thread_avisynth.h"
32 #include "thread_vapoursynth.h"
33 #include "thread_ipc.h"
34 #include "thread_encode.h"
36 #include "win_addJob.h"
37 #include "win_preferences.h"
42 #include <QCloseEvent>
43 #include <QMessageBox>
44 #include <QDesktopServices>
49 #include <QProgressDialog>
51 #include <QTextStream>
53 #include <QFileDialog>
57 const char *home_url = "http://muldersoft.com/";
58 const char *update_url = "http://code.google.com/p/mulder/downloads/list";
59 const char *tpl_last = "<LAST_USED>";
61 #define SET_FONT_BOLD(WIDGET,BOLD) do { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); } while(0)
62 #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)
63 #define LINK(URL) "<a href=\"" URL "\">" URL "</a>"
64 #define INIT_ERROR_EXIT() do { m_initialized = true; close(); qApp->exit(-1); return; } while(0)
66 //static int exceptionFilter(_EXCEPTION_RECORD *dst, _EXCEPTION_POINTERS *src) { memcpy(dst, src->ExceptionRecord, sizeof(_EXCEPTION_RECORD)); return EXCEPTION_EXECUTE_HANDLER; }
68 ///////////////////////////////////////////////////////////////////////////////
69 // Constructor & Destructor
70 ///////////////////////////////////////////////////////////////////////////////
75 MainWindow::MainWindow(const x264_cpu_t *const cpuFeatures)
77 m_cpuFeatures(cpuFeatures),
78 m_appDir(QApplication::applicationDirPath()),
84 m_skipVersionTest(false),
85 m_abortOnTimeout(true),
88 ui(new Ui::MainWindow())
90 //Init the dialog, from the .ui file
92 setWindowFlags(windowFlags() & (~Qt::WindowMaximizeButtonHint));
95 qRegisterMetaType<QUuid>("QUuid");
96 qRegisterMetaType<QUuid>("DWORD");
97 qRegisterMetaType<JobStatus>("JobStatus");
100 m_preferences = new PreferencesModel();
101 PreferencesModel::loadPreferences(m_preferences);
104 m_recentlyUsed = new RecentlyUsed();
105 RecentlyUsed::loadRecentlyUsed(m_recentlyUsed);
107 //Create options object
108 m_options = new OptionsModel();
109 OptionsModel::loadTemplate(m_options, QString::fromLatin1(tpl_last));
111 //Create IPC thread object
112 m_ipcThread = new IPCThread();
113 connect(m_ipcThread, SIGNAL(instanceCreated(unsigned int)), this, SLOT(instanceCreated(unsigned int)), Qt::QueuedConnection);
115 //Freeze minimum size
116 setMinimumSize(size());
117 ui->splitter->setSizes(QList<int>() << 16 << 196);
120 ui->labelBuildDate->setText(tr("Built on %1 at %2").arg(x264_version_date().toString(Qt::ISODate), QString::fromLatin1(x264_version_time())));
121 ui->labelBuildDate->installEventFilter(this);
122 setWindowTitle(QString("%1 (%2 Mode)").arg(windowTitle(), m_cpuFeatures->x64 ? "64-Bit" : "32-Bit"));
125 setWindowTitle(QString("%1 | !!! DEBUG VERSION !!!").arg(windowTitle()));
126 setStyleSheet("QMenuBar, QMainWindow { background-color: yellow }");
128 else if(x264_is_prerelease())
130 setWindowTitle(QString("%1 | PRE-RELEASE VERSION").arg(windowTitle()));
134 m_jobList = new JobListModel(m_preferences);
135 connect(m_jobList, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(jobChangedData(QModelIndex, QModelIndex)));
136 ui->jobsView->setModel(m_jobList);
139 ui->jobsView->horizontalHeader()->setSectionHidden(3, true);
140 ui->jobsView->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
141 ui->jobsView->horizontalHeader()->setResizeMode(1, QHeaderView::Fixed);
142 ui->jobsView->horizontalHeader()->setResizeMode(2, QHeaderView::Fixed);
143 ui->jobsView->horizontalHeader()->resizeSection(1, 150);
144 ui->jobsView->horizontalHeader()->resizeSection(2, 90);
145 ui->jobsView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
146 connect(ui->jobsView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(jobSelected(QModelIndex, QModelIndex)));
148 //Create context menu
149 QAction *actionClipboard = new QAction(QIcon(":/buttons/page_paste.png"), tr("Copy to Clipboard"), ui->logView);
150 actionClipboard->setEnabled(false);
151 ui->logView->addAction(actionClipboard);
152 connect(actionClipboard, SIGNAL(triggered(bool)), this, SLOT(copyLogToClipboard(bool)));
153 ui->jobsView->addActions(ui->menuJob->actions());
156 connect(ui->buttonAddJob, SIGNAL(clicked()), this, SLOT(addButtonPressed()));
157 connect(ui->buttonStartJob, SIGNAL(clicked()), this, SLOT(startButtonPressed()));
158 connect(ui->buttonAbortJob, SIGNAL(clicked()), this, SLOT(abortButtonPressed()));
159 connect(ui->buttonPauseJob, SIGNAL(toggled(bool)), this, SLOT(pauseButtonPressed(bool)));
160 connect(ui->actionJob_Delete, SIGNAL(triggered()), this, SLOT(deleteButtonPressed()));
161 connect(ui->actionJob_Restart, SIGNAL(triggered()), this, SLOT(restartButtonPressed()));
162 connect(ui->actionJob_Browse, SIGNAL(triggered()), this, SLOT(browseButtonPressed()));
165 connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openActionTriggered()));
166 connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAbout()));
167 connect(ui->actionWebMulder, SIGNAL(triggered()), this, SLOT(showWebLink()));
168 connect(ui->actionWebX264, SIGNAL(triggered()), this, SLOT(showWebLink()));
169 connect(ui->actionWebKomisar, SIGNAL(triggered()), this, SLOT(showWebLink()));
170 connect(ui->actionWebVideoLAN, SIGNAL(triggered()), this, SLOT(showWebLink()));
171 connect(ui->actionWebJEEB, SIGNAL(triggered()), this, SLOT(showWebLink()));
172 connect(ui->actionWebAvisynth32, SIGNAL(triggered()), this, SLOT(showWebLink()));
173 connect(ui->actionWebAvisynth64, SIGNAL(triggered()), this, SLOT(showWebLink()));
174 connect(ui->actionWebVapourSynth, SIGNAL(triggered()), this, SLOT(showWebLink()));
175 connect(ui->actionWebVapourSynthDocs, SIGNAL(triggered()), this, SLOT(showWebLink()));
176 connect(ui->actionWebWiki, SIGNAL(triggered()), this, SLOT(showWebLink()));
177 connect(ui->actionWebBluRay, SIGNAL(triggered()), this, SLOT(showWebLink()));
178 connect(ui->actionWebAvsWiki, SIGNAL(triggered()), this, SLOT(showWebLink()));
179 connect(ui->actionWebSecret, SIGNAL(triggered()), this, SLOT(showWebLink()));
180 connect(ui->actionWebSupport, SIGNAL(triggered()), this, SLOT(showWebLink()));
181 connect(ui->actionPreferences, SIGNAL(triggered()), this, SLOT(showPreferences()));
183 //Create floating label
184 m_label = new QLabel(ui->jobsView->viewport());
185 m_label->setText(tr("No job created yet. Please click the 'Add New Job' button!"));
186 m_label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
187 SET_TEXT_COLOR(m_label, Qt::darkGray);
188 SET_FONT_BOLD(m_label, true);
189 m_label->setVisible(true);
190 m_label->setContextMenuPolicy(Qt::ActionsContextMenu);
191 m_label->addActions(ui->jobsView->actions());
192 connect(ui->splitter, SIGNAL(splitterMoved(int, int)), this, SLOT(updateLabelPos()));
199 MainWindow::~MainWindow(void)
201 OptionsModel::saveTemplate(m_options, QString::fromLatin1(tpl_last));
203 X264_DELETE(m_jobList);
204 X264_DELETE(m_options);
205 X264_DELETE(m_droppedFiles);
206 X264_DELETE(m_label);
208 while(!m_toolsList.isEmpty())
210 QFile *temp = m_toolsList.takeFirst();
214 if(m_ipcThread->isRunning())
216 m_ipcThread->setAbort();
217 if(!m_ipcThread->wait(5000))
219 m_ipcThread->terminate();
224 X264_DELETE(m_ipcThread);
225 X264_DELETE(m_preferences);
226 X264_DELETE(m_recentlyUsed);
227 VapourSynthCheckThread::unload();
228 AvisynthCheckThread::unload();
233 ///////////////////////////////////////////////////////////////////////////////
235 ///////////////////////////////////////////////////////////////////////////////
238 * The "add" button was clicked
240 void MainWindow::addButtonPressed()
242 qDebug("MainWindow::addButtonPressed");
243 bool runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
244 QString sourceFileName, outputFileName;
246 if(createJob(sourceFileName, outputFileName, m_options, runImmediately))
248 appendJob(sourceFileName, outputFileName, m_options, runImmediately);
253 * The "open" action was triggered
255 void MainWindow::openActionTriggered()
257 QStringList fileList = QFileDialog::getOpenFileNames(this, tr("Open Source File(s)"), m_recentlyUsed->sourceDirectory(), AddJobDialog::getInputFilterLst(), NULL, QFileDialog::DontUseNativeDialog);
258 if(!fileList.empty())
260 m_recentlyUsed->setSourceDirectory(QFileInfo(fileList.last()).absolutePath());
261 if(fileList.count() > 1)
263 createJobMultiple(fileList);
267 bool runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
268 QString sourceFileName(fileList.first()), outputFileName;
269 if(createJob(sourceFileName, outputFileName, m_options, runImmediately))
271 appendJob(sourceFileName, outputFileName, m_options, runImmediately);
278 * The "start" button was clicked
280 void MainWindow::startButtonPressed(void)
282 m_jobList->startJob(ui->jobsView->currentIndex());
286 * The "abort" button was clicked
288 void MainWindow::abortButtonPressed(void)
290 m_jobList->abortJob(ui->jobsView->currentIndex());
294 * The "delete" button was clicked
296 void MainWindow::deleteButtonPressed(void)
298 m_jobList->deleteJob(ui->jobsView->currentIndex());
299 m_label->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
303 * The "browse" button was clicked
305 void MainWindow::browseButtonPressed(void)
307 QString outputFile = m_jobList->getJobOutputFile(ui->jobsView->currentIndex());
308 if((!outputFile.isEmpty()) && QFileInfo(outputFile).exists() && QFileInfo(outputFile).isFile())
310 QProcess::startDetached(QString::fromLatin1("explorer.exe"), QStringList() << QString::fromLatin1("/select,") << QDir::toNativeSeparators(outputFile), QFileInfo(outputFile).path());
314 QMessageBox::warning(this, tr("Not Found"), tr("Sorry, the output file could not be found!"));
319 * The "pause" button was clicked
321 void MainWindow::pauseButtonPressed(bool checked)
325 m_jobList->pauseJob(ui->jobsView->currentIndex());
329 m_jobList->resumeJob(ui->jobsView->currentIndex());
334 * The "restart" button was clicked
336 void MainWindow::restartButtonPressed(void)
338 const QModelIndex index = ui->jobsView->currentIndex();
339 const OptionsModel *options = m_jobList->getJobOptions(index);
340 QString sourceFileName = m_jobList->getJobSourceFile(index);
341 QString outputFileName = m_jobList->getJobOutputFile(index);
343 if((options) && (!sourceFileName.isEmpty()) && (!outputFileName.isEmpty()))
345 bool runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1)); //bool runImmediately = true;
346 OptionsModel *tempOptions = new OptionsModel(*options);
347 if(createJob(sourceFileName, outputFileName, tempOptions, runImmediately, true))
349 appendJob(sourceFileName, outputFileName, tempOptions, runImmediately);
351 X264_DELETE(tempOptions);
356 * Job item selected by user
358 void MainWindow::jobSelected(const QModelIndex & current, const QModelIndex & previous)
360 qDebug("Job selected: %d", current.row());
362 if(ui->logView->model())
364 disconnect(ui->logView->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(jobLogExtended(QModelIndex, int, int)));
367 if(current.isValid())
369 ui->logView->setModel(m_jobList->getLogFile(current));
370 connect(ui->logView->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(jobLogExtended(QModelIndex, int, int)));
371 ui->logView->actions().first()->setEnabled(true);
372 QTimer::singleShot(0, ui->logView, SLOT(scrollToBottom()));
374 ui->progressBar->setValue(m_jobList->getJobProgress(current));
375 ui->editDetails->setText(m_jobList->data(m_jobList->index(current.row(), 3, QModelIndex()), Qt::DisplayRole).toString());
376 updateButtons(m_jobList->getJobStatus(current));
377 updateTaskbar(m_jobList->getJobStatus(current), m_jobList->data(m_jobList->index(current.row(), 0, QModelIndex()), Qt::DecorationRole).value<QIcon>());
381 ui->logView->setModel(NULL);
382 ui->logView->actions().first()->setEnabled(false);
383 ui->progressBar->setValue(0);
384 ui->editDetails->clear();
385 updateButtons(JobStatus_Undefined);
386 updateTaskbar(JobStatus_Undefined, QIcon());
389 ui->progressBar->repaint();
393 * Handle update of job info (status, progress, details, etc)
395 void MainWindow::jobChangedData(const QModelIndex &topLeft, const QModelIndex &bottomRight)
397 int selected = ui->jobsView->currentIndex().row();
399 if(topLeft.column() <= 1 && bottomRight.column() >= 1) /*STATUS*/
401 for(int i = topLeft.row(); i <= bottomRight.row(); i++)
403 JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
406 qDebug("Current job changed status!");
407 updateButtons(status);
408 updateTaskbar(status, m_jobList->data(m_jobList->index(i, 0, QModelIndex()), Qt::DecorationRole).value<QIcon>());
410 if((status == JobStatus_Completed) || (status == JobStatus_Failed))
412 if(m_preferences->autoRunNextJob()) QTimer::singleShot(0, this, SLOT(launchNextJob()));
413 if(m_preferences->shutdownComputer()) QTimer::singleShot(0, this, SLOT(shutdownComputer()));
414 if(m_preferences->saveLogFiles()) saveLogFile(m_jobList->index(i, 1, QModelIndex()));
418 if(topLeft.column() <= 2 && bottomRight.column() >= 2) /*PROGRESS*/
420 for(int i = topLeft.row(); i <= bottomRight.row(); i++)
424 ui->progressBar->setValue(m_jobList->getJobProgress(m_jobList->index(i, 0, QModelIndex())));
425 WinSevenTaskbar::setTaskbarProgress(this, ui->progressBar->value(), ui->progressBar->maximum());
430 if(topLeft.column() <= 3 && bottomRight.column() >= 3) /*DETAILS*/
432 for(int i = topLeft.row(); i <= bottomRight.row(); i++)
436 ui->editDetails->setText(m_jobList->data(m_jobList->index(i, 3, QModelIndex()), Qt::DisplayRole).toString());
444 * Handle new log file content
446 void MainWindow::jobLogExtended(const QModelIndex & parent, int start, int end)
448 QTimer::singleShot(0, ui->logView, SLOT(scrollToBottom()));
454 void MainWindow::showAbout(void)
458 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());
459 text += QString().sprintf("Copyright (c) 2004-%04d LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved.<br>", qMax(x264_version_date().year(),QDate::currentDate().year()));
460 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());
461 text += QString().sprintf("This program is free software: you can redistribute it and/or modify<br>");
462 text += QString().sprintf("it under the terms of the GNU General Public License <http://www.gnu.org/>.<br>");
463 text += QString().sprintf("Note that this program is distributed with ABSOLUTELY NO WARRANTY.<br><br>");
464 text += QString().sprintf("Please check the web-site at <a href=\"%s\">%s</a> for updates !!!<br></tt></nobr>", home_url, home_url);
466 QMessageBox aboutBox(this);
467 aboutBox.setIconPixmap(QIcon(":/images/movie.png").pixmap(64,64));
468 aboutBox.setWindowTitle(tr("About..."));
469 aboutBox.setText(text.replace("-", "−"));
470 aboutBox.addButton(tr("About x264"), QMessageBox::NoRole);
471 aboutBox.addButton(tr("About AVS"), QMessageBox::NoRole);
472 aboutBox.addButton(tr("About VPY"), QMessageBox::NoRole);
473 aboutBox.addButton(tr("About Qt"), QMessageBox::NoRole);
474 aboutBox.setEscapeButton(aboutBox.addButton(tr("Close"), QMessageBox::NoRole));
478 x264_beep(x264_beep_info);
479 switch(aboutBox.exec())
484 text2 += tr("<nobr><tt>x264 - the best H.264/AVC encoder. Copyright (c) 2003-2013 x264 project.<br>");
485 text2 += tr("Free software library for encoding video streams into the H.264/MPEG-4 AVC format.<br>");
486 text2 += tr("Released under the terms of the GNU General Public License.<br><br>");
487 text2 += tr("Please visit <a href=\"%1\">%1</a> for obtaining a commercial x264 license.<br>").arg("http://x264licensing.com/");
488 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");
490 QMessageBox x264Box(this);
491 x264Box.setIconPixmap(QIcon(":/images/x264.png").pixmap(48,48));
492 x264Box.setWindowTitle(tr("About x264"));
493 x264Box.setText(text2.replace("-", "−"));
494 x264Box.setEscapeButton(x264Box.addButton(tr("Close"), QMessageBox::NoRole));
495 x264_beep(x264_beep_info);
502 text2 += tr("<nobr><tt>Avisynth - powerful video processing scripting language.<br>");
503 text2 += tr("Copyright (c) 2000 Ben Rudiak-Gould and all subsequent developers.<br>");
504 text2 += tr("Released under the terms of the GNU General Public License.<br><br>");
505 text2 += tr("Please visit the web-site <a href=\"%1\">%1</a> for more information.<br>").arg("http://avisynth.org/");
506 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");
508 QMessageBox x264Box(this);
509 x264Box.setIconPixmap(QIcon(":/images/avisynth.png").pixmap(48,67));
510 x264Box.setWindowTitle(tr("About Avisynth"));
511 x264Box.setText(text2.replace("-", "−"));
512 x264Box.setEscapeButton(x264Box.addButton(tr("Close"), QMessageBox::NoRole));
513 x264_beep(x264_beep_info);
520 text2 += tr("<nobr><tt>VapourSynth - application for video manipulation based on Python.<br>");
521 text2 += tr("Copyright (c) 2012 Fredrik Mellbin.<br>");
522 text2 += tr("Released under the terms of the GNU Lesser General Public.<br><br>");
523 text2 += tr("Please visit the web-site <a href=\"%1\">%1</a> for more information.<br>").arg("http://www.vapoursynth.com/");
524 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");
526 QMessageBox x264Box(this);
527 x264Box.setIconPixmap(QIcon(":/images/python.png").pixmap(48,48));
528 x264Box.setWindowTitle(tr("About VapourSynth"));
529 x264Box.setText(text2.replace("-", "−"));
530 x264Box.setEscapeButton(x264Box.addButton(tr("Close"), QMessageBox::NoRole));
531 x264_beep(x264_beep_info);
536 QMessageBox::aboutQt(this);
547 void MainWindow::showWebLink(void)
549 if(QObject::sender() == ui->actionWebMulder) QDesktopServices::openUrl(QUrl(home_url));
550 if(QObject::sender() == ui->actionWebX264) QDesktopServices::openUrl(QUrl("http://www.x264.com/"));
551 if(QObject::sender() == ui->actionWebKomisar) QDesktopServices::openUrl(QUrl("http://komisar.gin.by/"));
552 if(QObject::sender() == ui->actionWebVideoLAN) QDesktopServices::openUrl(QUrl("http://download.videolan.org/pub/x264/binaries/"));
553 if(QObject::sender() == ui->actionWebJEEB) QDesktopServices::openUrl(QUrl("http://x264.fushizen.eu/"));
554 if(QObject::sender() == ui->actionWebAvisynth32) QDesktopServices::openUrl(QUrl("http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/"));
555 if(QObject::sender() == ui->actionWebAvisynth64) QDesktopServices::openUrl(QUrl("http://code.google.com/p/avisynth64/downloads/list"));
556 if(QObject::sender() == ui->actionWebVapourSynth) QDesktopServices::openUrl(QUrl("http://www.vapoursynth.com/"));
557 if(QObject::sender() == ui->actionWebVapourSynthDocs) QDesktopServices::openUrl(QUrl("http://www.vapoursynth.com/doc/"));
558 if(QObject::sender() == ui->actionWebWiki) QDesktopServices::openUrl(QUrl("http://mewiki.project357.com/wiki/X264_Settings"));
559 if(QObject::sender() == ui->actionWebBluRay) QDesktopServices::openUrl(QUrl("http://www.x264bluray.com/"));
560 if(QObject::sender() == ui->actionWebAvsWiki) QDesktopServices::openUrl(QUrl("http://avisynth.nl/index.php/Main_Page#Usage"));
561 if(QObject::sender() == ui->actionWebSupport) QDesktopServices::openUrl(QUrl("http://forum.doom9.org/showthread.php?t=144140"));
562 if(QObject::sender() == ui->actionWebSecret) QDesktopServices::openUrl(QUrl("http://www.youtube.com/watch_popup?v=AXIeHY-OYNI"));
566 * Pereferences dialog
568 void MainWindow::showPreferences(void)
570 PreferencesDialog *preferences = new PreferencesDialog(this, m_preferences, m_cpuFeatures->x64);
572 X264_DELETE(preferences);
576 * Launch next job, after running job has finished
578 void MainWindow::launchNextJob(void)
580 qDebug("launchNextJob(void)");
582 const int rows = m_jobList->rowCount(QModelIndex());
584 if(countRunningJobs() >= m_preferences->maxRunningJobCount())
586 qDebug("Still have too many jobs running, won't launch next one yet!");
590 int startIdx= ui->jobsView->currentIndex().isValid() ? qBound(0, ui->jobsView->currentIndex().row(), rows-1) : 0;
592 for(int i = 0; i < rows; i++)
594 int currentIdx = (i + startIdx) % rows;
595 JobStatus status = m_jobList->getJobStatus(m_jobList->index(currentIdx, 0, QModelIndex()));
596 if(status == JobStatus_Enqueued)
598 if(m_jobList->startJob(m_jobList->index(currentIdx, 0, QModelIndex())))
600 ui->jobsView->selectRow(currentIdx);
606 qWarning("No enqueued jobs left!");
610 * Save log to text file
612 void MainWindow::saveLogFile(const QModelIndex &index)
616 if(LogFileModel *log = m_jobList->getLogFile(index))
618 QDir(QString("%1/logs").arg(x264_data_path())).mkpath(".");
619 QString logFilePath = QString("%1/logs/LOG.%2.%3.txt").arg(x264_data_path(), QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString(Qt::ISODate).replace(':', "-"));
620 QFile outFile(logFilePath);
621 if(outFile.open(QIODevice::WriteOnly))
623 QTextStream outStream(&outFile);
624 outStream.setCodec("UTF-8");
625 outStream.setGenerateByteOrderMark(true);
627 const int rows = log->rowCount(QModelIndex());
628 for(int i = 0; i < rows; i++)
630 outStream << log->data(log->index(i, 0, QModelIndex()), Qt::DisplayRole).toString() << QLatin1String("\r\n");
636 qWarning("Failed to open log file for writing:\n%s", logFilePath.toUtf8().constData());
643 * Shut down the computer (with countdown)
645 void MainWindow::shutdownComputer(void)
647 qDebug("shutdownComputer(void)");
649 if(countPendingJobs() > 0)
651 qDebug("Still have pending jobs, won't shutdown yet!");
655 const int iTimeout = 30;
656 const Qt::WindowFlags flags = Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowSystemMenuHint;
657 const QString text = QString("%1%2%1").arg(QString().fill(' ', 18), tr("Warning: Computer will shutdown in %1 seconds..."));
659 qWarning("Initiating shutdown sequence!");
661 QProgressDialog progressDialog(text.arg(iTimeout), tr("Cancel Shutdown"), 0, iTimeout + 1, this, flags);
662 QPushButton *cancelButton = new QPushButton(tr("Cancel Shutdown"), &progressDialog);
663 cancelButton->setIcon(QIcon(":/buttons/power_on.png"));
664 progressDialog.setModal(true);
665 progressDialog.setAutoClose(false);
666 progressDialog.setAutoReset(false);
667 progressDialog.setWindowIcon(QIcon(":/buttons/power_off.png"));
668 progressDialog.setWindowTitle(windowTitle());
669 progressDialog.setCancelButton(cancelButton);
670 progressDialog.show();
672 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
673 QApplication::setOverrideCursor(Qt::WaitCursor);
674 x264_play_sound(IDR_WAVE1, false);
675 QApplication::restoreOverrideCursor();
678 timer.setInterval(1000);
681 QEventLoop eventLoop(this);
682 connect(&timer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
683 connect(&progressDialog, SIGNAL(canceled()), &eventLoop, SLOT(quit()));
685 for(int i = 1; i <= iTimeout; i++)
688 if(progressDialog.wasCanceled())
690 progressDialog.close();
693 progressDialog.setValue(i+1);
694 progressDialog.setLabelText(text.arg(iTimeout-i));
695 if(iTimeout-i == 3) progressDialog.setCancelButton(NULL);
696 QApplication::processEvents();
697 x264_play_sound(((i < iTimeout) ? IDR_WAVE2 : IDR_WAVE3), false);
700 qWarning("Shutting down !!!");
702 if(x264_shutdown_computer("Simple x264 Launcher: All jobs completed, shutting down!", 10, true))
704 qApp->closeAllWindows();
709 * Main initialization function (called only once!)
711 void MainWindow::init(void)
713 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";
714 QStringList binaries = QString::fromLatin1(binFiles).split(":", QString::SkipEmptyParts);
718 //Check for a running instance
719 bool firstInstance = false;
720 if(m_ipcThread->initialize(&firstInstance))
722 m_ipcThread->start();
725 if(!m_ipcThread->wait(5000))
727 QMessageBox::warning(this, tr("Not Responding"), tr("<nobr>Another instance of this application is already running, but did not respond in time.<br>If the problem persists, please kill the running instance from the task manager!</nobr>"), tr("Quit"));
728 m_ipcThread->terminate();
736 while(!binaries.isEmpty())
738 qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
739 QString current = binaries.takeFirst();
740 QFile *file = new QFile(QString("%1/toolset/%2").arg(m_appDir, current));
741 if(file->open(QIODevice::ReadOnly))
743 if(!x264_is_executable(file->fileName()))
745 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("-", "−"));
746 qFatal(QString("Binary is invalid: %1/toolset/%2").arg(m_appDir, current).toLatin1().constData());
754 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("-", "−"));
755 qFatal(QString("Binary not found: %1/toolset/%2").arg(m_appDir, current).toLatin1().constData());
760 //Check for portable mode
764 static const char *data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
765 QFile writeTest(QString("%1/%2").arg(x264_data_path(), QUuid::createUuid().toString()));
766 if(writeTest.open(QIODevice::WriteOnly))
768 ok = (writeTest.write(data) == strlen(data));
773 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"));
774 if(val != 1) INIT_ERROR_EXIT();
779 if(x264_is_prerelease())
781 qsrand(time(NULL)); int rnd = qrand() % 3;
782 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);
783 if(rnd != val) INIT_ERROR_EXIT();
786 //Make sure this CPU can run x264 (requires MMX + MMXEXT/iSSE to run x264 with ASM enabled, additionally requires SSE1 for most x264 builds)
787 if(!(m_cpuFeatures->mmx && m_cpuFeatures->mmx2))
789 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"));
790 qFatal("System does not support MMX and MMXEXT, x264 will not work !!!");
793 else if(!(m_cpuFeatures->mmx && m_cpuFeatures->sse))
795 qWarning("WARNING: System does not support SSE1, most x264 builds will not work !!!\n");
796 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"));
797 if(val != 1) INIT_ERROR_EXIT();
800 //Skip version check (not recommended!)
801 if(qApp->arguments().contains("--skip-x264-version-check", Qt::CaseInsensitive))
803 qWarning("x264 version check disabled, you have been warned!\n");
804 m_skipVersionTest = true;
807 //Don't abort encoding process on timeout (not recommended!)
808 if(qApp->arguments().contains("--no-deadlock-detection", Qt::CaseInsensitive))
810 qWarning("Deadlock detection disabled, you have been warned!\n");
811 m_abortOnTimeout = false;
814 //Check for Avisynth support
815 if(!qApp->arguments().contains("--skip-avisynth-check", Qt::CaseInsensitive))
817 qDebug("[Check for Avisynth support]");
818 volatile double avisynthVersion = 0.0;
819 const int result = AvisynthCheckThread::detect(&avisynthVersion);
822 QString text = tr("A critical error was encountered while checking your Avisynth version.").append("<br>");
823 text += tr("This is most likely caused by an erroneous Avisynth Plugin, please try to clean your Plugins folder!").append("<br>");
824 text += tr("We suggest to move all .dll and .avsi files out of your Avisynth Plugins folder and try again.");
825 int val = QMessageBox::critical(this, tr("Avisynth Error"), QString("<nobr>%1</nobr>").arg(text).replace("-", "−"), tr("Quit"), tr("Ignore"));
826 if(val != 1) INIT_ERROR_EXIT();
828 if((!result) || (avisynthVersion < 2.5))
830 if(!m_preferences->disableWarnings())
832 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>");
833 text += tr("Please download and install Avisynth:").append("<br>").append(LINK("http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/"));
834 int val = QMessageBox::warning(this, tr("Avisynth Missing"), QString("<nobr>%1</nobr>").arg(text).replace("-", "−"), tr("Quit"), tr("Ignore"));
835 if(val != 1) INIT_ERROR_EXIT();
841 //Check for VapourSynth support
842 if(!qApp->arguments().contains("--skip-vapoursynth-check", Qt::CaseInsensitive))
844 qDebug("[Check for VapourSynth support]");
845 volatile double avisynthVersion = 0.0;
846 const int result = VapourSynthCheckThread::detect(m_vapoursynthPath);
849 QString text = tr("A critical error was encountered while checking your VapourSynth installation.").append("<br>");
850 text += tr("This is most likely caused by an erroneous VapourSynth Plugin, please try to clean your Filters folder!").append("<br>");
851 text += tr("We suggest to move all .dll files out of your VapourSynth Filters folder and try again.");
852 int val = QMessageBox::critical(this, tr("VapourSynth Error"), QString("<nobr>%1</nobr>").arg(text).replace("-", "−"), tr("Quit"), tr("Ignore"));
853 if(val != 1) INIT_ERROR_EXIT();
855 if((!result) || (m_vapoursynthPath.isEmpty()))
857 if(!m_preferences->disableWarnings())
859 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>");
860 text += tr("Please download and install VapourSynth for Windows (R19 or later):").append("<br>").append(LINK("http://www.vapoursynth.com/")).append("<br><br>");
861 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>");
862 int val = QMessageBox::warning(this, tr("VapourSynth Missing"), QString("<nobr>%1</nobr>").arg(text).replace("-", "−"), tr("Quit"), tr("Ignore"));
863 if(val != 1) INIT_ERROR_EXIT();
869 //Check for expiration
870 if(x264_version_date().addMonths(6) < QDate::currentDate())
872 QMessageBox msgBox(this);
873 msgBox.setIconPixmap(QIcon(":/images/update.png").pixmap(56,56));
874 msgBox.setWindowTitle(tr("Update Notification"));
875 msgBox.setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
876 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));
877 QPushButton *btn1 = msgBox.addButton(tr("Discard"), QMessageBox::NoRole);
878 QPushButton *btn2 = msgBox.addButton(tr("Discard"), QMessageBox::AcceptRole);
879 btn1->setEnabled(false);
880 btn2->setVisible(false);
881 QTimer::singleShot(5000, btn1, SLOT(hide()));
882 QTimer::singleShot(5000, btn2, SLOT(show()));
886 //Add files from command-line
887 bool bAddFile = false;
888 QStringList files, args = qApp->arguments();
889 while(!args.isEmpty())
891 QString current = args.takeFirst();
894 bAddFile = (current.compare("--add", Qt::CaseInsensitive) == 0);
897 if((!current.startsWith("--")) && QFileInfo(current).exists() && QFileInfo(current).isFile())
899 files << QFileInfo(current).canonicalFilePath();
902 if(files.count() > 0)
904 createJobMultiple(files);
907 //Enable drag&drop support for this window, required for Qt v4.8.4+
908 setAcceptDrops(true);
910 //Update initialized flag
911 m_initialized = true;
915 * Update the label position
917 void MainWindow::updateLabelPos(void)
919 const QWidget *const viewPort = ui->jobsView->viewport();
920 m_label->setGeometry(0, 0, viewPort->width(), viewPort->height());
924 * Copy the complete log to the clipboard
926 void MainWindow::copyLogToClipboard(bool checked)
928 qDebug("copyLogToClipboard");
930 if(LogFileModel *log = dynamic_cast<LogFileModel*>(ui->logView->model()))
932 log->copyToClipboard();
933 x264_beep(x264_beep_info);
938 * Process the dropped files
940 void MainWindow::handleDroppedFiles(void)
942 qDebug("MainWindow::handleDroppedFiles");
945 QStringList droppedFiles(*m_droppedFiles);
946 m_droppedFiles->clear();
947 createJobMultiple(droppedFiles);
949 qDebug("Leave from MainWindow::handleDroppedFiles!");
952 void MainWindow::instanceCreated(unsigned int pid)
954 qDebug("Notification from other instance (PID=0x%X) received!", pid);
956 x264_blink_window(this, 5, 125);
957 x264_bring_to_front(this);
958 qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
959 x264_blink_window(this, 5, 125);
962 ///////////////////////////////////////////////////////////////////////////////
964 ///////////////////////////////////////////////////////////////////////////////
969 void MainWindow::showEvent(QShowEvent *e)
971 QMainWindow::showEvent(e);
976 QTimer::singleShot(0, this, SLOT(init()));
983 void MainWindow::closeEvent(QCloseEvent *e)
991 if(countRunningJobs() > 0)
994 QMessageBox::warning(this, tr("Jobs Are Running"), tr("Sorry, can not exit while there still are running jobs!"));
998 if(countPendingJobs() > 0)
1000 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);
1001 if(ret != QMessageBox::Yes)
1008 while(m_jobList->rowCount(QModelIndex()) > 0)
1010 qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
1011 if(!m_jobList->deleteJob(m_jobList->index(0, 0, QModelIndex())))
1014 QMessageBox::warning(this, tr("Failed To Exit"), tr("Sorry, at least one job could not be deleted!"));
1019 qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
1020 QMainWindow::closeEvent(e);
1024 * Window resize event
1026 void MainWindow::resizeEvent(QResizeEvent *e)
1028 QMainWindow::resizeEvent(e);
1035 bool MainWindow::eventFilter(QObject *o, QEvent *e)
1037 if((o == ui->labelBuildDate) && (e->type() == QEvent::MouseButtonPress))
1039 QTimer::singleShot(0, this, SLOT(showAbout()));
1046 * Win32 message filter
1048 bool MainWindow::winEvent(MSG *message, long *result)
1050 return WinSevenTaskbar::handleWinEvent(message, result);
1054 * File dragged over window
1056 void MainWindow::dragEnterEvent(QDragEnterEvent *event)
1058 bool accept[2] = {false, false};
1060 foreach(const QString &fmt, event->mimeData()->formats())
1062 accept[0] = accept[0] || fmt.contains("text/uri-list", Qt::CaseInsensitive);
1063 accept[1] = accept[1] || fmt.contains("FileNameW", Qt::CaseInsensitive);
1066 if(accept[0] && accept[1])
1068 event->acceptProposedAction();
1073 * File dropped onto window
1075 void MainWindow::dropEvent(QDropEvent *event)
1077 QStringList droppedFiles;
1078 QList<QUrl> urls = event->mimeData()->urls();
1080 while(!urls.isEmpty())
1082 QUrl currentUrl = urls.takeFirst();
1083 QFileInfo file(currentUrl.toLocalFile());
1084 if(file.exists() && file.isFile())
1086 qDebug("MainWindow::dropEvent: %s", file.canonicalFilePath().toUtf8().constData());
1087 droppedFiles << file.canonicalFilePath();
1091 if(droppedFiles.count() > 0)
1095 m_droppedFiles = new QStringList();
1097 m_droppedFiles->append(droppedFiles);
1098 m_droppedFiles->sort();
1099 QTimer::singleShot(0, this, SLOT(handleDroppedFiles()));
1103 ///////////////////////////////////////////////////////////////////////////////
1104 // Private functions
1105 ///////////////////////////////////////////////////////////////////////////////
1110 bool MainWindow::createJob(QString &sourceFileName, QString &outputFileName, OptionsModel *options, bool &runImmediately, const bool restart, int fileNo, int fileTotal, bool *applyToAll)
1113 AddJobDialog *addDialog = new AddJobDialog(this, options, m_recentlyUsed, m_cpuFeatures->x64, m_preferences->use10BitEncoding(), m_preferences->saveToSourcePath());
1115 addDialog->setRunImmediately(runImmediately);
1116 if(!sourceFileName.isEmpty()) addDialog->setSourceFile(sourceFileName);
1117 if(!outputFileName.isEmpty()) addDialog->setOutputFile(outputFileName);
1118 if(restart) addDialog->setWindowTitle(tr("Restart Job"));
1120 const bool multiFile = (fileNo >= 0) && (fileTotal > 1);
1123 addDialog->setSourceEditable(false);
1124 addDialog->setWindowTitle(addDialog->windowTitle().append(tr(" (File %1 of %2)").arg(QString::number(fileNo+1), QString::number(fileTotal))));
1125 addDialog->setApplyToAllVisible(applyToAll);
1128 if(addDialog->exec() == QDialog::Accepted)
1130 sourceFileName = addDialog->sourceFile();
1131 outputFileName = addDialog->outputFile();
1132 runImmediately = addDialog->runImmediately();
1135 *applyToAll = addDialog->applyToAll();
1140 X264_DELETE(addDialog);
1145 * Creates a new job from *multiple* files
1147 bool MainWindow::createJobMultiple(const QStringList &filePathIn)
1149 QStringList::ConstIterator iter;
1150 bool applyToAll = false, runImmediately = false;
1153 //Add files individually
1154 for(iter = filePathIn.constBegin(); (iter != filePathIn.constEnd()) && (!applyToAll); iter++)
1156 runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
1157 QString sourceFileName(*iter), outputFileName;
1158 if(createJob(sourceFileName, outputFileName, m_options, runImmediately, false, counter++, filePathIn.count(), &applyToAll))
1160 if(appendJob(sourceFileName, outputFileName, m_options, runImmediately))
1168 //Add remaining files
1169 while(applyToAll && (iter != filePathIn.constEnd()))
1171 const bool runImmediatelyTmp = runImmediately && (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
1172 const QString sourceFileName = *iter;
1173 const QString outputFileName = AddJobDialog::generateOutputFileName(sourceFileName, m_recentlyUsed->outputDirectory(), m_recentlyUsed->filterIndex(), m_preferences->saveToSourcePath());
1174 if(!appendJob(sourceFileName, outputFileName, m_options, runImmediatelyTmp))
1188 bool MainWindow::appendJob(const QString &sourceFileName, const QString &outputFileName, OptionsModel *options, const bool runImmediately)
1192 EncodeThread *thrd = new EncodeThread
1197 QString("%1/toolset").arg(m_appDir),
1200 m_preferences->use10BitEncoding(),
1201 m_cpuFeatures->x64 && m_preferences->useAvisyth64Bit(),
1203 m_preferences->processPriority(),
1207 QModelIndex newIndex = m_jobList->insertJob(thrd);
1209 if(newIndex.isValid())
1213 ui->jobsView->selectRow(newIndex.row());
1214 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
1215 m_jobList->startJob(newIndex);
1221 m_label->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
1226 * Jobs that are not completed (or failed, or aborted) yet
1228 unsigned int MainWindow::countPendingJobs(void)
1230 unsigned int count = 0;
1231 const int rows = m_jobList->rowCount(QModelIndex());
1233 for(int i = 0; i < rows; i++)
1235 JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
1236 if(status != JobStatus_Completed && status != JobStatus_Aborted && status != JobStatus_Failed)
1246 * Jobs that are still active, i.e. not terminated or enqueued
1248 unsigned int MainWindow::countRunningJobs(void)
1250 unsigned int count = 0;
1251 const int rows = m_jobList->rowCount(QModelIndex());
1253 for(int i = 0; i < rows; i++)
1255 JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
1256 if(status != JobStatus_Completed && status != JobStatus_Aborted && status != JobStatus_Failed && status != JobStatus_Enqueued)
1266 * Update all buttons with respect to current job status
1268 void MainWindow::updateButtons(JobStatus status)
1270 qDebug("MainWindow::updateButtons(void)");
1272 ui->buttonStartJob->setEnabled(status == JobStatus_Enqueued);
1273 ui->buttonAbortJob->setEnabled(status == JobStatus_Indexing || status == JobStatus_Running || status == JobStatus_Running_Pass1 || status == JobStatus_Running_Pass2 || status == JobStatus_Paused);
1274 ui->buttonPauseJob->setEnabled(status == JobStatus_Indexing || status == JobStatus_Running || status == JobStatus_Paused || status == JobStatus_Running_Pass1 || status == JobStatus_Running_Pass2);
1275 ui->buttonPauseJob->setChecked(status == JobStatus_Paused || status == JobStatus_Pausing);
1277 ui->actionJob_Delete->setEnabled(status == JobStatus_Completed || status == JobStatus_Aborted || status == JobStatus_Failed || status == JobStatus_Enqueued);
1278 ui->actionJob_Restart->setEnabled(status == JobStatus_Completed || status == JobStatus_Aborted || status == JobStatus_Failed || status == JobStatus_Enqueued);
1279 ui->actionJob_Browse->setEnabled(status == JobStatus_Completed);
1281 ui->actionJob_Start->setEnabled(ui->buttonStartJob->isEnabled());
1282 ui->actionJob_Abort->setEnabled(ui->buttonAbortJob->isEnabled());
1283 ui->actionJob_Pause->setEnabled(ui->buttonPauseJob->isEnabled());
1284 ui->actionJob_Pause->setChecked(ui->buttonPauseJob->isChecked());
1286 ui->editDetails->setEnabled(status != JobStatus_Paused);
1290 * Update the taskbar with current job status
1292 void MainWindow::updateTaskbar(JobStatus status, const QIcon &icon)
1294 qDebug("MainWindow::updateTaskbar(void)");
1298 case JobStatus_Undefined:
1299 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNoState);
1301 case JobStatus_Aborting:
1302 case JobStatus_Starting:
1303 case JobStatus_Pausing:
1304 case JobStatus_Resuming:
1305 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarIndeterminateState);
1307 case JobStatus_Aborted:
1308 case JobStatus_Failed:
1309 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState);
1311 case JobStatus_Paused:
1312 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarPausedState);
1315 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState);
1321 case JobStatus_Aborting:
1322 case JobStatus_Starting:
1323 case JobStatus_Pausing:
1324 case JobStatus_Resuming:
1327 WinSevenTaskbar::setTaskbarProgress(this, ui->progressBar->value(), ui->progressBar->maximum());
1331 WinSevenTaskbar::setOverlayIcon(this, icon.isNull() ? NULL : &icon);