diff --git a/src/plugins/common/dfmplugin-dirshare/widget/sharecontrolwidget.cpp b/src/plugins/common/dfmplugin-dirshare/widget/sharecontrolwidget.cpp index 84de2841c6..e8298957fb 100644 --- a/src/plugins/common/dfmplugin-dirshare/widget/sharecontrolwidget.cpp +++ b/src/plugins/common/dfmplugin-dirshare/widget/sharecontrolwidget.cpp @@ -445,6 +445,12 @@ bool ShareControlWidget::validateShareName() } if (dlg.exec() != DDialog::Accepted) { + if(isShared){ + QString filePath = url.path(); + auto shareName = UserShareHelperInstance->shareNameByPath(filePath); + shareNameEditor->setText(shareName); + shareSwitcher->setChecked(isShared); + } shareNameEditor->setFocus(); return false; } @@ -457,18 +463,24 @@ bool ShareControlWidget::validateShareName() void ShareControlWidget::updateShare() { - shareFolder(); + if (!isUpdating) + shareFolder(); + return; } void ShareControlWidget::shareFolder() { + bool isShared = UserShareHelperInstance->isShared(url.path()); if (!shareSwitcher->isChecked()) return; - + isUpdating =true; if (!validateShareName()) { - shareSwitcher->setChecked(false); - sharePermissionSelector->setEnabled(false); - shareAnonymousSelector->setEnabled(false); + if(!isShared){ + shareSwitcher->setChecked(false); + sharePermissionSelector->setEnabled(false); + shareAnonymousSelector->setEnabled(false); + } + isUpdating =false; return; } @@ -512,6 +524,7 @@ void ShareControlWidget::shareFolder() sharePermissionSelector->setEnabled(false); shareAnonymousSelector->setEnabled(false); } + isUpdating =false; } void ShareControlWidget::unshareFolder() diff --git a/src/plugins/common/dfmplugin-dirshare/widget/sharecontrolwidget.h b/src/plugins/common/dfmplugin-dirshare/widget/sharecontrolwidget.h index bc83e3d88f..51190370fe 100644 --- a/src/plugins/common/dfmplugin-dirshare/widget/sharecontrolwidget.h +++ b/src/plugins/common/dfmplugin-dirshare/widget/sharecontrolwidget.h @@ -94,6 +94,7 @@ protected Q_SLOTS: QTimer *timer { Q_NULLPTR }; QUrl url; + bool isUpdating { false }; FileInfoPointer info { Q_NULLPTR }; AbstractFileWatcherPointer watcher { Q_NULLPTR }; };