summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-12-17 13:21:14 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-01-30 15:10:02 (GMT)
commitb897bac235a95f9c4654b31d101779bd0cc8f72f (patch)
tree8d00b3ab58ec200adf670e01671eed91876b485d /Swift/QtUI/QtProfileWindow.cpp
parent869c52b244c2d03313e9eda83fac05bf0fc3a619 (diff)
downloadswift-b897bac235a95f9c4654b31d101779bd0cc8f72f.zip
swift-b897bac235a95f9c4654b31d101779bd0cc8f72f.tar.bz2
Added profile edit dialog.
Resolves: #141, #587.
Diffstat (limited to 'Swift/QtUI/QtProfileWindow.cpp')
-rw-r--r--Swift/QtUI/QtProfileWindow.cpp132
1 files changed, 132 insertions, 0 deletions
diff --git a/Swift/QtUI/QtProfileWindow.cpp b/Swift/QtUI/QtProfileWindow.cpp
new file mode 100644
index 0000000..0a53f11
--- /dev/null
+++ b/Swift/QtUI/QtProfileWindow.cpp
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2011 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "QtProfileWindow.h"
+
+#include <QImage>
+#include <QPixmap>
+#include <QSizePolicy>
+#include <QGridLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QPushButton>
+#include <QMovie>
+
+#include "QtSwiftUtil.h"
+#include "QtAvatarWidget.h"
+
+namespace Swift {
+
+QtProfileWindow::QtProfileWindow() {
+ setWindowTitle("Edit Profile");
+
+ QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
+ sizePolicy.setHorizontalStretch(0);
+ sizePolicy.setVerticalStretch(0);
+ sizePolicy.setHeightForWidth(this->sizePolicy().hasHeightForWidth());
+ setSizePolicy(sizePolicy);
+
+ QVBoxLayout* layout = new QVBoxLayout(this);
+ layout->setContentsMargins(10, 10, 10, 10);
+
+ QHBoxLayout* topLayout = new QHBoxLayout();
+
+ avatar = new QtAvatarWidget(this);
+ topLayout->addWidget(avatar);
+
+ QVBoxLayout* fieldsLayout = new QVBoxLayout();
+
+ QHBoxLayout* horizontalLayout_2 = new QHBoxLayout();
+ nicknameLabel = new QLabel("Nickname: ", this);
+ horizontalLayout_2->addWidget(nicknameLabel);
+ nickname = new QLineEdit(this);
+ horizontalLayout_2->addWidget(nickname);
+
+ fieldsLayout->addLayout(horizontalLayout_2);
+
+ errorLabel = new QLabel(this);
+ errorLabel->setAlignment(Qt::AlignHCenter);
+ fieldsLayout->addWidget(errorLabel);
+
+ fieldsLayout->addItem(new QSpacerItem(198, 17, QSizePolicy::Minimum, QSizePolicy::Expanding));
+ topLayout->addLayout(fieldsLayout);
+
+ layout->addLayout(topLayout);
+
+ QHBoxLayout* horizontalLayout = new QHBoxLayout();
+ horizontalLayout->setContentsMargins(0, 0, 0, 0);
+ horizontalLayout->addItem(new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
+
+ throbberLabel = new QLabel(this);
+ throbberLabel->setMovie(new QMovie(":/icons/throbber.gif", QByteArray(), this));
+ horizontalLayout->addWidget(throbberLabel);
+
+ saveButton = new QPushButton("Save", this);
+ connect(saveButton, SIGNAL(clicked()), SLOT(handleSave()));
+ horizontalLayout->addWidget(saveButton);
+
+ fieldsLayout->addLayout(horizontalLayout);
+
+ resize(360, 120);
+}
+
+void QtProfileWindow::setVCard(Swift::VCard::ref vcard) {
+ this->vcard = vcard;
+ nickname->setText(P2QSTRING(vcard->getNickname()));
+ avatar->setAvatar(vcard->getPhoto(), vcard->getPhotoType());
+}
+
+void QtProfileWindow::setEnabled(bool b) {
+ nickname->setEnabled(b);
+ nicknameLabel->setEnabled(b);
+ avatar->setEnabled(b);
+ saveButton->setEnabled(b);
+}
+
+void QtProfileWindow::setProcessing(bool processing) {
+ if (processing) {
+ throbberLabel->movie()->start();
+ throbberLabel->show();
+ }
+ else {
+ throbberLabel->hide();
+ throbberLabel->movie()->stop();
+ }
+}
+
+void QtProfileWindow::show() {
+ QWidget::show();
+ QWidget::activateWindow();
+}
+
+void QtProfileWindow::hideEvent(QHideEvent* event) {
+ QWidget::hideEvent(event);
+}
+
+void QtProfileWindow::hide() {
+ QWidget::hide();
+}
+
+void QtProfileWindow::handleSave() {
+ assert(vcard);
+ vcard->setNickname(Q2PSTRING(nickname->text()));
+ vcard->setPhoto(avatar->getAvatarData());
+ vcard->setPhotoType(avatar->getAvatarType());
+ onVCardChangeRequest(vcard);
+}
+
+void QtProfileWindow::setError(const String& error) {
+ if (!error.isEmpty()) {
+ errorLabel->setText("<font color='red'>" + P2QSTRING(error) + "</font>");
+ }
+ else {
+ errorLabel->setText("");
+ }
+}
+
+
+
+}