summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-05-25 18:49:30 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-05-25 18:49:30 (GMT)
commit1934734a0a0ef46d5db2eeedfb380a269116e3b4 (patch)
tree8a777b83acc6405ad0c9a317725a4e786943d7e2 /Swift
parent2a5340bd4c758a1e61c10aaaf5ebed725243a151 (diff)
downloadswift-1934734a0a0ef46d5db2eeedfb380a269116e3b4.zip
swift-1934734a0a0ef46d5db2eeedfb380a269116e3b4.tar.bz2
Allow Ctrl-W to close chat windows
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtChatWindow.cpp14
-rw-r--r--Swift/QtUI/QtChatWindow.h1
-rw-r--r--Swift/QtUI/QtTextEdit.cpp3
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);