summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorRichard Maudsley <richard.maudsley@isode.com>2014-07-14 13:10:43 (GMT)
committerRichard Maudsley <richard.maudsley@isode.com>2014-07-14 13:25:11 (GMT)
commit4386fa0e6fa8c361d51ec085aefa2d15a61d399a (patch)
treec21ba329bd28610eda23f2d2cc023d08d0c7b4e0 /Swift
parentd949d1638c0778a6262c3afa13b55059a85b0499 (diff)
downloadswift-contrib-4386fa0e6fa8c361d51ec085aefa2d15a61d399a.zip
swift-contrib-4386fa0e6fa8c361d51ec085aefa2d15a61d399a.tar.bz2
Show status message instead of empty VCard dialog when receiving VCard or when an empty VCard is received.
Test-Information: Request VCard from a user in a MUC that is configured to NOT allow VCards from anonymous users and observe that "empty vcard" status message is displayed instead of an empty dialog. Check that VCard is displayed properly when a VCard is available and that the throbber is still functioning as before. Change-Id: I098b3ad9495b06b4efbca1547021311f5205cbf2
Diffstat (limited to 'Swift')
-rw-r--r--Swift/QtUI/QtProfileWindow.cpp41
-rw-r--r--Swift/QtUI/QtProfileWindow.h1
-rw-r--r--Swift/QtUI/QtProfileWindow.ui48
3 files changed, 76 insertions, 14 deletions
diff --git a/Swift/QtUI/QtProfileWindow.cpp b/Swift/QtUI/QtProfileWindow.cpp
index d0d1414..e643627 100644
--- a/Swift/QtUI/QtProfileWindow.cpp
+++ b/Swift/QtUI/QtProfileWindow.cpp
@@ -27,6 +27,13 @@ QtProfileWindow::QtProfileWindow() :
QWidget(),
ui(new Ui::QtProfileWindow) {
ui->setupUi(this);
+
+ ui->statusLabel->setText(tr("Retrieving profile information for this user."));
+ ui->statusLabel->setVisible(false);
+
+ ui->emptyLabel->setText(tr("No profile information is available for this user."));
+ ui->emptyLabel->setVisible(false);
+
new QShortcut(QKeySequence::Close, this, SLOT(close()));
ui->throbberLabel->setMovie(new QMovie(":/icons/throbber.gif", QByteArray(), this));
connect(ui->savePushButton, SIGNAL(clicked()), SLOT(handleSave()));
@@ -45,6 +52,15 @@ void QtProfileWindow::setJID(const JID& jid) {
void QtProfileWindow::setVCard(VCard::ref vcard) {
ui->vcard->setVCard(vcard);
+ if (vcard->isEmpty()) {
+ ui->vcard->setVisible(false);
+ ui->emptyLabel->setVisible(true);
+ } else {
+ ui->vcard->setVisible(true);
+ ui->emptyLabel->setVisible(false);
+ }
+
+ updateWindowSize();
}
void QtProfileWindow::setEnabled(bool b) {
@@ -64,11 +80,17 @@ void QtProfileWindow::setProcessing(bool processing) {
if (processing) {
ui->throbberLabel->movie()->start();
ui->throbberLabel->show();
+ ui->statusLabel->setVisible(true);
+ ui->vcard->setVisible(false);
}
else {
ui->throbberLabel->hide();
ui->throbberLabel->movie()->stop();
+ ui->statusLabel->setVisible(false);
+ ui->vcard->setVisible(true);
}
+
+ updateWindowSize();
}
void QtProfileWindow::setError(const std::string& error) {
@@ -102,6 +124,25 @@ void QtProfileWindow::updateTitle() {
}
}
+void QtProfileWindow::updateWindowSize() {
+ int width = 0;
+ int height = 0;
+
+ QSize size = ui->statusLabel->size();
+ width = std::max(width, size.width());
+ height = std::max(height, size.height() * 3);
+
+ size = ui->emptyLabel->size();
+ width = std::max(width, size.width());
+ height = std::max(height, size.height() * 3);
+
+ size = ui->vcard->size();
+ width = std::max(width, size.width());
+ height = std::max(height, size.height());
+
+ resize(width, height);
+}
+
void QtProfileWindow::closeEvent(QCloseEvent* event) {
event->accept();
onWindowAboutToBeClosed(jid);
diff --git a/Swift/QtUI/QtProfileWindow.h b/Swift/QtUI/QtProfileWindow.h
index a2af63a..57cc2df 100644
--- a/Swift/QtUI/QtProfileWindow.h
+++ b/Swift/QtUI/QtProfileWindow.h
@@ -44,6 +44,7 @@ class QtProfileWindow : public QWidget, public ProfileWindow {
private:
void updateTitle();
+ void updateWindowSize();
virtual void closeEvent(QCloseEvent* event);
private slots:
diff --git a/Swift/QtUI/QtProfileWindow.ui b/Swift/QtUI/QtProfileWindow.ui
index 9394dc5..ed2986d 100644
--- a/Swift/QtUI/QtProfileWindow.ui
+++ b/Swift/QtUI/QtProfileWindow.ui
@@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Edit Profile</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout" stretch="1,0">
+ <layout class="QVBoxLayout" name="verticalLayout" stretch="1,0,0,0,0">
<property name="margin">
<number>0</number>
</property>
@@ -21,6 +21,39 @@
<widget class="Swift::QtVCardWidget" name="vcard" native="true"/>
</item>
<item>
+ <widget class="QLabel" name="statusLabel">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="emptyLabel">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="throbberLabel">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::NoTextInteraction</set>
+ </property>
+ </widget>
+ </item>
+ <item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
@@ -46,19 +79,6 @@
</widget>
</item>
<item>
- <widget class="QLabel" name="throbberLabel">
- <property name="text">
- <string/>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- <property name="textInteractionFlags">
- <set>Qt::NoTextInteraction</set>
- </property>
- </widget>
- </item>
- <item>
<widget class="QPushButton" name="savePushButton">
<property name="text">
<string>Save</string>