Make it possible to save to the name of an existing template.

This commit is contained in:
LoRd_MuldeR 2012-02-04 19:09:27 +01:00
parent fa9488fb78
commit d7d5f27756
7 changed files with 47 additions and 17 deletions

Binary file not shown.

View File

@ -409,7 +409,7 @@ const char *x264_version_time(void)
bool x264_is_prerelease(void)
{
return (VER_x264_PRE_RELEASE);
return (VER_X264_PRE_RELEASE);
}
/*

View File

@ -233,12 +233,12 @@ QModelIndex JobListModel::insertJob(EncodeThread *thread)
switch(thread->options()->rcMode())
{
case OptionsModel::RCMode_CQ:
config = QString("CQ@%1").arg(QString::number(thread->options()->quantizer()));
break;
case OptionsModel::RCMode_CRF:
config = QString("CRF@%1").arg(QString::number(thread->options()->quantizer()));
break;
case OptionsModel::RCMode_CQ:
config = QString("CQ@%1").arg(QString::number(qRound(thread->options()->quantizer())));
break;
case OptionsModel::RCMode_2Pass:
config = QString("2Pass@%1").arg(QString::number(thread->options()->bitrate()));
break;

View File

@ -213,7 +213,7 @@ void EncodeThread::encode(void)
log(tr("\nWARNING: Your revision of x264 uses an unsupported core (API) version, take care!"));
log(tr("This application works best with x264 core (API) version %2.").arg(QString::number(VER_X264_CURRENT_API)));
}
if((revision_avs2yuv != UINT_MAX) && ((revision_avs2yuv % REV_MULT) != VER_x264_AVS2YUV_VER))
if((revision_avs2yuv != UINT_MAX) && ((revision_avs2yuv % REV_MULT) != VER_X264_AVS2YUV_VER))
{
log(tr("\nERROR: Your version of avs2yuv is unsupported (Required version: v0.24 BugMaster's mod 2)"));
log(tr("You can find the required version at: http://komisar.gin.by/tools/avs2yuv/"));

View File

@ -24,6 +24,6 @@
#define VER_X264_MINIMUM_REV (2146)
#define VER_X264_CURRENT_API (120)
#define VER_x264_AVS2YUV_VER (242)
#define VER_X264_AVS2YUV_VER (242)
#define VER_x264_PRE_RELEASE (0)
#define VER_X264_PRE_RELEASE (0)

View File

@ -364,13 +364,19 @@ void AddJobDialog::saveTemplateButtonClicked(void)
{
qDebug("Saving template");
QString name = tr("New Template");
int n = 2;
while(OptionsModel::templateExists(name))
{
name = tr("New Template (%1)").arg(QString::number(n++));
}
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!"));
QMessageBox::warning (this, tr("Oups"), tr("<nobr>It makes no sense to save the default settings!</nobr>"));
cbxTemplate->blockSignals(true);
cbxTemplate->setCurrentIndex(0);
cbxTemplate->blockSignals(false);
@ -386,7 +392,7 @@ void AddJobDialog::saveTemplateButtonClicked(void)
{
if(options->equals(test))
{
QMessageBox::warning (this, tr("Oups"), tr("<nobr>There already is a template for the current settings!"));
QMessageBox::warning (this, tr("Oups"), tr("<nobr>There already is a template for the current settings!</nobr>"));
cbxTemplate->blockSignals(true);
cbxTemplate->setCurrentIndex(i);
cbxTemplate->blockSignals(false);
@ -400,7 +406,7 @@ void AddJobDialog::saveTemplateButtonClicked(void)
forever
{
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(144, ' '), QLineEdit::Normal, name, &ok).simplified();
if(!ok)
{
X264_DELETE(options);
@ -408,7 +414,7 @@ void AddJobDialog::saveTemplateButtonClicked(void)
}
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("<nobr>Sorry, the name you have entered is invalid!</nobr>"));
while(name.contains('<')) name.remove('<');
while(name.contains('>')) name.remove('>');
while(name.contains('\\')) name.remove('\\');
@ -419,9 +425,12 @@ void AddJobDialog::saveTemplateButtonClicked(void)
}
if(OptionsModel::templateExists(name))
{
QMessageBox::warning (this, tr("Already Exists"), tr("Sorry, a template of that name already exists!"));
int ret = QMessageBox::warning (this, tr("Already Exists"), tr("<nobr>A template of that name already exists! Overwrite?</nobr>"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if(ret != QMessageBox::Yes)
{
continue;
}
}
break;
}
@ -434,8 +443,22 @@ void AddJobDialog::saveTemplateButtonClicked(void)
int index = cbxTemplate->model()->rowCount();
cbxTemplate->blockSignals(true);
for(int i = 0; i < cbxTemplate->count(); i++)
{
if(cbxTemplate->itemText(i).compare(name, Qt::CaseInsensitive) == 0)
{
index = -1; //Do not append new template
OptionsModel *oldItem = reinterpret_cast<OptionsModel*>(cbxTemplate->itemData(i).value<void*>());
cbxTemplate->setItemData(i, QVariant::fromValue<void*>(options));
cbxTemplate->setCurrentIndex(i);
X264_DELETE(oldItem);
}
}
if(index >= 0)
{
cbxTemplate->insertItem(index, name, QVariant::fromValue<void*>(options));
cbxTemplate->setCurrentIndex(index);
}
cbxTemplate->blockSignals(false);
REMOVE_USAFED_ITEM;
@ -446,12 +469,19 @@ void AddJobDialog::deleteTemplateButtonClicked(void)
const int index = cbxTemplate->currentIndex();
QString name = cbxTemplate->itemText(index);
if(name.contains('<') || name.contains('>'))
if(name.contains('<') || name.contains('>') || name.contains('\\') || name.contains('/'))
{
QMessageBox::warning (this, tr("Invalid Item"), tr("Sorry, the selected item cannot be deleted!"));
return;
}
int ret = QMessageBox::question (this, tr("Delete Template"), tr("<nobr>Do you really want to delete the selected template?</nobr>"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if(ret != QMessageBox::Yes)
{
return;
}
OptionsModel::deleteTemplate(name);
OptionsModel *item = reinterpret_cast<OptionsModel*>(cbxTemplate->itemData(index).value<void*>());
cbxTemplate->removeItem(index);

View File

@ -63,7 +63,7 @@ private:
unsigned int countRunningJobs(void);
private slots:
void addButtonPressed(const QString &filePath = QString(), int fileNo = 0, int fileTotal = 0, bool *ok = NULL);
void addButtonPressed(const QString &filePath = QString(), int fileNo = -1, int fileTotal = 0, bool *ok = NULL);
void abortButtonPressed(void);
void browseButtonPressed(void);
void deleteButtonPressed(void);