}
}
-void ShareLinkWidget::toggleButtonAnimation(QToolButton *button, QProgressIndicator *progressIndicator, const QAction *checkedAction, const bool start)
+void ShareLinkWidget::toggleButtonAnimation(QToolButton *button, QProgressIndicator *progressIndicator, const QAction *checkedAction) const
{
- if (!progressIndicator->isAnimated() && checkedAction->isChecked()) {
+ auto startAnimation = false;
+ const auto actionIsChecked = checkedAction->isChecked();
+ if (!progressIndicator->isAnimated() && actionIsChecked) {
progressIndicator->startAnimation();
+ startAnimation = true;
} else {
progressIndicator->stopAnimation();
}
- const auto startAnimation = checkedAction->isChecked()? progressIndicator->isAnimated() : checkedAction->isChecked();
- button->setVisible(!startAnimation && checkedAction->isChecked());
- progressIndicator->setVisible(startAnimation && checkedAction->isChecked());
+ button->setVisible(!startAnimation && actionIsChecked);
+ progressIndicator->setVisible(startAnimation && actionIsChecked);
}
void ShareLinkWidget::setLinkShare(QSharedPointer<LinkShare> linkShare)
if (_linkShare->getNote().isSimpleText() && !_linkShare->getNote().isEmpty()) {
_ui->textEdit_note->setText(_linkShare->getNote());
_noteLinkAction->setChecked(true);
- toggleNoteOptions(true);
+ toggleNoteOptions();
}
// Adds action to display password widget (check box)
if (_linkShare.data()->isPasswordSet()) {
_passwordProtectLinkAction->setChecked(true);
_ui->lineEdit_password->setPlaceholderText(QString::fromUtf8(passwordIsSetPlaceholder));
- togglePasswordOptions(true);
+ togglePasswordOptions();
}
// If password is enforced then don't allow users to disable it
if (!expireDate.isNull()) {
_ui->calendar->setDate(expireDate);
_expirationDateLinkAction->setChecked(true);
- toggleExpireDateOptions(true);
+ toggleExpireDateOptions();
}
connect(_ui->calendar, &QDateTimeEdit::dateChanged, this, &ShareLinkWidget::slotSetExpireDate);
connect(_linkShare.data(), &LinkShare::expireDateSet, this, &ShareLinkWidget::slotExpireDateSet);
return;
}
- toggleButtonAnimation(_ui->confirmNote, _ui->noteProgressIndicator, _noteLinkAction, true);
+ toggleButtonAnimation(_ui->confirmNote, _ui->noteProgressIndicator, _noteLinkAction);
_ui->errorLabel->hide();
_linkShare->setNote(note);
}
void ShareLinkWidget::slotNoteSet()
{
- toggleButtonAnimation(_ui->confirmNote, _ui->noteProgressIndicator, _noteLinkAction, false);
+ toggleButtonAnimation(_ui->confirmNote, _ui->noteProgressIndicator, _noteLinkAction);
}
-void ShareLinkWidget::slotCopyLinkShare(const bool clicked)
+void ShareLinkWidget::slotCopyLinkShare(const bool clicked) const
{
Q_UNUSED(clicked);
void ShareLinkWidget::slotExpireDateSet()
{
- toggleButtonAnimation(_ui->confirmExpirationDate, _ui->expirationDateProgressIndicator, _expirationDateLinkAction, false);
+ toggleButtonAnimation(_ui->confirmExpirationDate, _ui->expirationDateProgressIndicator, _expirationDateLinkAction);
}
void ShareLinkWidget::slotSetExpireDate()
return;
}
- toggleButtonAnimation(_ui->confirmExpirationDate, _ui->expirationDateProgressIndicator, _expirationDateLinkAction, true);
+ toggleButtonAnimation(_ui->confirmExpirationDate, _ui->expirationDateProgressIndicator, _expirationDateLinkAction);
_ui->errorLabel->hide();
_linkShare->setExpireDate(_ui->calendar->date());
}
return;
}
- toggleButtonAnimation(_ui->confirmPassword, _ui->passwordProgressIndicator, _passwordProtectLinkAction, true);
+ toggleButtonAnimation(_ui->confirmPassword, _ui->passwordProgressIndicator, _passwordProtectLinkAction);
_ui->errorLabel->hide();
emit createPassword(_ui->lineEdit_password->text());
}
-void ShareLinkWidget::slotCreateShareLink(bool clicked)
+void ShareLinkWidget::slotCreateShareLink(const bool clicked)
{
Q_UNUSED(clicked);
slotToggleShareLinkAnimation(true);
void ShareLinkWidget::slotPasswordSet()
{
- toggleButtonAnimation(_ui->confirmPassword, _ui->passwordProgressIndicator, _passwordProtectLinkAction, false);
+ toggleButtonAnimation(_ui->confirmPassword, _ui->passwordProgressIndicator, _passwordProtectLinkAction);
_ui->lineEdit_password->setText({});
void ShareLinkWidget::slotPasswordSetError(const int code, const QString &message)
{
- toggleButtonAnimation(_ui->confirmPassword, _ui->passwordProgressIndicator, _passwordProtectLinkAction, false);
+ toggleButtonAnimation(_ui->confirmPassword, _ui->passwordProgressIndicator, _passwordProtectLinkAction);
slotServerError(code, message);
- togglePasswordOptions(true);
+ togglePasswordOptions();
_ui->lineEdit_password->setFocus();
emit createPasswordProcessed();
}
return;
}
_shareLinkWidgetAction->setChecked(true);
- toggleButtonAnimation(_shareLinkButton, _shareLinkProgressIndicator, _shareLinkWidgetAction, true);
+ toggleButtonAnimation(_shareLinkButton, _shareLinkProgressIndicator, _shareLinkWidgetAction);
_ui->errorLabel->hide();
_linkShare->setLabel(_shareLinkEdit->text());
}
void ShareLinkWidget::slotLabelSet()
{
- _shareLinkWidgetAction->setChecked(false);
- toggleButtonAnimation(_shareLinkButton, _shareLinkProgressIndicator, _shareLinkWidgetAction, false);
+ toggleButtonAnimation(_shareLinkButton, _shareLinkProgressIndicator, _shareLinkWidgetAction);
displayShareLinkLabel();
}
_passwordRequired = true;
- togglePasswordOptions(true);
+ togglePasswordOptions();
}
void ShareLinkWidget::togglePasswordOptions(const bool enable)
public slots:
void slotDeleteShareFetched();
void slotToggleShareLinkAnimation(const bool start);
- void toggleButtonAnimation(QToolButton *button, QProgressIndicator *progressIndicator, const QAction *checkedAction, const bool start);
void slotServerError(const int code, const QString &message);
void slotCreateShareRequiresPassword(const QString &message);
void slotStyleChanged();
private slots:
- void slotCreateShareLink(bool clicked);
+ void slotCreateShareLink(const bool clicked);
+ void slotCopyLinkShare(const bool clicked) const;
void slotCreatePassword();
void slotPasswordSet();
private:
void displayError(const QString &errMsg);
- void togglePasswordOptions(const bool enable);
- void toggleNoteOptions(const bool enable);
- void toggleExpireDateOptions(const bool enable);
-
- void slotCopyLinkShare(const bool clicked);
+ void togglePasswordOptions(const bool enable = true);
+ void toggleNoteOptions(const bool enable = true);
+ void toggleExpireDateOptions(const bool enable = true);
+ void toggleButtonAnimation(QToolButton *button, QProgressIndicator *progressIndicator, const QAction *checkedAction) const;
/** Confirm with the user and then delete the share */
void confirmAndDeleteShare();