Merge branch 'master' into resizablebars

This commit is contained in:
itsmattkc
2018-12-26 18:44:15 +11:00
committed by GitHub
46 changed files with 2823 additions and 2456 deletions
+9
View File
@@ -0,0 +1,9 @@
#include "otreeview.h"
OTreeView::OTreeView(QWidget *parent) : QTreeView(parent) {
setSortingEnabled(true);
sortByColumn(0, Qt::AscendingOrder);
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu()));
connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(item_click(const QModelIndex&)));
}
+16
View File
@@ -0,0 +1,16 @@
#ifndef OTREEVIEW_H
#define OTREEVIEW_H
#include <QTreeView>
#include "ui/sourcetable.h"
class OTreeView : public QTreeView {
Q_OBJECT
public:
OTreeView(QWidget* parent = 0);
private:
};
#endif // OTREEVIEW_H
+67
View File
@@ -0,0 +1,67 @@
#include "sourceiconview.h"
#include <QMimeData>
#include "panels/project.h"
#include "project/media.h"
#include "project/sourcescommon.h"
#include "debug.h"
SourceIconView::SourceIconView(QWidget *parent) : QListView(parent) {
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(item_click(const QModelIndex&)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu()));
}
void SourceIconView::show_context_menu() {
project_parent->sources_common->show_context_menu(this, selectedIndexes());
}
void SourceIconView::item_click(const QModelIndex& index) {
if (selectionModel()->selectedRows().size() == 1 && index.column() == 0) {
project_parent->sources_common->item_click(project_parent->item_to_media(index), index);
}
}
void SourceIconView::mousePressEvent(QMouseEvent* event) {
project_parent->sources_common->mousePressEvent(event);
if (!indexAt(event->pos()).isValid()) selectionModel()->clear();
QListView::mousePressEvent(event);
}
void SourceIconView::dragEnterEvent(QDragEnterEvent *event) {
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
} else {
QListView::dragEnterEvent(event);
}
}
void SourceIconView::dragMoveEvent(QDragMoveEvent *event) {
if (event->mimeData()->hasUrls()) {
event->acceptProposedAction();
} else {
QListView::dragMoveEvent(event);
}
}
void SourceIconView::dropEvent(QDropEvent* event) {
QModelIndex drop_item = indexAt(event->pos());
if (!drop_item.isValid()) drop_item = rootIndex();
project_parent->sources_common->dropEvent(this, event, drop_item, selectedIndexes());
}
void SourceIconView::mouseDoubleClickEvent(QMouseEvent *event) {
bool default_behavior = true;
if (selectedIndexes().size() == 1) {
Media* m = project_parent->item_to_media(selectedIndexes().at(0));
if (m->get_type() == MEDIA_TYPE_FOLDER) {
default_behavior = false;
setRootIndex(selectedIndexes().at(0));
emit changed_root();
}
}
if (default_behavior) {
project_parent->sources_common->mouseDoubleClickEvent(event, selectedIndexes());
}
}
+26
View File
@@ -0,0 +1,26 @@
#ifndef SOURCEICONVIEW_H
#define SOURCEICONVIEW_H
#include <QListView>
class Project;
class SourceIconView : public QListView {
Q_OBJECT
public:
SourceIconView(QWidget* parent = 0);
Project* project_parent;
void mousePressEvent(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent* event);
signals:
void changed_root();
private slots:
void show_context_menu();
void item_click(const QModelIndex& index);
};
#endif // SOURCEICONVIEW_H
+7 -243
View File
@@ -11,6 +11,7 @@
#include "mainwindow.h"
#include "io/config.h"
#include "project/media.h"
#include "project/sourcescommon.h"
#include "debug.h"
#include <QDragEnterEvent>
@@ -25,193 +26,30 @@
#include <QProcess>
SourceTable::SourceTable(QWidget* parent) : QTreeView(parent) {
editing_item = NULL;
setSortingEnabled(true);
sortByColumn(0, Qt::AscendingOrder);
rename_timer.setInterval(1000);
setContextMenuPolicy(Qt::CustomContextMenu);
connect(&rename_timer, SIGNAL(timeout()), this, SLOT(rename_interval()));
connect(this, SIGNAL(clicked(const QModelIndex&)), this, SLOT(item_click(const QModelIndex&)));
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(show_context_menu()));
}
void SourceTable::show_context_menu() {
QMenu menu(this);
QAction* import_action = menu.addAction("Import...");
connect(import_action, SIGNAL(triggered(bool)), project_parent, SLOT(import_dialog()));
QAction* new_folder_action = menu.addAction("New Folder...");
connect(new_folder_action, SIGNAL(triggered(bool)), mainWindow, SLOT(on_actionFolder_triggered()));
QModelIndexList selected_items = selectionModel()->selectedRows();
if (selected_items.size() > 0) {
Media* m = project_parent->item_to_media(selected_items.at(0));
if (selected_items.size() == 1) {
// replace footage
int type = m->get_type();
if (type == MEDIA_TYPE_FOOTAGE) {
QAction* replace_action = menu.addAction("Replace/Relink Media");
connect(replace_action, SIGNAL(triggered(bool)), project_parent, SLOT(replace_selected_file()));
#if defined(Q_OS_WIN)
QAction* reveal_in_explorer = menu.addAction("Reveal in Explorer");
#elif defined(Q_OS_MAC)
QAction* reveal_in_explorer = menu.addAction("Reveal in Finder");
#else
QAction* reveal_in_explorer = menu.addAction("Reveal in File Manager");
#endif
connect(reveal_in_explorer, SIGNAL(triggered(bool)), this, SLOT(reveal_in_browser()));
}
if (type != MEDIA_TYPE_FOLDER) {
QAction* replace_clip_media = menu.addAction("Replace Clips Using This Media");
connect(replace_clip_media, SIGNAL(triggered(bool)), project_parent, SLOT(replace_clip_media()));
}
}
// duplicate item
bool all_sequences = true;
bool all_footage = true;
for (int i=0;i<selected_items.size();i++) {
if (m->get_type() != MEDIA_TYPE_SEQUENCE) {
all_sequences = false;
}
if (m->get_type() != MEDIA_TYPE_FOOTAGE) {
all_footage = false;
}
}
// create sequence from
QAction* create_seq_from = menu.addAction("Create Sequence With This Media");
connect(create_seq_from, SIGNAL(triggered(bool)), this, SLOT(create_seq_from_selected()));
// ONLY sequences are selected
if (all_sequences) {
// ONLY sequences are selected
QAction* duplicate_action = menu.addAction("Duplicate");
connect(duplicate_action, SIGNAL(triggered(bool)), project_parent, SLOT(duplicate_selected()));
}
// ONLY footage is selected
if (all_footage) {
QAction* delete_footage_from_sequences = menu.addAction("Delete All Clips Using This Media");
connect(delete_footage_from_sequences, SIGNAL(triggered(bool)), project_parent, SLOT(delete_clips_using_selected_media()));
}
// delete media
QAction* delete_action = menu.addAction("Delete");
connect(delete_action, SIGNAL(triggered(bool)), project_parent, SLOT(delete_selected_media()));
if (selected_items.size() == 1) {
QAction* properties_action = menu.addAction("Properties...");
connect(properties_action, SIGNAL(triggered(bool)), project_parent, SLOT(open_properties()));
}
}
menu.exec(QCursor::pos());
project_parent->sources_common->show_context_menu(this, selectionModel()->selectedRows());
}
void SourceTable::create_seq_from_selected() {
QModelIndexList selected_items = selectionModel()->selectedRows();
if (!selected_items.isEmpty()) {
QVector<Media*> media_list;
for (int i=0;i<selected_items.size();i++) {
media_list.append(project_parent->item_to_media(selected_items.at(i)));
}
ComboAction* ca = new ComboAction();
Sequence* s = create_sequence_from_media(media_list);
// add clips to it
panel_timeline->create_ghosts_from_media(s, 0, media_list);
panel_timeline->add_clips_from_ghosts(ca, s);
project_parent->new_sequence(ca, s, true, NULL);
undo_stack.push(ca);
}
}
void SourceTable::reveal_in_browser() {
QModelIndexList selected_items = selectionModel()->selectedRows();
Media* media = project_parent->item_to_media(selected_items.at(0));
Footage* m = media->to_footage();
#if defined(Q_OS_WIN)
QStringList args;
args << "/select," << QDir::toNativeSeparators(m->url);
QProcess::startDetached("explorer", args);
#elif defined(Q_OS_MAC)
QStringList args;
args << "-e";
args << "tell application \"Finder\"";
args << "-e";
args << "activate";
args << "-e";
args << "select POSIX file \""+m->url+"\"";
args << "-e";
args << "end tell";
QProcess::startDetached("osascript", args);
#else
QDesktopServices::openUrl(QUrl::fromLocalFile(m->url.left(m->url.lastIndexOf('/'))));
#endif
}
void SourceTable::item_renamed(Media* item) {
if (editing_item == item) {
MediaRename* mr = new MediaRename(item, "idk");
undo_stack.push(mr);
editing_item = NULL;
}
}
void SourceTable::stop_rename_timer() {
rename_timer.stop();
}
void SourceTable::rename_interval() {
stop_rename_timer();
if (hasFocus() && editing_item != NULL) {
edit(editing_index);
//editItem(editing_item, 0);
}
}
void SourceTable::item_click(const QModelIndex& index) {
if (selectionModel()->selectedRows().size() == 1 && index.column() == 0) {
Media* m = project_parent->item_to_media(index);
if (editing_item == m) {
rename_timer.start();
} else {
editing_item = m;
editing_index = index;
}
project_parent->sources_common->item_click(project_parent->item_to_media(index), index);
}
}
void SourceTable::mousePressEvent(QMouseEvent* event) {
stop_rename_timer();
project_parent->sources_common->mousePressEvent(event);
QTreeView::mousePressEvent(event);
}
void SourceTable::mouseDoubleClickEvent(QMouseEvent* e) {
stop_rename_timer();
QModelIndexList selected_items = selectionModel()->selectedRows();
if (selected_items.size() == 0) {
project_parent->import_dialog();
} else if (selected_items.size() == 1) {
Media* item = project_parent->item_to_media(selected_items.at(0));
switch (item->get_type()) {
case MEDIA_TYPE_FOOTAGE:
panel_footage_viewer->set_media(item);
panel_footage_viewer->setFocus();
break;
case MEDIA_TYPE_SEQUENCE:
undo_stack.push(new ChangeSequenceAction(item->to_sequence()));
break;
}
}
void SourceTable::mouseDoubleClickEvent(QMouseEvent* event) {
project_parent->sources_common->mouseDoubleClickEvent(event, selectionModel()->selectedRows());
}
void SourceTable::dragEnterEvent(QDragEnterEvent *event) {
@@ -231,79 +69,5 @@ void SourceTable::dragMoveEvent(QDragMoveEvent *event) {
}
void SourceTable::dropEvent(QDropEvent* event) {
const QMimeData* mimeData = event->mimeData();
const QModelIndex& drop_item = indexAt(event->pos());
Media* m = project_parent->item_to_media(drop_item);
if (mimeData->hasUrls()) {
// drag files in from outside
QList<QUrl> urls = mimeData->urls();
if (!urls.isEmpty()) {
QStringList paths;
for (int i=0;i<urls.size();i++) {
paths.append(urls.at(i).toLocalFile());
}
bool replace = false;
if (urls.size() == 1
&& drop_item.isValid()
&& m->get_type() == MEDIA_TYPE_FOOTAGE
&& !QFileInfo(paths.at(0)).isDir()
&& config.drop_on_media_to_replace
&& QMessageBox::question(this, "Replace Media", "You dropped a file onto '" + m->get_name() + "'. Would you like to replace it with the dropped file?", QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) {
replace = true;
project_parent->replace_media(m, paths.at(0));
}
if (!replace) {
QModelIndex parent;
if (drop_item.isValid()) {
if (m->get_type() == MEDIA_TYPE_FOLDER) {
parent = drop_item;
} else {
parent = drop_item.parent();
}
}
if (parent.isValid()) setExpanded(parent, true);
project_parent->process_file_list(paths, false, NULL, panel_project->item_to_media(parent));
}
}
event->acceptProposedAction();
} else {
event->ignore();
// dragging files within project
// if we dragged to the root OR dragged to a folder
if (!drop_item.isValid() || (drop_item.isValid() && m->get_type() == MEDIA_TYPE_FOLDER)) {
QVector<Media*> move_items;
QModelIndexList selected_items = selectionModel()->selectedRows();
for (int i=0;i<selected_items.size();i++) {
const QModelIndex& item = selected_items.at(i);
const QModelIndex& parent = item.parent();
Media* s = project_parent->item_to_media(item);
if (parent != drop_item && item != drop_item) {
bool ignore = false;
if (parent.isValid()) {
// if child belongs to a selected parent, assume the user is just moving the parent and ignore the child
QModelIndex par = parent;
while (par.isValid() && !ignore) {
for (int j=0;j<selected_items.size();j++) {
if (par == selected_items.at(j)) {
ignore = true;
break;
}
}
par = par.parent();
}
}
if (!ignore) {
move_items.append(s);
}
}
}
if (move_items.size() > 0) {
MediaMove* mm = new MediaMove(this);
mm->to = m;
mm->items = move_items;
undo_stack.push(mm);
}
}
}
project_parent->sources_common->dropEvent(this, event, indexAt(event->pos()), selectionModel()->selectedRows());
}
+3 -12
View File
@@ -12,26 +12,17 @@ class SourceTable : public QTreeView
{
Q_OBJECT
public:
SourceTable(QWidget* parent = 0);
SourceTable(QWidget* parent = 0);
Project* project_parent;
protected:
void mousePressEvent(QMouseEvent*);
void mouseDoubleClickEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent *);
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent *event);
private:
QTimer rename_timer;
Media* editing_item;
QModelIndex editing_index;
private slots:
void rename_interval();
void item_click(const QModelIndex& index);
void stop_rename_timer();
void item_renamed(Media *item);
void show_context_menu();
void create_seq_from_selected();
void reveal_in_browser();
void show_context_menu();
};
#endif // SOURCETABLE_H
+5 -2
View File
@@ -10,6 +10,7 @@
#include "panels/timeline.h"
#include "project/footage.h"
#include "ui/sourcetable.h"
#include "ui/sourceiconview.h"
#include "panels/effectcontrols.h"
#include "panels/viewer.h"
#include "project/undo.h"
@@ -265,8 +266,10 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
QVector<Media*> media_list;
panel_timeline->importing_files = false;
if (event->source() == panel_project->source_table) {
QModelIndexList items = panel_project->source_table->selectionModel()->selectedRows();
if (event->source() == panel_project->tree_view || event->source() == panel_project->icon_view) {
QModelIndexList items = (event->source() == panel_project->tree_view)
? panel_project->tree_view->selectionModel()->selectedRows()
: panel_project->icon_view->selectionModel()->selectedIndexes();
media_list.resize(items.size());
for (int i=0;i<items.size();i++) {
media_list[i] = panel_project->item_to_media(items.at(i));
+2 -1
View File
@@ -19,6 +19,7 @@ class TimelineAction;
class QScrollBar;
class SetSelectionsCommand;
class QPainter;
class Media;
bool same_sign(int a, int b);
void draw_waveform(Clip* clip, FootageStream* ms, long media_length, QPainter* p, const QRect& clip_rect, int waveform_start, int waveform_limit, double zoom);
@@ -65,7 +66,7 @@ private:
// used for "right click ripple"
long rc_ripple_min;
long rc_ripple_max;
void* rc_reveal_media;
Media* rc_reveal_media;
QTimer tooltip_timer;
int tooltip_clip;
+2
View File
@@ -75,6 +75,8 @@ void ViewerContainer::adjust() {
child->move(widget_x, widget_y);
child->resize(widget_width, widget_height);
zoom = double(widget_width) / double(viewer->seq->width);
} else {
int zoomed_width = double(viewer->seq->width)*zoom;
int zoomed_height = double(viewer->seq->height)*zoom;
+43 -6
View File
@@ -35,6 +35,7 @@
#include <QFileDialog>
#include <QPolygon>
#include <QDesktopWidget>
#include <QInputDialog>
extern "C" {
#include <libavformat/avformat.h>
@@ -91,6 +92,22 @@ void ViewerWidget::show_context_menu() {
QAction* show_fullscreen_action = menu.addAction("Show Fullscreen");
connect(show_fullscreen_action, SIGNAL(triggered()), this, SLOT(show_fullscreen()));
QMenu zoom_menu("Zoom");
QAction* fit_zoom = zoom_menu.addAction("Fit");
connect(fit_zoom, SIGNAL(triggered(bool)), this, SLOT(set_fit_zoom()));
zoom_menu.addAction("10%")->setData(0.1);
zoom_menu.addAction("25%")->setData(0.25);
zoom_menu.addAction("50%")->setData(0.5);
zoom_menu.addAction("75%")->setData(0.75);
zoom_menu.addAction("100%")->setData(1.0);
zoom_menu.addAction("150%")->setData(1.5);
zoom_menu.addAction("200%")->setData(2.0);
zoom_menu.addAction("400%")->setData(4.0);
QAction* custom_zoom = zoom_menu.addAction("Custom");
connect(custom_zoom, SIGNAL(triggered(bool)), this, SLOT(set_custom_zoom()));
connect(&zoom_menu, SIGNAL(triggered(QAction*)), this, SLOT(set_menu_zoom(QAction*)));
menu.addMenu(&zoom_menu);
menu.exec(QCursor::pos());
}
@@ -130,6 +147,30 @@ void ViewerWidget::show_fullscreen() {
showFullScreen();
}
void ViewerWidget::set_fit_zoom() {
container->fit = true;
container->adjust();
}
void ViewerWidget::set_custom_zoom() {
bool ok;
double d = QInputDialog::getDouble(this, "Viewer Zoom", "Set Custom Zoom Value:", container->zoom*100, 0, 2147483647, 2, &ok);
if (ok) {
container->fit = false;
container->zoom = d*0.01;
container->adjust();
}
}
void ViewerWidget::set_menu_zoom(QAction* action) {
const QVariant& data = action->data();
if (!data.isNull()) {
container->fit = false;
container->zoom = data.toDouble();
container->adjust();
}
}
void ViewerWidget::retry() {
update();
}
@@ -640,12 +681,8 @@ GLuint ViewerWidget::compose_sequence(QVector<Clip*>& nests, bool render_audio)
int widget_width = width();
int widget_height = height();
QString qt_scale_factor = QString(qgetenv("QT_SCALE_FACTOR"));
if (!qt_scale_factor.isEmpty()) {
double scale = qt_scale_factor.toDouble();
widget_width *= scale;
widget_height *= scale;
}
widget_width *= QApplication::desktop()->devicePixelRatio();
widget_height *= QApplication::desktop()->devicePixelRatio();
glViewport(0, 0, widget_width, widget_height);
}
+4
View File
@@ -70,6 +70,10 @@ private slots:
void show_context_menu();
void save_frame();
void show_fullscreen();
void set_fit_zoom();
void set_custom_zoom();
void set_menu_zoom(QAction *action);
};
#endif // VIEWERWIDGET_H