OSDN Git Service

Improved 32-Bit vs. 64-Bit selection code for Avisynth/VapourSynth source.
[x264-launcher/x264-launcher.git] / src / win_help.cpp
index 723b71d..d1c898a 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // Simple x264 Launcher
-// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2016 LoRd_MuldeR <MuldeR2@GMX.de>
 //
 // This program is free software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License as published by
 ///////////////////////////////////////////////////////////////////////////////
 
 #include "win_help.h"
+#include "UIC_win_help.h"
+
+//Internal
 #include "global.h"
+#include "model_options.h"
+#include "model_sysinfo.h"
+#include "model_preferences.h"
+#include "encoder_factory.h"
+#include "source_factory.h"
+
+//MUtils
+#include <MUtils/Sound.h>
 
+//Qt
 #include <QProcess>
 #include <QScrollBar>
 #include <QTimer>
 // Constructor & Destructor
 ///////////////////////////////////////////////////////////////////////////////
 
-HelpDialog::HelpDialog(QWidget *parent, bool avs2yuv, bool x64supported)
+HelpDialog::HelpDialog(QWidget *parent, bool avs2yuv, const SysinfoModel *const sysinfo, const OptionsModel *const options, const PreferencesModel *const preferences)
 :
        QDialog(parent),
-       m_appDir(QApplication::applicationDirPath()),
        m_avs2yuv(avs2yuv),
-       m_x64supported(x64supported),
-       m_process(new QProcess())
+       m_sysinfo(sysinfo),
+       m_preferences(preferences),
+       m_options(options),
+       m_process(new QProcess()),
+       ui(new Ui::HelpDialog())
 {
        //Init the dialog, from the .ui file
-       setupUi(this);
+       ui->setupUi(this);
        setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
 
        //Fix size
@@ -57,6 +71,7 @@ HelpDialog::HelpDialog(QWidget *parent, bool avs2yuv, bool x64supported)
 HelpDialog::~HelpDialog(void)
 {
        delete m_process;
+       delete ui;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -65,22 +80,25 @@ HelpDialog::~HelpDialog(void)
 
 void HelpDialog::showEvent(QShowEvent *event)
 {
+       ui->logo_x264->setHidden(m_avs2yuv);
+       ui->logo_avisynth->setVisible(m_avs2yuv);
+       
        QDialog::showEvent(event);
-
+       
        m_startAgain = true;
 
        if(!m_avs2yuv)
        {
-               m_process->start(QString("%1/toolset/%2.exe").arg(m_appDir, m_x64supported ? "x264_x64" : "x264"), QStringList() << "--version");
+               m_process->start(EncoderFactory::getEncoderInfo(m_options->encType()).getBinaryPath(m_sysinfo, m_options->encArch(), m_options->encVariant()), QStringList() << "--version");
        }
        else
        {
-               m_process->start(QString("%1/toolset/%2.exe").arg(m_appDir, m_x64supported ? "avs2yuv_x64" : "avs2yuv"), QStringList());
+               m_process->start(SourceFactory::getSourceInfo(SourceFactory::SourceType_AVS).getBinaryPath(m_sysinfo, m_preferences->getPrefer64BitSource() && m_sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64)), QStringList());
        }
 
        if(!m_process->waitForStarted())
        {
-               plainTextEdit->appendPlainText(tr("Failed to create x264 process :-("));
+               ui->plainTextEdit->appendPlainText(tr("Failed to create x264 process :-("));
        }
 }
 
@@ -89,7 +107,7 @@ void HelpDialog::closeEvent(QCloseEvent *e)
        if(m_process->state() != QProcess::NotRunning)
        {
                e->ignore();
-               MessageBeep(MB_ICONWARNING);
+               MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
                return;
        }
 
@@ -109,7 +127,7 @@ void HelpDialog::readyRead(void)
                {
                        line = line.left(line.length() - 1);
                }
-               plainTextEdit->appendPlainText(line);
+               ui->plainTextEdit->appendPlainText(line);
        }
 }
 
@@ -120,17 +138,17 @@ void HelpDialog::finished(void)
                m_startAgain = false;
                if(!m_avs2yuv)
                {
-                       m_process->start(QString("%1/toolset/x264.exe").arg(m_appDir), QStringList() << "--fullhelp");
-                       plainTextEdit->appendPlainText("\n--------\n");
+                       m_process->start(EncoderFactory::getEncoderInfo(m_options->encType()).getBinaryPath(m_sysinfo, m_options->encArch(), m_options->encVariant()), QStringList() << "--fullhelp");
+                       ui->plainTextEdit->appendPlainText("\n--------\n");
 
                        if(!m_process->waitForStarted())
                        {
-                               plainTextEdit->appendPlainText(tr("Failed to create x264 process :-("));
+                               ui->plainTextEdit->appendPlainText(tr("Failed to create x264 process :-("));
                        }
                }
        }
        else
        {
-               plainTextEdit->verticalScrollBar()->setSliderPosition(0);
+               ui->plainTextEdit->verticalScrollBar()->setSliderPosition(0);
        }
 }