diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-05-25 19:56:36 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-05-25 19:56:36 (GMT) |
commit | ee9eff16cd7024bdbd889bab7612c63bcfe3cbe9 (patch) | |
tree | d71842bf0c48c7163b8e67f42126d7f4c72fd3e4 | |
parent | 1934734a0a0ef46d5db2eeedfb380a269116e3b4 (diff) | |
download | swift-ee9eff16cd7024bdbd889bab7612c63bcfe3cbe9.zip swift-ee9eff16cd7024bdbd889bab7612c63bcfe3cbe9.tar.bz2 |
Support Ctrl-PgUp/PgDn for switch ing tabs
-rw-r--r-- | Swift/QtUI/QtChatTabs.cpp | 14 | ||||
-rw-r--r-- | Swift/QtUI/QtChatTabs.h | 3 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 14 | ||||
-rw-r--r-- | Swift/QtUI/QtTabbable.h | 2 | ||||
-rw-r--r-- | Swift/QtUI/QtTextEdit.cpp | 7 |
5 files changed, 36 insertions, 4 deletions
diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp index d327e7c..a7698c2 100644 --- a/Swift/QtUI/QtChatTabs.cpp +++ b/Swift/QtUI/QtChatTabs.cpp @@ -51,6 +51,8 @@ void QtChatTabs::addTab(QtTabbable* tab) { connect(tab, SIGNAL(windowClosing()), this, SLOT(handleTabClosing())); connect(tab, SIGNAL(windowOpening()), this, SLOT(handleWidgetShown())); connect(tab, SIGNAL(wantsToActivate()), this, SLOT(handleWantsToActivate())); + connect(tab, SIGNAL(requestNextTab()), this, SLOT(handleRequestedNextTab())); + connect(tab, SIGNAL(requestPreviousTab()), this, SLOT(handleRequestedPreviousTab())); } void QtChatTabs::handleWidgetShown() { @@ -95,6 +97,18 @@ void QtChatTabs::handleTabClosing() { handleTabTitleUpdated(tabs_->currentWidget()); } +void QtChatTabs::handleRequestedPreviousTab() { + int newIndex = tabs_->currentIndex() - 1; + tabs_->setCurrentIndex(newIndex >= 0 ? newIndex : tabs_->count() - 1); +} + +void QtChatTabs::handleRequestedNextTab() { + int newIndex = tabs_->currentIndex() + 1; + tabs_->setCurrentIndex(newIndex < tabs_->count() ? newIndex : 0); + +} + + void QtChatTabs::handleTabCloseRequested(int index) { QWidget* widget = tabs_->widget(index); widget->close(); diff --git a/Swift/QtUI/QtChatTabs.h b/Swift/QtUI/QtChatTabs.h index 84d9dbc..41d7b2f0 100644 --- a/Swift/QtUI/QtChatTabs.h +++ b/Swift/QtUI/QtChatTabs.h @@ -35,6 +35,9 @@ namespace Swift { void handleTabCloseRequested(int index); void handleWidgetShown(); void handleWantsToActivate(); + void handleRequestedPreviousTab(); + void handleRequestedNextTab(); + private: void checkForFirstShow(); QtTabWidget* tabs_; diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 2f85571..544efd3 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -83,10 +83,18 @@ QtChatWindow::~QtChatWindow() { void QtChatWindow::handleKeyPressEvent(QKeyEvent* event) { int key = event->key(); Qt::KeyboardModifiers modifiers = event->modifiers(); - if ( - (key == Qt::Key_W && modifiers == Qt::ControlModifier) - ) { + if (key == Qt::Key_W && modifiers == Qt::ControlModifier) { close(); + } else if ( + (key == Qt::Key_PageUp && modifiers == Qt::ControlModifier) + || (key == Qt::Key_Left && modifiers == (Qt::ControlModifier & Qt::ShiftModifier)) + ) { + emit requestPreviousTab(); + } else if ( + (key == Qt::Key_PageDown && modifiers == Qt::ControlModifier) + || (key == Qt::Key_Right && modifiers == (Qt::ControlModifier & Qt::ShiftModifier)) + ) { + emit requestNextTab(); } else { messageLog_->handleKeyPressEvent(event); } diff --git a/Swift/QtUI/QtTabbable.h b/Swift/QtUI/QtTabbable.h index 63bc140..dd87142 100644 --- a/Swift/QtUI/QtTabbable.h +++ b/Swift/QtUI/QtTabbable.h @@ -25,5 +25,7 @@ namespace Swift { void windowClosing(); void windowOpening(); void wantsToActivate(); + void requestPreviousTab(); + void requestNextTab(); }; } diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp index a5fe762..451a18c 100644 --- a/Swift/QtUI/QtTextEdit.cpp +++ b/Swift/QtUI/QtTextEdit.cpp @@ -24,7 +24,12 @@ void QtTextEdit::keyPressEvent(QKeyEvent* event) { emit returnPressed(); } else if (((key == Qt::Key_PageUp || key == Qt::Key_PageDown) && modifiers == Qt::ShiftModifier) || (key == Qt::Key_C && modifiers == Qt::ControlModifier && textCursor().selectedText().isEmpty()) - || (key == Qt::Key_W && modifiers == Qt::ControlModifier)) { + || (key == Qt::Key_W && modifiers == Qt::ControlModifier) + || (key == Qt::Key_PageUp && modifiers == Qt::ControlModifier) + || (key == Qt::Key_PageDown && modifiers == Qt::ControlModifier) + || (key == Qt::Key_Left && modifiers == (Qt::ControlModifier | Qt::ShiftModifier)) + || (key == Qt::Key_Right && modifiers == (Qt::ControlModifier | Qt::ShiftModifier)) + ) { emit unhandledKeyPressEvent(event); } else { QTextEdit::keyPressEvent(event); |