Commit 01ba6993 authored by Oliver Bock's avatar Oliver Bock

Added alternative shortcuts for run, pause and stop actions

* Required when menu is hidden
* Also: using shortcuts retrieved from widgets (not hardcoded)
parent 4ce88264
......@@ -37,11 +37,17 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
m_animControlFloating = ui.dockAnimControl->isFloating();
// register alternate shortcuts (will be enabled when menu is hidden)
m_rotationAxesShortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_R), this);
m_runShortcut = new QShortcut(ui.actionRun->shortcut(), this);
m_runShortcut->setEnabled(false);
m_pauseShortcut = new QShortcut(ui.actionPause->shortcut(), this);
m_pauseShortcut->setEnabled(false);
m_stopShortcut = new QShortcut(ui.actionStop->shortcut(), this);
m_stopShortcut->setEnabled(false);
m_rotationAxesShortcut = new QShortcut(ui.actionRotationAxes->shortcut(), this);
m_rotationAxesShortcut->setEnabled(false);
m_menuBarShortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_M), this);
m_menuBarShortcut = new QShortcut(ui.actionMenu_bar->shortcut(), this);
m_menuBarShortcut->setEnabled(false);
m_fullscreenShortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_F), this);
m_fullscreenShortcut = new QShortcut(ui.actionFullscreen->shortcut(), this);
m_fullscreenShortcut->setEnabled(false);
// TODO: register all remaining shortcuts, too (to use them while menu is hidden!)
......@@ -84,6 +90,21 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
PulsatingScience::~PulsatingScience()
{
if(m_runShortcut) {
m_runShortcut->disconnect();
delete m_runShortcut;
}
if(m_pauseShortcut) {
m_pauseShortcut->disconnect();
delete m_pauseShortcut;
}
if(m_stopShortcut) {
m_stopShortcut->disconnect();
delete m_stopShortcut;
}
if(m_rotationAxesShortcut) {
m_rotationAxesShortcut->disconnect();
delete m_rotationAxesShortcut;
......@@ -217,6 +238,12 @@ void PulsatingScience::on_actionMenu_bar_toggled(bool checked)
m_menuBarVisible = true;
// deactivate alternate shortcuts
m_runShortcut->disconnect();
m_runShortcut->setEnabled(false);
m_pauseShortcut->disconnect();
m_pauseShortcut->setEnabled(false);
m_stopShortcut->disconnect();
m_stopShortcut->setEnabled(false);
m_rotationAxesShortcut->disconnect();
m_rotationAxesShortcut->setEnabled(false);
m_fullscreenShortcut->disconnect();
......@@ -229,6 +256,12 @@ void PulsatingScience::on_actionMenu_bar_toggled(bool checked)
m_menuBarVisible = false;
// activate alternate shortcuts
m_runShortcut->setEnabled(true);
connect(m_runShortcut, SIGNAL(activated()), ui.pulsarGlWidget, SLOT(runAnimation()));
m_pauseShortcut->setEnabled(true);
connect(m_pauseShortcut, SIGNAL(activated()), ui.pulsarGlWidget, SLOT(pauseAnimation()));
m_stopShortcut->setEnabled(true);
connect(m_stopShortcut, SIGNAL(activated()), ui.pulsarGlWidget, SLOT(stopAnimation()));
m_rotationAxesShortcut->setEnabled(true);
connect(m_rotationAxesShortcut, SIGNAL(activated()), this, SLOT(rotationAxesToggled()));
m_fullscreenShortcut->setEnabled(true);
......
......@@ -66,6 +66,9 @@ public slots:
private:
Ui::PulsatingScienceClass ui;
QShortcut *m_runShortcut;
QShortcut *m_pauseShortcut;
QShortcut *m_stopShortcut;
QShortcut *m_rotationAxesShortcut;
QShortcut *m_menuBarShortcut;
QShortcut *m_fullscreenShortcut;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment