giant rendering overhaul and many small fixes
This commit is contained in:
+116
-106
@@ -32,142 +32,152 @@
|
||||
#include "project/footage.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
ProxyDialog::ProxyDialog(QWidget *parent, const QVector<FootagePtr> &footage) :
|
||||
QDialog(parent),
|
||||
selected_footage(footage)
|
||||
ProxyDialog::ProxyDialog(QWidget *parent, const QVector<Media*> &media) :
|
||||
QDialog(parent),
|
||||
selected_media(media)
|
||||
{
|
||||
// set dialog title
|
||||
setWindowTitle(tr("Create Proxy"));
|
||||
// set dialog title
|
||||
setWindowTitle(tr("Create Proxy"));
|
||||
|
||||
// set proxy folder name to "Proxy", depending on the user's language
|
||||
proxy_folder_name = tr("Proxy");
|
||||
// set proxy folder name to "Proxy", depending on the user's language
|
||||
proxy_folder_name = tr("Proxy");
|
||||
|
||||
// set up dialog's layout
|
||||
QGridLayout* layout = new QGridLayout(this);
|
||||
// set up dialog's layout
|
||||
QGridLayout* layout = new QGridLayout(this);
|
||||
|
||||
// set the video dimensions of the proxy
|
||||
layout->addWidget(new QLabel(tr("Dimensions:"), this), 0, 0);
|
||||
// set the video dimensions of the proxy
|
||||
layout->addWidget(new QLabel(tr("Dimensions:"), this), 0, 0);
|
||||
|
||||
size_combobox = new QComboBox(this);
|
||||
size_combobox->addItem(tr("Same Size as Source"), 1.0);
|
||||
size_combobox->addItem(tr("Half Resolution (1/2)"), 0.5);
|
||||
size_combobox->addItem(tr("Quarter Resolution (1/4)"), 0.25);
|
||||
size_combobox->addItem(tr("Eighth Resolution (1/8)"), 0.125);
|
||||
size_combobox->addItem(tr("Sixteenth Resolution (1/16)"), 0.0625);
|
||||
layout->addWidget(size_combobox, 0, 1);
|
||||
size_combobox = new QComboBox(this);
|
||||
size_combobox->addItem(tr("Same Size as Source"), 1.0);
|
||||
size_combobox->addItem(tr("Half Resolution (1/2)"), 0.5);
|
||||
size_combobox->addItem(tr("Quarter Resolution (1/4)"), 0.25);
|
||||
size_combobox->addItem(tr("Eighth Resolution (1/8)"), 0.125);
|
||||
size_combobox->addItem(tr("Sixteenth Resolution (1/16)"), 0.0625);
|
||||
layout->addWidget(size_combobox, 0, 1);
|
||||
|
||||
// set the desired format of the proxy to create
|
||||
layout->addWidget(new QLabel(tr("Format:"), this), 1, 0);
|
||||
// set the desired format of the proxy to create
|
||||
layout->addWidget(new QLabel(tr("Format:"), this), 1, 0);
|
||||
|
||||
format_combobox = new QComboBox(this);
|
||||
format_combobox->addItem(tr("ProRes HQ"));
|
||||
// format_combobox->addItem(tr("ProRes SQ"));
|
||||
// format_combobox->addItem(tr("ProRes LT"));
|
||||
// format_combobox->addItem(tr("DNxHD"));
|
||||
// format_combobox->addItem(tr("H.264"));
|
||||
layout->addWidget(format_combobox, 1, 1);
|
||||
format_combobox = new QComboBox(this);
|
||||
format_combobox->addItem(tr("ProRes HQ"));
|
||||
// format_combobox->addItem(tr("ProRes SQ"));
|
||||
// format_combobox->addItem(tr("ProRes LT"));
|
||||
// format_combobox->addItem(tr("DNxHD"));
|
||||
// format_combobox->addItem(tr("H.264"));
|
||||
layout->addWidget(format_combobox, 1, 1);
|
||||
|
||||
// set the location to place the proxies
|
||||
layout->addWidget(new QLabel(tr("Location:"), this), 2, 0);
|
||||
// set the location to place the proxies
|
||||
layout->addWidget(new QLabel(tr("Location:"), this), 2, 0);
|
||||
|
||||
location_combobox = new QComboBox(this);
|
||||
location_combobox->addItem(tr("Same as Source (in \"%1\" folder)").arg(proxy_folder_name));
|
||||
location_combobox->addItem("");
|
||||
connect(location_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(location_changed(int)));
|
||||
layout->addWidget(location_combobox, 2, 1);
|
||||
location_combobox = new QComboBox(this);
|
||||
location_combobox->addItem(tr("Same as Source (in \"%1\" folder)").arg(proxy_folder_name));
|
||||
location_combobox->addItem("");
|
||||
connect(location_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(location_changed(int)));
|
||||
layout->addWidget(location_combobox, 2, 1);
|
||||
|
||||
// location_changed will set the default "location" items
|
||||
location_changed(0);
|
||||
// location_changed will set the default "location" items
|
||||
location_changed(0);
|
||||
|
||||
// set up dialog buttons
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
||||
buttons->setCenterButtons(true);
|
||||
layout->addWidget(buttons, 3, 0, 1, 2);
|
||||
connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
// set up dialog buttons
|
||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
||||
buttons->setCenterButtons(true);
|
||||
layout->addWidget(buttons, 3, 0, 1, 2);
|
||||
connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
}
|
||||
|
||||
void ProxyDialog::accept() {
|
||||
QVector<ProxyInfo> info_list;
|
||||
QVector<ProxyInfo> info_list;
|
||||
|
||||
// set to TRUE if any existing proxies exist and the user chooses to overwrite all of them
|
||||
bool overwrite_all_existing = false;
|
||||
// set to TRUE if any existing proxies exist and the user chooses to overwrite all of them
|
||||
bool overwrite_all_existing = false;
|
||||
|
||||
for (int i=0;i<selected_footage.size();i++) {
|
||||
// loop through selected footage and send info to the proxy queue
|
||||
for (int i=0;i<selected_media.size();i++) {
|
||||
// loop through selected footage and send info to the proxy queue
|
||||
|
||||
ProxyInfo info;
|
||||
ProxyInfo info;
|
||||
|
||||
// fill info struct based on user input
|
||||
info.footage = selected_footage.at(i);
|
||||
info.codec_type = 0;
|
||||
info.size_multiplier = size_combobox->currentData().toDouble();
|
||||
// fill info struct based on user input
|
||||
info.media = selected_media.at(i);
|
||||
info.codec_type = 0;
|
||||
info.size_multiplier = size_combobox->currentData().toDouble();
|
||||
|
||||
QString base_footage_fn = QFileInfo(selected_footage.at(i)->url).baseName();
|
||||
FootagePtr footage = selected_media.at(i)->to_footage();
|
||||
|
||||
// TEMPORARILY hardcoded proxy format
|
||||
base_footage_fn.append(".mov");
|
||||
QString base_footage_fn = QFileInfo(footage->url).baseName();
|
||||
|
||||
// determine path from input
|
||||
if (custom_location.isEmpty()) {
|
||||
// use same as source (proxy subfolder)
|
||||
// TEMPORARILY hardcoded proxy format
|
||||
base_footage_fn.append(".mov");
|
||||
|
||||
// generate full path from footage path and proxy_folder_name's translated "Proxy"
|
||||
info.path = QDir(QFileInfo(selected_footage.at(i)->url).dir().filePath(proxy_folder_name)).filePath(base_footage_fn);
|
||||
} else {
|
||||
// use existing location
|
||||
info.path = QDir(custom_location).filePath(base_footage_fn);
|
||||
}
|
||||
// determine path from input
|
||||
if (custom_location.isEmpty()) {
|
||||
// use same as source (proxy subfolder)
|
||||
|
||||
// if the proposed proxy file already exists & user didn't select YesToAll box
|
||||
if (QFileInfo::exists(info.path) && !overwrite_all_existing){
|
||||
int rtn = QMessageBox::warning( this,
|
||||
tr("Proxy file exists"),
|
||||
tr("The file \"%1\" already exists. Do you wish to replace it?").arg(info.path),
|
||||
QMessageBox::YesToAll | QMessageBox::Yes | QMessageBox::No);
|
||||
// generate full path from footage path and proxy_folder_name's translated "Proxy"
|
||||
info.path = QDir(QFileInfo(footage->url).dir().filePath(proxy_folder_name)).filePath(base_footage_fn);
|
||||
} else {
|
||||
// use existing location
|
||||
info.path = QDir(custom_location).filePath(base_footage_fn);
|
||||
}
|
||||
|
||||
switch (rtn){
|
||||
case QMessageBox::Yes:
|
||||
// continue as normal, proxy generator will automatically overwrite this file
|
||||
break;
|
||||
case QMessageBox::YesToAll:
|
||||
// continue as normal, also set variable so that above messagebox is not shown again
|
||||
overwrite_all_existing = true;
|
||||
break;
|
||||
case QMessageBox::No:
|
||||
// return to dialog without closing or starting any proxy generation
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if the proposed proxy file already exists & user didn't select YesToAll box
|
||||
if (QFileInfo::exists(info.path) && !overwrite_all_existing){
|
||||
int rtn = QMessageBox::warning( this,
|
||||
tr("Proxy file exists"),
|
||||
tr("The file \"%1\" already exists. Do you wish to replace it?").arg(info.path),
|
||||
QMessageBox::YesToAll | QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
// send to proxy generator thread
|
||||
info_list.append(info);
|
||||
}
|
||||
switch (rtn){
|
||||
case QMessageBox::Yes:
|
||||
// continue as normal, proxy generator will automatically overwrite this file
|
||||
break;
|
||||
case QMessageBox::YesToAll:
|
||||
// continue as normal, also set variable so that above messagebox is not shown again
|
||||
overwrite_all_existing = true;
|
||||
break;
|
||||
case QMessageBox::No:
|
||||
// return to dialog without closing or starting any proxy generation
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// all proxy info checks out, queue it with the proxy generator
|
||||
for (int i=0;i<info_list.size();i++) {
|
||||
info_list.at(i).footage->proxy = true;
|
||||
info_list.at(i).footage->proxy_path.clear();
|
||||
// send to proxy generator thread
|
||||
info_list.append(info);
|
||||
}
|
||||
|
||||
proxy_generator.queue(info_list.at(i));
|
||||
}
|
||||
// all proxy info checks out, queue it with the proxy generator
|
||||
for (int i=0;i<info_list.size();i++) {
|
||||
FootagePtr footage = info_list.at(i).media->to_footage();
|
||||
footage->proxy = true;
|
||||
footage->proxy_path.clear();
|
||||
|
||||
olive::MainWindow->setWindowModified(true);
|
||||
olive::proxy_generator.queue(info_list.at(i));
|
||||
}
|
||||
|
||||
QDialog::accept();
|
||||
olive::MainWindow->setWindowModified(true);
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void ProxyDialog::location_changed(int i) {
|
||||
custom_location.clear();
|
||||
if (i == 1) {
|
||||
QString s = QFileDialog::getExistingDirectory(this);
|
||||
if (s.isEmpty()) {
|
||||
location_combobox->setCurrentIndex(0);
|
||||
} else {
|
||||
location_combobox->setItemText(1, s);
|
||||
custom_location = s;
|
||||
}
|
||||
} else {
|
||||
location_combobox->setItemText(1, tr("Custom Location"));
|
||||
}
|
||||
// clear any custom location - either the user picked a new one or chose not a custom location
|
||||
custom_location.clear();
|
||||
|
||||
if (i == 1) {
|
||||
// if the user picked a custom location, ask which directory
|
||||
QString s = QFileDialog::getExistingDirectory(this);
|
||||
|
||||
if (s.isEmpty()) {
|
||||
// if the user didn't input anything, set the combobox back to default
|
||||
location_combobox->setCurrentIndex(0);
|
||||
} else {
|
||||
// if the user chose a custom location, set the combobox text to it and custom_location for future usage
|
||||
location_combobox->setItemText(1, s);
|
||||
custom_location = s;
|
||||
}
|
||||
} else {
|
||||
// if the user doesn't picks something other than custom location, set this string back to default for clearer UX
|
||||
location_combobox->setItemText(1, tr("Custom Location"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user