Make "Add Job" dialog work + added some useful web-links.

This commit is contained in:
LoRd_MuldeR 2012-01-29 15:57:23 +01:00
parent aec0c927d7
commit 7a485a73f8
13 changed files with 346 additions and 28 deletions

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>560</width>
<height>498</height>
<height>494</height>
</rect>
</property>
<property name="windowTitle">
@ -411,7 +411,7 @@
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_3">
<widget class="QComboBox" name="cbxTuning">
<property name="currentIndex">
<number>0</number>
</property>
@ -495,7 +495,7 @@
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_2">
<widget class="QComboBox" name="cbxProfile">
<property name="currentIndex">
<number>0</number>
</property>
@ -545,7 +545,7 @@
</sizepolicy>
</property>
<property name="title">
<string>Advanced Options </string>
<string>Advanced Encoder Options </string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
@ -590,6 +590,51 @@
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>120</red>
<green>120</green>
<blue>120</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="font">
<font>
<underline>true</underline>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="text">
<string>Show Help Screen</string>
</property>
@ -598,7 +643,11 @@
</layout>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_3"/>
<widget class="QComboBox" name="cbxCustomParams">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
@ -630,6 +679,16 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="checkBoxRun">
<property name="text">
<string>Start Job Immediately</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -692,9 +751,8 @@
<tabstop>spinQuantizer</tabstop>
<tabstop>spinBitrate</tabstop>
<tabstop>cbxPreset</tabstop>
<tabstop>comboBox_3</tabstop>
<tabstop>comboBox_2</tabstop>
<tabstop>lineEdit_3</tabstop>
<tabstop>cbxTuning</tabstop>
<tabstop>cbxProfile</tabstop>
</tabstops>
<resources>
<include location="../res/resources.qrc"/>

View File

@ -223,6 +223,12 @@
<property name="title">
<string>?</string>
</property>
<addaction name="actionWebMulder"/>
<addaction name="actionWebX264"/>
<addaction name="actionWebKomisar"/>
<addaction name="actionWebJarod"/>
<addaction name="actionWebWiki"/>
<addaction name="separator"/>
<addaction name="actionAbout"/>
</widget>
<addaction name="menuFile"/>
@ -243,7 +249,52 @@
<normaloff>:/buttons/information.png</normaloff>:/buttons/information.png</iconset>
</property>
<property name="text">
<string>About</string>
<string>About...</string>
</property>
</action>
<action name="actionWebMulder">
<property name="icon">
<iconset resource="../res/resources.qrc">
<normaloff>:/buttons/world_link.png</normaloff>:/buttons/world_link.png</iconset>
</property>
<property name="text">
<string>MuldeR's Web-Site</string>
</property>
</action>
<action name="actionWebX264">
<property name="icon">
<iconset resource="../res/resources.qrc">
<normaloff>:/buttons/world_link.png</normaloff>:/buttons/world_link.png</iconset>
</property>
<property name="text">
<string>Official x264 Web-Site</string>
</property>
</action>
<action name="actionWebKomisar">
<property name="icon">
<iconset resource="../res/resources.qrc">
<normaloff>:/buttons/world_link.png</normaloff>:/buttons/world_link.png</iconset>
</property>
<property name="text">
<string>Komisar's Web-Site</string>
</property>
</action>
<action name="actionWebJarod">
<property name="icon">
<iconset resource="../res/resources.qrc">
<normaloff>:/buttons/world_link.png</normaloff>:/buttons/world_link.png</iconset>
</property>
<property name="text">
<string>Jarod's Web-Site</string>
</property>
</action>
<action name="actionWebWiki">
<property name="icon">
<iconset resource="../res/resources.qrc">
<normaloff>:/buttons/book_open.png</normaloff>:/buttons/book_open.png</iconset>
</property>
<property name="text">
<string>MeWiki - x264 Settings</string>
</property>
</action>
</widget>

BIN
res/buttons/book_open.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 B

BIN
res/buttons/world_link.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 957 B

View File

@ -4,6 +4,7 @@
<file>icons/movie.ico</file>
<file>buttons/accept.png</file>
<file>buttons/add.png</file>
<file>buttons/book_open.png</file>
<file>buttons/cancel.png</file>
<file>buttons/clock_pause.png</file>
<file>buttons/clock_stop.png</file>
@ -15,5 +16,6 @@
<file>buttons/lightning.png</file>
<file>buttons/play.png</file>
<file>buttons/play_big.png</file>
<file>buttons/world_link.png</file>
</qresource>
</RCC>

View File

@ -24,6 +24,7 @@
#include "thread_encode.h"
#include <QIcon>
#include <QFileInfo>
JobListModel::JobListModel(void)
{
@ -101,7 +102,7 @@ QVariant JobListModel::data(const QModelIndex &index, int role) const
switch(index.column())
{
case 0:
return m_jobs.at(index.row()).toString();
return m_name.value(m_jobs.at(index.row()));
break;
case 1:
switch(m_status.value(m_jobs.at(index.row())))
@ -211,6 +212,7 @@ QModelIndex JobListModel::insertJob(EncodeThread *thread)
beginInsertRows(QModelIndex(), m_jobs.count(), m_jobs.count());
m_jobs.append(id);
m_name.insert(id, QFileInfo(thread->sourceFileName()).completeBaseName());
m_status.insert(id, EncodeThread::JobStatus_Enqueued);
m_progress.insert(id, 0);
m_threads.insert(id, thread);

View File

@ -54,6 +54,7 @@ public:
protected:
QList<QUuid> m_jobs;
QMap<QUuid, QString> m_name;
QMap<QUuid, EncodeThread*> m_threads;
QMap<QUuid, EncodeThread::JobStatus> m_status;
QMap<QUuid, unsigned int> m_progress;

View File

@ -22,9 +22,11 @@
#include "thread_encode.h"
#include "global.h"
EncodeThread::EncodeThread(void)
EncodeThread::EncodeThread(const QString &sourceFileName, const QString &outputFileName)
:
m_jobId(QUuid::createUuid())
m_jobId(QUuid::createUuid()),
m_sourceFileName(sourceFileName),
m_outputFileName(outputFileName)
{
m_abort = false;
}

View File

@ -43,14 +43,20 @@ public:
JobStatus_Aborted = 9
};
EncodeThread(void);
EncodeThread(const QString &sourceFileName, const QString &outputFileName);
~EncodeThread(void);
QUuid getId(void) { return this->m_jobId; };
const QString &sourceFileName(void) { return this->m_sourceFileName; };
const QString &outputFileName(void) { return this->m_outputFileName; };
void abortJob(void) { m_abort = true; }
protected:
const QUuid m_jobId;
const QString m_sourceFileName;
const QString m_outputFileName;
volatile bool m_abort;
virtual void run(void);

View File

@ -27,6 +27,39 @@
#include <QTimer>
#include <QCloseEvent>
#include <QMessageBox>
#include <QFileDialog>
#include <QDesktopServices>
#include <QValidator>
///////////////////////////////////////////////////////////////////////////////
// Validator
///////////////////////////////////////////////////////////////////////////////
class StringValidator : public QValidator
{
virtual State validate(QString &input, int &pos) const
{
bool invalid = input.simplified().compare(input) && input.simplified().append(" ").compare(input) &&
input.simplified().prepend(" ").compare(input) && input.simplified().append(" ").prepend(" ").compare(input);
if(!invalid)
{
invalid = invalid || input.contains("--fps");
invalid = invalid || input.contains("--frames");
invalid = invalid || input.contains("--preset");
invalid = invalid || input.contains("--tune");
invalid = invalid || input.contains("--profile");
}
if(invalid) MessageBeep(MB_ICONWARNING);
return invalid ? QValidator::Invalid : QValidator::Acceptable;
}
virtual void fixup(QString &input) const
{
input = input.simplified();
}
};
///////////////////////////////////////////////////////////////////////////////
// Constructor & Destructor
@ -46,20 +79,128 @@ AddJobDialog::AddJobDialog(QWidget *parent)
//Activate combobox
connect(cbxRateControlMode, SIGNAL(currentIndexChanged(int)), this, SLOT(modeIndexChanged(int)));
//Activate buttons
connect(buttonBrowseSource, SIGNAL(clicked()), this, SLOT(browseButtonClicked()));
connect(buttonBrowseOutput, SIGNAL(clicked()), this, SLOT(browseButtonClicked()));
//Setup validator
cbxCustomParams->setValidator(new StringValidator());
cbxCustomParams->addItem("--bluray-compat --vbv-maxrate 40000 --vbv-bufsize 30000 --level 4.1 --keyint 25 --open-gop --slices 4");
cbxCustomParams->clearEditText();
}
AddJobDialog::~AddJobDialog(void)
{
}
///////////////////////////////////////////////////////////////////////////////
// Events
///////////////////////////////////////////////////////////////////////////////
void AddJobDialog::showEvent(QShowEvent *event)
{
QDialog::showEvent(event);
modeIndexChanged(cbxRateControlMode->currentIndex());
}
///////////////////////////////////////////////////////////////////////////////
// Slots
///////////////////////////////////////////////////////////////////////////////
void AddJobDialog::modeIndexChanged(int index)
{
spinQuantizer->setEnabled(index == 0 || index == 1);
spinBitrate->setEnabled(index == 2 || index == 3);
}
void AddJobDialog::accept(void)
{
if(editSource->text().trimmed().isEmpty())
{
QMessageBox::warning(this, tr("Not Found!"), tr("Please select a valid source file first!"));
return;
}
QFileInfo sourceFile = QFileInfo(editSource->text());
if(!(sourceFile.exists() && sourceFile.isFile()))
{
QMessageBox::warning(this, tr("Not Found!"), tr("The selected source file could not be found!"));
return;
}
QFileInfo outputDir = QFileInfo(QFileInfo(editOutput->text()).path());
if(!(outputDir.exists() && outputDir.isDir() && outputDir.isWritable()))
{
QMessageBox::warning(this, tr("Not Writable!"), tr("Output directory does not exist or is not writable!"));
return;
}
QFileInfo outputFile = QFileInfo(editOutput->text());
if(outputFile.exists() && outputFile.isFile())
{
if(QMessageBox::question(this, tr("Already Exists!"), tr("Output file already exists! Overwrite?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes)
{
return;
}
}
if(outputFile.exists() && (!outputFile.isFile()))
{
QMessageBox::warning(this, tr("Not a File!"), tr("Selected output files does not appear to be a file!"));
return;
}
QDialog::accept();
}
void AddJobDialog::browseButtonClicked(void)
{
QString initialDir = QDesktopServices::storageLocation(QDesktopServices::MoviesLocation);
if(QObject::sender() == buttonBrowseSource)
{
QString filters;
filters += tr("Avisynth Scripts (*.avs)").append(";;");
filters += tr("Matroska Files (*.mkv)").append(";;");
filters += tr("MPEG-4 Part 14 Container (*.mp4)").append(";;");
filters += tr("Audio Video Interleaved (*.avi)").append(";;");
filters += tr("Flash Video (*.flv)").append(";;");
QString filePath = QFileDialog::getOpenFileName(this, tr("Open Source File"), initialDir, filters);
if(!(filePath.isNull() || filePath.isEmpty()))
{
editSource->setText(filePath);
QString path = QFileInfo(filePath).path();
QString name = QFileInfo(filePath).completeBaseName();
QString outPath = QString("%1/%2.mkv").arg(path, name);
if(QFileInfo(outPath).exists())
{
int i = 2;
while(QFileInfo(outPath).exists())
{
outPath = QString("%1/%2 (%3).mkv").arg(path, name, QString::number(i++));
}
}
editOutput->setText(outPath);
}
}
else if(QObject::sender() == buttonBrowseOutput)
{
QString filters;
filters += tr("Matroska Files (*.mkv)").append(";;");
filters += tr("MPEG-4 Part 14 Container (*.mp4)").append(";;");
filters += tr("H.264 Elementary Stream (*.264)").append(";;");
QString filePath = QFileDialog::getSaveFileName(this, tr("Choose Output File"), initialDir, filters);
if(!(filePath.isNull() || filePath.isEmpty()))
{
editOutput->setText(filePath);
}
}
}

View File

@ -23,7 +23,7 @@
#include "uic_win_addJob.h"
class AddJobDialog: public QDialog, private Ui::AddJobDialog
class AddJobDialog : public QDialog, private Ui::AddJobDialog
{
Q_OBJECT
@ -31,9 +31,21 @@ public:
AddJobDialog(QWidget *parent);
~AddJobDialog(void);
QString sourceFile(void) { return editSource->text(); }
QString outputFile(void) { return editOutput->text(); }
QString preset(void) { return cbxPreset->itemText(cbxPreset->currentIndex()); }
QString tuning(void) { return cbxTuning->itemText(cbxTuning->currentIndex()); }
QString profile(void) { return cbxProfile->itemText(cbxProfile->currentIndex()); }
QString params(void) { return cbxCustomParams->currentText().simplified(); }
bool runImmediately(void) { return checkBoxRun->isChecked(); }
void setRunImmediately(bool run) { checkBoxRun->setChecked(run); }
protected:
virtual void AddJobDialog::showEvent(QShowEvent *event);
private slots:
void modeIndexChanged(int index);
void browseButtonClicked(void);
virtual void accept(void);
};

View File

@ -29,6 +29,10 @@
#include <QTimer>
#include <QCloseEvent>
#include <QMessageBox>
#include <QDesktopServices>
#include <QUrl>
const char *home_url = "http://mulder.brhack.net/";
///////////////////////////////////////////////////////////////////////////////
// Constructor & Destructor
@ -75,6 +79,11 @@ MainWindow::MainWindow(bool x64supported)
//Enable menu
connect(actionAbout, SIGNAL(triggered()), this, SLOT(showAbout()));
connect(actionWebMulder, SIGNAL(triggered()), this, SLOT(showWebLink()));
connect(actionWebX264, SIGNAL(triggered()), this, SLOT(showWebLink()));
connect(actionWebKomisar, SIGNAL(triggered()), this, SLOT(showWebLink()));
connect(actionWebJarod, SIGNAL(triggered()), this, SLOT(showWebLink()));
connect(actionWebWiki, SIGNAL(triggered()), this, SLOT(showWebLink()));
}
MainWindow::~MainWindow(void)
@ -89,13 +98,25 @@ MainWindow::~MainWindow(void)
void MainWindow::addButtonPressed(void)
{
AddJobDialog *addDialog = new AddJobDialog(this);
addDialog->setRunImmediately(!havePendingJobs());
int result = addDialog->exec();
if(result == QDialog::Accepted)
{
EncodeThread *thrd = new EncodeThread();
EncodeThread *thrd = new EncodeThread
(
addDialog->sourceFile(),
addDialog->outputFile()
);
QModelIndex newIndex = m_jobList->insertJob(thrd);
jobsView->selectRow(newIndex.row());
if(addDialog->runImmediately())
{
jobsView->selectRow(newIndex.row());
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
m_jobList->startJob(newIndex);
}
}
X264_DELETE(addDialog);
@ -181,7 +202,6 @@ void MainWindow::jobLogExtended(const QModelIndex & parent, int start, int end)
void MainWindow::showAbout(void)
{
QString text;
const char *url = "http://mulder.brhack.net/";
text += QString().sprintf("<nobr><tt>Simple x264 Launcher v%u.%02u - use 64-Bit x264 with 32-Bit Avisynth<br>", x264_version_major(), x264_version_minor());
text += QString().sprintf("Copyright (c) 2004-%04d LoRd_MuldeR &lt;mulder2@gmx.de&gt;. Some rights reserved.<br>", qMax(x264_version_date().year(),QDate::currentDate().year()));
@ -189,11 +209,20 @@ void MainWindow::showAbout(void)
text += QString().sprintf("This program is free software: you can redistribute it and/or modify<br>");
text += QString().sprintf("it under the terms of the GNU General Public License &lt;http://www.gnu.org/&gt;.<br>");
text += QString().sprintf("Note that this program is distributed with ABSOLUTELY NO WARRANTY.<br><br>");
text += QString().sprintf("Please check the web-site at <a href=\"%s\">%s</a> for updates !!!<br></tt></nobr>", url, url);
text += QString().sprintf("Please check the web-site at <a href=\"%s\">%s</a> for updates !!!<br></tt></nobr>", home_url, home_url);
QMessageBox::information(this, tr("About..."), text.replace("-", "&minus;"));
}
void MainWindow::showWebLink(void)
{
if(QObject::sender() == actionWebMulder) QDesktopServices::openUrl(QUrl(home_url));
if(QObject::sender() == actionWebX264) QDesktopServices::openUrl(QUrl("http://www.x264.com/"));
if(QObject::sender() == actionWebKomisar) QDesktopServices::openUrl(QUrl("http://komisar.gin.by/"));
if(QObject::sender() == actionWebJarod) QDesktopServices::openUrl(QUrl("http://www.x264.nl/"));
if(QObject::sender() == actionWebWiki) QDesktopServices::openUrl(QUrl("http://mewiki.project357.com/wiki/X264_Settings"));
}
void MainWindow::launchNextJob(void)
{
const int rows = m_jobList->rowCount(QModelIndex());
@ -227,24 +256,36 @@ void MainWindow::launchNextJob(void)
void MainWindow::closeEvent(QCloseEvent *e)
{
const int rows = m_jobList->rowCount(QModelIndex());
for(int i = 0; i < rows; i++)
if(havePendingJobs())
{
EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
if(status != EncodeThread::JobStatus_Completed && status != EncodeThread::JobStatus_Aborted && status != EncodeThread::JobStatus_Failed)
{
e->ignore();
MessageBeep(MB_ICONWARNING);
break;
}
e->ignore();
MessageBeep(MB_ICONWARNING);
return;
}
QMainWindow::closeEvent(e);
}
///////////////////////////////////////////////////////////////////////////////
// Private functions
///////////////////////////////////////////////////////////////////////////////
bool MainWindow::havePendingJobs(void)
{
const int rows = m_jobList->rowCount(QModelIndex());
for(int i = 0; i < rows; i++)
{
EncodeThread::JobStatus status = m_jobList->getJobStatus(m_jobList->index(i, 0, QModelIndex()));
if(status != EncodeThread::JobStatus_Completed && status != EncodeThread::JobStatus_Aborted && status != EncodeThread::JobStatus_Failed)
{
return true;
}
}
return false;
}
void MainWindow::updateButtons(EncodeThread::JobStatus status)
{
qDebug("MainWindow::updateButtons(void)");

View File

@ -42,6 +42,7 @@ private:
const bool m_x64supported;
void updateButtons(EncodeThread::JobStatus status);
bool havePendingJobs(void);
private slots:
void addButtonPressed(void);
@ -51,5 +52,6 @@ private slots:
void jobChangedData(const QModelIndex &top, const QModelIndex &bottom);
void jobLogExtended(const QModelIndex & parent, int start, int end);
void showAbout(void);
void showWebLink(void);
void launchNextJob(void);
};