Reset and unregister global shortcut when it's not locked anymore.

This commit is contained in:
Felix Geyer 2012-07-14 19:07:13 +02:00
parent fa51f7e10e
commit d3af39a7ae
2 changed files with 11 additions and 3 deletions

View File

@ -56,6 +56,14 @@ void ShortcutWidget::setShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers)
}
}
void ShortcutWidget::resetShortcut()
{
m_key = static_cast<Qt::Key>(0);
m_modifiers = 0;
m_locked = false;
autoType()->unregisterGlobalShortcut();
}
void ShortcutWidget::keyPressEvent(QKeyEvent* event)
{
keyEvent(event);
@ -106,15 +114,14 @@ void ShortcutWidget::keyEvent(QKeyEvent* event)
setShortcut(key, modifiers);
}
else {
m_locked = false;
resetShortcut();
setStyleSheet("");
displayShortcut(key, modifiers);
}
}
else {
if (m_locked) {
m_locked = false;
m_key = static_cast<Qt::Key>(0);
resetShortcut();
setStyleSheet("");
}

View File

@ -39,6 +39,7 @@ protected:
private:
void keyEvent(QKeyEvent* event);
void displayShortcut(Qt::Key key, Qt::KeyboardModifiers modifiers);
void resetShortcut();
Qt::Key m_key;
Qt::KeyboardModifiers m_modifiers;