summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-05-20 22:15:32 (GMT)
committerTobias Markmann <tm@ayena.de>2015-05-20 22:20:00 (GMT)
commitd1823afd38df62887b0c5e9f1f01a50ab84f77ba (patch)
tree9c79c6474d5b54b7d89fc72008599e886fd46476
parent79af3d5aed669839a916f8973953b608e4177e9b (diff)
downloadswift-d1823afd38df62887b0c5e9f1f01a50ab84f77ba.zip
swift-d1823afd38df62887b0c5e9f1f01a50ab84f77ba.tar.bz2
Usability improvements to "Enter Room" dialog
Require valid room JID to proceed with entering a room. Provide user feedback via tooltips on invalid input in the room and nickname field. Test-Information: Tested with invalid room JID and empty nickanme on OS X 10.9.5 and Qt 5.4.0. Change-Id: I8d8c75f5712f27cc72cce2d6dd16dbbea4fb504a
-rw-r--r--Swift/QtUI/QtJoinMUCWindow.cpp12
-rw-r--r--Swift/QtUI/QtJoinMUCWindow.h35
2 files changed, 37 insertions, 10 deletions
diff --git a/Swift/QtUI/QtJoinMUCWindow.cpp b/Swift/QtUI/QtJoinMUCWindow.cpp
index d111756..53944da 100644
--- a/Swift/QtUI/QtJoinMUCWindow.cpp
+++ b/Swift/QtUI/QtJoinMUCWindow.cpp
@@ -4,11 +4,12 @@
* See the COPYING file for more information.
*/
-
#include <Swift/QtUI/QtJoinMUCWindow.h>
#include <boost/smart_ptr/make_shared.hpp>
+#include <QToolTip>
+
#include <Swift/Controllers/UIEvents/JoinMUCUIEvent.h>
#include <Swift/Controllers/UIEvents/UIEventStream.h>
@@ -32,15 +33,16 @@ QtJoinMUCWindow::QtJoinMUCWindow(UIEventStream* uiEventStream) : uiEventStream(u
#endif
ui.instantRoom->setChecked(true);
ui.nickName->setValidator(new NickValidator(this));
+ ui.room->setValidator(new RoomJIDValidator(this));
}
void QtJoinMUCWindow::handleJoin() {
- if (ui.room->text().isEmpty()) {
- // TODO: Error
+ if (ui.room->text().isEmpty() || !ui.room->hasAcceptableInput()) {
+ QToolTip::showText(ui.room->mapToGlobal(QPoint()), tr("Please enter a valid room address."), ui.room);
return;
}
- if (ui.nickName->text().isEmpty()) {
- // TODO: Error
+ if (ui.nickName->text().isEmpty() || !ui.nickName->hasAcceptableInput()) {
+ QToolTip::showText(ui.nickName->mapToGlobal(QPoint()), tr("Please enter a valid nickname."), ui.nickName);
return;
}
diff --git a/Swift/QtUI/QtJoinMUCWindow.h b/Swift/QtUI/QtJoinMUCWindow.h
index ba12b86..92580ff 100644
--- a/Swift/QtUI/QtJoinMUCWindow.h
+++ b/Swift/QtUI/QtJoinMUCWindow.h
@@ -1,16 +1,20 @@
/*
- * Copyright (c) 2010 Isode Limited.
+ * Copyright (c) 2010-2015 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <QValidator>
+#include <Swift/QtUI/ui_QtJoinMUCWindow.h>
+
#include <string>
-#include "QtSwiftUtil.h"
+
+#include <QValidator>
+
#include <Swift/Controllers/UIInterfaces/JoinMUCWindow.h>
-#include <Swift/QtUI/ui_QtJoinMUCWindow.h>
+
+#include <Swift/QtUI/QtSwiftUtil.h>
namespace Swift {
class UIEventStream;
@@ -22,13 +26,34 @@ namespace Swift {
virtual QValidator::State validate(QString& input, int& /*pos*/) const {
if (input.isEmpty()) {
- return QValidator::Acceptable;
+ return QValidator::Intermediate;
}
JID test("alice", "wonderland.lit", Q2PSTRING(input));
return test.isValid() ? QValidator::Acceptable : QValidator::Invalid;
}
};
+
+ class RoomJIDValidator : public QValidator {
+ Q_OBJECT
+ public:
+ RoomJIDValidator(QObject* parent) : QValidator(parent) {
+ }
+
+ virtual QValidator::State validate(QString& input, int& /*pos*/) const {
+ if (input.isEmpty()) {
+ return QValidator::Intermediate;
+ }
+ JID roomJID(Q2PSTRING(input));
+
+ if (roomJID.getNode().empty() || roomJID.getDomain().empty()) {
+ return QValidator::Intermediate;
+ }
+
+ return (roomJID.getResource().empty() && !roomJID.getNode().empty() && !roomJID.getDomain().empty() && roomJID.isValid()) ? QValidator::Acceptable : QValidator::Invalid;
+ }
+ };
+
class QtJoinMUCWindow : public QWidget, public JoinMUCWindow {
Q_OBJECT
public: