[Pkg-owncloud-commits] [owncloud-client] 128/171: Sharing: Allow only one share dialog per path #3184

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Feb 17 09:36:59 UTC 2016


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to annotated tag upstream/2.1.1+dfsg
in repository owncloud-client.

commit 1534dad5b2ce0fce5b454772bdf853a122a87bd3
Author: Christian Kamm <mail at ckamm.de>
Date:   Wed Jan 20 13:17:54 2016 +0100

    Sharing: Allow only one share dialog per path #3184
---
 src/gui/owncloudgui.cpp | 29 +++++++++++++++++++++++++----
 src/gui/owncloudgui.h   |  3 +++
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp
index 5db9f5b..b97a637 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<QString, QPointer<ShareDialog> > 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 891bd74..0b5395b 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<QMenu*> _accountMenus;
     bool _qdbusmenuWorkaround;
+    QMap<QString, QPointer<ShareDialog> > _shareDialogs;
 
     QAction *_actionLogin;
     QAction *_actionLogout;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list