summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2013-10-18 11:14:47 (GMT)
committerSwift Review <review@swift.im>2013-10-26 15:35:44 (GMT)
commit08289aadf4065e1c404af50e25ed511b2e839fdb (patch)
tree9dca27a5108406da1f062e20a985861e13db5f2b /Swift/QtUI
parentc041a9ac96893d64f1b656c9ecb7f03eed1c310f (diff)
downloadswift-08289aadf4065e1c404af50e25ed511b2e839fdb.zip
swift-08289aadf4065e1c404af50e25ed511b2e839fdb.tar.bz2
VCard: Move 'Add Field' button inside the scroll view.
Change-Id: I1259e6de80a5c8781ba71dad1a52228f37a7ce7e License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtProfileWindow.cpp11
-rw-r--r--Swift/QtUI/QtProfileWindow.ui2
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp37
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardWidget.h3
-rw-r--r--Swift/QtUI/QtVCardWidget/QtVCardWidget.ui45
5 files changed, 55 insertions, 43 deletions
diff --git a/Swift/QtUI/QtProfileWindow.cpp b/Swift/QtUI/QtProfileWindow.cpp
index b1cdd19..d0d1414 100644
--- a/Swift/QtUI/QtProfileWindow.cpp
+++ b/Swift/QtUI/QtProfileWindow.cpp
@@ -53,13 +53,10 @@ void QtProfileWindow::setEnabled(bool b) {
}
void QtProfileWindow::setEditable(bool b) {
- if (b) {
- ui->savePushButton->show();
- ui->vcard->setEditable(true);
- } else {
- ui->savePushButton->hide();
- ui->vcard->setEditable(false);
- }
+ ui->throbberLabel->setVisible(b);
+ ui->errorLabel->setVisible(b);
+ ui->savePushButton->setVisible(b);
+ ui->vcard->setEditable(b);
updateTitle();
}
diff --git a/Swift/QtUI/QtProfileWindow.ui b/Swift/QtUI/QtProfileWindow.ui
index 68a36da..9394dc5 100644
--- a/Swift/QtUI/QtProfileWindow.ui
+++ b/Swift/QtUI/QtProfileWindow.ui
@@ -33,7 +33,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
- <height>20</height>
+ <height>0</height>
</size>
</property>
</spacer>
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp b/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
index ee3ef96..d681fe9 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
+++ b/Swift/QtUI/QtVCardWidget/QtVCardWidget.cpp
@@ -39,7 +39,13 @@ QtVCardWidget::QtVCardWidget(QWidget* parent) :
ui->cardFields->setColumnStretch(4,2);
menu = new QMenu(this);
- ui->toolButton->setMenu(menu);
+ toolButton = new QToolButton(this);
+ toolButton->setText(tr("Add Field"));
+ toolButton->setArrowType(Qt::NoArrow);
+ toolButton->setAutoRaise(false);
+ toolButton->setPopupMode(QToolButton::InstantPopup);
+ toolButton->hide();
+ toolButton->setMenu(menu);
addFieldType(menu, boost::make_shared<QtVCardInternetEMailField::FieldInfo>());
addFieldType(menu, boost::make_shared<QtVCardTelephoneField::FieldInfo>());
@@ -72,14 +78,7 @@ void QtVCardWidget::setEditable(bool editable) {
foreach(QtVCardGeneralField* field, fields) {
field->setEditable(editable);
}
-
- if (editable) {
- ui->toolButton->show();
- //if ((findChild<QtVCardBirthdayField*>() == 0)) {
- //}
- } else {
- ui->toolButton->hide();
- }
+ toolButton->setVisible(editable);
editableChanged(editable);
}
@@ -175,6 +174,7 @@ void QtVCardWidget::setVCard(VCard::ref vcard) {
appendField(urlField);
}
+ relayoutToolButton();
setEditable(editable);
window()->resize(sizeHint().width(), size().height() < 200 ? 200 : size().height());
}
@@ -294,6 +294,7 @@ void QtVCardWidget::addField() {
newGeneralField->initialize();
}
appendField(newGeneralField);
+ relayoutToolButton();
}
}
@@ -303,10 +304,12 @@ void QtVCardWidget::removeField(QtVCardGeneralField *field) {
}
void QtVCardWidget::addFieldType(QMenu* menu, boost::shared_ptr<QtVCardFieldInfo> fieldType) {
- QAction* action = new QAction(tr("Add ") + fieldType->getMenuName(), this);
- actionFieldInfo[action] = fieldType;
- connect(action, SIGNAL(triggered()), this, SLOT(addField()));
- menu->addAction(action);
+ if (!fieldType->getMenuName().isEmpty()) {
+ QAction* action = new QAction(tr("Add ") + fieldType->getMenuName(), this);
+ actionFieldInfo[action] = fieldType;
+ connect(action, SIGNAL(triggered()), this, SLOT(addField()));
+ menu->addAction(action);
+ }
}
int QtVCardWidget::fieldTypeInstances(boost::shared_ptr<QtVCardFieldInfo> fieldType) {
@@ -324,6 +327,10 @@ void layoutDeleteChildren(QLayout *layout) {
if (child->layout()) {
layoutDeleteChildren(child->layout());
}
+ if (dynamic_cast<QToolButton*>(child->widget())) {
+ delete child;
+ break;
+ }
delete child->widget();
delete child;
}
@@ -360,4 +367,8 @@ void QtVCardWidget::appendField(QtVCardGeneralField *field) {
fields.push_back(field);
}
+void QtVCardWidget::relayoutToolButton() {
+ ui->cardFields->addWidget(toolButton, ui->cardFields->rowCount(), ui->cardFields->columnCount()-2, 1, 1, Qt::AlignRight);
+}
+
}
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardWidget.h b/Swift/QtUI/QtVCardWidget/QtVCardWidget.h
index 07f528d..29ed499 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardWidget.h
+++ b/Swift/QtUI/QtVCardWidget/QtVCardWidget.h
@@ -7,6 +7,7 @@
#pragma once
#include <QWidget>
+#include <QToolButton>
#include <Swiften/Elements/VCard.h>
#include <boost/smart_ptr/make_shared.hpp>
@@ -47,10 +48,12 @@ namespace Swift {
void clearFields();
void clearEmptyFields();
void appendField(QtVCardGeneralField* field);
+ void relayoutToolButton();
private:
VCard::ref vcard;
Ui::QtVCardWidget* ui;
+ QToolButton* toolButton;
bool editable;
QMenu* menu;
std::list<QtVCardGeneralField*> fields;
diff --git a/Swift/QtUI/QtVCardWidget/QtVCardWidget.ui b/Swift/QtUI/QtVCardWidget/QtVCardWidget.ui
index eae1006..4fc8605 100644
--- a/Swift/QtUI/QtVCardWidget/QtVCardWidget.ui
+++ b/Swift/QtUI/QtVCardWidget/QtVCardWidget.ui
@@ -13,8 +13,17 @@
<property name="windowTitle">
<string>Form</string>
</property>
- <layout class="QGridLayout" name="gridLayout" rowstretch="1,0" columnstretch="1,0">
- <property name="margin">
+ <layout class="QGridLayout" name="gridLayout" rowstretch="1" columnstretch="1,0">
+ <property name="leftMargin">
+ <number>5</number>
+ </property>
+ <property name="topMargin">
+ <number>5</number>
+ </property>
+ <property name="rightMargin">
+ <number>5</number>
+ </property>
+ <property name="bottomMargin">
<number>5</number>
</property>
<item row="0" column="0" colspan="2">
@@ -64,7 +73,7 @@
<x>0</x>
<y>0</y>
<width>523</width>
- <height>76</height>
+ <height>110</height>
</rect>
</property>
<property name="sizePolicy">
@@ -77,12 +86,20 @@
<property name="sizeConstraint">
<enum>QLayout::SetMinAndMaxSize</enum>
</property>
- <property name="margin">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
- <layout class="QGridLayout" name="cardFields">
- </layout>
+ <layout class="QGridLayout" name="cardFields"/>
</item>
<item>
<spacer name="verticalSpacer">
@@ -106,22 +123,6 @@
</item>
</layout>
</item>
- <item row="1" column="1">
- <widget class="QToolButton" name="toolButton">
- <property name="text">
- <string>Add Field</string>
- </property>
- <property name="popupMode">
- <enum>QToolButton::InstantPopup</enum>
- </property>
- <property name="autoRaise">
- <bool>false</bool>
- </property>
- <property name="arrowType">
- <enum>Qt::NoArrow</enum>
- </property>
- </widget>
- </item>
</layout>
</widget>
<customwidgets>