Commit 20c2dcf1 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Solved bug when cancelling keyboard shortcut capture

parent 706e4622
......@@ -38,12 +38,16 @@ KeyboardShortcutInput::KeyboardShortcutInput( const QString& name,
m_timer->setSingleShot( true );
connect( m_timer, SIGNAL( timeout() ), this, SLOT( timeout() ) );
setText( initialValue );
QKeySequence ks( initialValue );
for ( int i = 0; i < 4; ++i )
m_shortcuts[i] = ks[i];
}
void KeyboardShortcutInput::mousePressEvent( QMouseEvent* )
{
m_capturing = true;
setDown( true );
memcpy( m_initialValue, m_shortcuts, 4 * sizeof(int) );
memset( m_shortcuts, 0, sizeof( m_shortcuts ) );
m_current = 0;
setText( "" );
......@@ -59,9 +63,16 @@ void KeyboardShortcutInput::release()
m_capturing = false;
setDown( false );
setText( seq.toString() );
emit changed( m_name, seq.toString() );
}
void KeyboardShortcutInput::cancel()
{
memcpy( m_shortcuts, m_initialValue, 4 * sizeof(int) );
release();
}
void KeyboardShortcutInput::keyPressEvent( QKeyEvent* e )
{
if ( m_capturing == false )
......@@ -71,7 +82,7 @@ void KeyboardShortcutInput::keyPressEvent( QKeyEvent* e )
}
if ( e->modifiers() == Qt::NoModifier && e->key() == Qt::Key_Escape )
{
release();
cancel();
}
else
{
......
......@@ -38,6 +38,7 @@ class KeyboardShortcutInput : public QPushButton
virtual void mousePressEvent( QMouseEvent* e );
virtual void mouseReleaseEvent( QMouseEvent* e );
void release();
void cancel();
protected slots:
void timeout();
......@@ -48,6 +49,7 @@ class KeyboardShortcutInput : public QPushButton
QTimer* m_timer;
unsigned int m_current;
int m_shortcuts[4];
int m_initialValue[4];
signals:
void changed( const QString&, const QString& );
};
......
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