1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2015 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"
29 #include "encoder_factory.h"
32 #include <MUtils/Sound.h>
39 ///////////////////////////////////////////////////////////////////////////////
40 // Constructor & Destructor
41 ///////////////////////////////////////////////////////////////////////////////
43 HelpDialog::HelpDialog(QWidget *parent, bool avs2yuv, const SysinfoModel *const sysinfo, const OptionsModel *const options, const PreferencesModel *const preferences)
48 m_preferences(preferences),
50 m_process(new QProcess()),
51 ui(new Ui::HelpDialog())
53 //Init the dialog, from the .ui file
55 setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
58 setMinimumSize(size());
61 m_process->setReadChannelMode(QProcess::MergedChannels);
62 m_process->setReadChannel(QProcess::StandardOutput);
63 connect(m_process, SIGNAL(readyRead()), this, SLOT(readyRead()));
64 connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished()));
69 HelpDialog::~HelpDialog(void)
75 ///////////////////////////////////////////////////////////////////////////////
77 ///////////////////////////////////////////////////////////////////////////////
79 void HelpDialog::showEvent(QShowEvent *event)
81 ui->logo_x264->setHidden(m_avs2yuv);
82 ui->logo_avisynth->setVisible(m_avs2yuv);
84 QDialog::showEvent(event);
90 m_process->start(EncoderFactory::getEncoderInfo(m_options->encType()).getBinaryPath(m_sysinfo, m_options->encArch(), m_options->encVariant()), QStringList() << "--version");
94 m_process->start(AVS_BINARY(m_sysinfo, m_preferences), QStringList());
97 if(!m_process->waitForStarted())
99 ui->plainTextEdit->appendPlainText(tr("Failed to create x264 process :-("));
103 void HelpDialog::closeEvent(QCloseEvent *e)
105 if(m_process->state() != QProcess::NotRunning)
108 MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
112 QDialog::closeEvent(e);
115 ///////////////////////////////////////////////////////////////////////////////
117 ///////////////////////////////////////////////////////////////////////////////
119 void HelpDialog::readyRead(void)
121 while(m_process->canReadLine())
123 QString line = QString::fromLatin1(m_process->readLine());
124 while(line.endsWith('\r') || line.endsWith('\n'))
126 line = line.left(line.length() - 1);
128 ui->plainTextEdit->appendPlainText(line);
132 void HelpDialog::finished(void)
136 m_startAgain = false;
139 m_process->start(EncoderFactory::getEncoderInfo(m_options->encType()).getBinaryPath(m_sysinfo, m_options->encArch(), m_options->encVariant()), QStringList() << "--fullhelp");
140 ui->plainTextEdit->appendPlainText("\n--------\n");
142 if(!m_process->waitForStarted())
144 ui->plainTextEdit->appendPlainText(tr("Failed to create x264 process :-("));
150 ui->plainTextEdit->verticalScrollBar()->setSliderPosition(0);