From 1934734a0a0ef46d5db2eeedfb380a269116e3b4 Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Tue, 25 May 2010 19:49:30 +0100 Subject: Allow Ctrl-W to close chat windows 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); -- cgit v0.10.2-6-g49f6