diff --git a/src/gui/sharelinkwidget.cpp b/src/gui/sharelinkwidget.cpp index 6eb4c2592..34ac9a84c 100644 --- a/src/gui/sharelinkwidget.cpp +++ b/src/gui/sharelinkwidget.cpp @@ -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> &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> &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); diff --git a/src/gui/sharelinkwidget.h b/src/gui/sharelinkwidget.h index 6f860c4aa..8094a9789 100644 --- a/src/gui/sharelinkwidget.h +++ b/src/gui/sharelinkwidget.h @@ -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; diff --git a/src/gui/sharelinkwidget.ui b/src/gui/sharelinkwidget.ui index 64d0fd594..8affe169a 100644 --- a/src/gui/sharelinkwidget.ui +++ b/src/gui/sharelinkwidget.ui @@ -11,33 +11,12 @@ - + 0 0 - - - 350 - 110 - - - - - 16777215 - 16777215 - - - - Share NewDocument.odt - - - - 10 - - - QLayout::SetFixedSize - + 0 @@ -50,375 +29,162 @@ 0 - - + + + + + + + 0 + 0 + + + + text-align: left + + + &Share link + + + + :/client/resources/public.svg:/client/resources/public.svg + + + true + + + + + + + Qt::Horizontal + + + + 40 + 25 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 25 + + + + + + + + Enable + + + + + + + + false + + + + :/client/resources/more.svg:/client/resources/more.svg + + + QToolButton::InstantPopup + + + + + + + + 1 + 0 + + + + Password: + + + 20 + + + + + + + + 1 + 0 + + + + QLineEdit::Password + + + + + + + + :/client/resources/confirm.svg:/client/resources/confirm.svg + + true + + + + - - 0 + + 1 0 - - - 350 - 0 - + + Expiration date: + + + 20 - - - 3 - - - QLayout::SetFixedSize - - - 0 - - - 0 - - - 0 - - - 0 - - - - - true - - - - 0 - 0 - - - - - 242 - 26 - - - - - 350 - 26 - - - - Qt::LeftToRight - - - false - - - text-align: left - - - &Share link - - - - :/client/resources/public.svg:/client/resources/public.svg - - - false - - - true - - - - - - - - 82 - 26 - - - - Enable - - - - - - - false - - - - 26 - 26 - - - - Qt::ActionsContextMenu - - - - - - - - - - :/client/resources/more.svg:/client/resources/more.svg - - - QToolButton::InstantPopup - - - Qt::ToolButtonIconOnly - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - 0 - 0 - - - - - 300 - 0 - - - - - 16777215 - 16777215 - - - - - 0 - - - QLayout::SetFixedSize - - - 18 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 162 - 0 - - - - Password: - - - 0 - - - - - - - - 0 - 0 - - - - - 120 - 26 - - - - - 100 - 16777215 - - - - QLineEdit::Password - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - :/client/resources/confirm.svg:/client/resources/confirm.svg - - - true - - - - - - - - - - - 0 - 0 - - - - - 300 - 0 - - - - - 0 - - - QLayout::SetFixedSize - - - 18 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 162 - 26 - - - - Expiration date: - - - 0 - - - - - - - - 0 - 0 - - - - - 120 - 26 - - - - - 16777215 - 16777215 - - - - true - - - - - - - - :/client/resources/confirm.svg:/client/resources/confirm.svg - - - true - - - - - - - - + + - 0 + 1 0 - - - 0 - 0 - + + + + + + + :/client/resources/confirm.svg:/client/resources/confirm.svg - - - 16777215 - 16777215 - + + true + + + + @@ -462,23 +228,22 @@ Qt::PlainText - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - true - - 0 - - - 0 - + + + QProgressIndicator + QWidget +
QProgressIndicator.h
+ 1 +
+