Wizard OAuth2 Page: add a context menu to copy the link

Relates to https://github.com/owncloud/enterprise/issues/2600
This commit is contained in:
Olivier Goffart 2018-07-13 11:02:16 +02:00 committed by Camila San
parent cb69944b5c
commit 986cf448a9
No known key found for this signature in database
GPG key ID: 7A4A6121E88E2AD4

View file

@ -13,6 +13,8 @@
*/
#include <QVariant>
#include <QMenu>
#include <QClipboard>
#include "wizard/owncloudoauthcredspage.h"
#include "theme.h"
@ -48,6 +50,16 @@ OwncloudOAuthCredsPage::OwncloudOAuthCredsPage()
if (_asyncAuth)
_asyncAuth->openBrowser();
});
_ui.openLinkButton->setContextMenuPolicy(Qt::CustomContextMenu);
QObject::connect(_ui.openLinkButton, &QWidget::customContextMenuRequested, [this](const QPoint &pos) {
auto menu = new QMenu(_ui.openLinkButton);
menu->addAction(tr("Copy link to clipboard"), this, [this] {
if (_asyncAuth)
QApplication::clipboard()->setText(_asyncAuth->authorisationLink().toString(QUrl::FullyEncoded));
});
menu->setAttribute(Qt::WA_DeleteOnClose);
menu->popup(_ui.openLinkButton->mapToGlobal(pos));
});
}
void OwncloudOAuthCredsPage::initializePage()