diff options
author | Christian Kamm <mail@ckamm.de> | 2017-06-15 17:03:24 +0300 |
---|---|---|
committer | ckamm <mail@ckamm.de> | 2017-07-07 12:23:32 +0300 |
commit | 99b1f69271b230e59b70dd02773ad483046a4328 (patch) | |
tree | a43b68728b151014552ebcc64f087d3d74c07871 /src/gui/sharelinkwidget.cpp | |
parent | e54be1c4ee878dd4c318d70430cfba4907003e84 (diff) |
Link share: Remove direct download if unavailable #5837
It would have been much nicer to keep the menu assigned to the
QToolButton, but if one switches away from InstantPopup (to adjust the
entries before they're displayed), the button always gets a menu
indicator that can't be removed.
Diffstat (limited to 'src/gui/sharelinkwidget.cpp')
-rw-r--r-- | src/gui/sharelinkwidget.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/gui/sharelinkwidget.cpp b/src/gui/sharelinkwidget.cpp index 79973b8e4..bba3151bb 100644 --- a/src/gui/sharelinkwidget.cpp +++ b/src/gui/sharelinkwidget.cpp @@ -156,6 +156,8 @@ ShareLinkWidget::ShareLinkWidget(AccountPtr account, // Prepare sharing menu _shareLinkMenu = new QMenu(this); + connect(_shareLinkMenu, SIGNAL(triggered(QAction *)), + SLOT(slotShareLinkActionTriggered(QAction *))); _openLinkAction = _shareLinkMenu->addAction(tr("Open link in browser")); _copyLinkAction = _shareLinkMenu->addAction(tr("Copy link to clipboard")); _copyDirectLinkAction = _shareLinkMenu->addAction(tr("Copy link to clipboard (direct download)")); @@ -245,9 +247,7 @@ void ShareLinkWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shar auto shareButton = new QToolButton; shareButton->setText("..."); shareButton->setProperty(propertyShareC, QVariant::fromValue(linkShare)); - shareButton->setMenu(_shareLinkMenu); - shareButton->setPopupMode(QToolButton::InstantPopup); - connect(shareButton, SIGNAL(triggered(QAction *)), SLOT(slotShareLinkButtonTriggered(QAction *))); + connect(shareButton, SIGNAL(clicked(bool)), SLOT(slotShareLinkButtonClicked())); table->setCellWidget(row, 1, shareButton); auto deleteButton = new QToolButton; @@ -514,7 +514,18 @@ void ShareLinkWidget::openShareLink(const QUrl &url) Utility::openBrowser(url, this); } -void ShareLinkWidget::slotShareLinkButtonTriggered(QAction *action) +void ShareLinkWidget::slotShareLinkButtonClicked() +{ + auto share = sender()->property(propertyShareC).value<QSharedPointer<LinkShare>>(); + bool downloadEnabled = share->getShowFileListing(); + _copyDirectLinkAction->setVisible(downloadEnabled); + _emailDirectLinkAction->setVisible(downloadEnabled); + + _shareLinkMenu->setProperty(propertyShareC, QVariant::fromValue(share)); + _shareLinkMenu->exec(QCursor::pos()); +} + +void ShareLinkWidget::slotShareLinkActionTriggered(QAction *action) { auto share = sender()->property(propertyShareC).value<QSharedPointer<LinkShare>>(); |