viewerpanelbase: stop playback when panel is defocused
This commit is contained in:
@@ -28,7 +28,8 @@ PanelManager* PanelManager::instance_ = nullptr;
|
||||
|
||||
PanelManager::PanelManager(QObject *parent) :
|
||||
QObject(parent),
|
||||
locked_(false)
|
||||
locked_(false),
|
||||
suppress_changed_signal_(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -165,7 +166,9 @@ void PanelManager::FocusChanged(QWidget *old, QWidget *now)
|
||||
focus_history_.move(panel_index, 0);
|
||||
}
|
||||
|
||||
emit FocusedPanelChanged(panel_cast_test);
|
||||
if (!suppress_changed_signal_) {
|
||||
emit FocusedPanelChanged(panel_cast_test);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -122,6 +122,11 @@ public:
|
||||
*/
|
||||
void UnregisterPanel(PanelWidget *panel);
|
||||
|
||||
void SetSuppressChangedSignal(bool e)
|
||||
{
|
||||
suppress_changed_signal_ = e;
|
||||
}
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Connect this to a QApplication's SIGNAL(focusChanged())
|
||||
@@ -157,6 +162,8 @@ private:
|
||||
*/
|
||||
static PanelManager* instance_;
|
||||
|
||||
bool suppress_changed_signal_;
|
||||
|
||||
};
|
||||
|
||||
template<class T>
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace olive {
|
||||
ViewerPanelBase::ViewerPanelBase(const QString& object_name, QWidget *parent) :
|
||||
TimeBasedPanel(object_name, parent)
|
||||
{
|
||||
connect(PanelManager::instance(), &PanelManager::FocusedPanelChanged, this, &ViewerPanelBase::FocusedPanelChanged);
|
||||
}
|
||||
|
||||
void ViewerPanelBase::PlayPause()
|
||||
@@ -101,4 +102,12 @@ void ViewerPanelBase::SetViewerWidget(ViewerWidget *vw)
|
||||
SetTimeBasedWidget(vw);
|
||||
}
|
||||
|
||||
void ViewerPanelBase::FocusedPanelChanged(PanelWidget *panel)
|
||||
{
|
||||
auto vw = static_cast<ViewerWidget*>(GetTimeBasedWidget());
|
||||
if (vw->IsPlaying() && panel != this) {
|
||||
vw->Pause();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -93,6 +93,9 @@ signals:
|
||||
protected:
|
||||
void SetViewerWidget(ViewerWidget *vw);
|
||||
|
||||
private slots:
|
||||
void FocusedPanelChanged(PanelWidget *panel);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -314,9 +314,18 @@ void MainWindow::ToggleMaximizedPanel()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Preserve currently focused panel
|
||||
auto currently_focused_panel = PanelManager::instance()->CurrentlyFocused(false);
|
||||
|
||||
// Assume we are currently maximized, restore the state
|
||||
PanelManager::instance()->SetSuppressChangedSignal(true);
|
||||
restoreState(premaximized_state_);
|
||||
premaximized_state_.clear();
|
||||
|
||||
currently_focused_panel->raise();
|
||||
currently_focused_panel->setFocus();
|
||||
|
||||
PanelManager::instance()->SetSuppressChangedSignal(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user