Merge branch 'master' of https://github.com/olive-editor/olive
This commit is contained in:
@@ -116,6 +116,10 @@ void Core::Start()
|
||||
// Set up the index manager for renderers
|
||||
IndexManager::CreateInstance();
|
||||
|
||||
// Reset config (Config sets to default on construction already, but we do it again here as a workaround that fixes
|
||||
// the fact that some of the config paths set by default rely on the app name having been set (in main())
|
||||
Config::Current().SetDefaults();
|
||||
|
||||
// Load application config
|
||||
Config::Load();
|
||||
|
||||
|
||||
@@ -450,8 +450,13 @@ void TrackOutput::UpdateInOutFrom(int index)
|
||||
|
||||
// Update track length
|
||||
if (new_track_length != track_length_) {
|
||||
rational old_track_length = track_length_;
|
||||
|
||||
track_length_ = new_track_length;
|
||||
emit TrackLengthChanged();
|
||||
|
||||
InvalidateCache(qMin(old_track_length, new_track_length),
|
||||
qMax(old_track_length, new_track_length));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,4 +150,15 @@ void PanelManager::SetPanelsLocked(bool locked)
|
||||
locked_ = locked;
|
||||
}
|
||||
|
||||
void PanelManager::PanelDestroyed()
|
||||
{
|
||||
PanelWidget* panel = static_cast<PanelWidget*>(sender());
|
||||
|
||||
focus_history_.removeOne(panel);
|
||||
|
||||
if (last_focused_panel_ == panel) {
|
||||
last_focused_panel_ = focus_history_.isEmpty() ? nullptr : focus_history_.first();
|
||||
}
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -162,6 +162,12 @@ private:
|
||||
*/
|
||||
PanelWidget* last_focused_panel_;
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* @brief Processing if a panel gets deleted
|
||||
*/
|
||||
void PanelDestroyed();
|
||||
|
||||
};
|
||||
|
||||
template<class T>
|
||||
@@ -171,6 +177,9 @@ T *PanelManager::CreatePanel(QWidget *parent)
|
||||
|
||||
panel->SetMovementLocked(locked_);
|
||||
|
||||
// Connect destroy signal so we can remove it from focus history
|
||||
connect(panel, &PanelWidget::destroyed, this, &PanelManager::PanelDestroyed);
|
||||
|
||||
// Add panel to the bottom of the focus history
|
||||
focus_history_.append(panel);
|
||||
|
||||
|
||||
@@ -122,15 +122,16 @@ void TimeBasedPanel::ConnectViewerNode(ViewerOutput *node)
|
||||
{
|
||||
if (widget_->GetConnectedNode()) {
|
||||
disconnect(widget_->GetConnectedNode(), &ViewerOutput::MediaNameChanged, this, &TimeBasedPanel::SetSubtitle);
|
||||
Retranslate();
|
||||
}
|
||||
|
||||
widget_->ConnectViewerNode(node);
|
||||
|
||||
if (node) {
|
||||
connect(node, &ViewerOutput::MediaNameChanged, this, &TimeBasedPanel::SetSubtitle);
|
||||
SetSubtitle(node->media_name());
|
||||
}
|
||||
|
||||
// Update strings
|
||||
Retranslate();
|
||||
}
|
||||
|
||||
void TimeBasedPanel::SetTimeBasedWidget(TimeBasedWidget *widget)
|
||||
@@ -152,7 +153,9 @@ void TimeBasedPanel::SetTimeBasedWidget(TimeBasedWidget *widget)
|
||||
|
||||
void TimeBasedPanel::Retranslate()
|
||||
{
|
||||
if (!GetTimeBasedWidget()->GetConnectedNode()) {
|
||||
if (GetTimeBasedWidget()->GetConnectedNode()) {
|
||||
SetSubtitle(GetTimeBasedWidget()->GetConnectedNode()->media_name());
|
||||
} else {
|
||||
SetSubtitle(tr("(none)"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
TimelinePanel::TimelinePanel(QWidget *parent) :
|
||||
TimeBasedPanel(parent)
|
||||
TimeBasedPanel(parent),
|
||||
signal_instead_of_close_(false)
|
||||
{
|
||||
// FIXME: This won't work if there's ever more than one of this panel
|
||||
setObjectName("TimelinePanel");
|
||||
@@ -152,6 +153,11 @@ void TimelinePanel::OverwriteFootageAtPlayhead(const QList<Footage *> &footage)
|
||||
static_cast<TimelineWidget*>(GetTimeBasedWidget())->OverwriteFootageAtPlayhead(footage);
|
||||
}
|
||||
|
||||
void TimelinePanel::SetSignalInsteadOfClose(bool e)
|
||||
{
|
||||
signal_instead_of_close_ = e;
|
||||
}
|
||||
|
||||
void TimelinePanel::Retranslate()
|
||||
{
|
||||
TimeBasedPanel::Retranslate();
|
||||
@@ -159,4 +165,14 @@ void TimelinePanel::Retranslate()
|
||||
SetTitle(tr("Timeline"));
|
||||
}
|
||||
|
||||
void TimelinePanel::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (signal_instead_of_close_) {
|
||||
event->ignore();
|
||||
emit CloseRequested();
|
||||
} else {
|
||||
PanelWidget::closeEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -77,12 +77,21 @@ public:
|
||||
|
||||
void OverwriteFootageAtPlayhead(const QList<Footage *> &footage);
|
||||
|
||||
void SetSignalInsteadOfClose(bool e);
|
||||
|
||||
protected:
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual void closeEvent(QCloseEvent* event) override;
|
||||
|
||||
signals:
|
||||
void SelectionChanged(const QList<Node*>& selected_blocks);
|
||||
|
||||
void CloseRequested();
|
||||
|
||||
private:
|
||||
bool signal_instead_of_close_;
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "dialog/footageproperties/footageproperties.h"
|
||||
#include "dialog/sequence/sequence.h"
|
||||
#include "widget/menu/menu.h"
|
||||
#include "window/mainwindow/mainwindow.h"
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
@@ -422,6 +423,15 @@ void ProjectExplorer::DeleteSelected()
|
||||
foreach (Item* item, selected) {
|
||||
ItemPtr item_ptr = item->get_shared_ptr();
|
||||
|
||||
// If this is a sequence, close it
|
||||
if (item_ptr->type() == Item::kSequence) {
|
||||
Sequence* s = static_cast<Sequence*>(item_ptr.get());
|
||||
|
||||
if (Core::instance()->main_window()->IsSequenceOpen(s)) {
|
||||
Core::instance()->main_window()->CloseSequence(s);
|
||||
}
|
||||
}
|
||||
|
||||
new ProjectViewModel::RemoveItemCommand(&model_, item_ptr, command);
|
||||
}
|
||||
|
||||
|
||||
@@ -144,26 +144,33 @@ void MainWindow::OpenSequence(Sequence *sequence)
|
||||
|
||||
panel->ConnectViewerNode(sequence->viewer_output());
|
||||
|
||||
TimelineFocused(panel);
|
||||
TimelineFocused(sequence->viewer_output());
|
||||
}
|
||||
|
||||
void MainWindow::CloseSequence(Sequence *sequence)
|
||||
{
|
||||
for (int i=0;i<timeline_panels_.size();i++) {
|
||||
TimelinePanel* tl = timeline_panels_.at(i);
|
||||
// We defer to RemoveTimelinePanel() to close the panels, which may delete and remove indices from timeline_panels_.
|
||||
// We make a copy so that our array here doesn't get ruined by what RemoveTimelinePanel() does
|
||||
QList<TimelinePanel*> copy = timeline_panels_;
|
||||
|
||||
if (tl->GetConnectedViewer() == sequence->viewer_output()) {
|
||||
tl->ConnectViewerNode(nullptr);
|
||||
|
||||
if (timeline_panels_.size() > 1) {
|
||||
delete tl;
|
||||
timeline_panels_.removeAt(i);
|
||||
i--;
|
||||
}
|
||||
foreach (TimelinePanel* tp, copy) {
|
||||
if (tp->GetConnectedViewer() == sequence->viewer_output()) {
|
||||
RemoveTimelinePanel(tp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::IsSequenceOpen(Sequence *sequence) const
|
||||
{
|
||||
foreach (TimelinePanel* tp, timeline_panels_) {
|
||||
if (tp->GetConnectedViewer() == sequence->viewer_output()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
void MainWindow::SetTaskbarButtonState(TBPFLAG flags)
|
||||
{
|
||||
@@ -305,6 +312,11 @@ void MainWindow::UpdateTitle()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::TimelineCloseRequested()
|
||||
{
|
||||
RemoveTimelinePanel(static_cast<TimelinePanel*>(sender()));
|
||||
}
|
||||
|
||||
TimelinePanel* MainWindow::AppendTimelinePanel()
|
||||
{
|
||||
TimelinePanel* panel = PanelManager::instance()->CreatePanel<TimelinePanel>(this);;
|
||||
@@ -321,6 +333,10 @@ TimelinePanel* MainWindow::AppendTimelinePanel()
|
||||
|
||||
timeline_panels_.append(panel);
|
||||
|
||||
// Let us handle the panel closing rather than the panel itself
|
||||
panel->SetSignalInsteadOfClose(true);
|
||||
connect(panel, &TimelinePanel::CloseRequested, this, &MainWindow::TimelineCloseRequested);
|
||||
|
||||
connect(panel, &TimelinePanel::TimeChanged, param_panel_, &ParamPanel::SetTime);
|
||||
connect(panel, &TimelinePanel::TimeChanged, sequence_viewer_panel_, &SequenceViewerPanel::SetTime);
|
||||
connect(panel, &TimelinePanel::TimeChanged, curve_panel_, &CurvePanel::SetTime);
|
||||
@@ -336,14 +352,28 @@ TimelinePanel* MainWindow::AppendTimelinePanel()
|
||||
return panel;
|
||||
}
|
||||
|
||||
void MainWindow::TimelineFocused(TimelinePanel* panel)
|
||||
void MainWindow::RemoveTimelinePanel(TimelinePanel *panel)
|
||||
{
|
||||
sequence_viewer_panel_->ConnectViewerNode(panel->GetConnectedViewer());
|
||||
// Stop showing this timeline in the viewer
|
||||
TimelineFocused(nullptr);
|
||||
|
||||
if (timeline_panels_.size() == 1) {
|
||||
// Leave our single remaining timeline panel open
|
||||
panel->ConnectViewerNode(nullptr);
|
||||
} else {
|
||||
timeline_panels_.removeOne(panel);
|
||||
panel->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::TimelineFocused(ViewerOutput* viewer)
|
||||
{
|
||||
sequence_viewer_panel_->ConnectViewerNode(viewer);
|
||||
|
||||
Sequence* seq = nullptr;
|
||||
|
||||
if (panel->GetConnectedViewer()) {
|
||||
seq = static_cast<Sequence*>(panel->GetConnectedViewer()->parent());
|
||||
if (viewer) {
|
||||
seq = static_cast<Sequence*>(viewer->parent());
|
||||
}
|
||||
|
||||
node_panel_->SetGraph(seq);
|
||||
@@ -354,7 +384,7 @@ void MainWindow::FocusedPanelChanged(PanelWidget *panel)
|
||||
TimelinePanel* timeline = dynamic_cast<TimelinePanel*>(panel);
|
||||
|
||||
if (timeline) {
|
||||
TimelineFocused(timeline);
|
||||
TimelineFocused(timeline->GetConnectedViewer());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ public:
|
||||
|
||||
void CloseSequence(Sequence* sequence);
|
||||
|
||||
bool IsSequenceOpen(Sequence* sequence) const;
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
void SetTaskbarButtonState(TBPFLAG flags);
|
||||
|
||||
@@ -80,7 +82,9 @@ protected:
|
||||
private:
|
||||
TimelinePanel* AppendTimelinePanel();
|
||||
|
||||
void TimelineFocused(TimelinePanel *panel);
|
||||
void RemoveTimelinePanel(TimelinePanel *panel);
|
||||
|
||||
void TimelineFocused(ViewerOutput *viewer);
|
||||
|
||||
QByteArray premaximized_state_;
|
||||
|
||||
@@ -108,6 +112,8 @@ private slots:
|
||||
|
||||
void UpdateTitle();
|
||||
|
||||
void TimelineCloseRequested();
|
||||
|
||||
};
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
Reference in New Issue
Block a user