Global Spacebar Play (#7762)

This PR refactors how the spacebar is handled by the editors and the MainWindow to allow it to play/stop (Shift+Space for play/pause) the last played editor, no matter if it is in focus or not.

---------

Co-authored-by: Fawn <rubiefawn@gmail.com>
Co-authored-by: Sotonye Atemie <satemiej@gmail.com>
This commit is contained in:
regulus79
2025-04-26 18:26:26 -04:00
committed by GitHub
parent 8b5297f914
commit 510fbf6ffc
13 changed files with 66 additions and 29 deletions

View File

@@ -57,6 +57,13 @@ protected:
DropToolBar * addDropToolBar(QWidget * parent, Qt::ToolBarArea whereToAdd, QString const & windowTitle);
void closeEvent(QCloseEvent * event) override;
void keyPressEvent(QKeyEvent *ke) override;
public slots:
//! Called by pressing the space key. Plays or stops.
void togglePlayStop();
//! Called by pressing shift+space. Toggles pause state.
void togglePause();
protected slots:
virtual void play() {}
virtual void record() {}
@@ -65,12 +72,6 @@ protected slots:
virtual void stop() {}
private slots:
/// Called by pressing the space key. Plays or stops.
void togglePlayStop();
/// Called by pressing shift+space. Toggles pause state.
void togglePause();
void toggleMaximize();
signals:

View File

@@ -61,7 +61,7 @@ public:
void contextMenuEvent(QContextMenuEvent*) override;
void mousePressEvent(QMouseEvent*) override;
void mouseDoubleClickEvent(QMouseEvent*) override;
bool eventFilter(QObject* dist, QEvent* event) override;
void keyPressEvent(QKeyEvent* ke) override;
void reset();
int channelIndex() const { return m_channelIndex; }

View File

@@ -257,6 +257,7 @@ public:
return m_playMode;
}
PlayMode lastPlayMode() const { return m_lastPlayMode; }
inline PlayPos & getPlayPos( PlayMode pm )
{
return m_playPos[static_cast<std::size_t>(pm)];
@@ -492,6 +493,7 @@ private:
std::array<Timeline, PlayModeCount> m_timelines;
PlayMode m_playMode;
PlayMode m_lastPlayMode;
PlayPos m_playPos[PlayModeCount];
bar_t m_length;