From fac921383348e997f2e163358484a5f68da7af7f Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 30 Jan 2019 13:44:23 +1100 Subject: [PATCH] added proxy dialog --- dialogs/proxydialog.cpp | 74 +++++++++++++++++++++++++++++++++++++++ dialogs/proxydialog.h | 30 ++++++++++++++++ olive.pro | 6 ++-- project/sourcescommon.cpp | 13 +++++++ project/sourcescommon.h | 37 ++++++++++---------- 5 files changed, 140 insertions(+), 20 deletions(-) create mode 100644 dialogs/proxydialog.cpp create mode 100644 dialogs/proxydialog.h diff --git a/dialogs/proxydialog.cpp b/dialogs/proxydialog.cpp new file mode 100644 index 000000000..bf3233a8b --- /dev/null +++ b/dialogs/proxydialog.cpp @@ -0,0 +1,74 @@ +#include "proxydialog.h" + +#include +#include +#include +#include +#include + +ProxyDialog::ProxyDialog(QWidget *parent, const QVector &footage) : QDialog(parent) { + // 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 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); + + QComboBox* 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); + + QComboBox* 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); + + 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); + + // 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::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")); + } +} diff --git a/dialogs/proxydialog.h b/dialogs/proxydialog.h new file mode 100644 index 000000000..fa994d1e1 --- /dev/null +++ b/dialogs/proxydialog.h @@ -0,0 +1,30 @@ +#ifndef PROXYDIALOG_H +#define PROXYDIALOG_H + +#include +#include +#include + +struct Footage; + +class ProxyDialog : public QDialog { + Q_OBJECT +public: + ProxyDialog(QWidget* parent, const QVector& footage); +private: + // user's dimensions + QComboBox* size_combobox; + + // allows users to set the location to store proxies + QComboBox* location_combobox; + + // stores the custom location to store proxies if the user sets a custom location + QString custom_location; + + // stores the subdirectory to be made next to the source in the user's language + QString proxy_folder_name; +private slots: + void location_changed(int i); +}; + +#endif // PROXYDIALOG_H diff --git a/olive.pro b/olive.pro index 126c43d5f..423b5dfac 100644 --- a/olive.pro +++ b/olive.pro @@ -133,7 +133,8 @@ SOURCES += \ project/effectloaders.cpp \ io/crossplatformlib.cpp \ effects/internal/vsthost.cpp \ - ui/flowlayout.cpp + ui/flowlayout.cpp \ + dialogs/proxydialog.cpp HEADERS += \ mainwindow.h \ @@ -234,7 +235,8 @@ HEADERS += \ project/effectloaders.h \ io/crossplatformlib.h \ effects/internal/vsthost.h \ - ui/flowlayout.h + ui/flowlayout.h \ + dialogs/proxydialog.h FORMS += diff --git a/project/sourcescommon.cpp b/project/sourcescommon.cpp index bb557381a..18462b889 100644 --- a/project/sourcescommon.cpp +++ b/project/sourcescommon.cpp @@ -9,6 +9,7 @@ #include "panels/viewer.h" #include "project/projectfilter.h" #include "io/config.h" +#include "dialogs/proxydialog.h" #include "mainwindow.h" #include @@ -126,6 +127,11 @@ void SourcesCommon::show_context_menu(QWidget* parent, const QModelIndexList& it if (all_footage) { QAction* delete_footage_from_sequences = menu.addAction(tr("Delete All Clips Using This Media")); QObject::connect(delete_footage_from_sequences, SIGNAL(triggered(bool)), project_parent, SLOT(delete_clips_using_selected_media())); + + QMenu* proxies = menu.addMenu(tr("Proxy")); + proxies->addAction(tr("Create Proxy"), this, SLOT(open_create_proxy_dialog())); +// proxies->addAction(tr("Modify Proxy")); +// proxies->addAction(tr("Restore Original")); } // delete media @@ -293,3 +299,10 @@ void SourcesCommon::item_renamed(Media* item) { editing_item = nullptr; } } + +void SourcesCommon::open_create_proxy_dialog() { + QVector selected_footage; + + ProxyDialog pd(mainWindow, selected_footage); + pd.exec(); +} diff --git a/project/sourcescommon.h b/project/sourcescommon.h index 4522efdfa..aa740f1d9 100644 --- a/project/sourcescommon.h +++ b/project/sourcescommon.h @@ -11,29 +11,30 @@ class QAbstractItemView; class QDropEvent; class SourcesCommon : public QObject { - Q_OBJECT + Q_OBJECT public: - SourcesCommon(Project *parent); - QAbstractItemView* view; - void show_context_menu(QWidget* parent, const QModelIndexList &items); + SourcesCommon(Project *parent); + QAbstractItemView* view; + void show_context_menu(QWidget* parent, const QModelIndexList &items); - void mousePressEvent(QMouseEvent* e); - void mouseDoubleClickEvent(QMouseEvent* e, const QModelIndexList& selected_items); - void dropEvent(QWidget *parent, QDropEvent* e, const QModelIndex& drop_item, const QModelIndexList &items); + void mousePressEvent(QMouseEvent* e); + void mouseDoubleClickEvent(QMouseEvent* e, const QModelIndexList& selected_items); + void dropEvent(QWidget *parent, QDropEvent* e, const QModelIndex& drop_item, const QModelIndexList &items); - void item_click(Media* m, const QModelIndex &index); + void item_click(Media* m, const QModelIndex &index); private slots: - void create_seq_from_selected(); - void reveal_in_browser(); - void rename_interval(); - void item_renamed(Media *item); + void create_seq_from_selected(); + void reveal_in_browser(); + void rename_interval(); + void item_renamed(Media *item); + void open_create_proxy_dialog(); private: - Media* editing_item; - QModelIndex editing_index; - QModelIndexList selected_items; - Project* project_parent; - void stop_rename_timer(); - QTimer rename_timer; + Media* editing_item; + QModelIndex editing_index; + QModelIndexList selected_items; + Project* project_parent; + void stop_rename_timer(); + QTimer rename_timer; }; #endif // SOURCESCOMMON_H