From b41695a739c2b75973b8d22e2be39add7051d076 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Fri, 3 Apr 2015 13:14:14 +0200 Subject: Elide rightmost fields in the VCard dialog This patch changes the rightmost widget in the VCard fields from a QLabel to a QtElidingLabel. It also improves the spacing in the header in VCard profile dialog. Test-Information: Tested on OS X 10.9.5 with Qt 5.4.1. Change-Id: I771ddb555c5990c67550d9e36f001e57644712da diff --git a/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp index af17d97..5f9fddf 100644 --- a/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp +++ b/Swift/QtUI/QtVCardWidget/QtVCardAddressField.cpp @@ -4,10 +4,17 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ -#include "QtVCardAddressField.h" +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include #include +#include #include namespace Swift { @@ -58,7 +65,7 @@ void QtVCardAddressField::setupContentWidgets() { countryLineEdit->setPlaceholderText(tr("Country")); #endif - deliveryTypeLabel = new QLabel(this); + deliveryTypeLabel = new QtElidingLabel(this); deliveryTypeLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); getGridLayout()->addWidget(deliveryTypeLabel, getGridLayout()->rowCount()-3, 4, Qt::AlignVCenter); diff --git a/Swift/QtUI/QtVCardWidget/QtVCardAddressField.h b/Swift/QtUI/QtVCardWidget/QtVCardAddressField.h index 5a1256a..8cbee18 100644 --- a/Swift/QtUI/QtVCardWidget/QtVCardAddressField.h +++ b/Swift/QtUI/QtVCardWidget/QtVCardAddressField.h @@ -4,20 +4,28 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ -#pragma once +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ -#include +#pragma once #include #include -#include "QtResizableLineEdit.h" -#include "QtVCardFieldInfo.h" -#include "QtVCardGeneralField.h" -#include "QtVCardHomeWork.h" +#include + +#include +#include +#include +#include namespace Swift { +class QtElidingLabel; + class QtVCardAddressField : public QtVCardGeneralField, public QtVCardHomeWork { Q_OBJECT @@ -51,7 +59,7 @@ class QtVCardAddressField : public QtVCardGeneralField, public QtVCardHomeWork { QGridLayout* textFieldGridLayout; QLayoutItem* textFieldGridLayoutItem; - QLabel* deliveryTypeLabel; + QtElidingLabel* deliveryTypeLabel; QRadioButton* domesticRadioButton; QRadioButton* internationalRadioButton; QButtonGroup* buttonGroup; diff --git a/Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.cpp index ba3d25f..64d2533 100644 --- a/Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.cpp +++ b/Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.cpp @@ -4,11 +4,19 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ -#include "QtVCardAddressLabelField.h" +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include -#include #include +#include + +#include #include namespace Swift { @@ -27,7 +35,7 @@ void QtVCardAddressLabelField::setupContentWidgets() { addressLabelPlainTextEdit->setTabChangesFocus(true); getGridLayout()->addWidget(addressLabelPlainTextEdit, getGridLayout()->rowCount()-1, 2, 3, 2, Qt::AlignVCenter); - deliveryTypeLabel = new QLabel(this); + deliveryTypeLabel = new QtElidingLabel(this); deliveryTypeLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); getGridLayout()->addWidget(deliveryTypeLabel, getGridLayout()->rowCount()-2, 4, Qt::AlignVCenter); diff --git a/Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.h b/Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.h index a665d31..7d9893b 100644 --- a/Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.h +++ b/Swift/QtUI/QtVCardWidget/QtVCardAddressLabelField.h @@ -4,6 +4,12 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #pragma once #include @@ -18,6 +24,8 @@ namespace Swift { +class QtElidingLabel; + class QtVCardAddressLabelField : public QtVCardGeneralField, public QtVCardHomeWork { Q_OBJECT @@ -41,7 +49,7 @@ class QtVCardAddressLabelField : public QtVCardGeneralField, public QtVCardHomeW private: QPlainTextEdit* addressLabelPlainTextEdit; - QLabel* deliveryTypeLabel; + QtElidingLabel* deliveryTypeLabel; QRadioButton* domesticRadioButton; QRadioButton* internationalRadioButton; QButtonGroup* buttonGroup; diff --git a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp index b3902bc..6aef507 100644 --- a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp +++ b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2014 Isode Limited. + * Copyright (c) 2014-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -17,6 +17,8 @@ #include #include +#include + namespace Swift { QtVCardGeneralField::QtVCardGeneralField(QWidget* parent, QGridLayout* layout, bool editable, int row, QString label, bool preferrable, bool taggable) : @@ -45,7 +47,7 @@ void QtVCardGeneralField::initialize() { label->setText(labelText); layout->addWidget(label, row, 1, Qt::AlignVCenter | Qt::AlignRight); - tagLabel = new QLabel(this); + tagLabel = new QtElidingLabel(this); tagLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); tagComboBox = new QtTagComboBox(this); diff --git a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h index 9bb7094..6583d12 100644 --- a/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h +++ b/Swift/QtUI/QtVCardWidget/QtVCardGeneralField.h @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2014 Isode Limited. + * Copyright (c) 2014-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -17,15 +17,17 @@ #include #include -#include "QtCloseButton.h" -#include "QtTagComboBox.h" +#include +#include namespace Swift { +class QtElidingLabel; + /* * covers features like: * - preffered (star ceckbox) - * - combo check boxh + * - combo check box * - label * - remove button */ @@ -84,7 +86,7 @@ class QtVCardGeneralField : public QWidget { QLabel* label; QString labelText; QtTagComboBox* tagComboBox; - QLabel* tagLabel; + QtElidingLabel* tagLabel; QtCloseButton* closeButton; }; diff --git a/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.cpp b/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.cpp index 46678f5..c8b010e 100644 --- a/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.cpp +++ b/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.cpp @@ -4,6 +4,12 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + #include #include @@ -21,6 +27,8 @@ QtVCardPhotoAndNameFields::QtVCardPhotoAndNameFields(QWidget* parent) : ui->lineEditSUFFIX->hide(); ui->lineEditFN->hide(); ui->lineEditNICKNAME->hide(); + ui->labelFN->hide(); + ui->labelNICKNAME->hide(); ui->labelFULLNAME->hide(); #if QT_VERSION >= 0x040700 @@ -48,15 +56,16 @@ void QtVCardPhotoAndNameFields::setEditable(bool editable) { this->editable = editable; ui->avatarWidget->setEditable(editable); - ui->lineEditFN->setVisible(editable ? true : !ui->lineEditFN->text().isEmpty()); - ui->lineEditFN->setEditable(editable); - ui->lineEditFN->setStyleSheet(editable ? "" : "QLineEdit {border: none; background-color: transparent;}"); + ui->horizontalLayoutFN->setSpacing(editable ? 2 : 0); + ui->lineEditFN->setVisible(editable); + ui->labelFN->setVisible(!editable); - ui->lineEditNICKNAME->setVisible(editable ? true : !ui->lineEditNICKNAME->text().isEmpty()); - ui->lineEditNICKNAME->setEditable(editable); - ui->lineEditNICKNAME->setStyleSheet(editable ? "" : "QLineEdit {border: none; background-color: transparent;}"); + ui->horizontalLayoutNICKNAME->setSpacing(editable ? 2 : 0); + ui->lineEditNICKNAME->setVisible(editable); + ui->labelNICKNAME->setVisible(!editable); // prefix given middle last suffix + ui->horizontalLayoutFULLNAME->setSpacing(editable ? 2 : 0); ui->lineEditPREFIX->setVisible(editable); ui->lineEditGIVEN->setVisible(editable); ui->lineEditMIDDLE->setVisible(editable); @@ -87,6 +96,7 @@ std::string QtVCardPhotoAndNameFields::getAvatarType() const { void QtVCardPhotoAndNameFields::setFormattedName(const QString& formattedName) { ui->lineEditFN->setText(formattedName); + ui->labelFN->setText(formattedName); } QString QtVCardPhotoAndNameFields::getFormattedName() const { @@ -95,6 +105,7 @@ QString QtVCardPhotoAndNameFields::getFormattedName() const { void QtVCardPhotoAndNameFields::setNickname(const QString& nickname) { ui->lineEditNICKNAME->setText(nickname); + ui->labelNICKNAME->setText(nickname); } QString QtVCardPhotoAndNameFields::getNickname() const { diff --git a/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.ui b/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.ui index 04da2bc..146b49d 100644 --- a/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.ui +++ b/Swift/QtUI/QtVCardWidget/QtVCardPhotoAndNameFields.ui @@ -26,15 +26,24 @@ QLayout::SetMinimumSize + + 0 + + + 0 + + + 0 + + + 0 + 5 1 - - 0 - @@ -52,7 +61,25 @@ - + + + + + + 0 + 0 + + + + + 18 + + + + + + + @@ -80,7 +107,7 @@ - 40 + 5 20 @@ -89,9 +116,28 @@ - + + + + + + 0 + 0 + + + + + + + + + + 0 + 0 + + Nickname @@ -107,7 +153,7 @@ - 40 + 5 20 @@ -116,7 +162,7 @@ - + 2 @@ -124,7 +170,13 @@ QLayout::SetMinimumSize - + + + + 0 + 0 + + @@ -245,6 +297,11 @@
Swift/QtUI/QtAvatarWidget.h
1 + + Swift::QtElidingLabel + QLabel +
Swift/QtUI/QtElidingLabel.h
+
-- cgit v0.10.2-6-g49f6