Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions src/gui/sharelinkwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
connect(_ui->pushButton_setPassword, &QAbstractButton::clicked, this, &ShareLinkWidget::slotPasswordReturnPressed);
connect(_ui->checkBox_expire, &QAbstractButton::clicked, this, &ShareLinkWidget::slotCheckBoxExpireClicked);
connect(_ui->calendar, &QDateTimeEdit::dateChanged, this, &ShareLinkWidget::slotExpireDateChanged);
connect(_ui->checkBox_editing, &QAbstractButton::clicked, this, &ShareLinkWidget::slotPermissionsCheckboxClicked);
connect(_ui->checkBox_fileListing, &QAbstractButton::clicked, this, &ShareLinkWidget::slotPermissionsCheckboxClicked);
connect(_ui->radio_readOnly, &QAbstractButton::clicked, this, &ShareLinkWidget::slotPermissionsClicked);
connect(_ui->radio_readWrite, &QAbstractButton::clicked, this, &ShareLinkWidget::slotPermissionsClicked);
connect(_ui->radio_uploadOnly, &QAbstractButton::clicked, this, &ShareLinkWidget::slotPermissionsClicked);

_ui->errorLabel->hide();

Expand Down Expand Up @@ -149,7 +150,7 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account,
// File can't have public upload set; we also hide it if the capability isn't there
_ui->widget_editing->setVisible(
!_isFile && _account->capabilities().sharePublicLinkAllowUpload());
_ui->checkBox_fileListing->setVisible(
_ui->radio_uploadOnly->setVisible(
_account->capabilities().sharePublicLinkSupportsUploadOnly());


Expand Down Expand Up @@ -282,7 +283,9 @@ void ShareLinkWidget::slotShareSelectionChanged()
auto share = selectedShare();
if (!share) {
_ui->shareProperties->setEnabled(false);
_ui->checkBox_editing->setChecked(false);
_ui->radio_readOnly->setChecked(false);
_ui->radio_readWrite->setChecked(false);
_ui->radio_uploadOnly->setChecked(false);
_ui->checkBox_expire->setChecked(false);
_ui->checkBox_password->setChecked(false);
return;
Expand All @@ -292,8 +295,11 @@ void ShareLinkWidget::slotShareSelectionChanged()

_ui->checkBox_password->setEnabled(!_passwordRequired);
_ui->checkBox_expire->setEnabled(!_expiryRequired);
_ui->checkBox_editing->setEnabled(
_account->capabilities().sharePublicLinkAllowUpload());
_ui->widget_editing->setEnabled(true);
if (!_account->capabilities().sharePublicLinkAllowUpload()) {
_ui->radio_readWrite->setEnabled(false);
_ui->radio_uploadOnly->setEnabled(false);
}

// Password state
_ui->checkBox_password->setText(tr("P&assword protect"));
Expand Down Expand Up @@ -324,9 +330,15 @@ void ShareLinkWidget::slotShareSelectionChanged()

// Public upload state (box is hidden for files)
if (!_isFile) {
_ui->checkBox_editing->setChecked(share->getPublicUpload());
_ui->checkBox_fileListing->setChecked(share->getShowFileListing());
_ui->checkBox_fileListing->setEnabled(share->getPublicUpload());
if (share->getPublicUpload()) {
if (share->getShowFileListing()) {
_ui->radio_readWrite->setChecked(true);
} else {
_ui->radio_uploadOnly->setChecked(true);
}
} else {
_ui->radio_readOnly->setChecked(true);
}
}
}

Expand Down Expand Up @@ -456,7 +468,7 @@ void ShareLinkWidget::slotCreateShareRequiresPassword(const QString &message)
_ui->checkBox_password->setEnabled(false);
_ui->checkBox_password->setText(tr("Public sh&aring requires a password"));
_ui->checkBox_expire->setEnabled(false);
_ui->checkBox_editing->setEnabled(false);
_ui->widget_editing->setEnabled(false);
if (!message.isEmpty()) {
_ui->errorLabel->setText(message);
_ui->errorLabel->show();
Expand Down Expand Up @@ -579,19 +591,18 @@ void ShareLinkWidget::slotDeleteShareClicked()
confirmAndDeleteShare(share);
}

void ShareLinkWidget::slotPermissionsCheckboxClicked()
void ShareLinkWidget::slotPermissionsClicked()
{
if (auto current = selectedShare()) {
_ui->checkBox_editing->setEnabled(false);
_ui->checkBox_fileListing->setEnabled(false);
_ui->widget_editing->setEnabled(false);
_pi_editing->startAnimation();
_ui->errorLabel->hide();

SharePermissions perm = SharePermissionRead;
if (_ui->checkBox_editing->isChecked() && _ui->checkBox_fileListing->isChecked()) {
if (_ui->radio_readWrite->isChecked()) {
perm = SharePermissionRead | SharePermissionCreate
| SharePermissionUpdate | SharePermissionDelete;
} else if (_ui->checkBox_editing->isChecked() && !_ui->checkBox_fileListing->isChecked()) {
} else if (_ui->radio_uploadOnly->isChecked()) {
perm = SharePermissionCreate;
}
current->setPermissions(perm);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/sharelinkwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private slots:
void slotCheckBoxPasswordClicked();
void slotCheckBoxExpireClicked();
void slotPasswordReturnPressed();
void slotPermissionsCheckboxClicked();
void slotPermissionsClicked();
void slotExpireDateChanged(const QDate &date);
void slotPasswordChanged(const QString &newText);
void slotNameEdited(QTableWidgetItem *item);
Expand Down
105 changes: 89 additions & 16 deletions src/gui/sharelinkwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>376</width>
<height>493</height>
<width>394</width>
<height>534</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -48,7 +48,7 @@
<item>
<widget class="QTableWidget" name="linkShares">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down Expand Up @@ -191,36 +191,110 @@
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox_editing">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Allow editing</string>
<string>Users can view and download contents.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
<width>20</width>
<height>6</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_fileListing">
<item row="6" column="0">
<widget class="QRadioButton" name="radio_uploadOnly">
<property name="text">
<string>Upload only (File Drop)</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Receive files from others without revealing the contents of the folder.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="radio_readOnly">
<property name="text">
<string>Read only</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QRadioButton" name="radio_readWrite">
<property name="text">
<string>Show file listing</string>
<string>Read &amp;&amp; Write</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Users can view, download, edit and upload contents.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>6</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -287,7 +361,6 @@
<tabstop>nameLineEdit</tabstop>
<tabstop>createShareButton</tabstop>
<tabstop>linkShares</tabstop>
<tabstop>checkBox_editing</tabstop>
<tabstop>checkBox_password</tabstop>
<tabstop>lineEdit_password</tabstop>
<tabstop>pushButton_setPassword</tabstop>
Expand Down