From c65e2557b56fda50230359f027e54399d2792219 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 21 Dec 2018 01:03:40 +1100 Subject: [PATCH] removed project ui, fixed some project panel crashes --- olive.pro | 405 +++++++++++++++++++++--------------------- panels/project.cpp | 35 +++- panels/project.h | 4 +- panels/project.ui | 64 ------- project/media.cpp | 28 ++- project/media.h | 4 +- ui/timelineheader.cpp | 5 +- 7 files changed, 256 insertions(+), 289 deletions(-) delete mode 100644 panels/project.ui diff --git a/olive.pro b/olive.pro index 16fa1bfcf..56f3bfe89 100644 --- a/olive.pro +++ b/olive.pro @@ -1,203 +1,202 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2018-05-11T10:31:59 -# -#------------------------------------------------- - -QT += core gui multimedia opengl - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = Olive -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - - -SOURCES += \ - main.cpp \ - mainwindow.cpp \ - panels/project.cpp \ - panels/effectcontrols.cpp \ - panels/viewer.cpp \ - panels/timeline.cpp \ - ui/sourcetable.cpp \ - dialogs/aboutdialog.cpp \ - ui/timelinewidget.cpp \ - project/media.cpp \ - project/footage.cpp \ - project/sequence.cpp \ - project/clip.cpp \ - playback/playback.cpp \ - playback/audio.cpp \ - io/config.cpp \ - dialogs/newsequencedialog.cpp \ - ui/viewerwidget.cpp \ - ui/viewercontainer.cpp \ - dialogs/exportdialog.cpp \ - ui/collapsiblewidget.cpp \ - panels/panels.cpp \ - playback/cacher.cpp \ - io/exportthread.cpp \ - ui/timelineheader.cpp \ - io/previewgenerator.cpp \ - ui/labelslider.cpp \ - dialogs/preferencesdialog.cpp \ - ui/audiomonitor.cpp \ - project/undo.cpp \ - ui/scrollarea.cpp \ - ui/comboboxex.cpp \ - ui/colorbutton.cpp \ - dialogs/replaceclipmediadialog.cpp \ - ui/fontcombobox.cpp \ - ui/checkboxex.cpp \ - ui/keyframeview.cpp \ - ui/texteditex.cpp \ - dialogs/demonotice.cpp \ - project/marker.cpp \ - dialogs/speeddialog.cpp \ - dialogs/mediapropertiesdialog.cpp \ - io/crc32.cpp \ - project/projectmodel.cpp \ - io/loadthread.cpp \ - dialogs/loaddialog.cpp \ - debug.cpp \ - io/path.cpp \ - effects/internal/linearfadetransition.cpp \ - effects/internal/transformeffect.cpp \ - effects/internal/solideffect.cpp \ - effects/internal/texteffect.cpp \ - effects/internal/timecodeeffect.cpp \ - effects/internal/audionoiseeffect.cpp \ - effects/internal/paneffect.cpp \ - effects/internal/toneeffect.cpp \ - effects/internal/volumeeffect.cpp \ - effects/internal/crossdissolvetransition.cpp \ - effects/internal/shakeeffect.cpp \ - effects/internal/exponentialfadetransition.cpp \ - effects/internal/logarithmicfadetransition.cpp \ - effects/internal/cornerpineffect.cpp \ - io/math.cpp \ - io/qpainterwrapper.cpp \ - project/effect.cpp \ - project/transition.cpp \ - project/effectrow.cpp \ - project/effectfield.cpp \ - effects/internal/cubetransition.cpp \ - project/effectgizmo.cpp \ - io/clipboard.cpp \ - dialogs/stabilizerdialog.cpp - -HEADERS += \ - mainwindow.h \ - panels/project.h \ - panels/effectcontrols.h \ - panels/viewer.h \ - panels/timeline.h \ - ui/sourcetable.h \ - dialogs/aboutdialog.h \ - ui/timelinewidget.h \ - project/media.h \ - project/footage.h \ - project/sequence.h \ - project/clip.h \ - playback/playback.h \ - playback/audio.h \ - io/config.h \ - dialogs/newsequencedialog.h \ - ui/viewerwidget.h \ - ui/viewercontainer.h \ - dialogs/exportdialog.h \ - ui/collapsiblewidget.h \ - panels/panels.h \ - playback/cacher.h \ - io/exportthread.h \ - ui/timelinetools.h \ - ui/timelineheader.h \ - io/previewgenerator.h \ - ui/labelslider.h \ - dialogs/preferencesdialog.h \ - ui/audiomonitor.h \ - project/undo.h \ - ui/scrollarea.h \ - ui/comboboxex.h \ - ui/colorbutton.h \ - dialogs/replaceclipmediadialog.h \ - ui/fontcombobox.h \ - ui/checkboxex.h \ - ui/keyframeview.h \ - ui/texteditex.h \ - dialogs/demonotice.h \ - project/marker.h \ - project/selection.h \ - dialogs/speeddialog.h \ - dialogs/mediapropertiesdialog.h \ - io/crc32.h \ - project/projectmodel.h \ - io/loadthread.h \ - dialogs/loaddialog.h \ - debug.h \ - io/path.h \ - effects/internal/transformeffect.h \ - effects/internal/solideffect.h \ - effects/internal/texteffect.h \ - effects/internal/timecodeeffect.h \ - effects/internal/audionoiseeffect.h \ - effects/internal/paneffect.h \ - effects/internal/toneeffect.h \ - effects/internal/volumeeffect.h \ - effects/internal/shakeeffect.h \ - effects/internal/linearfadetransition.h \ - effects/internal/crossdissolvetransition.h \ - effects/internal/exponentialfadetransition.h \ - effects/internal/logarithmicfadetransition.h \ - effects/internal/cornerpineffect.h \ - io/math.h \ - io/qpainterwrapper.h \ - project/effect.h \ - project/transition.h \ - project/effectrow.h \ - project/effectfield.h \ - effects/internal/cubetransition.h \ - project/effectgizmo.h \ - io/clipboard.h \ - dialogs/stabilizerdialog.h - -FORMS += \ - mainwindow.ui \ - panels/project.ui \ - panels/effectcontrols.ui \ - panels/viewer.ui \ - panels/timeline.ui \ - dialogs/aboutdialog.ui \ - dialogs/newsequencedialog.ui \ - dialogs/exportdialog.ui \ - dialogs/preferencesdialog.ui \ - dialogs/demonotice.ui - -win32 { - RC_FILE = icons/resources.rc - LIBS += -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample -lopengl32 -} - -mac { - LIBS += -L/usr/local/lib -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample - ICON = icons/olive.icns - INCLUDEPATH = /usr/local/include -} - -linux { - LIBS += -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample -} - -RESOURCES += \ - icons/icons.qrc +#------------------------------------------------- +# +# Project created by QtCreator 2018-05-11T10:31:59 +# +#------------------------------------------------- + +QT += core gui multimedia opengl + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = Olive +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + + +SOURCES += \ + main.cpp \ + mainwindow.cpp \ + panels/project.cpp \ + panels/effectcontrols.cpp \ + panels/viewer.cpp \ + panels/timeline.cpp \ + ui/sourcetable.cpp \ + dialogs/aboutdialog.cpp \ + ui/timelinewidget.cpp \ + project/media.cpp \ + project/footage.cpp \ + project/sequence.cpp \ + project/clip.cpp \ + playback/playback.cpp \ + playback/audio.cpp \ + io/config.cpp \ + dialogs/newsequencedialog.cpp \ + ui/viewerwidget.cpp \ + ui/viewercontainer.cpp \ + dialogs/exportdialog.cpp \ + ui/collapsiblewidget.cpp \ + panels/panels.cpp \ + playback/cacher.cpp \ + io/exportthread.cpp \ + ui/timelineheader.cpp \ + io/previewgenerator.cpp \ + ui/labelslider.cpp \ + dialogs/preferencesdialog.cpp \ + ui/audiomonitor.cpp \ + project/undo.cpp \ + ui/scrollarea.cpp \ + ui/comboboxex.cpp \ + ui/colorbutton.cpp \ + dialogs/replaceclipmediadialog.cpp \ + ui/fontcombobox.cpp \ + ui/checkboxex.cpp \ + ui/keyframeview.cpp \ + ui/texteditex.cpp \ + dialogs/demonotice.cpp \ + project/marker.cpp \ + dialogs/speeddialog.cpp \ + dialogs/mediapropertiesdialog.cpp \ + io/crc32.cpp \ + project/projectmodel.cpp \ + io/loadthread.cpp \ + dialogs/loaddialog.cpp \ + debug.cpp \ + io/path.cpp \ + effects/internal/linearfadetransition.cpp \ + effects/internal/transformeffect.cpp \ + effects/internal/solideffect.cpp \ + effects/internal/texteffect.cpp \ + effects/internal/timecodeeffect.cpp \ + effects/internal/audionoiseeffect.cpp \ + effects/internal/paneffect.cpp \ + effects/internal/toneeffect.cpp \ + effects/internal/volumeeffect.cpp \ + effects/internal/crossdissolvetransition.cpp \ + effects/internal/shakeeffect.cpp \ + effects/internal/exponentialfadetransition.cpp \ + effects/internal/logarithmicfadetransition.cpp \ + effects/internal/cornerpineffect.cpp \ + io/math.cpp \ + io/qpainterwrapper.cpp \ + project/effect.cpp \ + project/transition.cpp \ + project/effectrow.cpp \ + project/effectfield.cpp \ + effects/internal/cubetransition.cpp \ + project/effectgizmo.cpp \ + io/clipboard.cpp \ + dialogs/stabilizerdialog.cpp + +HEADERS += \ + mainwindow.h \ + panels/project.h \ + panels/effectcontrols.h \ + panels/viewer.h \ + panels/timeline.h \ + ui/sourcetable.h \ + dialogs/aboutdialog.h \ + ui/timelinewidget.h \ + project/media.h \ + project/footage.h \ + project/sequence.h \ + project/clip.h \ + playback/playback.h \ + playback/audio.h \ + io/config.h \ + dialogs/newsequencedialog.h \ + ui/viewerwidget.h \ + ui/viewercontainer.h \ + dialogs/exportdialog.h \ + ui/collapsiblewidget.h \ + panels/panels.h \ + playback/cacher.h \ + io/exportthread.h \ + ui/timelinetools.h \ + ui/timelineheader.h \ + io/previewgenerator.h \ + ui/labelslider.h \ + dialogs/preferencesdialog.h \ + ui/audiomonitor.h \ + project/undo.h \ + ui/scrollarea.h \ + ui/comboboxex.h \ + ui/colorbutton.h \ + dialogs/replaceclipmediadialog.h \ + ui/fontcombobox.h \ + ui/checkboxex.h \ + ui/keyframeview.h \ + ui/texteditex.h \ + dialogs/demonotice.h \ + project/marker.h \ + project/selection.h \ + dialogs/speeddialog.h \ + dialogs/mediapropertiesdialog.h \ + io/crc32.h \ + project/projectmodel.h \ + io/loadthread.h \ + dialogs/loaddialog.h \ + debug.h \ + io/path.h \ + effects/internal/transformeffect.h \ + effects/internal/solideffect.h \ + effects/internal/texteffect.h \ + effects/internal/timecodeeffect.h \ + effects/internal/audionoiseeffect.h \ + effects/internal/paneffect.h \ + effects/internal/toneeffect.h \ + effects/internal/volumeeffect.h \ + effects/internal/shakeeffect.h \ + effects/internal/linearfadetransition.h \ + effects/internal/crossdissolvetransition.h \ + effects/internal/exponentialfadetransition.h \ + effects/internal/logarithmicfadetransition.h \ + effects/internal/cornerpineffect.h \ + io/math.h \ + io/qpainterwrapper.h \ + project/effect.h \ + project/transition.h \ + project/effectrow.h \ + project/effectfield.h \ + effects/internal/cubetransition.h \ + project/effectgizmo.h \ + io/clipboard.h \ + dialogs/stabilizerdialog.h + +FORMS += \ + mainwindow.ui \ + panels/effectcontrols.ui \ + panels/viewer.ui \ + panels/timeline.ui \ + dialogs/aboutdialog.ui \ + dialogs/newsequencedialog.ui \ + dialogs/exportdialog.ui \ + dialogs/preferencesdialog.ui \ + dialogs/demonotice.ui + +win32 { + RC_FILE = icons/resources.rc + LIBS += -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample -lopengl32 +} + +mac { + LIBS += -L/usr/local/lib -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample + ICON = icons/olive.icns + INCLUDEPATH = /usr/local/include +} + +linux { + LIBS += -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample +} + +RESOURCES += \ + icons/icons.qrc diff --git a/panels/project.cpp b/panels/project.cpp index 280fab531..5f4c3cec7 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -37,6 +37,8 @@ #include #include #include +#include +#include extern "C" { #include @@ -53,20 +55,43 @@ QStringList recent_projects; QString recent_proj_file; Project::Project(QWidget *parent) : - QDockWidget(parent), - ui(new Ui::Project) + QDockWidget(parent) { - ui->setupUi(this); - source_table = ui->treeView; + setObjectName("Project"); + resize(504, 371); + QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth()); + setSizePolicy(sizePolicy); + + QWidget* dockWidgetContents = new QWidget(); + QVBoxLayout* verticalLayout = new QVBoxLayout(dockWidgetContents); + verticalLayout->setContentsMargins(0, 0, 0, 0); + + setWidget(dockWidgetContents); + + source_table = new SourceTable(dockWidgetContents); source_table->project_parent = this; + source_table->setAcceptDrops(true); + source_table->setEditTriggers(QAbstractItemView::NoEditTriggers); + source_table->setDragDropMode(QAbstractItemView::DragDrop); + source_table->setSelectionMode(QAbstractItemView::ExtendedSelection); + verticalLayout->addWidget(source_table); + //setWidget(source_table); + + //layout->addWidget(source_table); sorter = new QSortFilterProxyModel(this); sorter->setSourceModel(&project_model); source_table->setModel(sorter); + + //retranslateUi(Project); + setWindowTitle(QApplication::translate("Project", "Project", nullptr)); } Project::~Project() { - delete ui; + delete sorter; } QString Project::get_next_sequence_name(QString start) { diff --git a/panels/project.h b/panels/project.h index 7e6ec8229..563ae5ac0 100644 --- a/panels/project.h +++ b/panels/project.h @@ -75,9 +75,7 @@ public: //Media *new_item(); - void start_preview_generator(Media* item, bool replacing); - - Ui::Project *ui; + void start_preview_generator(Media* item, bool replacing); public slots: void import_dialog(); void delete_selected_media(); diff --git a/panels/project.ui b/panels/project.ui deleted file mode 100644 index fbf5d7094..000000000 --- a/panels/project.ui +++ /dev/null @@ -1,64 +0,0 @@ - - - Project - - - - 0 - 0 - 504 - 371 - - - - - 0 - 0 - - - - Project - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - true - - - QAbstractItemView::NoEditTriggers - - - QAbstractItemView::DragDrop - - - QAbstractItemView::ExtendedSelection - - - - - - - - - SourceTable - QTreeView -
ui/sourcetable.h
-
-
- - -
diff --git a/project/media.cpp b/project/media.cpp index 696a0f34b..7f190effe 100644 --- a/project/media.cpp +++ b/project/media.cpp @@ -197,15 +197,25 @@ void Media::set_name(const QString &n) { double Media::get_frame_rate(int stream) { switch (get_type()) { - case MEDIA_TYPE_FOOTAGE: return to_footage()->get_stream_from_file_index(true, stream)->video_frame_rate; + case MEDIA_TYPE_FOOTAGE: + { + Footage* f = to_footage(); + if (stream < 0) return f->video_tracks.at(0)->video_frame_rate; + return f->get_stream_from_file_index(true, stream)->video_frame_rate; + } case MEDIA_TYPE_SEQUENCE: return to_sequence()->frame_rate; } - return qSNaN(); + return NULL; } int Media::get_sampling_rate(int stream) { switch (get_type()) { - case MEDIA_TYPE_FOOTAGE: return to_footage()->get_stream_from_file_index(false, stream)->audio_frequency; + case MEDIA_TYPE_FOOTAGE: + { + Footage* f = to_footage(); + if (stream < 0) return f->audio_tracks.at(0)->audio_frequency; + return to_footage()->get_stream_from_file_index(false, stream)->audio_frequency; + } case MEDIA_TYPE_SEQUENCE: return to_sequence()->audio_frequency; } return 0; @@ -259,11 +269,11 @@ QVariant Media::data(int column, int role) { Footage* f = to_footage(); double r = 30; - if (f->video_tracks.size() > 0) r = f->video_tracks.at(0)->video_frame_rate; - if (!qIsNull(r)) { + if (f->video_tracks.size() > 0 && !qIsNull(f->video_tracks.at(0)->video_frame_rate)) r = f->video_tracks.at(0)->video_frame_rate; + //if (!qIsNull(r)) { long len = f->get_length_in_frames(r); if (len > 0) return frame_to_timecode(len, config.timecode_view, r); - } + //} } break; case 2: @@ -271,9 +281,9 @@ QVariant Media::data(int column, int role) { if (get_type() == MEDIA_TYPE_SEQUENCE) return QString::number(get_frame_rate()) + " FPS"; if (get_type() == MEDIA_TYPE_FOOTAGE) { Footage* f = to_footage(); - if (f->video_tracks.size() > 0) { - double r = get_frame_rate(); - if (!qIsNull(r)) return QString::number(get_frame_rate()) + " FPS"; + double r; + if (f->video_tracks.size() > 0 && !qIsNull(r = get_frame_rate())) { + return QString::number(get_frame_rate()) + " FPS"; } else if (f->audio_tracks.size() > 0) { return QString::number(get_sampling_rate()) + " Hz"; } diff --git a/project/media.h b/project/media.h index b917d0530..3c04de933 100644 --- a/project/media.h +++ b/project/media.h @@ -32,8 +32,8 @@ public: void set_name(const QString& n); MediaThrobber* throbber; - double get_frame_rate(int stream = 0); - int get_sampling_rate(int stream = 0); + double get_frame_rate(int stream = -1); + int get_sampling_rate(int stream = -1); // item functions void appendChild(Media *child); diff --git a/ui/timelineheader.cpp b/ui/timelineheader.cpp index 329bac195..53cddecab 100644 --- a/ui/timelineheader.cpp +++ b/ui/timelineheader.cpp @@ -401,12 +401,11 @@ void TimelineHeader::paintEvent(QPaintEvent*) { } } -void TimelineHeader::show_context_menu(const QPoint &pos) -{ +void TimelineHeader::show_context_menu(const QPoint &pos) { QMenu contextMenu(tr("Context menu"), this); QAction clear_in_out("Clear In/Out Points", this); - if (!viewer->seq->using_workarea) clear_in_out.setVisible(false); + if (!viewer->seq->using_workarea) clear_in_out.setEnabled(false); connect(&clear_in_out, SIGNAL(triggered()), mainWindow, SLOT(on_actionClear_In_Out_triggered())); contextMenu.addAction(&clear_in_out); contextMenu.exec(mapToGlobal(pos));