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"
31 #include <MUtils/Sound.h>
38 ///////////////////////////////////////////////////////////////////////////////
39 // Constructor & Destructor
40 ///////////////////////////////////////////////////////////////////////////////
42 HelpDialog::HelpDialog(QWidget *parent, bool avs2yuv, const SysinfoModel *const sysinfo, const OptionsModel *const options, const PreferencesModel *const preferences)
47 m_preferences(preferences),
49 m_process(new QProcess()),
50 ui(new Ui::HelpDialog())
52 //Init the dialog, from the .ui file
54 setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
57 setMinimumSize(size());
60 m_process->setReadChannelMode(QProcess::MergedChannels);
61 m_process->setReadChannel(QProcess::StandardOutput);
62 connect(m_process, SIGNAL(readyRead()), this, SLOT(readyRead()));
63 connect(m_process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finished()));
68 HelpDialog::~HelpDialog(void)
74 ///////////////////////////////////////////////////////////////////////////////
76 ///////////////////////////////////////////////////////////////////////////////
78 void HelpDialog::showEvent(QShowEvent *event)
80 ui->logo_x264->setHidden(m_avs2yuv);
81 ui->logo_avisynth->setVisible(m_avs2yuv);
83 QDialog::showEvent(event);
89 m_process->start(ENC_BINARY(m_sysinfo, m_options), QStringList() << "--version");
93 m_process->start(AVS_BINARY(m_sysinfo, m_preferences), QStringList());
96 if(!m_process->waitForStarted())
98 ui->plainTextEdit->appendPlainText(tr("Failed to create x264 process :-("));
102 void HelpDialog::closeEvent(QCloseEvent *e)
104 if(m_process->state() != QProcess::NotRunning)
107 MUtils::Sound::beep(MUtils::Sound::BEEP_WRN);
111 QDialog::closeEvent(e);
114 ///////////////////////////////////////////////////////////////////////////////
116 ///////////////////////////////////////////////////////////////////////////////
118 void HelpDialog::readyRead(void)
120 while(m_process->canReadLine())
122 QString line = QString::fromLatin1(m_process->readLine());
123 while(line.endsWith('\r') || line.endsWith('\n'))
125 line = line.left(line.length() - 1);
127 ui->plainTextEdit->appendPlainText(line);
131 void HelpDialog::finished(void)
135 m_startAgain = false;
138 m_process->start(ENC_BINARY(m_sysinfo, m_options), QStringList() << "--fullhelp");
139 ui->plainTextEdit->appendPlainText("\n--------\n");
141 if(!m_process->waitForStarted())
143 ui->plainTextEdit->appendPlainText(tr("Failed to create x264 process :-("));
149 ui->plainTextEdit->verticalScrollBar()->setSliderPosition(0);