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
Родитель bd93489b14
Коммит 847706432b
3 изменённых файлов: 186 добавлений и 409 удалений

Просмотреть файл

@ -58,18 +58,16 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
, _unshareLinkAction(nullptr)
{
_ui->setupUi(this);
QSizePolicy sp = _ui->shareLinkToolButton->sizePolicy();
sp.setRetainSizeWhenHidden(true);
_ui->shareLinkToolButton->setSizePolicy(sp);
_ui->shareLinkToolButton->hide();
//Is this a file or folder?
QFileInfo fi(localPath);
_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->lineEdit_password, &QLineEdit::returnPressed, this, &ShareLinkWidget::slotCreatePassword);
connect(_ui->confirmPassword, &QAbstractButton::clicked, this, &ShareLinkWidget::slotCreatePassword);
@ -87,18 +85,17 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
sharingPossible = false;
}
if (!sharingPossible)
_ui->shareLinkWidget->hide();
else
_ui->shareLinkWidget->show();
_ui->createShareButton->setVisible(sharingPossible);
_ui->enableShareLink->setVisible(sharingPossible);
_ui->shareLinkToolButton->setVisible(sharingPossible);
// Older servers don't support multiple public link shares
if (!_account->capabilities().sharePublicLinkMultiple()) {
_namesSupported = false;
}
_ui->passwordShareProperty->hide();
_ui->expirationShareProperty->hide();
togglePasswordOptions(false);
toggleExpireDateOptions(false);
_ui->calendar->setMinimumDate(QDate::currentDate().addDays(1));
// check if the file is already inside of a synced folder
@ -139,12 +136,12 @@ ShareLinkWidget::~ShareLinkWidget()
}
void ShareLinkWidget::toggleAnimation(bool start){
if(start && !_pi_indicator->isAnimated())
_pi_indicator->startAnimation();
else
_pi_indicator->stopAnimation();
_ui->indicatorWidget->setVisible(start);
if (start) {
if (!_ui->progressIndicator->isAnimated())
_ui->progressIndicator->startAnimation();
} else {
_ui->progressIndicator->stopAnimation();
}
}
void ShareLinkWidget::getShares()
@ -231,7 +228,7 @@ void ShareLinkWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shar
if(_linkShare->isPasswordSet()){
_passwordProtectLinkAction->setChecked(true);
_ui->lineEdit_password->setPlaceholderText("********");
_ui->passwordShareProperty->show();
showPasswordOptions(true);
}
// 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()){
_ui->calendar->setDate(_linkShare->getExpireDate());
_expirationDateLinkAction->setChecked(true);
_ui->expirationShareProperty->show();
showExpireDateOptions(true);
}
@ -401,7 +398,7 @@ void ShareLinkWidget::slotCreateShareRequiresPassword(const QString &message)
{
toggleAnimation(true);
_ui->passwordShareProperty->show();
showPasswordOptions(true);
if (!message.isEmpty()) {
_ui->errorLabel->setText(message);
_ui->errorLabel->show();
@ -412,9 +409,16 @@ void ShareLinkWidget::slotCreateShareRequiresPassword(const QString &message)
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)
{
_ui->passwordShareProperty->setVisible(enable);
showPasswordOptions(enable);
if(enable) {
_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)
{
_ui->expirationShareProperty->setVisible(enable);
showExpireDateOptions(enable);
if (enable) {
const QDate date = QDate::currentDate().addDays(1);
_ui->calendar->setDate(date);

Просмотреть файл

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

Просмотреть файл

@ -11,33 +11,12 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<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>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
@ -50,375 +29,162 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="shareLinkWidget" native="true">
<item row="0" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="createShareButton">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">text-align: left</string>
</property>
<property name="text">
<string>&amp;Share link</string>
</property>
<property name="icon">
<iconset resource="../../client.qrc">
<normaloff>:/client/resources/public.svg</normaloff>:/client/resources/public.svg</iconset>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<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="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">
<string>Enable</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="shareLinkToolButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="../../client.qrc">
<normaloff>:/client/resources/more.svg</normaloff>:/client/resources/more.svg</iconset>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="passwordLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Password:</string>
</property>
<property name="indent">
<number>20</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_password">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="confirmPassword">
<property name="icon">
<iconset resource="../../client.qrc">
<normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="expirationLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>0</height>
</size>
<property name="text">
<string>Expiration date:</string>
</property>
<property name="indent">
<number>20</number>
</property>
<layout class="QHBoxLayout" name="shareLinkLayout">
<property name="spacing">
<number>3</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="QPushButton" name="createShareButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</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">
<string notr="true">text-align: left</string>
</property>
<property name="text">
<string>&amp;Share link</string>
</property>
<property name="icon">
<iconset resource="../../client.qrc">
<normaloff>:/client/resources/public.svg</normaloff>:/client/resources/public.svg</iconset>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableShareLink">
<property name="minimumSize">
<size>
<width>82</width>
<height>26</height>
</size>
</property>
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="shareLinkToolButton">
<property name="enabled">
<bool>false</bool>
</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">
<iconset resource="../../client.qrc">
<normaloff>:/client/resources/more.svg</normaloff>:/client/resources/more.svg</iconset>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
</widget>
</item>
</layout>
</widget>
</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">
<sizepolicy hsizetype="Fixed" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</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">
<string>Password:</string>
</property>
<property name="indent">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_password">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</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">
<enum>QLineEdit::Password</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="confirmPassword">
<property name="icon">
<iconset resource="../../client.qrc">
<normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</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">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>162</width>
<height>26</height>
</size>
</property>
<property name="text">
<string>Expiration date:</string>
</property>
<property name="indent">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QDateEdit" name="calendar">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</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>
</item>
<item>
<widget class="QToolButton" name="confirmExpirationDate">
<property name="icon">
<iconset resource="../../client.qrc">
<normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="errorLabel">
<item row="2" column="1">
<widget class="QDateEdit" name="calendar">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="confirmExpirationDate">
<property name="icon">
<iconset resource="../../client.qrc">
<normaloff>:/client/resources/confirm.svg</normaloff>:/client/resources/confirm.svg</iconset>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0" colspan="4">
<widget class="QLabel" name="errorLabel">
<property name="palette">
<palette>
<active>
@ -462,23 +228,22 @@
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="indent">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QProgressIndicator</class>
<extends>QWidget</extends>
<header>QProgressIndicator.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../client.qrc"/>
</resources>