summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtLoginWindow.cpp17
-rw-r--r--Swift/QtUI/QtLoginWindow.h3
2 files changed, 19 insertions, 1 deletions
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 <QHBoxLayout>
#include <qdebug.h>
#include <QCloseEvent>
+#include <QCursor>
#include <QMessageBox>
-
+#include <QKeyEvent>
+
#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("<font size='-1' color='grey' >Example: alice@wonderland.lit</font>");
@@ -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<QKeyEvent *>(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<UIEvent> event) {
boost::shared_ptr<ToggleSoundsUIEvent> soundEvent = boost::dynamic_pointer_cast<ToggleSoundsUIEvent>(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<UIEvent> event);
+ protected:
+ bool eventFilter(QObject *obj, QEvent *event);
+
private:
void setInitialMenus();
QStringList usernames_;