Improved saving of new profiles.
This commit is contained in:
parent
c7d9019870
commit
0d22776128
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@
|
|||||||
/*.sdf
|
/*.sdf
|
||||||
/*.suo
|
/*.suo
|
||||||
/*.user
|
/*.user
|
||||||
|
/*.opensdf
|
||||||
|
@ -82,7 +82,7 @@ bool OptionsModel::saveTemplate(OptionsModel *model, const QString &name)
|
|||||||
const QString templateName = name.simplified();
|
const QString templateName = name.simplified();
|
||||||
const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
const QString appDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||||
|
|
||||||
if(templateName.startsWith("<") || templateName.endsWith(">") || templateName.contains("\\") || templateName.contains("/"))
|
if(templateName.contains('<') || templateName.contains('>') || templateName.contains('\\') || templateName.contains('/'))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,21 @@ g_filters[] =
|
|||||||
|
|
||||||
#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 \
|
||||||
|
{ \
|
||||||
|
for(int i = 0; i < cbxTemplate->count(); i++) \
|
||||||
|
{ \
|
||||||
|
OptionsModel* temp = reinterpret_cast<OptionsModel*>(cbxTemplate->itemData(i).value<void*>()); \
|
||||||
|
if(temp == NULL) \
|
||||||
|
{ \
|
||||||
|
cbxTemplate->blockSignals(true); \
|
||||||
|
cbxTemplate->removeItem(i); \
|
||||||
|
cbxTemplate->blockSignals(false); \
|
||||||
|
break; \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Validator
|
// Validator
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@ -333,17 +348,7 @@ void AddJobDialog::templateSelected(void)
|
|||||||
if(options)
|
if(options)
|
||||||
{
|
{
|
||||||
qDebug("Loading options!");
|
qDebug("Loading options!");
|
||||||
for(int i = 0; i < cbxTemplate->model()->rowCount(); i++)
|
REMOVE_USAFED_ITEM;
|
||||||
{
|
|
||||||
OptionsModel* temp = reinterpret_cast<OptionsModel*>(cbxTemplate->itemData(i).value<void*>());
|
|
||||||
if(temp == NULL)
|
|
||||||
{
|
|
||||||
cbxTemplate->blockSignals(true);
|
|
||||||
cbxTemplate->removeItem(i);
|
|
||||||
cbxTemplate->blockSignals(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
restoreOptions(options);
|
restoreOptions(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,16 +360,56 @@ void AddJobDialog::saveTemplateButtonClicked(void)
|
|||||||
qDebug("Saving template");
|
qDebug("Saving template");
|
||||||
QString name = tr("New Template");
|
QString name = tr("New Template");
|
||||||
|
|
||||||
|
OptionsModel *options = new OptionsModel();
|
||||||
|
saveOptions(options);
|
||||||
|
|
||||||
|
if(options->equals(m_defaults))
|
||||||
|
{
|
||||||
|
QMessageBox::warning (this, tr("Default"), tr("It makes no sense to save the defaults!"));
|
||||||
|
cbxTemplate->blockSignals(true);
|
||||||
|
cbxTemplate->setCurrentIndex(0);
|
||||||
|
cbxTemplate->blockSignals(false);
|
||||||
|
REMOVE_USAFED_ITEM;
|
||||||
|
X264_DELETE(options);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < cbxTemplate->count(); i++)
|
||||||
|
{
|
||||||
|
OptionsModel* test = reinterpret_cast<OptionsModel*>(cbxTemplate->itemData(i).value<void*>());
|
||||||
|
if(test != NULL)
|
||||||
|
{
|
||||||
|
if(options->equals(test))
|
||||||
|
{
|
||||||
|
QMessageBox::warning (this, tr("Oups"), tr("<nobr>There already is a template for the current settings!"));
|
||||||
|
cbxTemplate->blockSignals(true);
|
||||||
|
cbxTemplate->setCurrentIndex(i);
|
||||||
|
cbxTemplate->blockSignals(false);
|
||||||
|
REMOVE_USAFED_ITEM;
|
||||||
|
X264_DELETE(options);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
forever
|
forever
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
name = QInputDialog::getText(this, tr("Save Template"), tr("Please enter the name of the template:").leftJustified(160, ' '), QLineEdit::Normal, name, &ok).simplified();
|
name = QInputDialog::getText(this, tr("Save Template"), tr("Please enter the name of the template:").leftJustified(160, ' '), QLineEdit::Normal, name, &ok).simplified();
|
||||||
if(!ok) return;
|
if(!ok)
|
||||||
if(name.startsWith("<") || name.endsWith(">"))
|
{
|
||||||
|
X264_DELETE(options);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(name.contains('<') || name.contains('>') || name.contains('\\') || name.contains('/') || name.contains('"'))
|
||||||
{
|
{
|
||||||
QMessageBox::warning (this, tr("Invalid Name"), tr("Sorry, the name you have entered is invalid!"));
|
QMessageBox::warning (this, tr("Invalid Name"), tr("Sorry, the name you have entered is invalid!"));
|
||||||
while(name.startsWith("<")) name = name.mid(1).trimmed();
|
while(name.contains('<')) name.remove('<');
|
||||||
while(name.endsWith(">")) name = name.left(name.size() - 1).trimmed();
|
while(name.contains('>')) name.remove('>');
|
||||||
|
while(name.contains('\\')) name.remove('\\');
|
||||||
|
while(name.contains('/')) name.remove('/');
|
||||||
|
while(name.contains('"')) name.remove('"');
|
||||||
|
name = name.simplified();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(OptionsModel::templateExists(name))
|
if(OptionsModel::templateExists(name))
|
||||||
@ -375,18 +420,9 @@ void AddJobDialog::saveTemplateButtonClicked(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionsModel *options = new OptionsModel();
|
|
||||||
saveOptions(options);
|
|
||||||
|
|
||||||
if(options->equals(m_defaults))
|
|
||||||
{
|
|
||||||
QMessageBox::warning (this, tr("Default"), tr("It makes no sense to save the defaults!"));
|
|
||||||
X264_DELETE(options);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(!OptionsModel::saveTemplate(options, name))
|
if(!OptionsModel::saveTemplate(options, name))
|
||||||
{
|
{
|
||||||
QMessageBox::warning (this, tr("Save Failed"), tr("Sorry, the template could not be used!"));
|
QMessageBox::critical(this, tr("Save Failed"), tr("Sorry, the template could not be saved!"));
|
||||||
X264_DELETE(options);
|
X264_DELETE(options);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -395,16 +431,9 @@ void AddJobDialog::saveTemplateButtonClicked(void)
|
|||||||
cbxTemplate->blockSignals(true);
|
cbxTemplate->blockSignals(true);
|
||||||
cbxTemplate->insertItem(index, name, QVariant::fromValue<void*>(options));
|
cbxTemplate->insertItem(index, name, QVariant::fromValue<void*>(options));
|
||||||
cbxTemplate->setCurrentIndex(index);
|
cbxTemplate->setCurrentIndex(index);
|
||||||
for(int i = 0; i < cbxTemplate->model()->rowCount(); i++)
|
|
||||||
{
|
|
||||||
OptionsModel* temp = reinterpret_cast<OptionsModel*>(cbxTemplate->itemData(i).value<void*>());
|
|
||||||
if(temp == NULL)
|
|
||||||
{
|
|
||||||
cbxTemplate->removeItem(i);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cbxTemplate->blockSignals(false);
|
cbxTemplate->blockSignals(false);
|
||||||
|
|
||||||
|
REMOVE_USAFED_ITEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddJobDialog::deleteTemplateButtonClicked(void)
|
void AddJobDialog::deleteTemplateButtonClicked(void)
|
||||||
@ -412,7 +441,7 @@ void AddJobDialog::deleteTemplateButtonClicked(void)
|
|||||||
const int index = cbxTemplate->currentIndex();
|
const int index = cbxTemplate->currentIndex();
|
||||||
QString name = cbxTemplate->itemText(index);
|
QString name = cbxTemplate->itemText(index);
|
||||||
|
|
||||||
if(name.startsWith("<") || name.endsWith(">"))
|
if(name.contains('<') || name.contains('>'))
|
||||||
{
|
{
|
||||||
QMessageBox::warning (this, tr("Invalid Item"), tr("Sorry, the selected item cannot be deleted!"));
|
QMessageBox::warning (this, tr("Invalid Item"), tr("Sorry, the selected item cannot be deleted!"));
|
||||||
return;
|
return;
|
||||||
|
@ -140,8 +140,10 @@ MainWindow::~MainWindow(void)
|
|||||||
// Slots
|
// Slots
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void MainWindow::addButtonPressed(const QString &filePath)
|
void MainWindow::addButtonPressed(const QString &filePath, bool *ok)
|
||||||
{
|
{
|
||||||
|
if(ok) *ok = false;
|
||||||
|
|
||||||
AddJobDialog *addDialog = new AddJobDialog(this, m_options);
|
AddJobDialog *addDialog = new AddJobDialog(this, m_options);
|
||||||
addDialog->setRunImmediately(!havePendingJobs());
|
addDialog->setRunImmediately(!havePendingJobs());
|
||||||
if(!filePath.isEmpty()) addDialog->setSourceFile(filePath);
|
if(!filePath.isEmpty()) addDialog->setSourceFile(filePath);
|
||||||
@ -161,6 +163,8 @@ void MainWindow::addButtonPressed(const QString &filePath)
|
|||||||
|
|
||||||
QModelIndex newIndex = m_jobList->insertJob(thrd);
|
QModelIndex newIndex = m_jobList->insertJob(thrd);
|
||||||
|
|
||||||
|
if(newIndex.isValid())
|
||||||
|
{
|
||||||
if(addDialog->runImmediately())
|
if(addDialog->runImmediately())
|
||||||
{
|
{
|
||||||
jobsView->selectRow(newIndex.row());
|
jobsView->selectRow(newIndex.row());
|
||||||
@ -169,6 +173,8 @@ void MainWindow::addButtonPressed(const QString &filePath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_label->setVisible(false);
|
m_label->setVisible(false);
|
||||||
|
if(ok) *ok = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
X264_DELETE(addDialog);
|
X264_DELETE(addDialog);
|
||||||
@ -279,7 +285,7 @@ void MainWindow::showAbout(void)
|
|||||||
|
|
||||||
forever
|
forever
|
||||||
{
|
{
|
||||||
int ret = QMessageBox::information(this, tr("About..."), text.replace("-", "−"), tr("Abou x264"), tr("About Qt"), tr("Close"));
|
int ret = QMessageBox::information(this, tr("About..."), text.replace("-", "−"), tr("About x264"), tr("About Qt"), tr("Close"));
|
||||||
|
|
||||||
switch(ret)
|
switch(ret)
|
||||||
{
|
{
|
||||||
@ -289,7 +295,7 @@ void MainWindow::showAbout(void)
|
|||||||
text2 += tr("<nobr><tt>x264, the best H.264/AVC encoder. Copyright (c) 2003-2011 x264 project.<br>");
|
text2 += tr("<nobr><tt>x264, the best H.264/AVC encoder. Copyright (c) 2003-2011 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=\"http://x264licensing.com/\">http://x264licensing.com/</a> for obtaining a commercial x264 license!<br></tt></nobr>");
|
text2 += tr("Please visit <a href=\"http://x264licensing.com/\">http://x264licensing.com/</a> for obtaining a <u>commercial</u> x264 license!<br></tt></nobr>");
|
||||||
QMessageBox::information(this, tr("About x264"), text2.replace("-", "−"), tr("Close"));
|
QMessageBox::information(this, tr("About x264"), text2.replace("-", "−"), tr("Close"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -349,6 +355,7 @@ void MainWindow::init(void)
|
|||||||
//Check all binaries
|
//Check all binaries
|
||||||
while(!binaries.isEmpty())
|
while(!binaries.isEmpty())
|
||||||
{
|
{
|
||||||
|
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
|
||||||
QString current = binaries.takeFirst();
|
QString current = binaries.takeFirst();
|
||||||
QFile *file = new QFile(QString("%1/toolset/%2").arg(m_appDir, current));
|
QFile *file = new QFile(QString("%1/toolset/%2").arg(m_appDir, current));
|
||||||
if(file->open(QIODevice::ReadOnly))
|
if(file->open(QIODevice::ReadOnly))
|
||||||
@ -509,11 +516,12 @@ void MainWindow::dropEvent(QDropEvent *event)
|
|||||||
|
|
||||||
droppedFiles.sort();
|
droppedFiles.sort();
|
||||||
|
|
||||||
while(!droppedFiles.isEmpty())
|
bool ok = true;
|
||||||
|
while((!droppedFiles.isEmpty()) && ok)
|
||||||
{
|
{
|
||||||
QString currentFile = droppedFiles.takeFirst();
|
QString currentFile = droppedFiles.takeFirst();
|
||||||
qDebug("Adding file: %s", currentFile.toUtf8().constData());
|
qDebug("Adding file: %s", currentFile.toUtf8().constData());
|
||||||
addButtonPressed(currentFile);
|
addButtonPressed(currentFile, &ok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ private:
|
|||||||
bool havePendingJobs(void);
|
bool havePendingJobs(void);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void addButtonPressed(const QString &filePath = QString());
|
void addButtonPressed(const QString &filePath = QString(), bool *ok = NULL);
|
||||||
void abortButtonPressed(void);
|
void abortButtonPressed(void);
|
||||||
void copyLogToClipboard(bool checked);
|
void copyLogToClipboard(bool checked);
|
||||||
void init(void);
|
void init(void);
|
||||||
|
Loading…
Reference in New Issue
Block a user