ShareLinkWidget: redo the layout

NOTE: The progress indicator is temporarily moved one line up to avoid
inserting it on its own line, which would cause the content pushed down
and the dialog size jump back and forth.
This commit is contained in:
J-P Nurmi 2018-11-16 23:02:34 +01:00
parent bd93489b14
commit 847706432b
3 changed files with 186 additions and 409 deletions

View file

@ -58,18 +58,16 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
, _unshareLinkAction(nullptr) , _unshareLinkAction(nullptr)
{ {
_ui->setupUi(this); _ui->setupUi(this);
QSizePolicy sp = _ui->shareLinkToolButton->sizePolicy();
sp.setRetainSizeWhenHidden(true);
_ui->shareLinkToolButton->setSizePolicy(sp);
_ui->shareLinkToolButton->hide(); _ui->shareLinkToolButton->hide();
//Is this a file or folder? //Is this a file or folder?
QFileInfo fi(localPath); QFileInfo fi(localPath);
_isFile = fi.isFile(); _isFile = fi.isFile();
// the following progress indicator widgets are added to layouts which makes them
// automatically deleted once the dialog dies.
_pi_indicator = new QProgressIndicator();
_ui->horizontalLayout->insertWidget(1, _pi_indicator, Qt::AlignCenter);
_ui->indicatorWidget->hide();
connect(_ui->enableShareLink, &QCheckBox::toggled, this, &ShareLinkWidget::slotCreateOrDeleteShareLink); connect(_ui->enableShareLink, &QCheckBox::toggled, this, &ShareLinkWidget::slotCreateOrDeleteShareLink);
connect(_ui->lineEdit_password, &QLineEdit::returnPressed, this, &ShareLinkWidget::slotCreatePassword); connect(_ui->lineEdit_password, &QLineEdit::returnPressed, this, &ShareLinkWidget::slotCreatePassword);
connect(_ui->confirmPassword, &QAbstractButton::clicked, this, &ShareLinkWidget::slotCreatePassword); connect(_ui->confirmPassword, &QAbstractButton::clicked, this, &ShareLinkWidget::slotCreatePassword);
@ -87,18 +85,17 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
sharingPossible = false; sharingPossible = false;
} }
if (!sharingPossible) _ui->createShareButton->setVisible(sharingPossible);
_ui->shareLinkWidget->hide(); _ui->enableShareLink->setVisible(sharingPossible);
else _ui->shareLinkToolButton->setVisible(sharingPossible);
_ui->shareLinkWidget->show();
// Older servers don't support multiple public link shares // Older servers don't support multiple public link shares
if (!_account->capabilities().sharePublicLinkMultiple()) { if (!_account->capabilities().sharePublicLinkMultiple()) {
_namesSupported = false; _namesSupported = false;
} }
_ui->passwordShareProperty->hide(); togglePasswordOptions(false);
_ui->expirationShareProperty->hide(); toggleExpireDateOptions(false);
_ui->calendar->setMinimumDate(QDate::currentDate().addDays(1)); _ui->calendar->setMinimumDate(QDate::currentDate().addDays(1));
// check if the file is already inside of a synced folder // check if the file is already inside of a synced folder
@ -139,12 +136,12 @@ ShareLinkWidget::~ShareLinkWidget()
} }
void ShareLinkWidget::toggleAnimation(bool start){ void ShareLinkWidget::toggleAnimation(bool start){
if(start && !_pi_indicator->isAnimated()) if (start) {
_pi_indicator->startAnimation(); if (!_ui->progressIndicator->isAnimated())
else _ui->progressIndicator->startAnimation();
_pi_indicator->stopAnimation(); } else {
_ui->progressIndicator->stopAnimation();
_ui->indicatorWidget->setVisible(start); }
} }
void ShareLinkWidget::getShares() void ShareLinkWidget::getShares()
@ -231,7 +228,7 @@ void ShareLinkWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shar
if(_linkShare->isPasswordSet()){ if(_linkShare->isPasswordSet()){
_passwordProtectLinkAction->setChecked(true); _passwordProtectLinkAction->setChecked(true);
_ui->lineEdit_password->setPlaceholderText("********"); _ui->lineEdit_password->setPlaceholderText("********");
_ui->passwordShareProperty->show(); showPasswordOptions(true);
} }
// If password is enforced then don't allow users to disable it // If password is enforced then don't allow users to disable it
@ -247,7 +244,7 @@ void ShareLinkWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shar
if(_linkShare->getExpireDate().isValid()){ if(_linkShare->getExpireDate().isValid()){
_ui->calendar->setDate(_linkShare->getExpireDate()); _ui->calendar->setDate(_linkShare->getExpireDate());
_expirationDateLinkAction->setChecked(true); _expirationDateLinkAction->setChecked(true);
_ui->expirationShareProperty->show(); showExpireDateOptions(true);
} }
@ -401,7 +398,7 @@ void ShareLinkWidget::slotCreateShareRequiresPassword(const QString &message)
{ {
toggleAnimation(true); toggleAnimation(true);
_ui->passwordShareProperty->show(); showPasswordOptions(true);
if (!message.isEmpty()) { if (!message.isEmpty()) {
_ui->errorLabel->setText(message); _ui->errorLabel->setText(message);
_ui->errorLabel->show(); _ui->errorLabel->show();
@ -412,9 +409,16 @@ void ShareLinkWidget::slotCreateShareRequiresPassword(const QString &message)
togglePasswordOptions(true); togglePasswordOptions(true);
} }
void ShareLinkWidget::showPasswordOptions(bool show)
{
_ui->passwordLabel->setVisible(show);
_ui->lineEdit_password->setVisible(show);
_ui->confirmPassword->setVisible(show);
}
void ShareLinkWidget::togglePasswordOptions(bool enable) void ShareLinkWidget::togglePasswordOptions(bool enable)
{ {
_ui->passwordShareProperty->setVisible(enable); showPasswordOptions(enable);
if(enable) { if(enable) {
_ui->lineEdit_password->setFocus(); _ui->lineEdit_password->setFocus();
@ -425,9 +429,17 @@ void ShareLinkWidget::togglePasswordOptions(bool enable)
} }
} }
void ShareLinkWidget::showExpireDateOptions(bool show)
{
_ui->expirationLabel->setVisible(show);
_ui->calendar->setVisible(show);
_ui->confirmExpirationDate->setVisible(show);
}
void ShareLinkWidget::toggleExpireDateOptions(bool enable) void ShareLinkWidget::toggleExpireDateOptions(bool enable)
{ {
_ui->expirationShareProperty->setVisible(enable); showExpireDateOptions(enable);
if (enable) { if (enable) {
const QDate date = QDate::currentDate().addDays(1); const QDate date = QDate::currentDate().addDays(1);
_ui->calendar->setDate(date); _ui->calendar->setDate(date);

View file

@ -83,9 +83,11 @@ private slots:
private: private:
void displayError(const QString &errMsg); void displayError(const QString &errMsg);
void showPasswordOptions(bool show);
void togglePasswordOptions(bool enable); void togglePasswordOptions(bool enable);
void setPassword(const QString &password); void setPassword(const QString &password);
void showExpireDateOptions(bool show);
void toggleExpireDateOptions(bool enable); void toggleExpireDateOptions(bool enable);
void setExpireDate(const QDate &date); void setExpireDate(const QDate &date);
@ -105,8 +107,6 @@ private:
QString _localPath; QString _localPath;
QString _shareUrl; QString _shareUrl;
QProgressIndicator *_pi_indicator;
ShareManager *_manager; ShareManager *_manager;
QSharedPointer<LinkShare> _linkShare; QSharedPointer<LinkShare> _linkShare;

View file

@ -11,69 +11,12 @@
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize"> <layout class="QGridLayout" name="gridLayout">
<size>
<width>350</width>
<height>110</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Share NewDocument.odt</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>10</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<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>
<widget class="QWidget" name="shareLinkWidget" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>0</height>
</size>
</property>
<layout class="QHBoxLayout" name="shareLinkLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
@ -86,35 +29,16 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QPushButton" name="createShareButton"> <widget class="QPushButton" name="createShareButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>242</width>
<height>26</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>26</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">text-align: left</string> <string notr="true">text-align: left</string>
</property> </property>
@ -125,47 +49,54 @@
<iconset resource="../../client.qrc"> <iconset resource="../../client.qrc">
<normaloff>:/client/resources/public.svg</normaloff>:/client/resources/public.svg</iconset> <normaloff>:/client/resources/public.svg</normaloff>:/client/resources/public.svg</iconset>
</property> </property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="enableShareLink"> <spacer name="horizontalSpacer">
<property name="minimumSize"> <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size> <size>
<width>82</width> <width>40</width>
<height>26</height> <height>25</height>
</size> </size>
</property> </property>
</spacer>
</item>
<item>
<widget class="QProgressIndicator" name="progressIndicator"/>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>25</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="enableShareLink">
<property name="text"> <property name="text">
<string>Enable</string> <string>Enable</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> </layout>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="shareLinkToolButton"> <widget class="QToolButton" name="shareLinkToolButton">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="minimumSize">
<size>
<width>26</width>
<height>26</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon"> <property name="icon">
<iconset resource="../../client.qrc"> <iconset resource="../../client.qrc">
<normaloff>:/client/resources/more.svg</normaloff>:/client/resources/more.svg</iconset> <normaloff>:/client/resources/more.svg</normaloff>:/client/resources/more.svg</iconset>
@ -173,125 +104,38 @@
<property name="popupMode"> <property name="popupMode">
<enum>QToolButton::InstantPopup</enum> <enum>QToolButton::InstantPopup</enum>
</property> </property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
</widget> </widget>
</item> </item>
</layout> <item row="1" column="0">
</widget> <widget class="QLabel" name="passwordLabel">
</item>
<item>
<widget class="QWidget" name="indicatorWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<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>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="passwordShareProperty" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Maximum"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>1</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<layout class="QHBoxLayout" name="passwordHorizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<property name="leftMargin">
<number>18</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>162</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Password:</string> <string>Password:</string>
</property> </property>
<property name="indent"> <property name="indent">
<number>0</number> <number>20</number>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_password"> <widget class="QLineEdit" name="lineEdit_password">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>1</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>120</width>
<height>26</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="echoMode"> <property name="echoMode">
<enum>QLineEdit::Password</enum> <enum>QLineEdit::Password</enum>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="2">
<widget class="QToolButton" name="confirmPassword"> <widget class="QToolButton" name="confirmPassword">
<property name="icon"> <property name="icon">
<iconset resource="../../client.qrc"> <iconset resource="../../client.qrc">
@ -302,90 +146,33 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="2" column="0">
</widget>
</item>
<item>
<widget class="QWidget" name="expirationShareProperty" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
<layout class="QHBoxLayout" name="expirationShareLayout" stretch="0,0,0">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<property name="leftMargin">
<number>18</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="expirationLabel"> <widget class="QLabel" name="expirationLabel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>1</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>162</width>
<height>26</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Expiration date:</string> <string>Expiration date:</string>
</property> </property>
<property name="indent"> <property name="indent">
<number>0</number> <number>20</number>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="2" column="1">
<widget class="QDateEdit" name="calendar"> <widget class="QDateEdit" name="calendar">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>1</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>120</width>
<height>26</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item row="2" column="2">
<widget class="QToolButton" name="confirmExpirationDate"> <widget class="QToolButton" name="confirmExpirationDate">
<property name="icon"> <property name="icon">
<iconset resource="../../client.qrc"> <iconset resource="../../client.qrc">
@ -396,29 +183,8 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout> <item row="3" column="0" colspan="4">
</widget>
</item>
<item>
<widget class="QLabel" name="errorLabel"> <widget class="QLabel" name="errorLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="palette"> <property name="palette">
<palette> <palette>
<active> <active>
@ -462,23 +228,22 @@
<property name="textFormat"> <property name="textFormat">
<enum>Qt::PlainText</enum> <enum>Qt::PlainText</enum>
</property> </property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap"> <property name="wordWrap">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="margin">
<number>0</number>
</property>
<property name="indent">
<number>0</number>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QProgressIndicator</class>
<extends>QWidget</extends>
<header>QProgressIndicator.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources> <resources>
<include location="../../client.qrc"/> <include location="../../client.qrc"/>
</resources> </resources>