summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
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
@@ -21,36 +21,52 @@
#include <Swift/QtUI/QtSwiftUtil.h>
#include <Swift/QtUI/QtUtilities.h>
namespace Swift {
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()));
setEditable(false);
setAttribute(Qt::WA_DeleteOnClose);
}
QtProfileWindow::~QtProfileWindow() {
delete ui;
}
void QtProfileWindow::setJID(const JID& jid) {
this->jid = jid;
updateTitle();
}
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) {
ui->vcard->setEnabled(b);
ui->savePushButton->setEnabled(b);
}
void QtProfileWindow::setEditable(bool b) {
ui->throbberLabel->setVisible(b);
@@ -58,23 +74,29 @@ void QtProfileWindow::setEditable(bool b) {
ui->savePushButton->setVisible(b);
ui->vcard->setEditable(b);
updateTitle();
}
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) {
if (!error.empty()) {
ui->errorLabel->setText("<font color='red'>" + QtUtilities::htmlEscape(P2QSTRING(error)) + "</font>");
}
else {
ui->errorLabel->setText("");
}
@@ -96,18 +118,37 @@ void QtProfileWindow::updateTitle() {
}
if (ui->vcard->isEditable()) {
setWindowTitle(tr("Edit Profile") + jidString);
} else {
setWindowTitle(tr("Show Profile") + jidString);
}
}
+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);
}
void QtProfileWindow::handleSave() {
onVCardChangeRequest(ui->vcard->getVCard());
}
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
@@ -38,18 +38,19 @@ class QtProfileWindow : public QWidget, public ProfileWindow {
virtual void setProcessing(bool processing);
virtual void setError(const std::string& error);
virtual void setEditable(bool b);
virtual void show();
virtual void hide();
private:
void updateTitle();
+ void updateWindowSize();
virtual void closeEvent(QCloseEvent* event);
private slots:
void handleSave();
private:
Ui::QtProfileWindow* ui;
JID jid;
};
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
@@ -7,26 +7,59 @@
<x>0</x>
<y>0</y>
<width>334</width>
<height>197</height>
</rect>
</property>
<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>
<item>
<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>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -40,31 +73,18 @@
</item>
<item>
<widget class="QLabel" name="errorLabel">
<property name="text">
<string/>
</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>
<widget class="QPushButton" name="savePushButton">
<property name="text">
<string>Save</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>