OSDN Git Service

Bump x264 minimum required version to API-#160 (r2999).
[x264-launcher/x264-launcher.git] / src / win_main.cpp
index 3cfa569..e2722d5 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Simple x264 Launcher
-// Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2020 LoRd_MuldeR <MuldeR2@GMX.de>
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
@@ -33,6 +33,7 @@
 #include "model_preferences.h"
 #include "model_recently.h"
 #include "thread_avisynth.h"
+#include "thread_binaries.h"
 #include "thread_vapoursynth.h"
 #include "thread_encode.h"
 #include "thread_ipc_recv.h"
@@ -41,7 +42,6 @@
 #include "win_about.h"
 #include "win_preferences.h"
 #include "win_updater.h"
-#include "binaries.h"
 #include "resource.h"
 
 //MUtils
@@ -70,7 +70,8 @@
 #include <QSettings>
 #include <QFileDialog>
 #include <QSystemTrayIcon>
-
+#include <QMovie>
+#include <QTextDocument>
 #include <ctime>
 
 //Constants
@@ -87,10 +88,9 @@ static const int   vsynth_rev = 24;
 #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) (QString("<a href=\"%1\">%1</a>").arg((URL)))
 #define INIT_ERROR_EXIT() do { close(); qApp->exit(-1); return; } while(0)
-#define NEXT(X) ((*reinterpret_cast<int*>(&(X)))++)
 #define SETUP_WEBLINK(OBJ, URL) do { (OBJ)->setData(QVariant(QUrl(URL))); connect((OBJ), SIGNAL(triggered()), this, SLOT(showWebLink())); } while(0)
 #define APP_IS_READY (m_initialized && (!m_fileTimer->isActive()) && (QApplication::activeModalWidget() == NULL))
-#define ENSURE_APP_IS_READY() do { if(!APP_IS_READY) {                 MUtils::Sound::beep(MUtils::Sound::BEEP_WRN); qWarning("Cannot perfrom this action at this time!"); return; } } while(0)
+#define ENSURE_APP_IS_READY() do { if(!APP_IS_READY) { MUtils::Sound::beep(MUtils::Sound::BEEP_WRN); qWarning("Cannot perfrom this action at this time!"); return; } } while(0)
 #define X264_STRCMP(X,Y) ((X).compare((Y), Qt::CaseInsensitive) == 0)
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -109,6 +109,7 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil
        m_pendingFiles(new QStringList()),
        m_preferences(NULL),
        m_recentlyUsed(NULL),
+       m_postOperation(POST_OP_DONOTHING),
        m_initialized(false),
        ui(new Ui::MainWindow())
 {
@@ -140,6 +141,9 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil
        m_options.reset(new OptionsModel(m_sysinfo.data()));
        OptionsModel::loadTemplate(m_options.data(), QString::fromLatin1(tpl_last));
 
+       //DPI scaling
+       MUtils::GUI::scale_widget(this);
+
        //Freeze minimum size
        setMinimumSize(size());
        ui->splitter->setSizes(QList<int>() << 16 << 196);
@@ -165,10 +169,9 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil
        //Setup view
        ui->jobsView->horizontalHeader()->setSectionHidden(3, true);
        ui->jobsView->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
-       ui->jobsView->horizontalHeader()->setResizeMode(1, QHeaderView::Fixed);
-       ui->jobsView->horizontalHeader()->setResizeMode(2, QHeaderView::Fixed);
-       ui->jobsView->horizontalHeader()->resizeSection(1, 150);
-       ui->jobsView->horizontalHeader()->resizeSection(2, 90);
+       ui->jobsView->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents);
+       ui->jobsView->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents);
+       ui->jobsView->horizontalHeader()->setMinimumSectionSize(96);
        ui->jobsView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
        connect(ui->jobsView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(jobSelected(QModelIndex, QModelIndex)));
 
@@ -186,9 +189,21 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil
 
        //Create context menu
        QAction *actionClipboard = new QAction(QIcon(":/buttons/page_paste.png"), tr("Copy to Clipboard"), ui->logView);
+       QAction *actionSaveToLog = new QAction(QIcon(":/buttons/disk.png"), tr("Save to File..."), ui->logView);
+       QAction *actionSeparator = new QAction(ui->logView);
+       QAction *actionWordwraps = new QAction(QIcon(":/buttons/text_wrapping.png"), tr("Enable Line-Wrapping"), ui->logView);
+       actionSeparator->setSeparator(true);
+       actionWordwraps->setCheckable(true);
        actionClipboard->setEnabled(false);
+       actionSaveToLog->setEnabled(false);
+       actionWordwraps->setEnabled(false);
        ui->logView->addAction(actionClipboard);
+       ui->logView->addAction(actionSaveToLog);
+       ui->logView->addAction(actionSeparator);
+       ui->logView->addAction(actionWordwraps);
        connect(actionClipboard, SIGNAL(triggered(bool)), this, SLOT(copyLogToClipboard(bool)));
+       connect(actionSaveToLog, SIGNAL(triggered(bool)), this, SLOT(saveLogToLocalFile(bool)));
+       connect(actionWordwraps, SIGNAL(triggered(bool)), this, SLOT(toggleLineWrapping(bool)));
        ui->jobsView->addActions(ui->menuJob->actions());
 
        //Enable buttons
@@ -203,29 +218,40 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil
        connect(ui->actionJob_MoveDown, SIGNAL(triggered()),   this, SLOT(moveButtonPressed()     ));
 
        //Enable menu
-       connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openActionTriggered()));
-       connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAbout()));
-       connect(ui->actionPreferences, SIGNAL(triggered()), this, SLOT(showPreferences()));
-       connect(ui->actionCheckForUpdates, SIGNAL(triggered()), this, SLOT(checkUpdates()));
+       connect(ui->actionOpen,             SIGNAL(triggered()), this, SLOT(openActionTriggered()));
+       connect(ui->actionCleanup_Finished, SIGNAL(triggered()), this, SLOT(cleanupActionTriggered()));
+       connect(ui->actionCleanup_Enqueued, SIGNAL(triggered()), this, SLOT(cleanupActionTriggered()));
+       connect(ui->actionPostOp_DoNothing, SIGNAL(triggered()), this, SLOT(postOpActionTriggered()));
+       connect(ui->actionPostOp_PowerDown, SIGNAL(triggered()), this, SLOT(postOpActionTriggered()));
+       connect(ui->actionPostOp_Hibernate, SIGNAL(triggered()), this, SLOT(postOpActionTriggered()));
+       connect(ui->actionAbout,            SIGNAL(triggered()), this, SLOT(showAbout()));
+       connect(ui->actionPreferences,      SIGNAL(triggered()), this, SLOT(showPreferences()));
+       connect(ui->actionCheckForUpdates,  SIGNAL(triggered()), this, SLOT(checkUpdates()));
+       ui->actionCleanup_Finished->setData(QVariant(bool(0)));
+       ui->actionCleanup_Enqueued->setData(QVariant(bool(1)));
+       ui->actionPostOp_DoNothing->setData(QVariant(POST_OP_DONOTHING));
+       ui->actionPostOp_PowerDown->setData(QVariant(POST_OP_POWERDOWN));
+       ui->actionPostOp_Hibernate->setData(QVariant(POST_OP_HIBERNATE));
+       ui->actionPostOp_Hibernate->setEnabled(MUtils::OS::is_hibernation_supported());
 
        //Setup web-links
        SETUP_WEBLINK(ui->actionWebMulder,          home_url);
        SETUP_WEBLINK(ui->actionWebX264,            "http://www.videolan.org/developers/x264.html");
        SETUP_WEBLINK(ui->actionWebX265,            "http://www.videolan.org/developers/x265.html");
-       SETUP_WEBLINK(ui->actionWebKomisar,         "http://komisar.gin.by/");
-       SETUP_WEBLINK(ui->actionWebVideoLAN,        "http://download.videolan.org/pub/x264/binaries/");
-       SETUP_WEBLINK(ui->actionWebJEEB,            "http://x264.fushizen.eu/");
-       SETUP_WEBLINK(ui->actionWebFreeCodecs,      "http://www.free-codecs.com/x264_video_codec_download.htm");
-       SETUP_WEBLINK(ui->actionWebX265BinRU,       "http://x265.ru/en/builds/");
-       SETUP_WEBLINK(ui->actionWebX265BinEU,       "http://builds.x265.eu/");
-       SETUP_WEBLINK(ui->actionWebX265BinORG,      "http://chromashift.org/x265_builds/");
-       SETUP_WEBLINK(ui->actionWebX265BinFF,       "http://ffmpeg.zeranoe.com/builds/");
-       SETUP_WEBLINK(ui->actionWebAvisynth32,      "http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/");
-       SETUP_WEBLINK(ui->actionWebAvisynth64,      "http://code.google.com/p/avisynth64/downloads/list");
+       SETUP_WEBLINK(ui->actionWebX264LigH,        "http://www.mediafire.com/?bxvu1vvld31k1");
+       SETUP_WEBLINK(ui->actionWebX264VideoLAN,    "http://artifacts.videolan.org/x264/");
+       SETUP_WEBLINK(ui->actionWebX264Komisar,     "http://komisar.gin.by/");
+       SETUP_WEBLINK(ui->actionWebX265LigH,        "http://www.mediafire.com/?6lfp2jlygogwa");
+       SETUP_WEBLINK(ui->actionWebX264FreeCodecs,  "http://www.free-codecs.com/x264_video_codec_download.htm");
+       SETUP_WEBLINK(ui->actionWebX265Fllear,      "http://x265.ru/en/builds/");
+       SETUP_WEBLINK(ui->actionWebX265Snowfag,     "http://builds.x265.eu/");
+       SETUP_WEBLINK(ui->actionWebX265FreeCodecs,  "http://www.free-codecs.com/x265_hevc_encoder_download.htm");
+       SETUP_WEBLINK(ui->actionWebAvisynth32,      "https://sourceforge.net/projects/avisynth2/files/AviSynth%202.6/");
+       SETUP_WEBLINK(ui->actionWebAvisynth64,      "http://forum.doom9.org/showthread.php?t=152800");
        SETUP_WEBLINK(ui->actionWebAvisynthPlus,    "http://www.avs-plus.net/");
        SETUP_WEBLINK(ui->actionWebVapourSynth,     "http://www.vapoursynth.com/");
        SETUP_WEBLINK(ui->actionWebVapourSynthDocs, "http://www.vapoursynth.com/doc/");
-       SETUP_WEBLINK(ui->actionOnlineDocX264,      "http://mewiki.project357.com/wiki/X264_Settings");
+       SETUP_WEBLINK(ui->actionOnlineDocX264,      "http://en.wikibooks.org/wiki/MeGUI/x264_Settings");                        //http://mewiki.project357.com/wiki/X264_Settings
        SETUP_WEBLINK(ui->actionOnlineDocX265,      "http://x265.readthedocs.org/en/default/");
        SETUP_WEBLINK(ui->actionWebBluRay,          "http://www.x264bluray.com/");
        SETUP_WEBLINK(ui->actionWebAvsWiki,         "http://avisynth.nl/index.php/Main_Page#Usage");
@@ -233,14 +259,28 @@ MainWindow::MainWindow(const MUtils::CPUFetaures::cpu_info_t &cpuFeatures, MUtil
        SETUP_WEBLINK(ui->actionWebSecret,          "http://www.youtube.com/watch_popup?v=AXIeHY-OYNI");
 
        //Create floating label
-       m_label.reset(new QLabel(ui->jobsView->viewport()));
-       m_label->setText(tr("No job created yet. Please click the 'Add New Job' button!"));
-       m_label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
-       SET_TEXT_COLOR(m_label, Qt::darkGray);
-       SET_FONT_BOLD(m_label, true);
-       m_label->setVisible(true);
-       m_label->setContextMenuPolicy(Qt::ActionsContextMenu);
-       m_label->addActions(ui->jobsView->actions());
+       m_label[0].reset(new QLabel(ui->jobsView->viewport()));
+       m_label[1].reset(new QLabel(ui->logView->viewport()));
+       if(!m_label[0].isNull())
+       {
+               m_label[0]->setText(tr("No job created yet. Please click the 'Add New Job' button!"));
+               m_label[0]->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
+               SET_TEXT_COLOR(m_label[0], Qt::darkGray);
+               SET_FONT_BOLD(m_label[0], true);
+               m_label[0]->setVisible(true);
+               m_label[0]->setContextMenuPolicy(Qt::ActionsContextMenu);
+               m_label[0]->addActions(ui->jobsView->actions());
+       }
+       if(!m_label[1].isNull())
+       {
+               m_animation.reset(new QMovie(":/images/spinner.gif"));
+               m_label[1]->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
+               if(!m_animation.isNull())
+               {
+                       m_label[1]->setMovie(m_animation.data());
+                       m_animation->start();
+               }
+       }
        connect(ui->splitter, SIGNAL(splitterMoved(int, int)), this, SLOT(updateLabelPos()));
        updateLabelPos();
 
@@ -277,12 +317,6 @@ MainWindow::~MainWindow(void)
 {
        OptionsModel::saveTemplate(m_options.data(), QString::fromLatin1(tpl_last));
        
-       while(!m_toolsList->isEmpty())
-       {
-               QFile *temp = m_toolsList->takeFirst();
-               MUTILS_DELETE(temp);
-       }
-
        if(!m_ipcThread.isNull())
        {
                m_ipcThread->stop();
@@ -323,6 +357,7 @@ void MainWindow::addButtonPressed()
 void MainWindow::openActionTriggered()
 {
        ENSURE_APP_IS_READY();
+       qWarning("openActionTriggered()");
 
        QStringList fileList = QFileDialog::getOpenFileNames(this, tr("Open Source File(s)"), m_recentlyUsed->sourceDirectory(), AddJobDialog::getInputFilterLst(), NULL, QFileDialog::DontUseNativeDialog);
        if(!fileList.empty())
@@ -345,6 +380,76 @@ void MainWindow::openActionTriggered()
 }
 
 /*
+* The "clean-up" action was invoked
+*/
+void MainWindow::cleanupActionTriggered(void)
+{
+       ENSURE_APP_IS_READY();
+
+       QAction *const sender = dynamic_cast<QAction*>(QObject::sender());
+       if (sender)
+       {
+               const QVariant data = sender->data();
+               if (data.isValid() && (data.type() == QVariant::Bool))
+               {
+                       const bool mode = data.toBool();
+                       const int rows = m_jobList->rowCount(QModelIndex());
+                       QList<int> jobIndices;
+                       for (int i = 0; i < rows; i++)
+                       {
+                               const JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
+                               if (mode && (status == JobStatus_Enqueued))
+                               {
+                                       jobIndices.append(i);
+                               }
+                               else if ((!mode) && ((status == JobStatus_Completed) || (status == JobStatus_Aborted) || (status == JobStatus_Failed)))
+                               {
+                                       jobIndices.append(i);
+                               }
+                       }
+                       if (!jobIndices.isEmpty())
+                       {
+                               QListIterator<int> iter(jobIndices);
+                               iter.toBack();
+                               while(iter.hasPrevious())
+                               {
+                                       m_jobList->deleteJob(m_jobList->index(iter.previous(), 0, QModelIndex()));
+                               }
+                       }
+                       else
+                       {
+                               MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
+                       }
+               }
+       }
+}
+
+/*
+* The "clean-up" action was invoked
+*/
+void MainWindow::postOpActionTriggered(void)
+{
+       ENSURE_APP_IS_READY();
+
+       QAction *const sender = dynamic_cast<QAction*>(QObject::sender());
+       if (sender)
+       {
+               const QVariant data = sender->data();
+               if (data.isValid() && (data.type() == QVariant::Int))
+               {
+                       const postOp_t mode = (postOp_t)data.toInt();
+                       if ((mode >= POST_OP_DONOTHING) && (mode <= POST_OP_HIBERNATE))
+                       {
+                               m_postOperation = mode;
+                               ui->actionPostOp_PowerDown->setChecked(mode == POST_OP_POWERDOWN);
+                               ui->actionPostOp_Hibernate->setChecked(mode == POST_OP_HIBERNATE);
+                               ui->actionPostOp_DoNothing->setChecked(mode == POST_OP_DONOTHING);
+                       }
+               }
+       }
+}
+
+/*
  * The "start" button was clicked
  */
 void MainWindow::startButtonPressed(void)
@@ -374,7 +479,7 @@ void MainWindow::deleteButtonPressed(void)
        ENSURE_APP_IS_READY();
 
        m_jobList->deleteJob(ui->jobsView->currentIndex());
-       m_label->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
+       m_label[0]->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
 }
 
 /*
@@ -488,7 +593,10 @@ void MainWindow::jobSelected(const QModelIndex & current, const QModelIndex & pr
        {
                ui->logView->setModel(m_jobList->getLogFile(current));
                connect(ui->logView->model(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(jobLogExtended(QModelIndex, int, int)));
-               ui->logView->actions().first()->setEnabled(true);
+               foreach(QAction *action, ui->logView->actions())
+               {
+                       action->setEnabled(true);
+               }
                QTimer::singleShot(0, ui->logView, SLOT(scrollToBottom()));
 
                ui->progressBar->setValue(m_jobList->getJobProgress(current));
@@ -499,7 +607,10 @@ void MainWindow::jobSelected(const QModelIndex & current, const QModelIndex & pr
        else
        {
                ui->logView->setModel(NULL);
-               ui->logView->actions().first()->setEnabled(false);
+               foreach(QAction *action, ui->logView->actions())
+               {
+                       action->setEnabled(false);
+               }
                ui->progressBar->setValue(0);
                ui->editDetails->clear();
                updateButtons(JobStatus_Undefined);
@@ -646,8 +757,9 @@ void MainWindow::launchNextJob(void)
                
        qWarning("No enqueued jobs left to be started!");
 
-       if(m_preferences->getShutdownComputer())
+       if(m_postOperation)
        {
+               qDebug("Post operation has been scheduled! (m_postOperation: %d)", m_postOperation);
                QTimer::singleShot(0, this, SLOT(shutdownComputer()));
        }
 }
@@ -659,27 +771,31 @@ void MainWindow::saveLogFile(const QModelIndex &index)
 {
        if(index.isValid())
        {
-               if(LogFileModel *log = m_jobList->getLogFile(index))
+               const LogFileModel *const logData = m_jobList->getLogFile(index);
+               const QString &outputFilePath = m_jobList->getJobOutputFile(index);
+               if(logData && (!outputFilePath.isEmpty()))
                {
-                       QDir(QString("%1/logs").arg(x264_data_path())).mkpath(".");
-                       QString logFilePath = QString("%1/logs/LOG.%2.%3.txt").arg(x264_data_path(), QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString(Qt::ISODate).replace(':', "-"));
-                       QFile outFile(logFilePath);
-                       if(outFile.open(QIODevice::WriteOnly))
+                       const QFileInfo outputFileInfo(outputFilePath);
+                       if (outputFileInfo.absoluteDir().exists())
                        {
-                               QTextStream outStream(&outFile);
-                               outStream.setCodec("UTF-8");
-                               outStream.setGenerateByteOrderMark(true);
-                               
-                               const int rows = log->rowCount(QModelIndex());
-                               for(int i = 0; i < rows; i++)
+                               const QString outputDir = outputFileInfo.absolutePath(), outputName = outputFileInfo.fileName();
+                               const QString logFilePath = MUtils::make_unique_file(outputDir, outputName, QLatin1String("log"), true);
+                               if (!logFilePath.isEmpty())
                                {
-                                       outStream << log->data(log->index(i, 0, QModelIndex()), Qt::DisplayRole).toString() << QLatin1String("\r\n");
+                                       qDebug("Saving log file to: \"%s\"", MUTILS_UTF8(logFilePath));
+                                       if (!logData->saveToLocalFile(logFilePath))
+                                       {
+                                               qWarning("Failed to open log file for writing:\n%s", logFilePath.toUtf8().constData());
+                                       }
+                               }
+                               else
+                               {
+                                       qWarning("Failed to generate log file name. Giving up!");
                                }
-                               outFile.close();
                        }
                        else
                        {
-                               qWarning("Failed to open log file for writing:\n%s", logFilePath.toUtf8().constData());
+                               qWarning("Output directory does not seem to exist. Giving up!");
                        }
                }
        }
@@ -691,16 +807,23 @@ void MainWindow::saveLogFile(const QModelIndex &index)
 void MainWindow::shutdownComputer(void)
 {
        ENSURE_APP_IS_READY();
+       qDebug("shutdownComputer (m_postOperation: %d)", m_postOperation);
 
        if(countPendingJobs() > 0)
        {
-               qDebug("Still have pending jobs, won't shutdown yet!");
+               qWarning("Still have pending jobs, won't shutdown yet!");
                return;
        }
 
+       if ((m_postOperation != POST_OP_POWERDOWN) && (m_postOperation != POST_OP_HIBERNATE))
+       {
+               qWarning("No post-operation has been schedule!");
+       }
+
        const int iTimeout = 30;
        const Qt::WindowFlags flags = Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowSystemMenuHint;
-       const QString text = QString("%1%2%1").arg(QString().fill(' ', 18), tr("Warning: Computer will shutdown in %1 seconds..."));
+       const bool hibernate = (m_postOperation == POST_OP_HIBERNATE);
+       const QString text = QString("%1%2%1").arg(QString().fill(' ', 18), hibernate ? tr("Warning: Computer will hibernate in %1 seconds...") : tr("Warning: Computer will shutdown in %1 seconds..."));
        
        qWarning("Initiating shutdown sequence!");
        
@@ -745,7 +868,7 @@ void MainWindow::shutdownComputer(void)
        
        qWarning("Shutting down !!!");
 
-       if(MUtils::OS::shutdown_computer("Simple x264 Launcher: All jobs completed, shutting down!", 10, true, false))
+       if(MUtils::OS::shutdown_computer("Simple x264 Launcher: All jobs completed, shutting down!", 10, true, hibernate))
        {
                qApp->closeAllWindows();
        }
@@ -765,59 +888,18 @@ void MainWindow::init(void)
 
        updateLabelPos();
        const MUtils::OS::ArgumentMap &arguments = MUtils::OS::arguments();
+       qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
 
        //---------------------------------------
        // Check required binaries
        //---------------------------------------
-
-       QStringList binFiles;
-       for(OptionsModel::EncArch arch = OptionsModel::EncArch_x32; arch <= OptionsModel::EncArch_x64; NEXT(arch))
-       {
-               for(OptionsModel::EncType encdr = OptionsModel::EncType_X264; encdr <= OptionsModel::EncType_X265; NEXT(encdr))
-               {
-                       for(OptionsModel::EncVariant varnt = OptionsModel::EncVariant_LoBit; varnt <= OptionsModel::EncVariant_HiBit; NEXT(varnt))
-                       {
-                               binFiles << ENC_BINARY(m_sysinfo.data(), encdr, arch, varnt);
-                       }
-               }
-               binFiles << AVS_BINARY(m_sysinfo.data(), arch == OptionsModel::EncArch_x64);
-       }
-       for(size_t i = 0; UpdaterDialog::BINARIES[i].name; i++)
-       {
-               if(UpdaterDialog::BINARIES[i].exec)
-               {
-                       binFiles << QString("%1/toolset/common/%2").arg(m_sysinfo->getAppPath(), QString::fromLatin1(UpdaterDialog::BINARIES[i].name));
-               }
-       }
                
        qDebug("[Validating binaries]");
-       for(QStringList::ConstIterator iter = binFiles.constBegin(); iter != binFiles.constEnd(); iter++)
+       QString failedPath;
+       if(!BinariesCheckThread::check(m_sysinfo.data(), &failedPath))
        {
-               qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
-               QFile *file = new QFile(*iter);
-               qDebug("%s", file->fileName().toLatin1().constData());
-               if(file->open(QIODevice::ReadOnly))
-               {
-                       if(!MUtils::OS::is_executable_file(file->fileName()))
-                       {
-                               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(file->fileName())).replace("-", "&minus;"));
-                               qFatal(QString("Binary is invalid: %1").arg(file->fileName()).toLatin1().constData());
-                               MUTILS_DELETE(file);
-                               INIT_ERROR_EXIT();
-                       }
-                       if(m_toolsList.isNull())
-                       {
-                               m_toolsList.reset(new QFileList());
-                       }
-                       m_toolsList->append(file);
-               }
-               else
-               {
-                       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(file->fileName())).replace("-", "&minus;"));
-                       qFatal(QString("Binary not found: %1/toolset/%2").arg(m_sysinfo->getAppPath(), file->fileName()).toLatin1().constData());
-                       MUTILS_DELETE(file);
-                       INIT_ERROR_EXIT();
-               }
+               QMessageBox::critical(this, tr("Invalid File!"), tr("<nobr>At least one tool is missing or is not a valid Win32/Win64 binary:</nobr><br><tt>%1</tt><br><br><nobr>Please re-install the program in order to fix the problem!</nobr>").replace("-", "&minus;").arg(Qt::escape(QDir::toNativeSeparators(failedPath))));
+               qFatal("At least one tool is missing or is not a valid Win32/Win64 binary. Program will exit now!");
        }
        qDebug(" ");
        
@@ -850,6 +932,8 @@ void MainWindow::init(void)
                if(rnd != val) INIT_ERROR_EXIT();
        }
 
+       qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+
        //---------------------------------------
        // Check CPU capabilities
        //---------------------------------------
@@ -882,6 +966,8 @@ void MainWindow::init(void)
                m_preferences->setAbortOnTimeout(false);
        }
 
+       qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
+
        //---------------------------------------
        // Check Avisynth support
        //---------------------------------------
@@ -889,9 +975,7 @@ void MainWindow::init(void)
        if(!arguments.contains(CLI_PARAM_SKIP_AVS_CHECK))
        {
                qDebug("[Check for Avisynth support]");
-               volatile double avisynthVersion = 0.0;
-               const int result = AvisynthCheckThread::detect(&avisynthVersion);
-               if(result < 0)
+               if(!AvisynthCheckThread::detect(m_sysinfo.data()))
                {
                        QString text = tr("A critical error was encountered while checking your Avisynth version.").append("<br>");
                        text += tr("This is most likely caused by an erroneous Avisynth Plugin, please try to clean your Plugins folder!").append("<br>");
@@ -899,25 +983,15 @@ void MainWindow::init(void)
                        int val = QMessageBox::critical(this, tr("Avisynth Error"), QString("<nobr>%1</nobr>").arg(text).replace("-", "&minus;"), tr("Quit"), tr("Ignore"));
                        if(val != 1) INIT_ERROR_EXIT();
                }
-               if(result && (avisynthVersion >= 2.5))
-               {
-                       qDebug("Avisynth support is officially enabled now!");
-                       m_sysinfo->setAvisynth(SysinfoModel::Avisynth_X86, true);
-                       m_sysinfo->setAvisynth(SysinfoModel::Avisynth_X64, true);
-               }
-               else
+               else if((!m_sysinfo->hasAvisynth()) && (!m_preferences->getDisableWarnings()))
                {
-                       if(!m_preferences->getDisableWarnings())
+                       QString text = tr("It appears that Avisynth is <b>not</b> currently installed on your computer.<br>Therefore Avisynth (.avs) input will <b>not</b> be working at all!").append("<br><br>");
+                       text += tr("Please download and install Avisynth:").append("<br>").append(LINK(avs_dl_url));
+                       int val = QMessageBox::warning(this, tr("Avisynth Missing"), QString("<nobr>%1</nobr>").arg(text).replace("-", "&minus;"), tr("Close"), tr("Disable this Warning"));
+                       if(val == 1)
                        {
-                               QString text = tr("It appears that Avisynth is <b>not</b> currently installed on your computer.<br>Therefore Avisynth (.avs) input will <b>not</b> be working at all!").append("<br><br>");
-                               text += tr("Please download and install Avisynth:").append("<br>").append(LINK(avs_dl_url));
-                               int val = QMessageBox::warning(this, tr("Avisynth Missing"), QString("<nobr>%1</nobr>").arg(text).replace("-", "&minus;"), tr("Close"), tr("Disable this Warning"));
-                               if(val == 1)
-                               {
-                                       m_preferences->setDisableWarnings(true);
-                                       PreferencesModel::savePreferences(m_preferences.data());
-                               }
-
+                               m_preferences->setDisableWarnings(true);
+                               PreferencesModel::savePreferences(m_preferences.data());
                        }
                }
                qDebug(" ");
@@ -930,10 +1004,7 @@ void MainWindow::init(void)
        if(!arguments.contains(CLI_PARAM_SKIP_VPS_CHECK))
        {
                qDebug("[Check for VapourSynth support]");
-               VapourSynthCheckThread::VapourSynthType vapoursynthType;
-               QString vapoursynthPath;
-               const int result = VapourSynthCheckThread::detect(vapoursynthPath, vapoursynthType);
-               if(result < 0)
+               if(!VapourSynthCheckThread::detect(m_sysinfo.data()))
                {
                        QString text = tr("A critical error was encountered while checking your VapourSynth installation.").append("<br>");
                        text += tr("This is most likely caused by an erroneous VapourSynth Plugin, please try to clean your Filters folder!").append("<br>");
@@ -941,32 +1012,33 @@ void MainWindow::init(void)
                        const int val = QMessageBox::critical(this, tr("VapourSynth Error"), QString("<nobr>%1</nobr>").arg(text).replace("-", "&minus;"), tr("Quit"), tr("Ignore"));
                        if(val != 1) INIT_ERROR_EXIT();
                }
-               if(result && (!!vapoursynthType) && (!vapoursynthPath.isEmpty()))
+               else if((!m_sysinfo->hasVapourSynth()) && (!m_preferences->getDisableWarnings()))
                {
-                       qDebug("VapourSynth support is officially enabled now!");
-                       m_sysinfo->setVapourSynth(SysinfoModel::VapourSynth_X86, (vapoursynthType.testFlag(VapourSynthCheckThread::VAPOURSYNTH_X86)));
-                       m_sysinfo->setVapourSynth(SysinfoModel::VapourSynth_X64, (vapoursynthType.testFlag(VapourSynthCheckThread::VAPOURSYNTH_X64)));
-                       m_sysinfo->setVPSPath(vapoursynthPath);
-               }
-               else
-               {
-                       if(!m_preferences->getDisableWarnings())
+                       QString text = tr("It appears that VapourSynth is <b>not</b> currently installed on your computer.<br>Therefore VapourSynth (.vpy) input will <b>not</b> be working at all!").append("<br><br>");
+                       text += tr("Please download and install VapourSynth (<b>r%1</b> or later) for Windows:").arg(QString::number(vsynth_rev)).append("<br>").append(LINK(vsynth_url)).append("<br><br>");
+                       text += tr("Note that Python v3.4 is a prerequisite for installing VapourSynth:").append("<br>").append(LINK(python_url)).append("<br>");
+                       const int val = QMessageBox::warning(this, tr("VapourSynth Missing"), QString("<nobr>%1</nobr>").arg(text).replace("-", "&minus;"), tr("Close"), tr("Disable this Warning"));
+                       if(val == 1)
                        {
-                               QString text = tr("It appears that VapourSynth is <b>not</b> currently installed on your computer.<br>Therefore VapourSynth (.vpy) input will <b>not</b> be working at all!").append("<br><br>");
-                               text += tr("Please download and install VapourSynth (<b>r%1</b> or later) for Windows:").arg(QString::number(vsynth_rev)).append("<br>").append(LINK(vsynth_url)).append("<br><br>");
-                               text += tr("Note that Python v3.4 is a prerequisite for installing VapourSynth:").append("<br>").append(LINK(python_url)).append("<br>");
-                               const int val = QMessageBox::warning(this, tr("VapourSynth Missing"), QString("<nobr>%1</nobr>").arg(text).replace("-", "&minus;"), tr("Close"), tr("Disable this Warning"));
-                               if(val == 1)
-                               {
-                                       m_preferences->setDisableWarnings(true);
-                                       PreferencesModel::savePreferences(m_preferences.data());
-                               }
+                               m_preferences->setDisableWarnings(true);
+                               PreferencesModel::savePreferences(m_preferences.data());
                        }
                }
                qDebug(" ");
        }
        
        //---------------------------------------
+       // Create the IPC listener thread
+       //---------------------------------------
+
+       if(m_ipcChannel)
+       {
+               m_ipcThread.reset(new IPCThread_Recv(m_ipcChannel));
+               connect(m_ipcThread.data(), SIGNAL(receivedCommand(int,QStringList,quint32)), this, SLOT(handleCommand(int,QStringList,quint32)), Qt::QueuedConnection);
+               m_ipcThread->start();
+       }
+
+       //---------------------------------------
        // Finish initialization
        //---------------------------------------
 
@@ -979,6 +1051,16 @@ void MainWindow::init(void)
        //Update flag
        m_initialized = true;
 
+       //Hide the spinner animation
+       if(!m_label[1].isNull())
+       {
+               if(!m_animation.isNull())
+               {
+                       m_animation->stop();
+               }
+               m_label[1]->setVisible(false);
+       }
+
        //---------------------------------------
        // Check for Expiration
        //---------------------------------------
@@ -1031,21 +1113,10 @@ void MainWindow::init(void)
                }
        }
 
-       //---------------------------------------
-       // Create the IPC listener thread
-       //---------------------------------------
-
-       if(m_ipcChannel)
-       {
-               m_ipcThread.reset(new IPCThread_Recv(m_ipcChannel));
-               connect(m_ipcThread.data(), SIGNAL(receivedCommand(int,QStringList,quint32)), this, SLOT(handleCommand(int,QStringList,quint32)), Qt::QueuedConnection);
-               m_ipcThread->start();
-       }
-
        //Load queued jobs
        if(m_jobList->loadQueuedJobs(m_sysinfo.data()) > 0)
        {
-               m_label->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
+               m_label[0]->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
                m_jobList->clearQueuedJobs();
        }
 }
@@ -1055,8 +1126,15 @@ void MainWindow::init(void)
  */
 void MainWindow::updateLabelPos(void)
 {
-       const QWidget *const viewPort = ui->jobsView->viewport();
-       m_label->setGeometry(0, 0, viewPort->width(), viewPort->height());
+       for(int i = 0; i < 2; i++)
+       {
+               //const QWidget *const viewPort = ui->jobsView->viewport();
+               const QWidget *const viewPort = dynamic_cast<QWidget*>(m_label[i]->parent());
+               if(viewPort)
+               {
+                       m_label[i]->setGeometry(0, 0, viewPort->width(), viewPort->height());
+               }
+       }
 }
 
 /*
@@ -1074,6 +1152,36 @@ void MainWindow::copyLogToClipboard(bool checked)
 }
 
 /*
+ * Save log to local file
+ */
+void MainWindow::saveLogToLocalFile(bool checked)
+{
+       ENSURE_APP_IS_READY();
+
+       const QModelIndex index = ui->jobsView->currentIndex();
+       const QString initialName = index.isValid() ? QFileInfo(m_jobList->getJobOutputFile(index)).completeBaseName() : tr("Logfile");
+       const QString fileName = QFileDialog::getSaveFileName(this, tr("Save Log File"), initialName, tr("Log File (*.log)"));
+       if(!fileName.isEmpty())
+       {
+               if(LogFileModel *log = dynamic_cast<LogFileModel*>(ui->logView->model()))
+               {
+                       if(!log->saveToLocalFile(fileName))
+                       {
+                               QMessageBox::warning(this, this->windowTitle(), tr("Error: Log file could not be saved!"));
+                       }
+               }
+       }
+}
+
+/*
+ * Toggle line-wrapping
+ */
+void MainWindow::toggleLineWrapping(bool checked)
+{
+       ui->logView->setWordWrap(checked);
+}
+
+/*
  * Process the dropped files
  */
 void MainWindow::handlePendingFiles(void)
@@ -1291,18 +1399,22 @@ void MainWindow::closeEvent(QCloseEvent *e)
        //Save pending jobs for next time, if desired by user
        if(countPendingJobs() > 0)
        {
-               int ret = QMessageBox::question(this, tr("Jobs Are Pending"), tr("You still have pending jobs. How do you want to proceed?"), tr("Save Pending Jobs"), tr("Discard"));
-               if(ret == 0)
+               if (!m_preferences->getSaveQueueNoConfirm())
                {
-                       m_jobList->saveQueuedJobs();
+                       const int ret = QMessageBox::question(this, tr("Jobs Are Pending"), tr("<nobr>You still have some pending jobs in your queue. How do you want to proceed?</nobr>"), tr("Save Jobs"), tr("Always Save Jobs"), tr("Discard Jobs"));
+                       if ((ret >= 0) && (ret <= 1))
+                       {
+                               if (ret > 0)
+                               {
+                                       m_preferences->setSaveQueueNoConfirm(true);
+                                       PreferencesModel::savePreferences(m_preferences.data());
+                               }
+                               m_jobList->saveQueuedJobs();
+                       }
                }
                else
                {
-                       if(QMessageBox::warning(this, tr("Jobs Are Pending"), tr("Do you really want to discard all pending jobs?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes)
-                       {
-                               e->ignore();
-                               return;
-                       }
+                       m_jobList->saveQueuedJobs();
                }
        }
        
@@ -1491,7 +1603,7 @@ bool MainWindow::appendJob(const QString &sourceFileName, const QString &outputF
                okay = true;
        }
 
-       m_label->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
+       m_label[0]->setVisible(m_jobList->rowCount(QModelIndex()) == 0);
        return okay;
 }