summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtAddContactDialog.cpp')
-rw-r--r--Swift/QtUI/QtAddContactDialog.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/Swift/QtUI/QtAddContactDialog.cpp b/Swift/QtUI/QtAddContactDialog.cpp
new file mode 100644
index 0000000..09059c1
--- /dev/null
+++ b/Swift/QtUI/QtAddContactDialog.cpp
@@ -0,0 +1,32 @@
+#include "QtAddContactDialog.h"
+#include "QtSwiftUtil.h"
+
+namespace Swift {
+
+QtAddContactDialog::QtAddContactDialog(QWidget* parent) : QDialog(parent) {
+ setupUi(this);
+ errorLabel_->hide();
+ setAttribute(Qt::WA_DeleteOnClose, true);
+ connect(buttons_, SIGNAL(accepted()), SLOT(accept()));
+ connect(buttons_, SIGNAL(rejected()), SLOT(reject()));
+}
+
+void QtAddContactDialog::accept() {
+ if (contactJID_->displayText().isEmpty()) {
+ showError("You must specify a contact to add.");
+ return;
+ }
+ if (name_->displayText().isEmpty()) {
+ showError("You must specify a name for the contact.");
+ return;
+ }
+ errorLabel_->hide();
+ emit onAddCommand(JID(Q2PSTRING(contactJID_->displayText())), name_->displayText());
+ QDialog::accept();
+}
+
+void QtAddContactDialog::showError(const QString& error) {
+ errorLabel_->setText(QString("<font color='red'>%1</font>").arg(error));
+ errorLabel_->show();
+}
+}