merged with master

This commit is contained in:
itsmattkc
2019-03-25 12:43:23 +11:00
83 changed files with 7823 additions and 1469 deletions
+34
View File
@@ -0,0 +1,34 @@
#include "columnedgridlayout.h"
ColumnedGridLayout::ColumnedGridLayout(QWidget* parent,
int maximum_columns) :
QGridLayout (parent),
maximum_columns_(maximum_columns)
{
}
void ColumnedGridLayout::Add(QWidget *widget)
{
if (maximum_columns_ > 0) {
int row = count() / maximum_columns_;
int column = count() % maximum_columns_;
addWidget(widget, row, column);
} else {
addWidget(widget);
}
}
int ColumnedGridLayout::MaximumColumns() const
{
return maximum_columns_;
}
void ColumnedGridLayout::SetMaximumColumns(int maximum_columns)
{
maximum_columns_ = maximum_columns;
}
+27
View File
@@ -0,0 +1,27 @@
#ifndef COLUMNEDGRIDLAYOUT_H
#define COLUMNEDGRIDLAYOUT_H
#include <QGridLayout>
/**
* @brief The ColumnedGridLayout class
*
* A simple derivative of QGridLayout that provides a automatic row/column layout based on a specified maximum
* column count.
*/
class ColumnedGridLayout : public QGridLayout
{
Q_OBJECT
public:
ColumnedGridLayout(QWidget* parent = nullptr,
int maximum_columns = 0);
void Add(QWidget* widget);
int MaximumColumns() const;
void SetMaximumColumns(int maximum_columns);
private:
int maximum_columns_;
};
#endif // COLUMNEDGRIDLAYOUT_H
+2 -2
View File
@@ -96,8 +96,8 @@ void olive::icon::Initialize()
Diamond = CreateIconFromSVG(":/icons/diamond.svg", false);
Clock = CreateIconFromSVG(":/icons/clock.svg", false);
MediaVideo = CreateIconFromSVG(":/icons/videosource.svg", false);
MediaAudio = CreateIconFromSVG(":/icons/audiosource.svg", false);
MediaVideo = CreateIconFromSVG(":/icons/videosource.svg");
MediaAudio = CreateIconFromSVG(":/icons/audiosource.svg");
MediaImage = CreateIconFromSVG(":/icons/imagesource.svg", false);
MediaError = CreateIconFromSVG(":/icons/error.svg", false);
MediaSequence = CreateIconFromSVG(":/icons/sequence.svg", false);
+17 -92
View File
@@ -358,7 +358,6 @@ void kbd_shortcut_processor(QByteArray& file, QMenu* menu, bool save, bool first
}
}
}
a->setShortcutContext(Qt::ApplicationShortcut);
}
}
}
@@ -408,16 +407,14 @@ bool MainWindow::load_css_from_file(const QString &fn) {
void MainWindow::Restyle()
{
// Set up UI style
if (olive::styling::UseNativeUI()) {
qApp->setStyle(QStyleFactory::create(""));
} else {
if (!olive::styling::UseNativeUI()) {
qApp->setStyle(QStyleFactory::create("Fusion"));
// Set up whether to load custom CSS or default CSS+palette
if (!olive::CurrentConfig.css_path.isEmpty()
&& load_css_from_file(olive::CurrentConfig.css_path)) {
setPalette(QPalette());
qApp->setPalette(qApp->style()->standardPalette());
} else {
@@ -476,7 +473,17 @@ void MainWindow::Restyle()
palette.setColor(QPalette::HighlightedText, Qt::white);
// set default CSS
setStyleSheet("QPushButton::checked { background: rgb(25, 25, 25); }");
QString stylesheet = "QPushButton::checked { background: rgb(25, 25, 25); }";
// Windows menus have the option of being native, so we may not need this CSS
#ifdef Q_OS_WIN
if (!olive::CurrentConfig.use_native_menu_styling) {
#endif
stylesheet.append("QMenu::separator { background: #404040; }");
#ifdef Q_OS_WIN
}
#endif
setStyleSheet(stylesheet);
}
@@ -779,61 +786,7 @@ void MainWindow::setup_menus() {
tools_menu->addSeparator();
selecting_also_seeks = MenuHelper::create_menu_action(tools_menu, "selectingalsoseeks", &olive::MenuHelper, SLOT(toggle_bool_action()));
selecting_also_seeks->setCheckable(true);
selecting_also_seeks->setData(reinterpret_cast<quintptr>(&olive::CurrentConfig.select_also_seeks));
edit_tool_also_seeks = MenuHelper::create_menu_action(tools_menu, "editalsoseeks", &olive::MenuHelper, SLOT(toggle_bool_action()));
edit_tool_also_seeks->setCheckable(true);
edit_tool_also_seeks->setData(reinterpret_cast<quintptr>(&olive::CurrentConfig.edit_tool_also_seeks));
edit_tool_selects_links = MenuHelper::create_menu_action(tools_menu, "editselectslinks", &olive::MenuHelper, SLOT(toggle_bool_action()));
edit_tool_selects_links->setCheckable(true);
edit_tool_selects_links->setData(reinterpret_cast<quintptr>(&olive::CurrentConfig.edit_tool_selects_links));
seek_also_selects = MenuHelper::create_menu_action(tools_menu, "seekalsoselects", &olive::MenuHelper, SLOT(toggle_bool_action()));
seek_also_selects->setCheckable(true);
seek_also_selects->setData(reinterpret_cast<quintptr>(&olive::CurrentConfig.seek_also_selects));
seek_to_end_of_pastes = MenuHelper::create_menu_action(tools_menu, "seektoendofpastes", &olive::MenuHelper, SLOT(toggle_bool_action()));
seek_to_end_of_pastes->setCheckable(true);
seek_to_end_of_pastes->setData(reinterpret_cast<quintptr>(&olive::CurrentConfig.paste_seeks));
scroll_wheel_zooms = MenuHelper::create_menu_action(tools_menu, "scrollwheelzooms", &olive::MenuHelper, SLOT(toggle_bool_action()));
scroll_wheel_zooms->setCheckable(true);
scroll_wheel_zooms->setData(reinterpret_cast<quintptr>(&olive::CurrentConfig.scroll_zooms));
invert_timeline_scroll_axes = MenuHelper::create_menu_action(tools_menu, "inverttimelinescrollaxes", &olive::MenuHelper, SLOT(toggle_bool_action()));
invert_timeline_scroll_axes->setCheckable(true);
invert_timeline_scroll_axes->setData(reinterpret_cast<quintptr>(&olive::CurrentConfig.invert_timeline_scroll_axes));
enable_drag_files_to_timeline = MenuHelper::create_menu_action(tools_menu, "enabledragfilestotimeline", &olive::MenuHelper, SLOT(toggle_bool_action()));
enable_drag_files_to_timeline->setCheckable(true);
enable_drag_files_to_timeline->setData(reinterpret_cast<quintptr>(&olive::CurrentConfig.enable_drag_files_to_timeline));
autoscale_by_default = MenuHelper::create_menu_action(tools_menu, "autoscalebydefault", &olive::MenuHelper, SLOT(toggle_bool_action()));
autoscale_by_default->setCheckable(true);
autoscale_by_default->setData(reinterpret_cast<quintptr>(&olive::CurrentConfig.autoscale_by_default));
enable_seek_to_import = MenuHelper::create_menu_action(tools_menu, "enableseektoimport", &olive::MenuHelper, SLOT(toggle_bool_action()));
enable_seek_to_import->setCheckable(true);
enable_seek_to_import->setData(reinterpret_cast<quintptr>(&olive::CurrentConfig.enable_seek_to_import));
enable_audio_scrubbing = MenuHelper::create_menu_action(tools_menu, "audioscrubbing", &olive::MenuHelper, SLOT(toggle_bool_action()));
enable_audio_scrubbing->setCheckable(true);
enable_audio_scrubbing->setData(reinterpret_cast<quintptr>(&olive::CurrentConfig.enable_audio_scrubbing));
enable_drop_on_media_to_replace = MenuHelper::create_menu_action(tools_menu, "enabledropmediareplace", &olive::MenuHelper, SLOT(toggle_bool_action()));
enable_drop_on_media_to_replace->setCheckable(true);
enable_drop_on_media_to_replace->setData(reinterpret_cast<quintptr>(&olive::CurrentConfig.drop_on_media_to_replace));
enable_hover_focus = MenuHelper::create_menu_action(tools_menu, "hoverfocus", &olive::MenuHelper, SLOT(toggle_bool_action()));
enable_hover_focus->setCheckable(true);
enable_hover_focus->setData(reinterpret_cast<quintptr>(&olive::CurrentConfig.hover_focus));
set_name_and_marker = MenuHelper::create_menu_action(tools_menu, "asknamemarkerset", &olive::MenuHelper, SLOT(toggle_bool_action()));
set_name_and_marker->setCheckable(true);
set_name_and_marker->setData(reinterpret_cast<quintptr>(&olive::CurrentConfig.set_name_with_marker));
autocut_silence_ = MenuHelper::create_menu_action(tools_menu, "autocutsilence", olive::Global.get(), SLOT(open_autocut_silence_dialog()));
tools_menu->addSeparator();
@@ -971,21 +924,7 @@ void MainWindow::Retranslate()
hand_tool_action->setText(tr("Hand Tool"));
transition_tool_action->setText(tr("Transition Tool"));
snap_toggle->setText(tr("Enable Snapping"));
selecting_also_seeks->setText(tr("Selecting Also Seeks"));
edit_tool_also_seeks->setText(tr("Edit Tool Also Seeks"));
edit_tool_selects_links->setText(tr("Edit Tool Selects Links"));
seek_also_selects->setText(tr("Seek Also Selects"));
seek_to_end_of_pastes->setText(tr("Seek to the End of Pastes"));
scroll_wheel_zooms->setText(tr("Scroll Wheel Zooms"));
scroll_wheel_zooms->setToolTip(tr("Hold CTRL to toggle this setting"));
invert_timeline_scroll_axes->setText(tr("Invert Timeline Scroll Axes"));
enable_drag_files_to_timeline->setText(tr("Enable Drag Files to Timeline"));
autoscale_by_default->setText(tr("Auto-Scale By Default"));
enable_seek_to_import->setText(tr("Enable Seek to Import"));
enable_audio_scrubbing->setText(tr("Audio Scrubbing"));
enable_drop_on_media_to_replace->setText(tr("Enable Drop on Media to Replace"));
enable_hover_focus->setText(tr("Enable Hover Focus"));
set_name_and_marker->setText(tr("Ask For Name When Setting Marker"));
autocut_silence_->setText(tr("Auto-Cut Silence"));
no_autoscroll->setText(tr("No Auto-Scroll"));
page_autoscroll->setText(tr("Page Auto-Scroll"));
@@ -1194,6 +1133,8 @@ void MainWindow::playbackMenu_About_To_Be_Shown() {
void MainWindow::viewMenu_About_To_Be_Shown() {
olive::MenuHelper.set_bool_action_checked(track_lines);
olive::MenuHelper.set_bool_action_checked(rectified_waveforms);
olive::MenuHelper.set_int_action_checked(frames_action, olive::CurrentConfig.timecode_view);
olive::MenuHelper.set_int_action_checked(drop_frame_action, olive::CurrentConfig.timecode_view);
olive::MenuHelper.set_int_action_checked(nondrop_frame_action, olive::CurrentConfig.timecode_view);
@@ -1229,22 +1170,6 @@ void MainWindow::toolMenu_About_To_Be_Shown() {
olive::MenuHelper.set_button_action_checked(transition_tool_action);
olive::MenuHelper.set_button_action_checked(snap_toggle);
olive::MenuHelper.set_bool_action_checked(selecting_also_seeks);
olive::MenuHelper.set_bool_action_checked(edit_tool_also_seeks);
olive::MenuHelper.set_bool_action_checked(edit_tool_selects_links);
olive::MenuHelper.set_bool_action_checked(seek_to_end_of_pastes);
olive::MenuHelper.set_bool_action_checked(scroll_wheel_zooms);
olive::MenuHelper.set_bool_action_checked(invert_timeline_scroll_axes);
olive::MenuHelper.set_bool_action_checked(rectified_waveforms);
olive::MenuHelper.set_bool_action_checked(enable_drag_files_to_timeline);
olive::MenuHelper.set_bool_action_checked(autoscale_by_default);
olive::MenuHelper.set_bool_action_checked(enable_seek_to_import);
olive::MenuHelper.set_bool_action_checked(enable_audio_scrubbing);
olive::MenuHelper.set_bool_action_checked(enable_drop_on_media_to_replace);
olive::MenuHelper.set_bool_action_checked(enable_hover_focus);
olive::MenuHelper.set_bool_action_checked(set_name_and_marker);
olive::MenuHelper.set_bool_action_checked(seek_also_selects);
olive::MenuHelper.set_int_action_checked(no_autoscroll, olive::CurrentConfig.autoscroll);
olive::MenuHelper.set_int_action_checked(page_autoscroll, olive::CurrentConfig.autoscroll);
olive::MenuHelper.set_int_action_checked(smooth_autoscroll, olive::CurrentConfig.autoscroll);
+1 -14
View File
@@ -328,21 +328,8 @@ private:
QAction* hand_tool_action;
QAction* transition_tool_action;
QAction* snap_toggle;
QAction* selecting_also_seeks;
QAction* edit_tool_also_seeks;
QAction* edit_tool_selects_links;
QAction* seek_to_end_of_pastes;
QAction* scroll_wheel_zooms;
QAction* invert_timeline_scroll_axes;
QAction* rectified_waveforms;
QAction* enable_drag_files_to_timeline;
QAction* autoscale_by_default;
QAction* enable_seek_to_import;
QAction* enable_audio_scrubbing;
QAction* enable_drop_on_media_to_replace;
QAction* enable_hover_focus;
QAction* set_name_and_marker;
QAction* seek_also_selects;
QAction* autocut_silence_;
QAction* preferences_action_;
QAction* clear_undo_action_;
+135 -9
View File
@@ -21,32 +21,38 @@
#include "sourceiconview.h"
#include <QMimeData>
#include <QImage>
#include "panels/project.h"
#include "project/media.h"
#include "project/sourcescommon.h"
#include "global/debug.h"
#include "global/math.h"
SourceIconView::SourceIconView(QWidget *parent) : QListView(parent) {
SourceIconView::SourceIconView(SourcesCommon &commons) :
commons_(commons)
{
setMovement(QListView::Free);
setSelectionMode(QAbstractItemView::ExtendedSelection);
setResizeMode(QListView::Adjust);
setContextMenuPolicy(Qt::CustomContextMenu);
setItemDelegate(&delegate_);
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());
commons_.show_context_menu(this, selectedIndexes());
}
void SourceIconView::item_click(const QModelIndex& index) {
if (selectedIndexes().size() == 1 && index.column() == 0) {
project_parent->sources_common->item_click(project_parent->item_to_media(index), index);
commons_.item_click(project_parent->item_to_media(index), index);
}
}
void SourceIconView::mousePressEvent(QMouseEvent* event) {
project_parent->sources_common->mousePressEvent(event);
commons_.mousePressEvent(event);
if (!indexAt(event->pos()).isValid()) selectionModel()->clear();
QListView::mousePressEvent(event);
}
@@ -70,20 +76,140 @@ void SourceIconView::dragMoveEvent(QDragMoveEvent *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());
commons_.dropEvent(this, event, drop_item, selectedIndexes());
}
void SourceIconView::mouseDoubleClickEvent(QMouseEvent *) {
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();
return;
}
}
if (default_behavior) {
project_parent->sources_common->mouseDoubleClickEvent(selectedIndexes());
// Double click was not a folder, so we perform the default behavior (sending the double click to SourcesCommon)
commons_.mouseDoubleClickEvent(selectedIndexes());
}
SourceIconDelegate::SourceIconDelegate(QObject *parent) :
QStyledItemDelegate (parent)
{
}
QSize SourceIconDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
if (option.decorationPosition == QStyleOptionViewItem::Top) { // Icon Mode
return QSize(256, 256);
} else {
return QSize(option.decorationSize.height(), option.decorationSize.height());
}
}
void SourceIconDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QFontMetrics fm = painter->fontMetrics();
QRect img_rect = option.rect;
if (option.decorationPosition == QStyleOptionViewItem::Top) { // Icon Mode
// Draw Text
if (fm.height() < option.rect.height() / 2) {
img_rect.setHeight(img_rect.height()-fm.height());
QRect text_rect = option.rect;
text_rect.setTop(text_rect.top() + option.rect.height() - fm.height());
QColor text_bgcolor;
QColor text_fgcolor;
if (option.state & QStyle::State_Selected) {
text_bgcolor = option.palette.highlight().color();
text_fgcolor = option.palette.highlightedText().color();
} else {
text_bgcolor = Qt::white;
text_fgcolor = Qt::black;
}
painter->fillRect(text_rect, text_bgcolor);
painter->setPen(text_fgcolor);
QString duration_str = index.data(Qt::UserRole).toString();
int timecode_width = fm.width(duration_str);
int max_name_width = option.rect.width();
if (timecode_width < option.rect.width() / 2) {
painter->drawText(text_rect, Qt::AlignBottom | Qt::AlignRight, index.data(Qt::UserRole).toString());
max_name_width -= timecode_width;
}
painter->drawText(text_rect,
Qt::AlignBottom | Qt::AlignLeft,
fm.elidedText(index.data(Qt::DisplayRole).toString(), Qt::ElideRight, max_name_width));
}
// Draw image
QIcon ico = index.data(Qt::DecorationRole).value<QIcon>();
QSize icon_size = ico.actualSize(img_rect.size());
img_rect = QRect(img_rect.x() + (img_rect.width() / 2 - icon_size.width() / 2),
img_rect.y() + (img_rect.height() / 2 - icon_size.height() / 2),
icon_size.width(),
icon_size.height());
painter->drawPixmap(img_rect, ico.pixmap(icon_size));
if (option.state & QStyle::State_Selected) {
QColor highlight_color = option.palette.highlight().color();
highlight_color.setAlphaF(0.5);
painter->setCompositionMode(QPainter::CompositionMode_SourceAtop);
painter->fillRect(img_rect, highlight_color);
}
} else if (option.decorationPosition == QStyleOptionViewItem::Left) { // List Mode
if (option.state & QStyle::State_Selected) {
painter->fillRect(option.rect, option.palette.highlight());
}
img_rect.setWidth(qMin(img_rect.width(), img_rect.height()));
QIcon ico = index.data(Qt::DecorationRole).value<QIcon>();
QSize icon_size = ico.actualSize(img_rect.size());
img_rect = QRect(img_rect.x() + (img_rect.width() / 2 - icon_size.width() / 2),
img_rect.y() + (img_rect.height() / 2 - icon_size.height() / 2),
icon_size.width(),
icon_size.height());
painter->drawPixmap(img_rect, ico.pixmap(icon_size));
QRect text_rect = option.rect;
text_rect.setLeft(text_rect.left() + option.rect.height());
int maximum_line_count = qMax(1, option.rect.height() / fm.height() - 1);
QString text;
if (maximum_line_count == 1) {
text = index.data(Qt::DisplayRole).toString();
} else {
text = index.data(Qt::ToolTipRole).toString();
if (text.isEmpty()) {
text = index.data(Qt::DisplayRole).toString();
} else {
QStringList strings = text.split("\n");
while (strings.size() > maximum_line_count) {
strings.removeLast();
}
text = strings.join("\n");
}
}
painter->setPen(option.state & QStyle::State_Selected ?
option.palette.highlightedText().color() : option.palette.text().color());
painter->drawText(text_rect, Qt::AlignLeft | Qt::AlignVCenter, text);
}
}
+26 -11
View File
@@ -22,25 +22,40 @@
#define SOURCEICONVIEW_H
#include <QListView>
#include <QDropEvent>
#include <QStyledItemDelegate>
#include "project/sourcescommon.h"
class Project;
class SourceIconDelegate;
class SourceIconDelegate : public QStyledItemDelegate {
public:
SourceIconDelegate(QObject *parent = nullptr);
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
};
class SourceIconView : public QListView {
Q_OBJECT
Q_OBJECT
public:
SourceIconView(QWidget* parent = 0);
Project* project_parent;
SourceIconView(SourcesCommon& commons);
Project* project_parent;
void mousePressEvent(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseDoubleClickEvent(QMouseEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dropEvent(QDropEvent* event);
signals:
void changed_root();
void changed_root();
private slots:
void show_context_menu();
void item_click(const QModelIndex& index);
void show_context_menu();
void item_click(const QModelIndex& index);
private:
SourcesCommon& commons_;
SourceIconDelegate delegate_;
};
#endif // SOURCEICONVIEW_H
+6 -6
View File
@@ -45,7 +45,7 @@
#include <QDir>
#include <QProcess>
SourceTable::SourceTable(QWidget* parent) : QTreeView(parent) {
SourceTable::SourceTable(SourcesCommon& commons) : commons_(commons) {
setSortingEnabled(true);
setAcceptDrops(true);
sortByColumn(0, Qt::AscendingOrder);
@@ -58,22 +58,22 @@ SourceTable::SourceTable(QWidget* parent) : QTreeView(parent) {
}
void SourceTable::show_context_menu() {
project_parent->sources_common->show_context_menu(this, selectionModel()->selectedRows());
commons_.show_context_menu(this, selectionModel()->selectedRows());
}
void SourceTable::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);
commons_.item_click(project_parent->item_to_media(index), index);
}
}
void SourceTable::mousePressEvent(QMouseEvent* event) {
project_parent->sources_common->mousePressEvent(event);
commons_.mousePressEvent(event);
QTreeView::mousePressEvent(event);
}
void SourceTable::mouseDoubleClickEvent(QMouseEvent* ) {
project_parent->sources_common->mouseDoubleClickEvent(selectionModel()->selectedRows());
commons_.mouseDoubleClickEvent(selectionModel()->selectedRows());
}
void SourceTable::dragEnterEvent(QDragEnterEvent *event) {
@@ -93,5 +93,5 @@ void SourceTable::dragMoveEvent(QDragMoveEvent *event) {
}
void SourceTable::dropEvent(QDropEvent* event) {
project_parent->sources_common->dropEvent(this, event, indexAt(event->pos()), selectionModel()->selectedRows());
commons_.dropEvent(this, event, indexAt(event->pos()), selectionModel()->selectedRows());
}
+5 -1
View File
@@ -25,6 +25,8 @@
#include <QTimer>
#include <QUndoCommand>
#include "project/sourcescommon.h"
class Project;
class Media;
@@ -32,7 +34,7 @@ class SourceTable : public QTreeView
{
Q_OBJECT
public:
SourceTable(QWidget* parent = 0);
SourceTable(SourcesCommon& commons);
Project* project_parent;
protected:
void mousePressEvent(QMouseEvent*);
@@ -43,6 +45,8 @@ protected:
private slots:
void item_click(const QModelIndex& index);
void show_context_menu();
private:
SourcesCommon& commons_;
};
#endif // SOURCETABLE_H
+23 -5
View File
@@ -118,11 +118,26 @@ void TimelineWidget::show_context_menu(const QPoint& pos) {
if (!selected_clips.isEmpty()) {
bool video_clips_are_selected = false;
bool audio_clips_are_selected = false;
for (int i=0;i<selected_clips.size();i++) {
if (selected_clips.at(i)->track() < 0) {
video_clips_are_selected = true;
} else {
audio_clips_are_selected = true;
}
}
menu.addSeparator();
menu.addAction(tr("&Speed/Duration"), olive::Global.get(), SLOT(open_speed_dialog()));
QAction* autoscaleAction = menu.addAction(tr("Auto-s&cale"), this, SLOT(toggle_autoscale()));
if (audio_clips_are_selected) {
menu.addAction(tr("Auto-Cut Silence"), olive::Global.get(), SLOT(open_autocut_silence_dialog()));
}
QAction* autoscaleAction = menu.addAction(tr("Auto-S&cale"), this, SLOT(toggle_autoscale()));
autoscaleAction->setCheckable(true);
// set autoscale to the first selected clip
autoscaleAction->setChecked(selected_clips.at(0)->autoscaled());
@@ -237,10 +252,10 @@ bool same_sign(int a, int b) {
void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
bool import_init = false;
QVector<Media*> media_list;
QVector<olive::timeline::MediaImportData> media_list;
panel_timeline->importing_files = false;
if (event->source() == panel_project->tree_view || event->source() == panel_project->icon_view) {
if (panel_project->IsProjectWidget(event->source())) {
QModelIndexList items = panel_project->get_current_selected();
media_list.resize(items.size());
for (int i=0;i<items.size();i++) {
@@ -249,10 +264,13 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
import_init = true;
}
if (event->source() == panel_footage_viewer->viewer_widget) {
if (event->source() == panel_footage_viewer) {
if (panel_footage_viewer->seq != olive::ActiveSequence) { // don't allow nesting the same sequence
media_list.append(panel_footage_viewer->media);
media_list.append(olive::timeline::MediaImportData(panel_footage_viewer->media,
static_cast<olive::timeline::MediaImportType>(event->mimeData()->text().toInt())));
import_init = true;
}
}
+6 -9
View File
@@ -90,10 +90,6 @@ ViewerWidget::~ViewerWidget() {
renderer.cancel();
}
void ViewerWidget::delete_function() {
close_active_clips(viewer->seq.get());
}
void ViewerWidget::set_waveform_scroll(int s) {
if (waveform) {
waveform_scroll = s;
@@ -383,11 +379,7 @@ void ViewerWidget::mouseMoveEvent(QMouseEvent* event) {
container->dragScrollMove(event->pos()*container->zoom);
} else if (event->buttons() & Qt::LeftButton) {
if (gizmos == nullptr) {
QDrag* drag = new QDrag(this);
QMimeData* mimeData = new QMimeData;
mimeData->setText("h"); // QMimeData will fail without some kind of data
drag->setMimeData(mimeData);
drag->exec();
viewer->initiate_drag(olive::timeline::kImportBoth);
dragging = false;
} else {
move_gizmos(event, false);
@@ -421,6 +413,11 @@ void ViewerWidget::close_window() {
window->hide();
}
void ViewerWidget::wait_until_render_is_paused()
{
renderer.wait_until_paused();
}
void ViewerWidget::draw_waveform_func() {
QPainter p(this);
if (viewer->seq->using_workarea) {
+1 -1
View File
@@ -50,8 +50,8 @@ public:
ViewerWidget(QWidget *parent = nullptr);
~ViewerWidget();
void delete_function();
void close_window();
void wait_until_render_is_paused();
void paintGL();
void initializeGL();
+36
View File
@@ -31,6 +31,7 @@
#include <QDebug>
#include "rendering/renderfunctions.h"
#include "ui/mainwindow.h"
ViewerWindow::ViewerWindow(QWidget *parent) :
QOpenGLWidget(parent, Qt::Window),
@@ -51,6 +52,41 @@ void ViewerWindow::set_texture(GLuint t, double iar, QMutex* imutex) {
update();
}
void ViewerWindow::shortcut_copier(QVector<QShortcut*>& shortcuts, QMenu* menu) {
QList<QAction*> menu_action = menu->actions();
for (int i=0;i<menu_action.size();i++) {
if (menu_action.at(i)->menu() != nullptr) {
shortcut_copier(shortcuts, menu_action.at(i)->menu());
} else if (!menu_action.at(i)->isSeparator() && !menu_action.at(i)->shortcut().isEmpty()) {
QShortcut* sc = new QShortcut(this);
sc->setKey(menu_action.at(i)->shortcut());
connect(sc, SIGNAL(activated()), menu_action.at(i), SLOT(trigger()));
shortcuts.append(sc);
}
}
}
void ViewerWindow::showEvent(QShowEvent *)
{
// Here, we copy all shortcuts from the MainWindow to this window. I don't like this solution, but messing around
// with Qt's event system proved fruitless. Also setting the shortcuts to ApplicationShortcut rather than
// WindowShortcut caused issues elsewhere (shortcuts being picked up in comboboxes and dialog boxes - we only
// want the shortcuts to be shared to this window). Therefore, this and shortcut_copier() are so far the best
// solutions I can find.
// Clear any existing shortcuts in case they've changed since the last showing
for (int i=0;i<shortcuts_.size();i++) {
delete shortcuts_.at(i);
}
shortcuts_.clear();
// Recursively copy all shortcuts from MainWindow to this window
QList<QAction*> menubar_actions = olive::MainWindow->menuBar()->actions();
for (int i=0;i<menubar_actions.size();i++) {
shortcut_copier(shortcuts_, menubar_actions.at(i)->menu());
}
}
void ViewerWindow::keyPressEvent(QKeyEvent *e) {
if (e->key() == Qt::Key_Escape) {
hide();
+6
View File
@@ -24,6 +24,7 @@
#include <QOpenGLWidget>
#include <QTimer>
#include <QMutex>
#include <QMenu>
#include "rendering/qopenglshaderprogramptr.h"
@@ -33,6 +34,7 @@ public:
ViewerWindow(QWidget *parent);
void set_texture(GLuint t, double iar, QMutex *imutex);
protected:
virtual void showEvent(QShowEvent*) override;
virtual void keyPressEvent(QKeyEvent*) override;
virtual void mousePressEvent(QMouseEvent*) override;
virtual void mouseMoveEvent(QMouseEvent*) override;
@@ -45,6 +47,10 @@ private:
QMutex* mutex_;
QOpenGLShaderProgramPtr pipeline_;
// shortcuts
void shortcut_copier(QVector<QShortcut*>& shortcuts, QMenu* menu);
QVector<QShortcut*> shortcuts_;
// exit full screen message
QTimer fullscreen_msg_timer_;
bool show_fullscreen_msg_;