Stop on second space key press
This commit is contained in:
@@ -48,6 +48,10 @@ protected slots:
|
||||
virtual void recordAccompany() {}
|
||||
virtual void stop() {}
|
||||
|
||||
private slots:
|
||||
/// Called by pressing the space key. Plays or stops.
|
||||
void togglePlayStop();
|
||||
|
||||
signals:
|
||||
|
||||
protected:
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <QAction>
|
||||
#include <QActionGroup>
|
||||
#include <QMdiArea>
|
||||
#include <QShortcut>
|
||||
|
||||
|
||||
void Editor::setPauseIcon(bool displayPauseIcon)
|
||||
@@ -41,6 +42,14 @@ void Editor::setPauseIcon(bool displayPauseIcon)
|
||||
m_playAction->setIcon(embed::getIconPixmap("play"));
|
||||
}
|
||||
|
||||
void Editor::togglePlayStop()
|
||||
{
|
||||
if (Engine::getSong()->isPlaying())
|
||||
stop();
|
||||
else
|
||||
play();
|
||||
}
|
||||
|
||||
Editor::Editor(bool record) :
|
||||
m_toolBar(new QToolBar(this)),
|
||||
m_playAction(nullptr),
|
||||
@@ -63,13 +72,12 @@ Editor::Editor(bool record) :
|
||||
m_recordAction = new QAction(embed::getIconPixmap("record"), tr("Record"), this);
|
||||
m_recordAccompanyAction = new QAction(embed::getIconPixmap("record_accompany"), tr("Record while playing"), this);
|
||||
|
||||
m_playAction->setShortcut(Qt::Key_Space);
|
||||
|
||||
// Set up connections
|
||||
connect(m_playAction, SIGNAL(triggered()), this, SLOT(play()));
|
||||
connect(m_recordAction, SIGNAL(triggered()), this, SLOT(record()));
|
||||
connect(m_recordAccompanyAction, SIGNAL(triggered()), this, SLOT(recordAccompany()));
|
||||
connect(m_stopAction, SIGNAL(triggered()), this, SLOT(stop()));
|
||||
new QShortcut(Qt::Key_Space, this, SLOT(togglePlayStop()));
|
||||
|
||||
// Add toolbar to window
|
||||
addToolBar(Qt::TopToolBarArea, m_toolBar);
|
||||
|
||||
Reference in New Issue
Block a user