mainwindow/timelinepanel: closing a timeline will close a sequence entirely

UI detail.
This commit is contained in:
itsmattkc
2020-04-07 03:07:43 +10:00
parent 9f89f57090
commit cf04cad238
7 changed files with 92 additions and 21 deletions
+11
View File
@@ -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
+9
View File
@@ -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);
+6 -3
View File
@@ -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)"));
}
}
+17 -1
View File
@@ -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
+9
View File
@@ -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
+35 -16
View File
@@ -144,22 +144,18 @@ 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);
}
}
}
@@ -305,6 +301,11 @@ void MainWindow::UpdateTitle()
}
}
void MainWindow::TimelineCloseRequested()
{
RemoveTimelinePanel(static_cast<TimelinePanel*>(sender()));
}
TimelinePanel* MainWindow::AppendTimelinePanel()
{
TimelinePanel* panel = PanelManager::instance()->CreatePanel<TimelinePanel>(this);;
@@ -321,6 +322,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 +341,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 +373,7 @@ void MainWindow::FocusedPanelChanged(PanelWidget *panel)
TimelinePanel* timeline = dynamic_cast<TimelinePanel*>(panel);
if (timeline) {
TimelineFocused(timeline);
TimelineFocused(timeline->GetConnectedViewer());
}
}
+5 -1
View File
@@ -80,7 +80,9 @@ protected:
private:
TimelinePanel* AppendTimelinePanel();
void TimelineFocused(TimelinePanel *panel);
void RemoveTimelinePanel(TimelinePanel *panel);
void TimelineFocused(ViewerOutput *viewer);
QByteArray premaximized_state_;
@@ -108,6 +110,8 @@ private slots:
void UpdateTitle();
void TimelineCloseRequested();
};
OLIVE_NAMESPACE_EXIT