1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2016 LoRd_MuldeR <MuldeR2@GMX.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
23 #include "UIC_win_help.h"
27 #include "model_options.h"
28 #include "model_sysinfo.h"
29 #include "model_preferences.h"
30 #include "encoder_factory.h"
31 #include "source_factory.h"
34 #include <MUtils/Sound.h>
41 ///////////////////////////////////////////////////////////////////////////////
42 // Constructor & Destructor
43 ///////////////////////////////////////////////////////////////////////////////
45 HelpDialog::HelpDialog(QWidget *parent, bool avs2yuv, const SysinfoModel *const sysinfo, const OptionsModel *const options, const PreferencesModel *const preferences)
50 m_preferences(preferences),
52 m_process(new QProcess()),
53 ui(new Ui::HelpDialog())
55 //Init the dialog, from the .ui file
57 setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
60 setMinimumSize(size());
63 m_process->setReadChannelMode(QProcess::MergedChannels);
64 m_process->setReadChannel(QProcess::StandardOutput);
65 connect(m_process, SIGNAL(readyRead()), this, SLOT(readyRead()));
66 connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished()));
71 HelpDialog::~HelpDialog(void)
77 ///////////////////////////////////////////////////////////////////////////////
79 ///////////////////////////////////////////////////////////////////////////////
81 void HelpDialog::showEvent(QShowEvent *event)
83 ui->logo_x264->setHidden(m_avs2yuv);
84 ui->logo_avisynth->setVisible(m_avs2yuv);
86 QDialog::showEvent(event);
92 m_process->start(EncoderFactory::getEncoderInfo(m_options->encType()).getBinaryPath(m_sysinfo, m_options->encArch(), m_options->encVariant()), QStringList() << "--version");
96 m_process->start(SourceFactory::getSourceInfo(SourceFactory::SourceType_AVS).getBinaryPath(m_sysinfo, m_preferences->getPrefer64BitSource() && m_sysinfo->getCPUFeatures(SysinfoModel::CPUFeatures_X64)), QStringList());
99 if(!m_process->waitForStarted())
101 ui->plainTextEdit->appendPlainText(tr("Failed to create x264 process :-("));
105 void HelpDialog::closeEvent(QCloseEvent *e)
107 if(m_process->state() != QProcess::NotRunning)
110 MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
114 QDialog::closeEvent(e);
117 ///////////////////////////////////////////////////////////////////////////////
119 ///////////////////////////////////////////////////////////////////////////////
121 void HelpDialog::readyRead(void)
123 while(m_process->canReadLine())
125 QString line = QString::fromLatin1(m_process->readLine());
126 while(line.endsWith('\r') || line.endsWith('\n'))
128 line = line.left(line.length() - 1);
130 ui->plainTextEdit->appendPlainText(line);
134 void HelpDialog::finished(void)
138 m_startAgain = false;
141 m_process->start(EncoderFactory::getEncoderInfo(m_options->encType()).getBinaryPath(m_sysinfo, m_options->encArch(), m_options->encVariant()), QStringList() << "--fullhelp");
142 ui->plainTextEdit->appendPlainText("\n--------\n");
144 if(!m_process->waitForStarted())
146 ui->plainTextEdit->appendPlainText(tr("Failed to create x264 process :-("));
152 ui->plainTextEdit->verticalScrollBar()->setSliderPosition(0);