2012-02-01 01:08:54 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Simple x264 Launcher
|
2017-01-07 18:48:20 +01:00
|
|
|
// Copyright (C) 2004-2017 LoRd_MuldeR <MuldeR2@GMX.de>
|
2012-02-01 01:08:54 +01:00
|
|
|
//
|
|
|
|
// 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
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
// http://www.gnu.org/licenses/gpl-2.0.txt
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "win_help.h"
|
2015-02-01 16:33:31 +01:00
|
|
|
#include "UIC_win_help.h"
|
2013-11-14 02:29:18 +01:00
|
|
|
|
2015-02-02 22:11:06 +01:00
|
|
|
//Internal
|
2012-02-01 01:08:54 +01:00
|
|
|
#include "global.h"
|
2014-02-11 02:33:17 +01:00
|
|
|
#include "model_options.h"
|
2015-08-02 21:16:36 +02:00
|
|
|
#include "model_sysinfo.h"
|
|
|
|
#include "model_preferences.h"
|
2015-08-02 19:16:37 +02:00
|
|
|
#include "encoder_factory.h"
|
2015-08-02 21:16:36 +02:00
|
|
|
#include "source_factory.h"
|
2012-02-01 01:08:54 +01:00
|
|
|
|
2015-02-02 22:11:06 +01:00
|
|
|
//MUtils
|
|
|
|
#include <MUtils/Sound.h>
|
|
|
|
|
|
|
|
//Qt
|
2012-02-01 01:08:54 +01:00
|
|
|
#include <QProcess>
|
|
|
|
#include <QScrollBar>
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Constructor & Destructor
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-02-12 21:36:10 +01:00
|
|
|
HelpDialog::HelpDialog(QWidget *parent, bool avs2yuv, const SysinfoModel *const sysinfo, const OptionsModel *const options, const PreferencesModel *const preferences)
|
2012-02-01 01:08:54 +01:00
|
|
|
:
|
|
|
|
QDialog(parent),
|
2012-02-12 15:58:28 +01:00
|
|
|
m_avs2yuv(avs2yuv),
|
2014-02-12 21:36:10 +01:00
|
|
|
m_sysinfo(sysinfo),
|
|
|
|
m_preferences(preferences),
|
2014-02-11 02:33:17 +01:00
|
|
|
m_options(options),
|
2013-11-14 02:29:18 +01:00
|
|
|
m_process(new QProcess()),
|
|
|
|
ui(new Ui::HelpDialog())
|
2012-02-01 01:08:54 +01:00
|
|
|
{
|
|
|
|
//Init the dialog, from the .ui file
|
2013-11-14 02:29:18 +01:00
|
|
|
ui->setupUi(this);
|
2012-02-01 01:08:54 +01:00
|
|
|
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
|
|
|
|
|
|
|
//Fix size
|
|
|
|
setMinimumSize(size());
|
|
|
|
|
|
|
|
//Prepare process
|
|
|
|
m_process->setReadChannelMode(QProcess::MergedChannels);
|
|
|
|
m_process->setReadChannel(QProcess::StandardOutput);
|
|
|
|
connect(m_process, SIGNAL(readyRead()), this, SLOT(readyRead()));
|
|
|
|
connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished()));
|
|
|
|
|
|
|
|
m_startAgain = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
HelpDialog::~HelpDialog(void)
|
|
|
|
{
|
|
|
|
delete m_process;
|
2013-11-14 02:29:18 +01:00
|
|
|
delete ui;
|
2012-02-01 01:08:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Events
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void HelpDialog::showEvent(QShowEvent *event)
|
|
|
|
{
|
2013-11-14 02:29:18 +01:00
|
|
|
ui->logo_x264->setHidden(m_avs2yuv);
|
|
|
|
ui->logo_avisynth->setVisible(m_avs2yuv);
|
2012-02-13 16:44:50 +01:00
|
|
|
|
2012-02-01 01:08:54 +01:00
|
|
|
QDialog::showEvent(event);
|
2012-02-13 16:44:50 +01:00
|
|
|
|
2012-02-01 01:08:54 +01:00
|
|
|
m_startAgain = true;
|
2012-02-12 15:58:28 +01:00
|
|
|
|
|
|
|
if(!m_avs2yuv)
|
|
|
|
{
|
2015-08-02 19:16:37 +02:00
|
|
|
m_process->start(EncoderFactory::getEncoderInfo(m_options->encType()).getBinaryPath(m_sysinfo, m_options->encArch(), m_options->encVariant()), QStringList() << "--version");
|
2012-02-12 15:58:28 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-08-02 21:16:36 +02:00
|
|
|
m_process->start(SourceFactory::getSourceInfo(SourceFactory::SourceType_AVS).getBinaryPath(m_sysinfo, m_preferences->getPrefer64BitSource() && m_sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64)), QStringList());
|
2012-02-12 15:58:28 +01:00
|
|
|
}
|
2012-02-01 01:08:54 +01:00
|
|
|
|
|
|
|
if(!m_process->waitForStarted())
|
|
|
|
{
|
2013-11-14 02:29:18 +01:00
|
|
|
ui->plainTextEdit->appendPlainText(tr("Failed to create x264 process :-("));
|
2012-02-01 01:08:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void HelpDialog::closeEvent(QCloseEvent *e)
|
|
|
|
{
|
|
|
|
if(m_process->state() != QProcess::NotRunning)
|
|
|
|
{
|
|
|
|
e->ignore();
|
2015-02-02 22:11:06 +01:00
|
|
|
MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
|
2012-02-01 01:08:54 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QDialog::closeEvent(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Slots
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void HelpDialog::readyRead(void)
|
|
|
|
{
|
|
|
|
while(m_process->canReadLine())
|
|
|
|
{
|
|
|
|
QString line = QString::fromLatin1(m_process->readLine());
|
|
|
|
while(line.endsWith('\r') || line.endsWith('\n'))
|
|
|
|
{
|
|
|
|
line = line.left(line.length() - 1);
|
|
|
|
}
|
2013-11-14 02:29:18 +01:00
|
|
|
ui->plainTextEdit->appendPlainText(line);
|
2012-02-01 01:08:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void HelpDialog::finished(void)
|
|
|
|
{
|
|
|
|
if(m_startAgain)
|
|
|
|
{
|
|
|
|
m_startAgain = false;
|
2012-02-12 15:58:28 +01:00
|
|
|
if(!m_avs2yuv)
|
2012-02-01 01:08:54 +01:00
|
|
|
{
|
2016-05-08 22:51:10 +02:00
|
|
|
const AbstractEncoderInfo &encInfo = EncoderFactory::getEncoderInfo(m_options->encType());
|
|
|
|
m_process->start(encInfo.getBinaryPath(m_sysinfo, m_options->encArch(), m_options->encVariant()), QStringList() << encInfo.getHelpCommand());
|
2013-11-14 02:29:18 +01:00
|
|
|
ui->plainTextEdit->appendPlainText("\n--------\n");
|
2012-02-12 15:58:28 +01:00
|
|
|
|
|
|
|
if(!m_process->waitForStarted())
|
|
|
|
{
|
2013-11-14 02:29:18 +01:00
|
|
|
ui->plainTextEdit->appendPlainText(tr("Failed to create x264 process :-("));
|
2012-02-12 15:58:28 +01:00
|
|
|
}
|
2012-02-01 01:08:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-14 02:29:18 +01:00
|
|
|
ui->plainTextEdit->verticalScrollBar()->setSliderPosition(0);
|
2012-02-01 01:08:54 +01:00
|
|
|
}
|
|
|
|
}
|