diff options
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/QtUI/QtChatWindow.cpp | 14 | ||||
-rw-r--r-- | Swift/QtUI/QtChatWindow.h | 1 | ||||
-rw-r--r-- | Swift/QtUI/QtTextEdit.cpp | 3 |
3 files changed, 16 insertions, 2 deletions
diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index e5c48f2..2f85571 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -67,7 +67,7 @@ QtChatWindow::QtChatWindow(const QString &contact, UIEventStream* eventStream) : inputClearing_ = false; contactIsTyping_ = false; - connect(input_, SIGNAL(unhandledKeyPressEvent(QKeyEvent*)), messageLog_, SLOT(handleKeyPressEvent(QKeyEvent*))); + connect(input_, SIGNAL(unhandledKeyPressEvent(QKeyEvent*)), this, SLOT(handleKeyPressEvent(QKeyEvent*))); connect(input_, SIGNAL(returnPressed()), this, SLOT(returnPressed())); connect(input_, SIGNAL(textChanged()), this, SLOT(handleInputChanged())); setFocusProxy(input_); @@ -80,6 +80,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) + ) { + close(); + } else { + messageLog_->handleKeyPressEvent(event); + } +} + void QtChatWindow::setRosterModel(Roster* roster) { treeWidget_->setRosterModel(roster); } diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index 4581a67..9d3e3a7 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -55,6 +55,7 @@ namespace Swift { private slots: void returnPressed(); void handleInputChanged(); + void handleKeyPressEvent(QKeyEvent* event); private: void updateTitleWithUnreadCount(); diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp index 70f7aca..a5fe762 100644 --- a/Swift/QtUI/QtTextEdit.cpp +++ b/Swift/QtUI/QtTextEdit.cpp @@ -23,7 +23,8 @@ void QtTextEdit::keyPressEvent(QKeyEvent* event) { && (modifiers == Qt::NoModifier || modifiers == Qt::KeypadModifier)) { 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_C && modifiers == Qt::ControlModifier && textCursor().selectedText().isEmpty()) + || (key == Qt::Key_W && modifiers == Qt::ControlModifier)) { emit unhandledKeyPressEvent(event); } else { QTextEdit::keyPressEvent(event); |