diff options
author | Tobias Markmann <tm@ayena.de> | 2015-01-15 20:58:00 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2015-02-17 11:54:49 (GMT) |
commit | 265b779d6766130afa8f2f166733dc172ba22dca (patch) | |
tree | 5eb420f523cdfc561ff8c3a2ee44ecc28a717062 /Swift/QtUI/QtTabbable.cpp | |
parent | 619c4611e7c495c4545d65df5c86aa051ab6d354 (diff) | |
download | swift-265b779d6766130afa8f2f166733dc172ba22dca.zip swift-265b779d6766130afa8f2f166733dc172ba22dca.tar.bz2 |
Fix shortcut handling for chat window navigation
This commit fixes CTRL-Tab, CTRL-Backtab and CTRL-W shortcuts on Mac,
Windows and Linux.
These shortcuts work in all mode except --no-tabs mode. This will be fixed
in a future commit. There is still different behavior across platforms:
on Windows and Linux they are handled on key press and repeat, and on
Mac they are handled on key release and do not repeat.
Test-Information:
Tested on OS X 10.9.5, Windows 7 and Elementary OS.
Change-Id: I2179f234cfd76b86cf261f2cf7500fc1cf0439a4
Diffstat (limited to 'Swift/QtUI/QtTabbable.cpp')
-rw-r--r-- | Swift/QtUI/QtTabbable.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/Swift/QtUI/QtTabbable.cpp b/Swift/QtUI/QtTabbable.cpp index 962bd9d..feab35e 100644 --- a/Swift/QtUI/QtTabbable.cpp +++ b/Swift/QtUI/QtTabbable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -19,16 +19,10 @@ namespace Swift { QtTabbable::QtTabbable() : QWidget() { - shortcuts << new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), window(), SLOT(close())); - shortcuts << new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageUp), window(), SIGNAL(requestPreviousTab())); - shortcuts << new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageDown), window(), SIGNAL(requestNextTab())); - shortcuts << new QShortcut(QKeySequence(Qt::ALT + Qt::Key_A), window(), SIGNAL(requestActiveTab())); + } QtTabbable::~QtTabbable() { - foreach (QShortcut* shortcut, shortcuts) { - delete shortcut; - } emit windowClosing(); } @@ -45,16 +39,20 @@ bool QtTabbable::event(QEvent* event) { QKeyEvent* keyEvent = dynamic_cast<QKeyEvent*>(event); if (keyEvent) { // According to Qt's focus documentation, one can only override CTRL+TAB via reimplementing QWidget::event(). -#ifdef SWIFTEN_PLATFORM_LINUX - if (keyEvent->modifiers().testFlag(QtUtilities::ctrlHardwareKeyModifier) && keyEvent->key() == Qt::Key_Tab && event->type() != QEvent::KeyRelease) { -#else if (keyEvent->modifiers().testFlag(QtUtilities::ctrlHardwareKeyModifier) && keyEvent->key() == Qt::Key_Tab) { -#endif - emit requestNextTab(); + if (keyEvent->type() != QEvent::ShortcutOverride) { + emit requestNextTab(); + } return true; } +#ifdef SWIFTEN_PLATFORM_LINUX + else if (keyEvent->modifiers().testFlag(QtUtilities::ctrlHardwareKeyModifier) && keyEvent->key() == Qt::Key_Backtab && keyEvent->type() != QEvent::KeyRelease) { +#else else if (keyEvent->modifiers().testFlag(QtUtilities::ctrlHardwareKeyModifier) && keyEvent->key() == Qt::Key_Backtab) { - emit requestPreviousTab(); +#endif + if (keyEvent->type() != QEvent::ShortcutOverride) { + emit requestPreviousTab(); + } return true; } } |