summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/QtUI/QtChatTabs.cpp19
-rw-r--r--Swift/QtUI/QtChatTabs.h7
-rw-r--r--Swift/QtUI/QtTabbable.cpp26
-rw-r--r--Swift/QtUI/QtTabbable.h8
4 files changed, 37 insertions, 23 deletions
diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp
index 0701d33..04c6a49 100644
--- a/Swift/QtUI/QtChatTabs.cpp
+++ b/Swift/QtUI/QtChatTabs.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2014 Isode Limited.
+ * Copyright (c) 2010-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -70,9 +70,19 @@ QtChatTabs::QtChatTabs(bool singleWindow, SettingsProvider* settingsProvider, bo
}
gridSelectionDialog_ = new QtGridSelectionDialog();
+
+ // setup shortcuts
+ shortcuts_ << new QShortcut(QKeySequence(tr("CTRL+W", "Close chat tab.")), window(), SLOT(handleCloseTabShortcut()));
+ shortcuts_ << new QShortcut(QKeySequence(Qt::CTRL, Qt::Key_PageUp), window(), SLOT(handleRequestedPreviousTab()));
+ shortcuts_ << new QShortcut(QKeySequence(Qt::CTRL, Qt::Key_PageDown), window(), SLOT(handleRequestedNextTab()));
+ shortcuts_ << new QShortcut(QKeySequence(Qt::ALT + Qt::Key_A), window(), SLOT(handleRequestedActiveTab()));
}
QtChatTabs::~QtChatTabs() {
+ foreach (QShortcut* shortcut, shortcuts_) {
+ delete shortcut;
+ }
+
if (trellisMode_) {
storeTabPositions();
}
@@ -230,6 +240,13 @@ void QtChatTabs::handleRequestedActiveTab() {
}
+void QtChatTabs::handleCloseTabShortcut() {
+ QWidget* currentWidget = dynamicGrid_->currentWidget();
+ if (currentWidget) {
+ currentWidget->close();
+ }
+}
+
void QtChatTabs::handleTabCloseRequested(int index) {
if (trellisMode_) {
storeTabPositions();
diff --git a/Swift/QtUI/QtChatTabs.h b/Swift/QtUI/QtChatTabs.h
index 6cb4dfe..04e9eca 100644
--- a/Swift/QtUI/QtChatTabs.h
+++ b/Swift/QtUI/QtChatTabs.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2014 Isode Limited.
+ * Copyright (c) 2010-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -8,6 +8,7 @@
#include <QWidget>
#include <QRect>
+#include <QShortcut>
class QTabWidget;
class QMenu;
@@ -54,6 +55,8 @@ namespace Swift {
void handleOpenLayoutChangeDialog();
+ void handleCloseTabShortcut();
+
private:
void storeTabPositions();
void checkForFirstShow();
@@ -64,6 +67,8 @@ namespace Swift {
bool trellisMode_;
QtDynamicGridLayout* dynamicGrid_;
QtGridSelectionDialog* gridSelectionDialog_;
+
+ QList<QShortcut*> shortcuts_;
};
}
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;
}
}
diff --git a/Swift/QtUI/QtTabbable.h b/Swift/QtUI/QtTabbable.h
index c3cfa76..db83ba9 100644
--- a/Swift/QtUI/QtTabbable.h
+++ b/Swift/QtUI/QtTabbable.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 Isode Limited.
+ * Copyright (c) 2014-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
@@ -8,11 +8,8 @@
#include <string>
-#include <QList>
#include <QWidget>
-class QShortcut;
-
namespace Swift {
class QtTabbable : public QWidget {
Q_OBJECT
@@ -38,8 +35,5 @@ namespace Swift {
void requestNextTab();
void requestActiveTab();
void requestFlash();
-
- private:
- QList<QShortcut*> shortcuts;
};
}