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 ///////////////////////////////////////////////////////////////////////////////
24 #include "model_jobList.h"
25 #include "model_options.h"
26 #include "model_preferences.h"
27 #include "model_recently.h"
28 #include "thread_avisynth.h"
29 #include "thread_ipc.h"
30 #include "thread_encode.h"
32 #include "win_addJob.h"
33 #include "win_preferences.h"
38 #include <QCloseEvent>
39 #include <QMessageBox>
40 #include <QDesktopServices>
45 #include <QProgressDialog>
47 #include <QTextStream>
49 #include <QFileDialog>
53 const char *home_url = "http://muldersoft.com/";
54 const char *update_url = "http://code.google.com/p/mulder/downloads/list";
55 const char *tpl_last = "<LAST_USED>";
57 #define SET_FONT_BOLD(WIDGET,BOLD) { QFont _font = WIDGET->font(); _font.setBold(BOLD); WIDGET->setFont(_font); }
58 #define SET_TEXT_COLOR(WIDGET,COLOR) { QPalette _palette = WIDGET->palette(); _palette.setColor(QPalette::WindowText, (COLOR)); _palette.setColor(QPalette::Text, (COLOR)); WIDGET->setPalette(_palette); }
60 static int exceptionFilter(_EXCEPTION_RECORD *dst, _EXCEPTION_POINTERS *src) { memcpy(dst, src->ExceptionRecord, sizeof(_EXCEPTION_RECORD)); return EXCEPTION_EXECUTE_HANDLER; }
62 ///////////////////////////////////////////////////////////////////////////////
63 // Constructor & Destructor
64 ///////////////////////////////////////////////////////////////////////////////
69 MainWindow::MainWindow(const x264_cpu_t *const cpuFeatures)
71 m_cpuFeatures(cpuFeatures),
72 m_appDir(QApplication::applicationDirPath()),
78 m_skipVersionTest(false),
81 //Init the dialog, from the .ui file
83 setWindowFlags(windowFlags() & (~Qt::WindowMaximizeButtonHint));
86 qRegisterMetaType<QUuid>("QUuid");
87 qRegisterMetaType<QUuid>("DWORD");
88 qRegisterMetaType<JobStatus>("JobStatus");
91 m_preferences = new PreferencesModel();
92 PreferencesModel::loadPreferences(m_preferences);
95 m_recentlyUsed = new RecentlyUsed();
96 RecentlyUsed::loadRecentlyUsed(m_recentlyUsed);
98 //Create options object
99 m_options = new OptionsModel();
100 OptionsModel::loadTemplate(m_options, QString::fromLatin1(tpl_last));
102 //Create IPC thread object
103 m_ipcThread = new IPCThread();
104 connect(m_ipcThread, SIGNAL(instanceCreated(DWORD)), this, SLOT(instanceCreated(DWORD)), Qt::QueuedConnection);
106 //Freeze minimum size
107 setMinimumSize(size());
108 splitter->setSizes(QList<int>() << 16 << 196);
111 labelBuildDate->setText(tr("Built on %1 at %2").arg(x264_version_date().toString(Qt::ISODate), QString::fromLatin1(x264_version_time())));
112 labelBuildDate->installEventFilter(this);
113 setWindowTitle(QString("%1 (%2 Mode)").arg(windowTitle(), m_cpuFeatures->x64 ? "64-Bit" : "32-Bit"));
116 setWindowTitle(QString("%1 | !!! DEBUG VERSION !!!").arg(windowTitle()));
117 setStyleSheet("QMenuBar, QMainWindow { background-color: yellow }");
119 else if(x264_is_prerelease())
121 setWindowTitle(QString("%1 | PRE-RELEASE VERSION").arg(windowTitle()));
125 m_jobList = new JobListModel(m_preferences);
126 connect(m_jobList, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(jobChangedData(QModelIndex, QModelIndex)));
127 jobsView->setModel(m_jobList);
130 jobsView->horizontalHeader()->setSectionHidden(3, true);
131 jobsView->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
132 jobsView->horizontalHeader()->setResizeMode(1, QHeaderView::Fixed);
133 jobsView->horizontalHeader()->setResizeMode(2, QHeaderView::Fixed);
134 jobsView->horizontalHeader()->resizeSection(1, 150);
135 jobsView->horizontalHeader()->resizeSection(2, 90);
136 jobsView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
137 connect(jobsView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(jobSelected(QModelIndex, QModelIndex)));
139 //Create context menu
140 QAction *actionClipboard = new QAction(QIcon(":/buttons/page_paste.png"), tr("Copy to Clipboard"), logView);
141 actionClipboard->setEnabled(false);
142 logView->addAction(actionClipboard);
143 connect(actionClipboard, SIGNAL(triggered(bool)), this, SLOT(copyLogToClipboard(bool)));
144 jobsView->addActions(menuJob->actions());
147 connect(buttonAddJob, SIGNAL(clicked()), this, SLOT(addButtonPressed()));
148 connect(buttonStartJob, SIGNAL(clicked()), this, SLOT(startButtonPressed()));
149 connect(buttonAbortJob, SIGNAL(clicked()), this, SLOT(abortButtonPressed()));
150 connect(buttonPauseJob, SIGNAL(toggled(bool)), this, SLOT(pauseButtonPressed(bool)));
151 connect(actionJob_Delete, SIGNAL(triggered()), this, SLOT(deleteButtonPressed()));
152 connect(actionJob_Restart, SIGNAL(triggered()), this, SLOT(restartButtonPressed()));
153 connect(actionJob_Browse, SIGNAL(triggered()), this, SLOT(browseButtonPressed()));
156 connect(actionOpen, SIGNAL(triggered()), this, SLOT(openActionTriggered()));
157 connect(actionAbout, SIGNAL(triggered()), this, SLOT(showAbout()));
158 connect(actionWebMulder, SIGNAL(triggered()), this, SLOT(showWebLink()));
159 connect(actionWebX264, SIGNAL(triggered()), this, SLOT(showWebLink()));
160 connect(actionWebKomisar, SIGNAL(triggered()), this, SLOT(showWebLink()));
161 connect(actionWebJarod, SIGNAL(triggered()), this, SLOT(showWebLink()));
162 connect(actionWebJEEB, SIGNAL(triggered()), this, SLOT(showWebLink()));
163 connect(actionWebAvisynth32, SIGNAL(triggered()), this, SLOT(showWebLink()));
164 connect(actionWebAvisynth64, SIGNAL(triggered()), this, SLOT(showWebLink()));
165 connect(actionWebWiki, SIGNAL(triggered()), this, SLOT(showWebLink()));
166 connect(actionWebBluRay, SIGNAL(triggered()), this, SLOT(showWebLink()));
167 connect(actionWebAvsWiki, SIGNAL(triggered()), this, SLOT(showWebLink()));
168 connect(actionWebSecret, SIGNAL(triggered()), this, SLOT(showWebLink()));
169 connect(actionWebSupport, SIGNAL(triggered()), this, SLOT(showWebLink()));
170 connect(actionPreferences, SIGNAL(triggered()), this, SLOT(showPreferences()));
172 //Create floating label
173 m_label = new QLabel(jobsView->viewport());
174 m_label->setText(tr("No job created yet. Please click the 'Add New Job' button!"));
175 m_label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
176 SET_TEXT_COLOR(m_label, Qt::darkGray);
177 SET_FONT_BOLD(m_label, true);
178 m_label->setVisible(true);
179 m_label->setContextMenuPolicy(Qt::ActionsContextMenu);
180 m_label->addActions(jobsView->actions());
181 connect(splitter, SIGNAL(splitterMoved(int, int)), this, SLOT(updateLabelPos()));
188 MainWindow::~MainWindow(void)
190 OptionsModel::saveTemplate(m_options, QString::fromLatin1(tpl_last));
192 X264_DELETE(m_jobList);
193 X264_DELETE(m_options);
194 X264_DELETE(m_droppedFiles);
195 X264_DELETE(m_label);
197 while(!m_toolsList.isEmpty())
199 QFile *temp = m_toolsList.takeFirst();
203 if(m_ipcThread->isRunning())
205 m_ipcThread->setAbort();
206 if(!m_ipcThread->wait(5000))
208 m_ipcThread->terminate();
213 X264_DELETE(m_ipcThread);
214 AvisynthCheckThread::unload();
215 X264_DELETE(m_preferences);
216 X264_DELETE(m_recentlyUsed);
219 ///////////////////////////////////////////////////////////////////////////////
221 ///////////////////////////////////////////////////////////////////////////////
224 * The "add" button was clicked
226 void MainWindow::addButtonPressed()
228 qDebug("MainWindow::addButtonPressed");
229 bool runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
230 QString sourceFileName, outputFileName;
232 if(createJob(sourceFileName, outputFileName, m_options, runImmediately))
234 appendJob(sourceFileName, outputFileName, m_options, runImmediately);
239 * The "open" action was triggered
241 void MainWindow::openActionTriggered()
243 QStringList fileList = QFileDialog::getOpenFileNames(this, tr("Open Source File(s)"), m_recentlyUsed->sourceDirectory(), AddJobDialog::getInputFilterLst(), NULL, QFileDialog::DontUseNativeDialog);
244 if(!fileList.empty())
246 m_recentlyUsed->setSourceDirectory(QFileInfo(fileList.last()).absolutePath());
247 if(fileList.count() > 1)
249 createJobMultiple(fileList);
253 bool runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
254 QString sourceFileName(fileList.first()), outputFileName;
255 if(createJob(sourceFileName, outputFileName, m_options, runImmediately))
257 appendJob(sourceFileName, outputFileName, m_options, runImmediately);
264 * The "start" button was clicked
266 void MainWindow::startButtonPressed(void)
268 m_jobList->startJob(jobsView->currentIndex());
272 * The "abort" button was clicked
274 void MainWindow::abortButtonPressed(void)
276 m_jobList->abortJob(jobsView->currentIndex());
280 * The "delete" button was clicked
282 void MainWindow::deleteButtonPressed(void)
284 m_jobList->deleteJob(jobsView->currentIndex());
285 m_label->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
289 * The "browse" button was clicked
291 void MainWindow::browseButtonPressed(void)
293 QString outputFile = m_jobList->getJobOutputFile(jobsView->currentIndex());
294 if((!outputFile.isEmpty()) && QFileInfo(outputFile).exists() && QFileInfo(outputFile).isFile())
296 QProcess::startDetached(QString::fromLatin1("explorer.exe"), QStringList() << QString::fromLatin1("/select,") << QDir::toNativeSeparators(outputFile), QFileInfo(outputFile).path());
300 QMessageBox::warning(this, tr("Not Found"), tr("Sorry, the output file could not be found!"));
305 * The "pause" button was clicked
307 void MainWindow::pauseButtonPressed(bool checked)
311 m_jobList->pauseJob(jobsView->currentIndex());
315 m_jobList->resumeJob(jobsView->currentIndex());
320 * The "restart" button was clicked
322 void MainWindow::restartButtonPressed(void)
324 const QModelIndex index = jobsView->currentIndex();
325 const OptionsModel *options = m_jobList->getJobOptions(index);
326 QString sourceFileName = m_jobList->getJobSourceFile(index);
327 QString outputFileName = m_jobList->getJobOutputFile(index);
329 if((options) && (!sourceFileName.isEmpty()) && (!outputFileName.isEmpty()))
331 bool runImmediately = true;
332 OptionsModel *tempOptions = new OptionsModel(*options);
333 if(createJob(sourceFileName, outputFileName, tempOptions, runImmediately, true))
335 appendJob(sourceFileName, outputFileName, tempOptions, runImmediately);
337 X264_DELETE(tempOptions);
342 * Job item selected by user
344 void MainWindow::jobSelected(const QModelIndex & current, const QModelIndex & previous)
346 qDebug("Job selected: %d", current.row());
350 disconnect(logView->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(jobLogExtended(QModelIndex, int, int)));
353 if(current.isValid())
355 logView->setModel(m_jobList->getLogFile(current));
356 connect(logView->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(jobLogExtended(QModelIndex, int, int)));
357 logView->actions().first()->setEnabled(true);
358 QTimer::singleShot(0, logView, SLOT(scrollToBottom()));
360 progressBar->setValue(m_jobList->getJobProgress(current));
361 editDetails->setText(m_jobList->data(m_jobList->index(current.row(), 3, QModelIndex()), Qt::DisplayRole).toString());
362 updateButtons(m_jobList->getJobStatus(current));
363 updateTaskbar(m_jobList->getJobStatus(current), m_jobList->data(m_jobList->index(current.row(), 0, QModelIndex()), Qt::DecorationRole).value<QIcon>());
367 logView->setModel(NULL);
368 logView->actions().first()->setEnabled(false);
369 progressBar->setValue(0);
370 editDetails->clear();
371 updateButtons(JobStatus_Undefined);
372 updateTaskbar(JobStatus_Undefined, QIcon());
375 progressBar->repaint();
379 * Handle update of job info (status, progress, details, etc)
381 void MainWindow::jobChangedData(const QModelIndex &topLeft, const QModelIndex &bottomRight)
383 int selected = jobsView->currentIndex().row();
385 if(topLeft.column() <= 1 && bottomRight.column() >= 1) /*STATUS*/
387 for(int i = topLeft.row(); i <= bottomRight.row(); i++)
389 JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
392 qDebug("Current job changed status!");
393 updateButtons(status);
394 updateTaskbar(status, m_jobList->data(m_jobList->index(i, 0, QModelIndex()), Qt::DecorationRole).value<QIcon>());
396 if((status == JobStatus_Completed) || (status == JobStatus_Failed))
398 if(m_preferences->autoRunNextJob()) QTimer::singleShot(0, this, SLOT(launchNextJob()));
399 if(m_preferences->shutdownComputer()) QTimer::singleShot(0, this, SLOT(shutdownComputer()));
400 if(m_preferences->saveLogFiles()) saveLogFile(m_jobList->index(i, 1, QModelIndex()));
404 if(topLeft.column() <= 2 && bottomRight.column() >= 2) /*PROGRESS*/
406 for(int i = topLeft.row(); i <= bottomRight.row(); i++)
410 progressBar->setValue(m_jobList->getJobProgress(m_jobList->index(i, 0, QModelIndex())));
411 WinSevenTaskbar::setTaskbarProgress(this, progressBar->value(), progressBar->maximum());
416 if(topLeft.column() <= 3 && bottomRight.column() >= 3) /*DETAILS*/
418 for(int i = topLeft.row(); i <= bottomRight.row(); i++)
422 editDetails->setText(m_jobList->data(m_jobList->index(i, 3, QModelIndex()), Qt::DisplayRole).toString());
430 * Handle new log file content
432 void MainWindow::jobLogExtended(const QModelIndex & parent, int start, int end)
434 QTimer::singleShot(0, logView, SLOT(scrollToBottom()));
440 void MainWindow::showAbout(void)
444 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());
445 text += QString().sprintf("Copyright (c) 2004-%04d LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved.<br>", qMax(x264_version_date().year(),QDate::currentDate().year()));
446 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());
447 text += QString().sprintf("This program is free software: you can redistribute it and/or modify<br>");
448 text += QString().sprintf("it under the terms of the GNU General Public License <http://www.gnu.org/>.<br>");
449 text += QString().sprintf("Note that this program is distributed with ABSOLUTELY NO WARRANTY.<br><br>");
450 text += QString().sprintf("Please check the web-site at <a href=\"%s\">%s</a> for updates !!!<br></tt></nobr>", home_url, home_url);
452 QMessageBox aboutBox(this);
453 aboutBox.setIconPixmap(QIcon(":/images/movie.png").pixmap(64,64));
454 aboutBox.setWindowTitle(tr("About..."));
455 aboutBox.setText(text.replace("-", "−"));
456 aboutBox.addButton(tr("About x264"), QMessageBox::NoRole);
457 aboutBox.addButton(tr("About AVS"), QMessageBox::NoRole);
458 aboutBox.addButton(tr("About Qt"), QMessageBox::NoRole);
459 aboutBox.setEscapeButton(aboutBox.addButton(tr("Close"), QMessageBox::NoRole));
463 MessageBeep(MB_ICONINFORMATION);
464 switch(aboutBox.exec())
469 text2 += tr("<nobr><tt>x264 - the best H.264/AVC encoder. Copyright (c) 2003-2013 x264 project.<br>");
470 text2 += tr("Free software library for encoding video streams into the H.264/MPEG-4 AVC format.<br>");
471 text2 += tr("Released under the terms of the GNU General Public License.<br><br>");
472 text2 += tr("Please visit <a href=\"%1\">%1</a> for obtaining a commercial x264 license.<br>").arg("http://x264licensing.com/");
473 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");
475 QMessageBox x264Box(this);
476 x264Box.setIconPixmap(QIcon(":/images/x264.png").pixmap(48,48));
477 x264Box.setWindowTitle(tr("About x264"));
478 x264Box.setText(text2.replace("-", "−"));
479 x264Box.setEscapeButton(x264Box.addButton(tr("Close"), QMessageBox::NoRole));
480 MessageBeep(MB_ICONINFORMATION);
487 text2 += tr("<nobr><tt>Avisynth - powerful video processing scripting language.<br>");
488 text2 += tr("Copyright (c) 2000 Ben Rudiak-Gould and all subsequent developers.<br>");
489 text2 += tr("Released under the terms of the GNU General Public License.<br><br>");
490 text2 += tr("Please visit the web-site <a href=\"%1\">%1</a> for more information.<br>").arg("http://avisynth.org/");
491 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.org/mediawiki/First_script", "http://forum.doom9.org/forumdisplay.php?f=33");
493 QMessageBox x264Box(this);
494 x264Box.setIconPixmap(QIcon(":/images/avisynth.png").pixmap(48,67));
495 x264Box.setWindowTitle(tr("About Avisynth"));
496 x264Box.setText(text2.replace("-", "−"));
497 x264Box.setEscapeButton(x264Box.addButton(tr("Close"), QMessageBox::NoRole));
498 MessageBeep(MB_ICONINFORMATION);
503 QMessageBox::aboutQt(this);
514 void MainWindow::showWebLink(void)
516 if(QObject::sender() == actionWebMulder) QDesktopServices::openUrl(QUrl(home_url));
517 if(QObject::sender() == actionWebX264) QDesktopServices::openUrl(QUrl("http://www.x264.com/"));
518 if(QObject::sender() == actionWebKomisar) QDesktopServices::openUrl(QUrl("http://komisar.gin.by/"));
519 if(QObject::sender() == actionWebJarod) QDesktopServices::openUrl(QUrl("http://www.x264.nl/"));
520 if(QObject::sender() == actionWebJEEB) QDesktopServices::openUrl(QUrl("http://x264.fushizen.eu/"));
521 if(QObject::sender() == actionWebAvisynth32) QDesktopServices::openUrl(QUrl("http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/"));
522 if(QObject::sender() == actionWebAvisynth64) QDesktopServices::openUrl(QUrl("http://code.google.com/p/avisynth64/downloads/list"));
523 if(QObject::sender() == actionWebWiki) QDesktopServices::openUrl(QUrl("http://mewiki.project357.com/wiki/X264_Settings"));
524 if(QObject::sender() == actionWebBluRay) QDesktopServices::openUrl(QUrl("http://www.x264bluray.com/"));
525 if(QObject::sender() == actionWebAvsWiki) QDesktopServices::openUrl(QUrl("http://avisynth.org/mediawiki/Main_Page#Usage"));
526 if(QObject::sender() == actionWebSupport) QDesktopServices::openUrl(QUrl("http://forum.doom9.org/showthread.php?t=144140"));
527 if(QObject::sender() == actionWebSecret) QDesktopServices::openUrl(QUrl("http://www.youtube.com/watch_popup?v=AXIeHY-OYNI"));
531 * Pereferences dialog
533 void MainWindow::showPreferences(void)
535 PreferencesDialog *preferences = new PreferencesDialog(this, m_preferences, m_cpuFeatures->x64);
537 X264_DELETE(preferences);
541 * Launch next job, after running job has finished
543 void MainWindow::launchNextJob(void)
545 qDebug("launchNextJob(void)");
547 const int rows = m_jobList->rowCount(QModelIndex());
549 if(countRunningJobs() >= m_preferences->maxRunningJobCount())
551 qDebug("Still have too many jobs running, won't launch next one yet!");
555 int startIdx= jobsView->currentIndex().isValid() ? qBound(0, jobsView->currentIndex().row(), rows-1) : 0;
557 for(int i = 0; i < rows; i++)
559 int currentIdx = (i + startIdx) % rows;
560 JobStatus status = m_jobList->getJobStatus(m_jobList->index(currentIdx, 0, QModelIndex()));
561 if(status == JobStatus_Enqueued)
563 if(m_jobList->startJob(m_jobList->index(currentIdx, 0, QModelIndex())))
565 jobsView->selectRow(currentIdx);
571 qWarning("No enqueued jobs left!");
575 * Save log to text file
577 void MainWindow::saveLogFile(const QModelIndex &index)
581 if(LogFileModel *log = m_jobList->getLogFile(index))
583 QDir(QString("%1/logs").arg(x264_data_path())).mkpath(".");
584 QString logFilePath = QString("%1/logs/LOG.%2.%3.txt").arg(x264_data_path(), QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString(Qt::ISODate).replace(':', "-"));
585 QFile outFile(logFilePath);
586 if(outFile.open(QIODevice::WriteOnly))
588 QTextStream outStream(&outFile);
589 outStream.setCodec("UTF-8");
590 outStream.setGenerateByteOrderMark(true);
592 const int rows = log->rowCount(QModelIndex());
593 for(int i = 0; i < rows; i++)
595 outStream << log->data(log->index(i, 0, QModelIndex()), Qt::DisplayRole).toString() << QLatin1String("\r\n");
601 qWarning("Failed to open log file for writing:\n%s", logFilePath.toUtf8().constData());
608 * Shut down the computer (with countdown)
610 void MainWindow::shutdownComputer(void)
612 qDebug("shutdownComputer(void)");
614 if(countPendingJobs() > 0)
616 qDebug("Still have pending jobs, won't shutdown yet!");
620 const int iTimeout = 30;
621 const Qt::WindowFlags flags = Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowSystemMenuHint;
622 const QString text = QString("%1%2%1").arg(QString().fill(' ', 18), tr("Warning: Computer will shutdown in %1 seconds..."));
624 qWarning("Initiating shutdown sequence!");
626 QProgressDialog progressDialog(text.arg(iTimeout), tr("Cancel Shutdown"), 0, iTimeout + 1, this, flags);
627 QPushButton *cancelButton = new QPushButton(tr("Cancel Shutdown"), &progressDialog);
628 cancelButton->setIcon(QIcon(":/buttons/power_on.png"));
629 progressDialog.setModal(true);
630 progressDialog.setAutoClose(false);
631 progressDialog.setAutoReset(false);
632 progressDialog.setWindowIcon(QIcon(":/buttons/power_off.png"));
633 progressDialog.setWindowTitle(windowTitle());
634 progressDialog.setCancelButton(cancelButton);
635 progressDialog.show();
637 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
638 QApplication::setOverrideCursor(Qt::WaitCursor);
639 PlaySound(MAKEINTRESOURCE(IDR_WAVE1), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
640 QApplication::restoreOverrideCursor();
643 timer.setInterval(1000);
646 QEventLoop eventLoop(this);
647 connect(&timer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
648 connect(&progressDialog, SIGNAL(canceled()), &eventLoop, SLOT(quit()));
650 for(int i = 1; i <= iTimeout; i++)
653 if(progressDialog.wasCanceled())
655 progressDialog.close();
658 progressDialog.setValue(i+1);
659 progressDialog.setLabelText(text.arg(iTimeout-i));
660 if(iTimeout-i == 3) progressDialog.setCancelButton(NULL);
661 QApplication::processEvents();
662 PlaySound(MAKEINTRESOURCE((i < iTimeout) ? IDR_WAVE2 : IDR_WAVE3), GetModuleHandle(NULL), SND_RESOURCE | SND_SYNC);
665 qWarning("Shutting down !!!");
667 if(x264_shutdown_computer("Simple x264 Launcher: All jobs completed, shutting down!", 10, true))
669 qApp->closeAllWindows();
674 * Main initialization function (called only once!)
676 void MainWindow::init(void)
678 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";
679 QStringList binaries = QString::fromLatin1(binFiles).split(":", QString::SkipEmptyParts);
683 //Check for a running instance
684 bool firstInstance = false;
685 if(m_ipcThread->initialize(&firstInstance))
687 m_ipcThread->start();
690 if(!m_ipcThread->wait(5000))
692 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"));
693 m_ipcThread->terminate();
696 close(); qApp->exit(-1); return;
701 while(!binaries.isEmpty())
703 qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
704 QString current = binaries.takeFirst();
705 QFile *file = new QFile(QString("%1/toolset/%2").arg(m_appDir, current));
706 if(file->open(QIODevice::ReadOnly))
708 bool binaryTypeOkay = false;
710 if(GetBinaryType(QWCHAR(QDir::toNativeSeparators(file->fileName())), &binaryType))
712 binaryTypeOkay = (binaryType == SCS_32BIT_BINARY || binaryType == SCS_64BIT_BINARY);
716 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("-", "−"));
717 qFatal(QString("Binary is invalid: %1/toolset/%2").arg(m_appDir, current).toLatin1().constData());
718 close(); qApp->exit(-1); return;
725 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("-", "−"));
726 qFatal(QString("Binary not found: %1/toolset/%2").arg(m_appDir, current).toLatin1().constData());
727 close(); qApp->exit(-1); return;
731 //Check for portable mode
735 static const char *data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
736 QFile writeTest(QString("%1/%2").arg(x264_data_path(), QUuid::createUuid().toString()));
737 if(writeTest.open(QIODevice::WriteOnly))
739 ok = (writeTest.write(data) == strlen(data));
744 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"));
745 if(val != 1) { close(); qApp->exit(-1); return; }
750 if(x264_is_prerelease())
752 qsrand(time(NULL)); int rnd = qrand() % 3;
753 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);
754 if(rnd != val) { close(); qApp->exit(-1); return; }
757 //Make sure this CPU can run x264 (requires MMX + MMXEXT/iSSE to run x264 with ASM enabled, additionally requires SSE1 for most x264 builds)
758 if(!(m_cpuFeatures->mmx && m_cpuFeatures->mmx2))
760 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"));
761 qFatal("System does not support MMX and MMXEXT, x264 will not work !!!");
762 close(); qApp->exit(-1); return;
764 else if(!(m_cpuFeatures->mmx && m_cpuFeatures->sse))
766 qWarning("WARNING: System does not support SSE1, most x264 builds will not work !!!\n");
767 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"));
768 if(val != 1) { close(); qApp->exit(-1); return; }
771 //Skip version check (not recommended!)
772 if(qApp->arguments().contains("--skip-x264-version-check", Qt::CaseInsensitive))
774 qWarning("x264 version check disabled, you have been warned!\n");
775 m_skipVersionTest = true;
778 //Check for Avisynth support
779 if(!qApp->arguments().contains("--skip-avisynth-check", Qt::CaseInsensitive))
781 qDebug("[Check for Avisynth support]");
782 volatile double avisynthVersion = 0.0;
783 const int result = AvisynthCheckThread::detect(&avisynthVersion);
786 QString text = tr("A critical error was encountered while checking your Avisynth version.").append("<br>");
787 text += tr("This is most likely caused by an erroneous Avisynth Plugin, please try to clean your Plugins folder!").append("<br>");
788 text += tr("We suggest to move all .dll and .avsi files out of your Avisynth Plugins folder and try again.");
789 int val = QMessageBox::critical(this, tr("Avisynth Error"), QString("<nobr>%1</nobr>").arg(text).replace("-", "−"), tr("Quit"), tr("Ignore"));
790 if(val != 1) { close(); qApp->exit(-1); return; }
792 if((!result) || (avisynthVersion < 2.5))
794 int val = QMessageBox::warning(this, tr("Avisynth Missing"), tr("<nobr>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!<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"));
795 if(val != 1) { close(); qApp->exit(-1); return; }
800 //Check for Vapoursynth support
801 if(!qApp->arguments().contains("--skip-vapoursynth-check", Qt::CaseInsensitive))
803 qDebug("[Check for VapourSynth support]");
804 const QString vapursynthPath = getVapoursynthLocation();
805 if(!vapursynthPath.isEmpty())
808 QFile *vpsExePath = new QFile(QString("%1/core/vspipe.exe").arg(vapursynthPath));
809 QFile *vpsDllPath = new QFile(QString("%1/core/vapoursynth.dll").arg(vapursynthPath));
810 qDebug("VapourSynth EXE: %s", vpsExePath->fileName().toUtf8().constData());
811 qDebug("VapourSynth DLL: %s", vpsDllPath->fileName().toUtf8().constData());
812 if(vpsExePath->open(QIODevice::ReadOnly) && vpsDllPath->open(QIODevice::ReadOnly))
815 if(GetBinaryType(QWCHAR(QDir::toNativeSeparators(vpsExePath->fileName())), &binaryType))
817 okay = (binaryType == SCS_32BIT_BINARY || binaryType == SCS_64BIT_BINARY);
822 qDebug("VapourSynth support enabled.");
823 m_vapoursynthPath = QFileInfo(vpsExePath->fileName()).canonicalFilePath();
824 m_toolsList << vpsExePath;
825 m_toolsList << vpsDllPath;
829 qDebug("VapourSynth binaries not found -> disable Vapousynth support!");
830 X264_DELETE(vpsExePath);
831 X264_DELETE(vpsDllPath);
832 int val = QMessageBox::warning(this, tr("VapourSynth Missing"), tr("<nobr>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!<br><br>Please download and install VapourSynth (r19 or later) here:<br><a href=\"http://www.vapoursynth.com/\">http://www.vapoursynth.com/</a></nobr>").replace("-", "−"), tr("Quit"), tr("Ignore"));
833 if(val != 1) { close(); qApp->exit(-1); return; }
839 //Check for expiration
840 if(x264_version_date().addMonths(6) < QDate::currentDate())
842 QMessageBox msgBox(this);
843 msgBox.setIconPixmap(QIcon(":/images/update.png").pixmap(56,56));
844 msgBox.setWindowTitle(tr("Update Notification"));
845 msgBox.setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
846 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));
847 QPushButton *btn1 = msgBox.addButton(tr("Discard"), QMessageBox::NoRole);
848 QPushButton *btn2 = msgBox.addButton(tr("Discard"), QMessageBox::AcceptRole);
849 btn1->setEnabled(false);
850 btn2->setVisible(false);
851 QTimer::singleShot(5000, btn1, SLOT(hide()));
852 QTimer::singleShot(5000, btn2, SLOT(show()));
856 //Add files from command-line
857 bool bAddFile = false;
858 QStringList files, args = qApp->arguments();
859 while(!args.isEmpty())
861 QString current = args.takeFirst();
864 bAddFile = (current.compare("--add", Qt::CaseInsensitive) == 0);
867 if((!current.startsWith("--")) && QFileInfo(current).exists() && QFileInfo(current).isFile())
869 files << QFileInfo(current).canonicalFilePath();
872 if(files.count() > 0)
874 createJobMultiple(files);
877 //Enable drag&drop support for this window, required for Qt v4.8.4+
878 setAcceptDrops(true);
882 * Update the label position
884 void MainWindow::updateLabelPos(void)
886 const QWidget *const viewPort = jobsView->viewport();
887 m_label->setGeometry(0, 0, viewPort->width(), viewPort->height());
891 * Copy the complete log to the clipboard
893 void MainWindow::copyLogToClipboard(bool checked)
895 qDebug("copyLogToClipboard");
897 if(LogFileModel *log = dynamic_cast<LogFileModel*>(logView->model()))
899 log->copyToClipboard();
900 MessageBeep(MB_ICONINFORMATION);
905 * Process the dropped files
907 void MainWindow::handleDroppedFiles(void)
909 qDebug("MainWindow::handleDroppedFiles");
912 QStringList droppedFiles(*m_droppedFiles);
913 m_droppedFiles->clear();
914 createJobMultiple(droppedFiles);
916 qDebug("Leave from MainWindow::handleDroppedFiles!");
919 void MainWindow::instanceCreated(DWORD pid)
921 qDebug("Notification from other instance (PID=0x%X) received!", pid);
923 FLASHWINFO flashWinInfo;
924 memset(&flashWinInfo, 0, sizeof(FLASHWINFO));
925 flashWinInfo.cbSize = sizeof(FLASHWINFO);
926 flashWinInfo.hwnd = this->winId();
927 flashWinInfo.dwFlags = FLASHW_ALL;
928 flashWinInfo.dwTimeout = 125;
929 flashWinInfo.uCount = 5;
931 SwitchToThisWindow(this->winId(), TRUE);
932 SetForegroundWindow(this->winId());
933 qApp->processEvents();
934 FlashWindowEx(&flashWinInfo);
937 ///////////////////////////////////////////////////////////////////////////////
939 ///////////////////////////////////////////////////////////////////////////////
944 void MainWindow::showEvent(QShowEvent *e)
946 QMainWindow::showEvent(e);
951 QTimer::singleShot(0, this, SLOT(init()));
958 void MainWindow::closeEvent(QCloseEvent *e)
960 if(countRunningJobs() > 0)
963 QMessageBox::warning(this, tr("Jobs Are Running"), tr("Sorry, can not exit while there still are running jobs!"));
967 if(countPendingJobs() > 0)
969 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);
970 if(ret != QMessageBox::Yes)
977 while(m_jobList->rowCount(QModelIndex()) > 0)
979 qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
980 if(!m_jobList->deleteJob(m_jobList->index(0, 0, QModelIndex())))
983 QMessageBox::warning(this, tr("Failed To Exit"), tr("Sorry, at least one job could not be deleted!"));
988 qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
989 QMainWindow::closeEvent(e);
993 * Window resize event
995 void MainWindow::resizeEvent(QResizeEvent *e)
997 QMainWindow::resizeEvent(e);
1004 bool MainWindow::eventFilter(QObject *o, QEvent *e)
1006 if((o == labelBuildDate) && (e->type() == QEvent::MouseButtonPress))
1008 QTimer::singleShot(0, this, SLOT(showAbout()));
1015 * Win32 message filter
1017 bool MainWindow::winEvent(MSG *message, long *result)
1019 return WinSevenTaskbar::handleWinEvent(message, result);
1023 * File dragged over window
1025 void MainWindow::dragEnterEvent(QDragEnterEvent *event)
1027 bool accept[2] = {false, false};
1029 foreach(const QString &fmt, event->mimeData()->formats())
1031 accept[0] = accept[0] || fmt.contains("text/uri-list", Qt::CaseInsensitive);
1032 accept[1] = accept[1] || fmt.contains("FileNameW", Qt::CaseInsensitive);
1035 if(accept[0] && accept[1])
1037 event->acceptProposedAction();
1042 * File dropped onto window
1044 void MainWindow::dropEvent(QDropEvent *event)
1046 QStringList droppedFiles;
1047 QList<QUrl> urls = event->mimeData()->urls();
1049 while(!urls.isEmpty())
1051 QUrl currentUrl = urls.takeFirst();
1052 QFileInfo file(currentUrl.toLocalFile());
1053 if(file.exists() && file.isFile())
1055 qDebug("MainWindow::dropEvent: %s", file.canonicalFilePath().toUtf8().constData());
1056 droppedFiles << file.canonicalFilePath();
1060 if(droppedFiles.count() > 0)
1064 m_droppedFiles = new QStringList();
1066 m_droppedFiles->append(droppedFiles);
1067 m_droppedFiles->sort();
1068 QTimer::singleShot(0, this, SLOT(handleDroppedFiles()));
1072 ///////////////////////////////////////////////////////////////////////////////
1073 // Private functions
1074 ///////////////////////////////////////////////////////////////////////////////
1079 bool MainWindow::createJob(QString &sourceFileName, QString &outputFileName, OptionsModel *options, bool &runImmediately, const bool restart, int fileNo, int fileTotal, bool *applyToAll)
1082 AddJobDialog *addDialog = new AddJobDialog(this, options, m_recentlyUsed, m_cpuFeatures->x64, m_preferences->use10BitEncoding(), m_preferences->saveToSourcePath());
1084 addDialog->setRunImmediately(runImmediately);
1085 if(!sourceFileName.isEmpty()) addDialog->setSourceFile(sourceFileName);
1086 if(!outputFileName.isEmpty()) addDialog->setOutputFile(outputFileName);
1087 if(restart) addDialog->setWindowTitle(tr("Restart Job"));
1089 const bool multiFile = (fileNo >= 0) && (fileTotal > 1);
1092 addDialog->setSourceEditable(false);
1093 addDialog->setWindowTitle(addDialog->windowTitle().append(tr(" (File %1 of %2)").arg(QString::number(fileNo+1), QString::number(fileTotal))));
1094 addDialog->setApplyToAllVisible(applyToAll);
1097 if(addDialog->exec() == QDialog::Accepted)
1099 sourceFileName = addDialog->sourceFile();
1100 outputFileName = addDialog->outputFile();
1101 runImmediately = addDialog->runImmediately();
1104 *applyToAll = addDialog->applyToAll();
1109 X264_DELETE(addDialog);
1114 * Creates a new job from *multiple* files
1116 bool MainWindow::createJobMultiple(const QStringList &filePathIn)
1118 QStringList::ConstIterator iter;
1119 bool applyToAll = false, runImmediately = false;
1122 //Add files individually
1123 for(iter = filePathIn.constBegin(); (iter != filePathIn.constEnd()) && (!applyToAll); iter++)
1125 runImmediately = (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
1126 QString sourceFileName(*iter), outputFileName;
1127 if(createJob(sourceFileName, outputFileName, m_options, runImmediately, false, counter++, filePathIn.count(), &applyToAll))
1129 if(appendJob(sourceFileName, outputFileName, m_options, runImmediately))
1137 //Add remaining files
1138 while(applyToAll && (iter != filePathIn.constEnd()))
1140 const bool runImmediatelyTmp = runImmediately && (countRunningJobs() < (m_preferences->autoRunNextJob() ? m_preferences->maxRunningJobCount() : 1));
1141 const QString sourceFileName = *iter;
1142 const QString outputFileName = AddJobDialog::generateOutputFileName(sourceFileName, m_recentlyUsed->outputDirectory(), m_recentlyUsed->filterIndex(), m_preferences->saveToSourcePath());
1143 if(!appendJob(sourceFileName, outputFileName, m_options, runImmediatelyTmp))
1157 bool MainWindow::appendJob(const QString &sourceFileName, const QString &outputFileName, OptionsModel *options, const bool runImmediately)
1161 EncodeThread *thrd = new EncodeThread
1166 QString("%1/toolset").arg(m_appDir),
1168 m_preferences->use10BitEncoding(),
1169 m_cpuFeatures->x64 && m_preferences->useAvisyth64Bit(),
1171 m_preferences->processPriority()
1174 QModelIndex newIndex = m_jobList->insertJob(thrd);
1176 if(newIndex.isValid())
1180 jobsView->selectRow(newIndex.row());
1181 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
1182 m_jobList->startJob(newIndex);
1188 m_label->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
1193 * Jobs that are not completed (or failed, or aborted) yet
1195 unsigned int MainWindow::countPendingJobs(void)
1197 unsigned int count = 0;
1198 const int rows = m_jobList->rowCount(QModelIndex());
1200 for(int i = 0; i < rows; i++)
1202 JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
1203 if(status != JobStatus_Completed && status != JobStatus_Aborted && status != JobStatus_Failed)
1213 * Jobs that are still active, i.e. not terminated or enqueued
1215 unsigned int MainWindow::countRunningJobs(void)
1217 unsigned int count = 0;
1218 const int rows = m_jobList->rowCount(QModelIndex());
1220 for(int i = 0; i < rows; i++)
1222 JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
1223 if(status != JobStatus_Completed && status != JobStatus_Aborted && status != JobStatus_Failed && status != JobStatus_Enqueued)
1233 * Update all buttons with respect to current job status
1235 void MainWindow::updateButtons(JobStatus status)
1237 qDebug("MainWindow::updateButtons(void)");
1239 buttonStartJob->setEnabled(status == JobStatus_Enqueued);
1240 buttonAbortJob->setEnabled(status == JobStatus_Indexing || status == JobStatus_Running || status == JobStatus_Running_Pass1 || status == JobStatus_Running_Pass2 || status == JobStatus_Paused);
1241 buttonPauseJob->setEnabled(status == JobStatus_Indexing || status == JobStatus_Running || status == JobStatus_Paused || status == JobStatus_Running_Pass1 || status == JobStatus_Running_Pass2);
1242 buttonPauseJob->setChecked(status == JobStatus_Paused || status == JobStatus_Pausing);
1244 actionJob_Delete->setEnabled(status == JobStatus_Completed || status == JobStatus_Aborted || status == JobStatus_Failed || status == JobStatus_Enqueued);
1245 actionJob_Restart->setEnabled(status == JobStatus_Completed || status == JobStatus_Aborted || status == JobStatus_Failed || status == JobStatus_Enqueued);
1246 actionJob_Browse->setEnabled(status == JobStatus_Completed);
1248 actionJob_Start->setEnabled(buttonStartJob->isEnabled());
1249 actionJob_Abort->setEnabled(buttonAbortJob->isEnabled());
1250 actionJob_Pause->setEnabled(buttonPauseJob->isEnabled());
1251 actionJob_Pause->setChecked(buttonPauseJob->isChecked());
1253 editDetails->setEnabled(status != JobStatus_Paused);
1257 * Update the taskbar with current job status
1259 void MainWindow::updateTaskbar(JobStatus status, const QIcon &icon)
1261 qDebug("MainWindow::updateTaskbar(void)");
1265 case JobStatus_Undefined:
1266 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNoState);
1268 case JobStatus_Aborting:
1269 case JobStatus_Starting:
1270 case JobStatus_Pausing:
1271 case JobStatus_Resuming:
1272 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarIndeterminateState);
1274 case JobStatus_Aborted:
1275 case JobStatus_Failed:
1276 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarErrorState);
1278 case JobStatus_Paused:
1279 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarPausedState);
1282 WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState);
1288 case JobStatus_Aborting:
1289 case JobStatus_Starting:
1290 case JobStatus_Pausing:
1291 case JobStatus_Resuming:
1294 WinSevenTaskbar::setTaskbarProgress(this, progressBar->value(), progressBar->maximum());
1298 WinSevenTaskbar::setOverlayIcon(this, icon.isNull() ? NULL : &icon);
1302 * Read Vapursynth location from registry
1304 QString MainWindow::getVapoursynthLocation(void)
1306 QString vapoursynthPath;
1307 static const wchar_t *VPS_REG_KEY = L"SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VapourSynth_is1";
1309 if(RegOpenKey(HKEY_LOCAL_MACHINE, VPS_REG_KEY, &hKey) == ERROR_SUCCESS)
1311 const size_t DATA_LEN = 2048;
1312 wchar_t data[DATA_LEN];
1313 DWORD type = REG_NONE, size = sizeof(wchar_t) * DATA_LEN;
1314 if(RegQueryValueEx(hKey, L"InstallLocation", NULL, &type, ((BYTE*)&data[0]), &size) == ERROR_SUCCESS)
1316 if((type == REG_SZ) || (type == REG_EXPAND_SZ))
1318 vapoursynthPath = QDir::fromNativeSeparators(QString::fromUtf16((const ushort*)&data[0]));
1319 while(vapoursynthPath.endsWith("/")) { vapoursynthPath.chop(1); }
1320 qDebug("Vapoursynth location: %s", vapoursynthPath.toUtf8().constData());
1327 qDebug("Vapoursynth registry key not found -> not installed!");
1329 return vapoursynthPath;