Finished work to better handle multiple input files.

This commit is contained in:
LoRd_MuldeR 2013-05-11 01:50:05 +02:00
parent 680debf496
commit a56ed35a1a
9 changed files with 205 additions and 157 deletions

View File

@ -1231,7 +1231,7 @@
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>12</width> <width>4</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
@ -1240,7 +1240,7 @@
<item> <item>
<widget class="QCheckBox" name="checkBoxApplyToAll"> <widget class="QCheckBox" name="checkBoxApplyToAll">
<property name="text"> <property name="text">
<string>Apply Configuration To All Files</string> <string>Apply To All Selected Files</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -1261,7 +1261,7 @@
<widget class="QPushButton" name="buttonAccept"> <widget class="QPushButton" name="buttonAccept">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>128</width> <width>112</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
@ -1278,7 +1278,7 @@
<widget class="QPushButton" name="buttonCancel"> <widget class="QPushButton" name="buttonCancel">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>128</width> <width>112</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>

View File

@ -321,6 +321,8 @@
<property name="title"> <property name="title">
<string>File</string> <string>File</string>
</property> </property>
<addaction name="actionOpen"/>
<addaction name="separator"/>
<addaction name="actionPreferences"/> <addaction name="actionPreferences"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionExit"/> <addaction name="actionExit"/>
@ -593,6 +595,15 @@
<string>Help and Support</string> <string>Help and Support</string>
</property> </property>
</action> </action>
<action name="actionOpen">
<property name="icon">
<iconset resource="../res/resources.qrc">
<normaloff>:/buttons/folder_add.png</normaloff>:/buttons/folder_add.png</iconset>
</property>
<property name="text">
<string>Open...</string>
</property>
</action>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>buttonAddJob</tabstop> <tabstop>buttonAddJob</tabstop>

BIN
res/buttons/folder_add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 B

View File

@ -17,6 +17,7 @@
<file>buttons/error.png</file> <file>buttons/error.png</file>
<file>buttons/exclamation.png</file> <file>buttons/exclamation.png</file>
<file>buttons/find.png</file> <file>buttons/find.png</file>
<file>buttons/folder_add.png</file>
<file>buttons/folder_magnify.png</file> <file>buttons/folder_magnify.png</file>
<file>buttons/group.png</file> <file>buttons/group.png</file>
<file>buttons/hourglass.png</file> <file>buttons/hourglass.png</file>

View File

@ -21,8 +21,8 @@
#define VER_X264_MAJOR 2 #define VER_X264_MAJOR 2
#define VER_X264_MINOR 1 #define VER_X264_MINOR 1
#define VER_X264_PATCH 0 #define VER_X264_PATCH 1
#define VER_X264_BUILD 439 #define VER_X264_BUILD 460
#define VER_X264_MINIMUM_REV 2282 #define VER_X264_MINIMUM_REV 2282
#define VER_X264_CURRENT_API 132 #define VER_X264_CURRENT_API 132

View File

@ -41,6 +41,7 @@
#include <QClipboard> #include <QClipboard>
#include <QToolTip> #include <QToolTip>
#define ARRAY_SIZE(ARRAY) (sizeof((ARRAY))/sizeof((ARRAY[0])))
#define VALID_DIR(PATH) ((!(PATH).isEmpty()) && QFileInfo(PATH).exists() && QFileInfo(PATH).isDir()) #define VALID_DIR(PATH) ((!(PATH).isEmpty()) && QFileInfo(PATH).exists() && QFileInfo(PATH).isDir())
#define REMOVE_USAFED_ITEM \ #define REMOVE_USAFED_ITEM \
@ -392,8 +393,9 @@ void AddJobDialog::dropEvent(QDropEvent *event)
if(!droppedFile.isEmpty()) if(!droppedFile.isEmpty())
{ {
const QString outFileName = generateOutputFileName(droppedFile, currentOutputPath(), currentOutputIndx(), m_saveToSourceFolder);
editSource->setText(QDir::toNativeSeparators(droppedFile)); editSource->setText(QDir::toNativeSeparators(droppedFile));
generateOutputFileName(droppedFile, m_recentlyUsed->outputDirectory, m_recentlyUsed->filterIndex, m_saveToSourceFolder); editOutput->setText(QDir::toNativeSeparators(outFileName));
} }
} }
@ -429,14 +431,6 @@ void AddJobDialog::accept(void)
return; return;
} }
//Is destination dir writable?
QFileInfo outputDir = QFileInfo(QFileInfo(this->outputFile()).absolutePath());
if(!(outputDir.exists() && outputDir.isDir() && outputDir.isWritable()))
{
QMessageBox::warning(this, tr("Not Writable!"), tr("<nobr>Output directory does not exist or is not writable!</nobr>"));
return;
}
//Does output file already exist? //Does output file already exist?
QFileInfo outputFile = QFileInfo(this->outputFile()); QFileInfo outputFile = QFileInfo(this->outputFile());
if(outputFile.exists() && outputFile.isFile()) if(outputFile.exists() && outputFile.isFile())
@ -450,6 +444,14 @@ void AddJobDialog::accept(void)
return; return;
} }
//Is destination dir writable?
QFileInfo outputDir = QFileInfo(outputFile.absolutePath());
if(!(outputDir.exists() && outputDir.isDir() && outputDir.isWritable()))
{
QMessageBox::warning(this, tr("Not Writable!"), tr("<nobr>Output directory does not exist or is not writable!</nobr>"));
return;
}
//Custom parameters okay? //Custom parameters okay?
if(!editCustomX264Params->hasAcceptableInput()) if(!editCustomX264Params->hasAcceptableInput())
{ {
@ -458,9 +460,9 @@ void AddJobDialog::accept(void)
} }
//Update recently used //Update recently used
m_recentlyUsed->sourceDirectory = sourceFile.canonicalPath(); m_recentlyUsed->filterIndex = currentOutputIndx();
m_recentlyUsed->outputDirectory = outputFile.canonicalPath(); m_recentlyUsed->sourceDirectory = currentSourcePath();
m_recentlyUsed->filterIndex = qMax(0, getFilterIdx(outputFile.suffix())); m_recentlyUsed->outputDirectory = currentOutputPath();
saveRecentlyUsed(m_recentlyUsed); saveRecentlyUsed(m_recentlyUsed);
//Save options //Save options
@ -472,38 +474,34 @@ void AddJobDialog::browseButtonClicked(void)
{ {
if(QObject::sender() == buttonBrowseSource) if(QObject::sender() == buttonBrowseSource)
{ {
QString initDir = m_recentlyUsed->sourceDirectory; QString filePath = QFileDialog::getOpenFileName(this, tr("Open Source File"), currentSourcePath(true), getInputFilterLst(), NULL, QFileDialog::DontUseNativeDialog);
if(!editSource->text().isEmpty())
{
QString tempDir = QFileInfo(QDir::fromNativeSeparators(editSource->text())).canonicalPath();
if(VALID_DIR(tempDir)) initDir = tempDir;
}
QString filePath = QFileDialog::getOpenFileName(this, tr("Open Source File"), initDir, getInputFilterLst(), NULL, QFileDialog::DontUseNativeDialog);
if(!(filePath.isNull() || filePath.isEmpty())) if(!(filePath.isNull() || filePath.isEmpty()))
{ {
QString destFile = generateOutputFileName(filePath, currentOutputPath(), currentOutputIndx(), m_saveToSourceFolder);
editSource->setText(QDir::toNativeSeparators(filePath)); editSource->setText(QDir::toNativeSeparators(filePath));
QString destPath = generateOutputFileName(filePath, m_recentlyUsed->outputDirectory, m_recentlyUsed->filterIndex, m_saveToSourceFolder); editOutput->setText(QDir::toNativeSeparators(destFile));
editOutput->setText(QDir::toNativeSeparators(destPath));
} }
} }
else if(QObject::sender() == buttonBrowseOutput) else if(QObject::sender() == buttonBrowseOutput)
{ {
QString initDir = m_recentlyUsed->outputDirectory; QString selectedType = getFilterStr(currentOutputIndx());
if(!editOutput->text().isEmpty()) QString filePath = QFileDialog::getSaveFileName(this, tr("Choose Output File"), currentOutputPath(true), getFilterLst(), &selectedType, QFileDialog::DontUseNativeDialog | QFileDialog::DontConfirmOverwrite);
{
QString tempDir = QFileInfo(QDir::fromNativeSeparators(editOutput->text())).canonicalPath();
if(VALID_DIR(tempDir)) initDir = tempDir;
}
QString selectedType = getFilterStr(m_recentlyUsed->filterIndex);
QString filePath = QFileDialog::getSaveFileName(this, tr("Choose Output File"), initDir, getFilterLst(), &selectedType, QFileDialog::DontUseNativeDialog | QFileDialog::DontConfirmOverwrite);
if(!(filePath.isNull() || filePath.isEmpty())) if(!(filePath.isNull() || filePath.isEmpty()))
{ {
if(getFilterIdx(QFileInfo(filePath).suffix()) < 0) if(getFilterIdx(QFileInfo(filePath).suffix()) < 0)
{ {
filePath = QString("%1.%2").arg(filePath, getFilterExt(m_recentlyUsed->filterIndex)); int tempIndex = -1;
QRegExp regExp("\\(\\*\\.(\\w+)\\)");
if(regExp.lastIndexIn(selectedType) >= 0)
{
tempIndex = getFilterIdx(regExp.cap(1));
}
if(tempIndex < 0)
{
tempIndex = m_recentlyUsed->filterIndex;
}
filePath = QString("%1.%2").arg(filePath, getFilterExt(tempIndex));
} }
editOutput->setText(QDir::toNativeSeparators(filePath)); editOutput->setText(QDir::toNativeSeparators(filePath));
} }
@ -808,47 +806,65 @@ void AddJobDialog::saveOptions(OptionsModel *options)
options->setCustomAvs2YUV(editCustomAvs2YUVParams->hasAcceptableInput() ? editCustomAvs2YUVParams->text().simplified() : QString()); options->setCustomAvs2YUV(editCustomAvs2YUVParams->hasAcceptableInput() ? editCustomAvs2YUVParams->text().simplified() : QString());
} }
/* QString AddJobDialog::currentSourcePath(const bool bWithName)
void AddJobDialog::generateOutputFileName(const QString &filePath)
{ {
QString name = QFileInfo(filePath).completeBaseName(); QString path = m_recentlyUsed->sourceDirectory;
QString path = m_saveToSourceFolder ? QFileInfo(filePath).canonicalPath() : (VALID_DIR(m_initialDir_out) ? m_initialDir_out : QFileInfo(filePath).path()); QString currentSourceFile = this->sourceFile();
QString fext = getFilterExt(m_lastFilterIndex);
QString outPath = QString("%1/%2.%3").arg(path, name, fext); if(!currentSourceFile.isEmpty())
if(QFileInfo(outPath).exists())
{ {
int i = 2; QString currentSourceDir = QFileInfo(currentSourceFile).absolutePath();
while(QFileInfo(outPath).exists()) if(VALID_DIR(currentSourceDir))
{ {
outPath = QString("%1/%2 (%3).%4").arg(path, name, QString::number(i++), fext); path = currentSourceDir;
}
if(bWithName)
{
path.append("/").append(QFileInfo(currentSourceFile).fileName());
} }
} }
editOutput->setText(QDir::toNativeSeparators(outPath)); return path;
} }
int AddJobDialog::getFilterIndex(const QString &fileExt) QString AddJobDialog::currentOutputPath(const bool bWithName)
{ {
if(!fileExt.isEmpty()) QString path = m_recentlyUsed->outputDirectory;
QString currentOutputFile = this->outputFile();
if(!currentOutputFile.isEmpty())
{ {
QRegExp ext("\\(\\*\\.(.+)\\)"); QString currentOutputDir = QFileInfo(currentOutputFile).absolutePath();
for(int i = 0; i < m_types.count(); i++) if(VALID_DIR(currentOutputDir))
{ {
if(ext.lastIndexIn(m_types.at(i)) >= 0) path = currentOutputDir;
{
if(fileExt.compare(ext.cap(1), Qt::CaseInsensitive) == 0)
{
return i;
}
} }
if(bWithName)
{
path.append("/").append(QFileInfo(currentOutputFile).fileName());
} }
} }
return -1; return path;
}
int AddJobDialog::currentOutputIndx(void)
{
int index = m_recentlyUsed->filterIndex;
QString currentOutputFile = this->outputFile();
if(!currentOutputFile.isEmpty())
{
const QString currentOutputExtn = QFileInfo(currentOutputFile).suffix();
const int tempIndex = getFilterIdx(currentOutputExtn);
if(tempIndex >= 0)
{
index = tempIndex;
}
}
return index;
} }
*/
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Static functions // Static functions
@ -858,6 +874,20 @@ static const char *KEY_FILTER_IDX = "path/filterIndex";
static const char *KEY_SOURCE_DIR = "path/directory_openFrom"; static const char *KEY_SOURCE_DIR = "path/directory_openFrom";
static const char *KEY_OUTPUT_DIR = "path/directory_saveTo"; static const char *KEY_OUTPUT_DIR = "path/directory_saveTo";
static const struct
{
const char *pcExt;
const char *pcStr;
}
FILE_TYPE_FILTERS[] =
{
{ "mkv", "Matroska Files" },
{ "mp4", "MPEG-4 Part 14 Container" },
{ "264", "H.264 Elementary Stream"},
};
/* ------------------------------------------------------------------------- */
void AddJobDialog::initRecentlyUsed(RecentlyUsed *recentlyUsed) void AddJobDialog::initRecentlyUsed(RecentlyUsed *recentlyUsed)
{ {
recentlyUsed->sourceDirectory = QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation)); recentlyUsed->sourceDirectory = QDir::fromNativeSeparators(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation));
@ -877,6 +907,7 @@ void AddJobDialog::loadRecentlyUsed(RecentlyUsed *recentlyUsed)
if(!VALID_DIR(recentlyUsed->sourceDirectory)) recentlyUsed->sourceDirectory = defaults.sourceDirectory; if(!VALID_DIR(recentlyUsed->sourceDirectory)) recentlyUsed->sourceDirectory = defaults.sourceDirectory;
if(!VALID_DIR(recentlyUsed->outputDirectory)) recentlyUsed->outputDirectory = defaults.outputDirectory; if(!VALID_DIR(recentlyUsed->outputDirectory)) recentlyUsed->outputDirectory = defaults.outputDirectory;
recentlyUsed->filterIndex = qBound(0, recentlyUsed->filterIndex, int(ARRAY_SIZE(FILE_TYPE_FILTERS)-1));
} }
void AddJobDialog::saveRecentlyUsed(RecentlyUsed *recentlyUsed) void AddJobDialog::saveRecentlyUsed(RecentlyUsed *recentlyUsed)
@ -917,23 +948,9 @@ QString AddJobDialog::generateOutputFileName(const QString &sourceFilePath, cons
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
static const struct
{
const char *pcExt;
const char *pcStr;
}
FILE_TYPE_FILTERS[] =
{
{ "mkv", "Matroska Files" },
{ "mp4", "MPEG-4 Part 14 Container" },
{ "264", "H.264 Elementary Stream"},
{ NULL, NULL }
};
QString AddJobDialog::getFilterExt(const int filterIndex) QString AddJobDialog::getFilterExt(const int filterIndex)
{ {
int count = 0; const int count = ARRAY_SIZE(FILE_TYPE_FILTERS);
while((FILE_TYPE_FILTERS[count].pcExt) && (FILE_TYPE_FILTERS[count].pcStr)) count++;
if((filterIndex >= 0) && (filterIndex < count)) if((filterIndex >= 0) && (filterIndex < count))
{ {
@ -945,7 +962,9 @@ QString AddJobDialog::getFilterExt(const int filterIndex)
int AddJobDialog::getFilterIdx(const QString &fileExt) int AddJobDialog::getFilterIdx(const QString &fileExt)
{ {
for(int i = 0; (FILE_TYPE_FILTERS[i].pcExt && FILE_TYPE_FILTERS[i].pcStr); i++) const int count = ARRAY_SIZE(FILE_TYPE_FILTERS);
for(int i = 0; i < count; i++)
{ {
if(fileExt.compare(QString::fromLatin1(FILE_TYPE_FILTERS[i].pcExt), Qt::CaseInsensitive) == 0) if(fileExt.compare(QString::fromLatin1(FILE_TYPE_FILTERS[i].pcExt), Qt::CaseInsensitive) == 0)
{ {
@ -958,8 +977,7 @@ int AddJobDialog::getFilterIdx(const QString &fileExt)
QString AddJobDialog::getFilterStr(const int filterIndex) QString AddJobDialog::getFilterStr(const int filterIndex)
{ {
int count = 0; const int count = ARRAY_SIZE(FILE_TYPE_FILTERS);
while((FILE_TYPE_FILTERS[count].pcExt) && (FILE_TYPE_FILTERS[count].pcStr)) count++;
if((filterIndex >= 0) && (filterIndex < count)) if((filterIndex >= 0) && (filterIndex < count))
{ {
@ -972,8 +990,9 @@ QString AddJobDialog::getFilterStr(const int filterIndex)
QString AddJobDialog::getFilterLst(void) QString AddJobDialog::getFilterLst(void)
{ {
QStringList filters; QStringList filters;
const int count = ARRAY_SIZE(FILE_TYPE_FILTERS);
for(int i = 0; (FILE_TYPE_FILTERS[i].pcExt && FILE_TYPE_FILTERS[i].pcStr); i++) for(int i = 0; i < count; i++)
{ {
filters << QString("%1 (*.%2)").arg(QString::fromLatin1(FILE_TYPE_FILTERS[i].pcStr), QString::fromLatin1(FILE_TYPE_FILTERS[i].pcExt)); filters << QString("%1 (*.%2)").arg(QString::fromLatin1(FILE_TYPE_FILTERS[i].pcStr), QString::fromLatin1(FILE_TYPE_FILTERS[i].pcExt));
} }
@ -997,23 +1016,25 @@ QString AddJobDialog::getInputFilterLst(void)
{"Flash Video", "flv"}, {"Flash Video", "flv"},
{"YUV4MPEG2 Stream", "y4m"}, {"YUV4MPEG2 Stream", "y4m"},
{"Uncompresses YUV Data", "yuv"}, {"Uncompresses YUV Data", "yuv"},
{NULL, NULL}
}; };
QString filters("All supported files ("); const int count = ARRAY_SIZE(FILE_TYPE_FILTERS);
for(size_t index = 0; (s_filters[index].name && s_filters[index].fext); index++) QString allTypes;
for(size_t index = 0; index < count; index++)
{ {
filters += QString((index > 0) ? " *.%1" : "*.%1").arg(QString::fromLatin1(s_filters[index].fext));
allTypes += QString((index > 0) ? " *.%1" : "*.%1").arg(QString::fromLatin1(s_filters[index].fext));
} }
filters += QString(");;"); QStringList filters;
filters << QString("All supported files (%1)").arg(allTypes);
for(size_t index = 0; s_filters[index].name && s_filters[index].fext; index++) for(size_t index = 0; index < count; index++)
{ {
filters += QString("%1 (*.%2);;").arg(QString::fromLatin1(s_filters[index].name), QString::fromLatin1(s_filters[index].fext)); filters << QString("%1 (*.%2)").arg(QString::fromLatin1(s_filters[index].name), QString::fromLatin1(s_filters[index].fext));
} }
filters += QString("All files (*.*)"); filters << QString("All files (*.*)");
return filters; return filters.join(";;");
} }

View File

@ -100,4 +100,8 @@ private:
void restoreOptions(OptionsModel *options); void restoreOptions(OptionsModel *options);
void saveOptions(OptionsModel *options); void saveOptions(OptionsModel *options);
void updateComboBox(QComboBox *cbox, const QString &text); void updateComboBox(QComboBox *cbox, const QString &text);
QString currentSourcePath(const bool bWithName = false);
QString currentOutputPath(const bool bWithName = false);
int currentOutputIndx(void);
}; };

View File

@ -40,10 +40,11 @@
#include <QScrollBar> #include <QScrollBar>
#include <QTextStream> #include <QTextStream>
#include <QSettings> #include <QSettings>
#include <QFileDialog>
#include <Mmsystem.h> #include <Mmsystem.h>
const char *home_url = "http://mulder.brhack.net/"; const char *home_url = "http://muldersoft.com/";
const char *update_url = "http://code.google.com/p/mulder/downloads/list"; const char *update_url = "http://code.google.com/p/mulder/downloads/list";
const char *tpl_last = "<LAST_USED>"; const char *tpl_last = "<LAST_USED>";
@ -143,6 +144,7 @@ MainWindow::MainWindow(const x264_cpu_t *const cpuFeatures)
connect(actionJob_Browse, SIGNAL(triggered()), this, SLOT(browseButtonPressed())); connect(actionJob_Browse, SIGNAL(triggered()), this, SLOT(browseButtonPressed()));
//Enable menu //Enable menu
connect(actionOpen, SIGNAL(triggered()), this, SLOT(openActionTriggered()));
connect(actionAbout, SIGNAL(triggered()), this, SLOT(showAbout())); connect(actionAbout, SIGNAL(triggered()), this, SLOT(showAbout()));
connect(actionWebMulder, SIGNAL(triggered()), this, SLOT(showWebLink())); connect(actionWebMulder, SIGNAL(triggered()), this, SLOT(showWebLink()));
connect(actionWebX264, SIGNAL(triggered()), this, SLOT(showWebLink())); connect(actionWebX264, SIGNAL(triggered()), this, SLOT(showWebLink()));
@ -222,6 +224,31 @@ void MainWindow::addButtonPressed()
} }
} }
/*
* The "open" action was triggered
*/
void MainWindow::openActionTriggered()
{
QStringList fileList = QFileDialog::getOpenFileNames(this, tr("Open Source File(s)"), m_recentlyUsed.sourceDirectory, AddJobDialog::getInputFilterLst(), NULL, QFileDialog::DontUseNativeDialog);
if(!fileList.empty())
{
m_recentlyUsed.sourceDirectory = QFileInfo(fileList.last()).absolutePath();
if(fileList.count() > 1)
{
createJobMultiple(fileList);
}
else
{
bool runImmediately = (countRunningJobs() < (m_preferences.autoRunNextJob ? m_preferences.maxRunningJobCount : 1));
QString sourceFileName(fileList.first()), outputFileName;
if(createJob(sourceFileName, outputFileName, m_options, runImmediately))
{
appendJob(sourceFileName, outputFileName, m_options, runImmediately);
}
}
}
}
/* /*
* The "start" button was clicked * The "start" button was clicked
*/ */
@ -428,7 +455,7 @@ void MainWindow::showAbout(void)
case 0: case 0:
{ {
QString text2; QString text2;
text2 += tr("<nobr><tt>x264 - the best H.264/AVC encoder. Copyright (c) 2003-2012 x264 project.<br>"); text2 += tr("<nobr><tt>x264 - the best H.264/AVC encoder. Copyright (c) 2003-2013 x264 project.<br>");
text2 += tr("Free software library for encoding video streams into the H.264/MPEG-4 AVC format.<br>"); text2 += tr("Free software library for encoding video streams into the H.264/MPEG-4 AVC format.<br>");
text2 += tr("Released under the terms of the GNU General Public License.<br><br>"); text2 += tr("Released under the terms of the GNU General Public License.<br><br>");
text2 += tr("Please visit <a href=\"%1\">%1</a> for obtaining a commercial x264 license.<br>").arg("http://x264licensing.com/"); text2 += tr("Please visit <a href=\"%1\">%1</a> for obtaining a commercial x264 license.<br>").arg("http://x264licensing.com/");
@ -785,16 +812,9 @@ void MainWindow::init(void)
files << QFileInfo(current).canonicalFilePath(); files << QFileInfo(current).canonicalFilePath();
} }
} }
if(int totalFiles = files.count()) if(files.count() > 0)
{ {
bool ok = true; int n = 0; createJobMultiple(files);
while((!files.isEmpty()) && ok)
{
QString currentFile = files.takeFirst();
qDebug("Adding file: %s", currentFile.toUtf8().constData());
/*TODO: Add multiple files!*/
//ok = createJob(currentFile, QString(), NULL, n++, totalFiles);
}
} }
//Enable drag&drop support for this window, required for Qt v4.8.4+ //Enable drag&drop support for this window, required for Qt v4.8.4+
@ -834,17 +854,7 @@ void MainWindow::handleDroppedFiles(void)
{ {
QStringList droppedFiles(*m_droppedFiles); QStringList droppedFiles(*m_droppedFiles);
m_droppedFiles->clear(); m_droppedFiles->clear();
/* createJobMultiple(droppedFiles);
int totalFiles = droppedFiles.count();
bool ok = true; int n = 0;
while((!droppedFiles.isEmpty()) && ok)
{
QString currentFile = droppedFiles.takeFirst();
qDebug("Adding file: %s", currentFile.toUtf8().constData());
ok = createJob(currentFile, QString(), NULL, n++, totalFiles);
}
*/
//createJobMultiple(droppedFiles);
} }
qDebug("Leave from MainWindow::handleDroppedFiles!"); qDebug("Leave from MainWindow::handleDroppedFiles!");
} }
@ -1043,6 +1053,48 @@ bool MainWindow::createJob(QString &sourceFileName, QString &outputFileName, Opt
return okay; return okay;
} }
/*
* Creates a new job from *multiple* files
*/
bool MainWindow::createJobMultiple(const QStringList &filePathIn)
{
QStringList::ConstIterator iter;
bool applyToAll = false, runImmediately = false;
int counter = 0;
//Add files individually
for(iter = filePathIn.constBegin(); iter != filePathIn.constEnd(); iter++)
{
runImmediately = (countRunningJobs() < (m_preferences.autoRunNextJob ? m_preferences.maxRunningJobCount : 1));
QString sourceFileName(*iter), outputFileName;
if(createJob(sourceFileName, outputFileName, m_options, runImmediately, false, counter++, filePathIn.count(), &applyToAll))
{
if(appendJob(sourceFileName, outputFileName, m_options, runImmediately))
{
if(applyToAll) break;
continue;
}
}
return false;
}
//Add remaining files
while(applyToAll && (iter != filePathIn.constEnd()))
{
const bool runImmediatelyTmp = runImmediately && (countRunningJobs() < (m_preferences.autoRunNextJob ? m_preferences.maxRunningJobCount : 1));
const QString sourceFileName = *iter;
const QString outputFileName = AddJobDialog::generateOutputFileName(sourceFileName, m_recentlyUsed.outputDirectory, m_recentlyUsed.filterIndex, m_preferences.saveToSourcePath);
if(!appendJob(sourceFileName, outputFileName, m_options, runImmediatelyTmp))
{
return false;
}
iter++;
}
return true;
}
/* /*
* Append a new job * Append a new job
*/ */
@ -1079,48 +1131,6 @@ bool MainWindow::appendJob(const QString &sourceFileName, const QString &outputF
return okay; return okay;
} }
/*
* Creates a new job
*/
bool MainWindow::createJobMultiple(const QStringList &filePathIn)
{
//bool ok = true, force = false; int counter = 0;
//
////Add files
//QStringList::ConstIterator iter = filePathIn.constBegin();
//while(ok && (!force) && (iter != filePathIn.constEnd()))
//{
// ok = createJob(*iter, QString(), NULL, ++counter, filePathIn.count(), &force);
// iter++;
//}
//if(force) qWarning("Force mode!");
////Add remaining files
//if(force && (iter != filePathIn.constEnd()))
//{
// QSettings settings(QString("%1/last.ini").arg(x264_data_path()), QSettings::IniFormat);
// QString outDirectory = settings.value("path/directory_saveTo", QDesktopServices::storageLocation(QDesktopServices::MoviesLocation)).toString();
//
// while(iter != filePathIn.constEnd())
// {
// int n = 2;
// QString outBaseName = QFileInfo(*iter).completeBaseName();
// QString outPath = QString("%1/%2.mkv").arg(outDirectory, outBaseName);
// while(QFileInfo(outPath).exists())
// {
// outPath = QString("%1/%2 (%3).mkv").arg(outDirectory, outBaseName, QString::number(n++));
// }
// ok = createJob(*iter, outPath, NULL, ++counter, filePathIn.count(), &force);
// iter++;
// }
//}
//return ok;
return true;
}
/* /*
* Jobs that are not completed (or failed, or aborted) yet * Jobs that are not completed (or failed, or aborted) yet
*/ */

View File

@ -77,6 +77,7 @@ private:
private slots: private slots:
void addButtonPressed(); void addButtonPressed();
void openActionTriggered();
void abortButtonPressed(void); void abortButtonPressed(void);
void browseButtonPressed(void); void browseButtonPressed(void);
void deleteButtonPressed(void); void deleteButtonPressed(void);