diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 17ef8fe62b5..3580c018bba 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -1038,6 +1038,7 @@ void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &l Utility::openBrowser(queryUrl, nullptr); }); } else { + // oC10 code path const auto accountState = folder->accountState(); SyncJournalFileRecord fileRecord; @@ -1063,34 +1064,22 @@ void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &l maxSharingPermissions = SharePermission(0); } - - ShareDialog *w = nullptr; - if (_shareDialogs.contains(localPath) && _shareDialogs[localPath]) { - qCInfo(lcApplication) << "Raising share dialog" << sharePath << localPath; - w = _shareDialogs[localPath]; + if (_shareDialog && _shareDialog->localPath() == localPath) { + qCInfo(lcApplication) << "A share dialog for this path already exists" << sharePath << localPath; + // There might be another modal dialog on top, but that is usually more important (e.g. a login dialog). + raise(); } else { - qCInfo(lcApplication) << "Opening share dialog" << sharePath << localPath << maxSharingPermissions; - w = new ShareDialog(accountState, folder->webDavUrl(), sharePath, localPath, maxSharingPermissions, startPage, settingsDialog()); - w->setAttribute(Qt::WA_DeleteOnClose, true); - - _shareDialogs[localPath] = w; - connect(w, &QObject::destroyed, this, &ownCloudGui::slotRemoveDestroyedShareDialogs); - } - ocApp() - ->gui() - ->settingsDialog() - ->accountSettings(accountState->account().get()) - ->addModalLegacyDialog(w, AccountSettings::ModalWidgetSizePolicy::Expanding); - } -} - -void ownCloudGui::slotRemoveDestroyedShareDialogs() -{ - QMutableMapIterator> it(_shareDialogs); - while (it.hasNext()) { - it.next(); - if (!it.value() || it.value() == sender()) { - it.remove(); + qCInfo(lcApplication) << "Opening new share dialog" << sharePath << localPath << maxSharingPermissions; + if (_shareDialog) { + _shareDialog->close(); + } + _shareDialog = new ShareDialog(accountState, folder->webDavUrl(), sharePath, localPath, maxSharingPermissions, startPage, settingsDialog()); + _shareDialog->setAttribute(Qt::WA_DeleteOnClose, true); + ocApp() + ->gui() + ->settingsDialog() + ->accountSettings(accountState->account().get()) + ->addModalLegacyDialog(_shareDialog, AccountSettings::ModalWidgetSizePolicy::Expanding); } } } diff --git a/src/gui/owncloudgui.h b/src/gui/owncloudgui.h index 7dd7970e848..7e90fa6d62d 100644 --- a/src/gui/owncloudgui.h +++ b/src/gui/owncloudgui.h @@ -110,8 +110,6 @@ public Q_SLOTS: */ void slotShowShareDialog(const QString &sharePath, const QString &localPath, ShareDialogStartPage startPage); - void slotRemoveDestroyedShareDialogs(); - private: void setPauseOnAllFoldersHelper(const QList &accounts, bool pause); void setupActions(); @@ -135,7 +133,7 @@ public Q_SLOTS: bool _workaroundFakeDoubleClick = false; bool _workaroundManualVisibility = false; QTimer _delayedTrayUpdateTimer; - QMap> _shareDialogs; + QPointer _shareDialog; QAction *_actionStatus; diff --git a/src/gui/sharedialog.h b/src/gui/sharedialog.h index 838d6ff1a98..00309248baf 100644 --- a/src/gui/sharedialog.h +++ b/src/gui/sharedialog.h @@ -35,6 +35,11 @@ namespace Ui { class ShareLinkWidget; class ShareUserGroupWidget; +/** + * @brief The ShareDialog for oC10. + * + * (OCIS sharing is done by showing the web page.) + */ class ShareDialog : public QDialog { Q_OBJECT @@ -49,6 +54,8 @@ class ShareDialog : public QDialog QWidget *parent); ~ShareDialog() override; + QString localPath() const { return _localPath; } + private Q_SLOTS: void slotPropfindReceived(const QString &, const QMap &result); void slotPropfindError();