Added options Model.
This commit is contained in:
parent
7a485a73f8
commit
055b9ef673
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>560</width>
|
||||
<width>640</width>
|
||||
<height>494</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -238,7 +238,14 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinQuantizer"/>
|
||||
<widget class="QSpinBox" name="spinQuantizer">
|
||||
<property name="maximum">
|
||||
<number>52</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>22</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@ -268,7 +275,17 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBitrate"/>
|
||||
<widget class="QSpinBox" name="spinBitrate">
|
||||
<property name="minimum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>250000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1200</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@ -329,7 +346,7 @@
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbxPreset">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
@ -413,7 +430,7 @@
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbxTuning">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
|
@ -93,6 +93,9 @@
|
||||
<family>Lucida Console</family>
|
||||
</font>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
|
@ -63,7 +63,7 @@ QModelIndex LogFileModel::parent(const QModelIndex &index) const
|
||||
|
||||
QVariant LogFileModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if(role == Qt::DisplayRole)
|
||||
if((role == Qt::DisplayRole) || (role == Qt::ToolTipRole))
|
||||
{
|
||||
if(index.row() >= 0 && index.row() < m_lines.count() && index.column() == 0)
|
||||
{
|
||||
@ -81,6 +81,10 @@ QVariant LogFileModel::data(const QModelIndex &index, int role) const
|
||||
void LogFileModel::addLogMessage(const QUuid &jobId, const QString &text)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), m_lines.count(), m_lines.count());
|
||||
m_lines.append(text);
|
||||
QStringList lines = text.split("\n");
|
||||
for(int i = 0; i < lines.count(); i++)
|
||||
{
|
||||
m_lines.append(lines.at(i));
|
||||
}
|
||||
endInsertRows();
|
||||
}
|
||||
|
59
src/model_options.cpp
Normal file
59
src/model_options.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Simple x264 Launcher
|
||||
// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "model_options.h"
|
||||
|
||||
OptionsModel::OptionsModel(void)
|
||||
{
|
||||
m_rcMode = RCMode_CRF;
|
||||
m_bitrate = 1200;
|
||||
m_quantizer = 22;
|
||||
m_preset = "Medium";
|
||||
m_tune = "None";
|
||||
m_profile = "High";
|
||||
m_custom = "";
|
||||
}
|
||||
|
||||
OptionsModel::~OptionsModel(void)
|
||||
{
|
||||
}
|
||||
|
||||
QString OptionsModel::rcMode2String(RCMode mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case RCMode_CRF:
|
||||
return QObject::tr("CRF");
|
||||
break;
|
||||
case RCMode_CQ:
|
||||
return QObject::tr("CQ");
|
||||
break;
|
||||
case RCMode_2Pass:
|
||||
return QObject::tr("2-Pass");
|
||||
break;
|
||||
case RCMode_ABR:
|
||||
return QObject::tr("ABR");
|
||||
break;
|
||||
default:
|
||||
return QString();
|
||||
break;
|
||||
}
|
||||
}
|
70
src/model_options.h
Normal file
70
src/model_options.h
Normal file
@ -0,0 +1,70 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Simple x264 Launcher
|
||||
// Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
//
|
||||
// http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
class OptionsModel
|
||||
{
|
||||
public:
|
||||
OptionsModel(void);
|
||||
~OptionsModel(void);
|
||||
|
||||
enum RCMode
|
||||
{
|
||||
RCMode_CRF = 0,
|
||||
RCMode_CQ = 1,
|
||||
RCMode_2Pass = 2,
|
||||
RCMode_ABR = 3,
|
||||
};
|
||||
|
||||
//Getter
|
||||
RCMode rcMode(void) const { return m_rcMode; }
|
||||
unsigned int bitrate(void) const { return m_bitrate; }
|
||||
unsigned int quantizer(void) const { return m_quantizer; }
|
||||
QString preset(void) const { return m_preset; }
|
||||
QString tune(void) const { return m_tune; }
|
||||
QString profile(void) const { return m_profile; }
|
||||
QString custom(void) const { return m_custom; }
|
||||
|
||||
//Setter
|
||||
void setRCMode(RCMode mode) { m_rcMode = qBound(RCMode_CQ, mode, RCMode_ABR); }
|
||||
void setBitrate(unsigned int bitrate) { m_bitrate = qBound(100U, bitrate, 250000U); }
|
||||
void setQuantizer(unsigned int quantizer) { m_quantizer = qBound(0U, quantizer, 52U); }
|
||||
void setPreset(const QString &preset) { m_preset = preset.trimmed(); }
|
||||
void setTune(const QString &tune) { m_tune = tune.trimmed(); }
|
||||
void setProfile(const QString &profile) { m_profile = profile.trimmed(); }
|
||||
void setCustom(const QString &custom) { m_custom = custom.trimmed(); }
|
||||
|
||||
//Helper
|
||||
static QString rcMode2String(RCMode mode);
|
||||
|
||||
protected:
|
||||
RCMode m_rcMode;
|
||||
unsigned int m_bitrate;
|
||||
unsigned int m_quantizer;
|
||||
QString m_preset;
|
||||
QString m_tune;
|
||||
QString m_profile;
|
||||
QString m_custom;
|
||||
};
|
@ -20,19 +20,26 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "thread_encode.h"
|
||||
#include "global.h"
|
||||
|
||||
EncodeThread::EncodeThread(const QString &sourceFileName, const QString &outputFileName)
|
||||
#include "global.h"
|
||||
#include "model_options.h"
|
||||
|
||||
#include <QDate>
|
||||
#include <QTime>
|
||||
|
||||
EncodeThread::EncodeThread(const QString &sourceFileName, const QString &outputFileName, const OptionsModel *options)
|
||||
:
|
||||
m_jobId(QUuid::createUuid()),
|
||||
m_sourceFileName(sourceFileName),
|
||||
m_outputFileName(outputFileName)
|
||||
m_outputFileName(outputFileName),
|
||||
m_options(new OptionsModel(*options))
|
||||
{
|
||||
m_abort = false;
|
||||
}
|
||||
|
||||
EncodeThread::~EncodeThread(void)
|
||||
{
|
||||
X264_DELETE(m_options);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -59,6 +66,18 @@ void EncodeThread::encode(void)
|
||||
{
|
||||
Sleep(1500);
|
||||
|
||||
//Print some basic info
|
||||
log(tr("Job started at %1, %2.\n").arg(QDate::currentDate().toString(Qt::ISODate), QTime::currentTime().toString( Qt::ISODate)));
|
||||
log(tr("Source file: %1").arg(m_sourceFileName));
|
||||
log(tr("Output file: %1").arg(m_outputFileName));
|
||||
log(tr("\n[Encoder Options]"));
|
||||
log(tr("RC Mode: %1").arg(OptionsModel::rcMode2String(m_options->rcMode())));
|
||||
log(tr("Preset: %1").arg(m_options->preset()));
|
||||
log(tr("Tuning: %1").arg(m_options->tune()));
|
||||
log(tr("Profile: %1").arg(m_options->profile()));
|
||||
log(tr("Custom: %1").arg(m_options->custom().isEmpty() ? tr("(None)") : m_options->custom()));
|
||||
log(tr("\n[Input Properties]"));
|
||||
|
||||
for(int i = 0; i <= 100; i += 5)
|
||||
{
|
||||
emit progressChanged(m_jobId, i);
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include <QThread>
|
||||
#include <QUuid>
|
||||
|
||||
class OptionsModel;
|
||||
|
||||
class EncodeThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -43,7 +45,7 @@ public:
|
||||
JobStatus_Aborted = 9
|
||||
};
|
||||
|
||||
EncodeThread(const QString &sourceFileName, const QString &outputFileName);
|
||||
EncodeThread(const QString &sourceFileName, const QString &outputFileName, const OptionsModel *options);
|
||||
~EncodeThread(void);
|
||||
|
||||
QUuid getId(void) { return this->m_jobId; };
|
||||
@ -56,11 +58,16 @@ protected:
|
||||
const QUuid m_jobId;
|
||||
const QString m_sourceFileName;
|
||||
const QString m_outputFileName;
|
||||
const OptionsModel *m_options;
|
||||
|
||||
volatile bool m_abort;
|
||||
|
||||
virtual void run(void);
|
||||
|
||||
//Encode functions
|
||||
void encode(void);
|
||||
|
||||
//Auxiallary Stuff
|
||||
void log(const QString &text) { emit messageLogged(m_jobId, text); }
|
||||
|
||||
signals:
|
||||
void statusChanged(const QUuid &jobId, EncodeThread::JobStatus newStatus);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "win_addJob.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "model_options.h"
|
||||
|
||||
#include <QDate>
|
||||
#include <QTimer>
|
||||
@ -65,12 +66,14 @@ class StringValidator : public QValidator
|
||||
// Constructor & Destructor
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AddJobDialog::AddJobDialog(QWidget *parent)
|
||||
AddJobDialog::AddJobDialog(QWidget *parent, OptionsModel *options)
|
||||
:
|
||||
QDialog(parent)
|
||||
QDialog(parent),
|
||||
m_options(options)
|
||||
{
|
||||
//Init the dialog, from the .ui file
|
||||
setupUi(this);
|
||||
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
|
||||
//Fix dialog size
|
||||
resize(width(), minimumHeight());
|
||||
@ -101,6 +104,7 @@ AddJobDialog::~AddJobDialog(void)
|
||||
void AddJobDialog::showEvent(QShowEvent *event)
|
||||
{
|
||||
QDialog::showEvent(event);
|
||||
restoreOptions(m_options);
|
||||
modeIndexChanged(cbxRateControlMode->currentIndex());
|
||||
}
|
||||
|
||||
@ -150,6 +154,7 @@ void AddJobDialog::accept(void)
|
||||
return;
|
||||
}
|
||||
|
||||
saveOptions(m_options);
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
@ -204,3 +209,41 @@ void AddJobDialog::browseButtonClicked(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Private functions
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void AddJobDialog::updateComboBox(QComboBox *cbox, const QString &text)
|
||||
{
|
||||
for(int i = 0; i < cbox->model()->rowCount(); i++)
|
||||
{
|
||||
if(cbox->model()->data(cbox->model()->index(i, 0, QModelIndex())).toString().compare(text, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
cbox->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AddJobDialog::restoreOptions(OptionsModel *options)
|
||||
{
|
||||
cbxRateControlMode->setCurrentIndex(options->rcMode());
|
||||
spinQuantizer->setValue(options->quantizer());
|
||||
spinBitrate->setValue(options->bitrate());
|
||||
updateComboBox(cbxPreset, options->preset());
|
||||
updateComboBox(cbxTuning, options->tune());
|
||||
updateComboBox(cbxProfile, options->profile());
|
||||
cbxCustomParams->setEditText(options->custom());
|
||||
}
|
||||
|
||||
void AddJobDialog::saveOptions(OptionsModel *options)
|
||||
{
|
||||
options->setRCMode(static_cast<OptionsModel::RCMode>(cbxRateControlMode->currentIndex()));
|
||||
options->setQuantizer(spinQuantizer->value());
|
||||
options->setBitrate(spinBitrate->value());
|
||||
options->setPreset(cbxPreset->model()->data(cbxPreset->model()->index(cbxPreset->currentIndex(), 0)).toString());
|
||||
options->setTune(cbxTuning->model()->data(cbxTuning->model()->index(cbxTuning->currentIndex(), 0)).toString());
|
||||
options->setProfile(cbxProfile->model()->data(cbxProfile->model()->index(cbxProfile->currentIndex(), 0)).toString());
|
||||
options->setCustom(cbxCustomParams->currentText());
|
||||
}
|
||||
|
@ -23,12 +23,14 @@
|
||||
|
||||
#include "uic_win_addJob.h"
|
||||
|
||||
class OptionsModel;
|
||||
|
||||
class AddJobDialog : public QDialog, private Ui::AddJobDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AddJobDialog(QWidget *parent);
|
||||
AddJobDialog(QWidget *parent, OptionsModel *options);
|
||||
~AddJobDialog(void);
|
||||
|
||||
QString sourceFile(void) { return editSource->text(); }
|
||||
@ -41,6 +43,8 @@ public:
|
||||
void setRunImmediately(bool run) { checkBoxRun->setChecked(run); }
|
||||
|
||||
protected:
|
||||
OptionsModel *m_options;
|
||||
|
||||
virtual void AddJobDialog::showEvent(QShowEvent *event);
|
||||
|
||||
private slots:
|
||||
@ -48,4 +52,9 @@ private slots:
|
||||
void browseButtonClicked(void);
|
||||
|
||||
virtual void accept(void);
|
||||
|
||||
private:
|
||||
void restoreOptions(OptionsModel *options);
|
||||
void saveOptions(OptionsModel *options);
|
||||
void updateComboBox(QComboBox *cbox, const QString &text);
|
||||
};
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "global.h"
|
||||
#include "model_jobList.h"
|
||||
#include "model_options.h"
|
||||
#include "win_addJob.h"
|
||||
|
||||
#include <QDate>
|
||||
@ -44,7 +45,7 @@ MainWindow::MainWindow(bool x64supported)
|
||||
{
|
||||
//Init the dialog, from the .ui file
|
||||
setupUi(this);
|
||||
setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint);
|
||||
setWindowFlags(windowFlags() & (~Qt::WindowMaximizeButtonHint));
|
||||
|
||||
//Register meta types
|
||||
qRegisterMetaType<QUuid>("QUuid");
|
||||
@ -84,11 +85,15 @@ MainWindow::MainWindow(bool x64supported)
|
||||
connect(actionWebKomisar, SIGNAL(triggered()), this, SLOT(showWebLink()));
|
||||
connect(actionWebJarod, SIGNAL(triggered()), this, SLOT(showWebLink()));
|
||||
connect(actionWebWiki, SIGNAL(triggered()), this, SLOT(showWebLink()));
|
||||
|
||||
//Create options object
|
||||
m_options = new OptionsModel();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow(void)
|
||||
{
|
||||
X264_DELETE(m_jobList);
|
||||
X264_DELETE(m_options);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -97,7 +102,7 @@ MainWindow::~MainWindow(void)
|
||||
|
||||
void MainWindow::addButtonPressed(void)
|
||||
{
|
||||
AddJobDialog *addDialog = new AddJobDialog(this);
|
||||
AddJobDialog *addDialog = new AddJobDialog(this, m_options);
|
||||
addDialog->setRunImmediately(!havePendingJobs());
|
||||
int result = addDialog->exec();
|
||||
|
||||
@ -106,7 +111,8 @@ void MainWindow::addButtonPressed(void)
|
||||
EncodeThread *thrd = new EncodeThread
|
||||
(
|
||||
addDialog->sourceFile(),
|
||||
addDialog->outputFile()
|
||||
addDialog->outputFile(),
|
||||
m_options
|
||||
);
|
||||
|
||||
QModelIndex newIndex = m_jobList->insertJob(thrd);
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "thread_encode.h"
|
||||
|
||||
class JobListModel;
|
||||
class OptionsModel;
|
||||
|
||||
class MainWindow: public QMainWindow, private Ui::MainWindow
|
||||
{
|
||||
@ -39,6 +40,7 @@ protected:
|
||||
|
||||
private:
|
||||
JobListModel *m_jobList;
|
||||
OptionsModel *m_options;
|
||||
const bool m_x64supported;
|
||||
|
||||
void updateButtons(EncodeThread::JobStatus status);
|
||||
|
@ -159,6 +159,7 @@
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs)</Outputs>
|
||||
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)tmp\moc\moc_%(Filename).cpp;%(Outputs)</Outputs>
|
||||
</CustomBuild>
|
||||
<ClInclude Include="src\model_options.h" />
|
||||
<ClInclude Include="src\targetver.h" />
|
||||
<ClInclude Include="src\version.h" />
|
||||
<CustomBuild Include="src\win_main.h">
|
||||
@ -173,6 +174,7 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\model_jobList.cpp" />
|
||||
<ClCompile Include="src\model_logFile.cpp" />
|
||||
<ClCompile Include="src\model_options.cpp" />
|
||||
<ClCompile Include="src\thread_encode.cpp" />
|
||||
<ClCompile Include="src\global.cpp" />
|
||||
<ClCompile Include="src\main.cpp" />
|
||||
|
@ -39,6 +39,9 @@
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\model_options.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\main.cpp">
|
||||
@ -80,6 +83,9 @@
|
||||
<ClCompile Include="tmp\moc\moc_win_addJob.cpp">
|
||||
<Filter>Generated Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\model_options.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="gui\win_main.ui">
|
||||
|
Loading…
Reference in New Issue
Block a user