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"
26 #include "model_options.h"
33 ///////////////////////////////////////////////////////////////////////////////
34 // Constructor & Destructor
35 ///////////////////////////////////////////////////////////////////////////////
37 HelpDialog::HelpDialog(QWidget *parent, bool avs2yuv, const SysinfoModel *const sysinfo, const OptionsModel *const options, const PreferencesModel *const preferences)
42 m_preferences(preferences),
44 m_process(new QProcess()),
45 ui(new Ui::HelpDialog())
47 //Init the dialog, from the .ui file
49 setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
52 setMinimumSize(size());
55 m_process->setReadChannelMode(QProcess::MergedChannels);
56 m_process->setReadChannel(QProcess::StandardOutput);
57 connect(m_process, SIGNAL(readyRead()), this, SLOT(readyRead()));
58 connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished()));
63 HelpDialog::~HelpDialog(void)
69 ///////////////////////////////////////////////////////////////////////////////
71 ///////////////////////////////////////////////////////////////////////////////
73 void HelpDialog::showEvent(QShowEvent *event)
75 ui->logo_x264->setHidden(m_avs2yuv);
76 ui->logo_avisynth->setVisible(m_avs2yuv);
78 QDialog::showEvent(event);
84 m_process->start(ENC_BINARY(m_sysinfo, m_options), QStringList() << "--version");
88 m_process->start(AVS_BINARY(m_sysinfo, m_preferences), QStringList());
91 if(!m_process->waitForStarted())
93 ui->plainTextEdit->appendPlainText(tr("Failed to create x264 process :-("));
97 void HelpDialog::closeEvent(QCloseEvent *e)
99 if(m_process->state() != QProcess::NotRunning)
102 x264_beep(x264_beep_warning);
106 QDialog::closeEvent(e);
109 ///////////////////////////////////////////////////////////////////////////////
111 ///////////////////////////////////////////////////////////////////////////////
113 void HelpDialog::readyRead(void)
115 while(m_process->canReadLine())
117 QString line = QString::fromLatin1(m_process->readLine());
118 while(line.endsWith('\r') || line.endsWith('\n'))
120 line = line.left(line.length() - 1);
122 ui->plainTextEdit->appendPlainText(line);
126 void HelpDialog::finished(void)
130 m_startAgain = false;
133 m_process->start(ENC_BINARY(m_sysinfo, m_options), QStringList() << "--fullhelp");
134 ui->plainTextEdit->appendPlainText("\n--------\n");
136 if(!m_process->waitForStarted())
138 ui->plainTextEdit->appendPlainText(tr("Failed to create x264 process :-("));
144 ui->plainTextEdit->verticalScrollBar()->setSliderPosition(0);