diff options
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,8 +1,8 @@ /* - * Copyright (c) 2010 Isode Limited. + * Copyright (c) 2010-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Swift/QtUI/QtTabbable.h> @@ -16,22 +16,16 @@ #include <Swift/QtUI/QtChatTabs.h> #include <Swift/QtUI/QtUtilities.h> 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(); } bool QtTabbable::isWidgetSelected() { /*isActiveWindow() shouldn't be necessary, but I don't trust it as far as I can throw it*/ if (!isActiveWindow()) { @@ -42,22 +36,26 @@ bool QtTabbable::isWidgetSelected() { } 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; } } return QWidget::event(event); } |