From fd7a668326dde86c11dd57c2c2e201fd959b02f5 Mon Sep 17 00:00:00 2001 From: Thilo Cestonaro Date: Mon, 13 Dec 2010 11:28:19 +0100 Subject: Identify the marked jid and recognize del or backspace License: This patch is BSD-licensed, see http://www.opensource.org/licenses/bsd-license.php diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp index 7d17f88..d028253 100644 --- a/Swift/QtUI/QtLoginWindow.cpp +++ b/Swift/QtUI/QtLoginWindow.cpp @@ -22,8 +22,10 @@ #include #include #include +#include #include - +#include + #include "Swift/Controllers/UIEvents/UIEventStream.h" #include "Swift/Controllers/UIEvents/RequestXMLConsoleUIEvent.h" #include "Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h" @@ -83,6 +85,7 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow() { username_->setEditable(true); username_->setWhatsThis("User address - looks like someuser@someserver.com"); username_->setToolTip("User address - looks like someuser@someserver.com"); + username_->view()->installEventFilter(this); layout->addWidget(username_); QLabel* jidHintLabel = new QLabel(this); jidHintLabel->setText("Example: alice@wonderland.lit"); @@ -186,6 +189,18 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow() { this->show(); } +bool QtLoginWindow::eventFilter(QObject *obj, QEvent *event) { + if (obj == username_->view() && event->type() == QEvent::KeyPress) { + QKeyEvent *keyEvent = static_cast(event); + if(keyEvent->key() == Qt::Key_Delete || Qt::Key_Backspace) { + QMessageBox::information(this, "Delete this login data?", "Remove the save login data regarding the jid: " + username_->view()->currentIndex().data().toString()); + return true; + } + } + // standard event processing + return QObject::eventFilter(obj, event); +} + void QtLoginWindow::handleUIEvent(boost::shared_ptr event) { boost::shared_ptr soundEvent = boost::dynamic_pointer_cast(event); if (soundEvent) { diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h index 454b9ba..90defd1 100644 --- a/Swift/QtUI/QtLoginWindow.h +++ b/Swift/QtUI/QtLoginWindow.h @@ -59,6 +59,9 @@ namespace Swift { void moveEvent(QMoveEvent* event); void handleUIEvent(boost::shared_ptr event); + protected: + bool eventFilter(QObject *obj, QEvent *event); + private: void setInitialMenus(); QStringList usernames_; -- cgit v0.10.2-6-g49f6