From: Olivier Goffart Date: Wed, 20 Sep 2017 14:49:41 +0000 (+0200) Subject: Gui: Use lambda instead of QSignalMapper X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~701^2~68 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c219ceea52b7c9c1836635d5af3458287f1f302d;p=nextcloud-desktop.git Gui: Use lambda instead of QSignalMapper It's simpler, and QSignalMapper is deprecated in Qt 5.10 --- diff --git a/src/gui/folderman.h b/src/gui/folderman.h index a504cc99b..5802789c8 100644 --- a/src/gui/folderman.h +++ b/src/gui/folderman.h @@ -24,7 +24,6 @@ #include "folderwatcher.h" #include "syncfileitem.h" -class QSignalMapper; class TestFolderMan; namespace OCC { diff --git a/src/gui/owncloudgui.cpp b/src/gui/owncloudgui.cpp index e5a398c8e..225cbf3b3 100644 --- a/src/gui/owncloudgui.cpp +++ b/src/gui/owncloudgui.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #if defined(Q_OS_X11) #include @@ -63,8 +62,6 @@ ownCloudGui::ownCloudGui(Application *parent) , _contextMenuVisibleOsx(false) , _recentActionsMenu(0) , _qdbusmenuWorkaround(false) - , _folderOpenActionMapper(new QSignalMapper(this)) - , _recentItemsMapper(new QSignalMapper(this)) , _app(parent) { _tray = new Systray(); @@ -81,13 +78,6 @@ ownCloudGui::ownCloudGui(Application *parent) _tray->show(); - /* use a signal mapper to map the open requests to the alias names */ - connect(_folderOpenActionMapper, SIGNAL(mapped(QString)), - this, SLOT(slotFolderOpenAction(QString))); - - connect(_recentItemsMapper, SIGNAL(mapped(QString)), - this, SLOT(slotOpenPath(QString))); - ProgressDispatcher *pd = ProgressDispatcher::instance(); connect(pd, SIGNAL(progressInfo(QString, ProgressInfo)), this, SLOT(slotUpdateProgress(QString, ProgressInfo))); @@ -337,9 +327,8 @@ void ownCloudGui::addAccountContextMenu(AccountStatePtr accountState, QMenu *men } QAction *action = new QAction(tr("Open folder '%1'").arg(folder->shortGuiLocalPath()), menu); - connect(action, SIGNAL(triggered()), _folderOpenActionMapper, SLOT(map())); - _folderOpenActionMapper->setMapping(action, folder->alias()); - menu->addAction(action); + auto alias = folder->alias(); + connect(action, &QAction::triggered, this, [this, alias] { this->slotFolderOpenAction(alias); }); } menu->addSeparator(); @@ -805,8 +794,7 @@ void ownCloudGui::slotUpdateProgress(const QString &folder, const ProgressInfo & if (f) { QString fullPath = f->path() + '/' + progress._lastCompletedItem._file; if (QFile(fullPath).exists()) { - _recentItemsMapper->setMapping(action, fullPath); - connect(action, SIGNAL(triggered()), _recentItemsMapper, SLOT(map())); + connect(action, &QAction::triggered, this, [this, fullPath] { this->slotOpenPath(fullPath); }); } else { action->setEnabled(false); } diff --git a/src/gui/owncloudgui.h b/src/gui/owncloudgui.h index c24fa173a..da4ae38a2 100644 --- a/src/gui/owncloudgui.h +++ b/src/gui/owncloudgui.h @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -144,10 +143,6 @@ private: QAction *_actionCrash; QList _recentItemsActions; - - QSignalMapper *_folderOpenActionMapper; - QSignalMapper *_recentItemsMapper; - Application *_app; };