diff options
author | Kevin Smith <git@kismith.co.uk> | 2009-08-16 15:14:56 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2009-08-16 15:14:56 (GMT) |
commit | 6bb73fb2d367a95cc1df2addf7dd5477b643c2e8 (patch) | |
tree | f6c42a9de8ff3800c9ffe1e44b92bff1e6eda7e6 /Swift/QtUI/QtAddContactDialog.cpp | |
parent | 6d64d22bdc18a8b4d3ef1ae7087f657de6c9abd9 (diff) | |
download | swift-contrib-6bb73fb2d367a95cc1df2addf7dd5477b643c2e8.zip swift-contrib-6bb73fb2d367a95cc1df2addf7dd5477b643c2e8.tar.bz2 |
Adding in a button to the roster for 'Add Contact'
Diffstat (limited to 'Swift/QtUI/QtAddContactDialog.cpp')
-rw-r--r-- | Swift/QtUI/QtAddContactDialog.cpp | 32 |
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(); +} +} |