From: Christian Kamm Date: Wed, 20 Jan 2016 12:17:54 +0000 (+0100) Subject: Sharing: Allow only one share dialog per path #3184 X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~1254^2~49 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=1534dad5b2ce0fce5b454772bdf853a122a87bd3;p=nextcloud-desktop.git Sharing: Allow only one share dialog per path #3184 --- diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index 5db9f5bdd..b97a637f7 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -771,12 +771,33 @@ void ownCloudGui::slotShowShareDialog(const QString &sharePath, const QString &l const auto accountState = folder->accountState(); - qDebug() << Q_FUNC_INFO << "Opening share dialog" << sharePath << localPath; - ShareDialog *w = new ShareDialog(accountState->account(), sharePath, localPath, resharingAllowed); - w->getShares(); - w->setAttribute( Qt::WA_DeleteOnClose, true ); + ShareDialog *w = 0; + if (_shareDialogs.contains(localPath) && _shareDialogs[localPath]) { + qDebug() << Q_FUNC_INFO << "Raising share dialog" << sharePath << localPath; + w = _shareDialogs[localPath]; + } else { + qDebug() << Q_FUNC_INFO << "Opening share dialog" << sharePath << localPath; + w = new ShareDialog(accountState->account(), sharePath, localPath, resharingAllowed); + w->getShares(); + w->setAttribute( Qt::WA_DeleteOnClose, true ); + + _shareDialogs[localPath] = w; + connect(w, SIGNAL(destroyed(QObject*)), SLOT(slotRemoveDestroyedShareDialogs())); + } raiseDialog(w); } +void ownCloudGui::slotRemoveDestroyedShareDialogs() +{ + QMutableMapIterator > it(_shareDialogs); + while (it.hasNext()) { + it.next(); + if (! it.value() || it.value() == sender()) { + it.remove(); + qDebug() << "REMOVED"; + } + } +} + } // end namespace diff --git a/src/gui/owncloudgui.h b/src/gui/owncloudgui.h index 891bd74d7..0b5395b89 100644 --- a/src/gui/owncloudgui.h +++ b/src/gui/owncloudgui.h @@ -31,6 +31,7 @@ class Folder; class SettingsDialog; class SettingsDialogMac; +class ShareDialog; class Application; class LogBrowser; class AccountState; @@ -77,6 +78,7 @@ public slots: void slotOpenPath(const QString& path); void slotAccountStateChanged(); void slotShowShareDialog(const QString &sharePath, const QString &localPath, bool resharingAllowed); + void slotRemoveDestroyedShareDialogs(); private slots: void slotDisplayIdle(); @@ -99,6 +101,7 @@ private: QMenu *_recentActionsMenu; QVector _accountMenus; bool _qdbusmenuWorkaround; + QMap > _shareDialogs; QAction *_actionLogin; QAction *_actionLogout;