aboutsummaryrefslogtreecommitdiff
path: root/src/webengine
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-08-19 11:48:13 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-08-19 11:48:13 +0200
commit1af072e928e9903dec78bc9e323ce47f5e0e151a (patch)
treef4e334c40744ebaf413421bcc7a1477f484ec10f /src/webengine
parentAdd back/forward/refresh buttons to page context menu (diff)
downloadsmolbote-1af072e928e9903dec78bc9e323ce47f5e0e151a.tar.xz
WebView: close context menu when buttons are pressed
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/webview.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp
index 0e48703..25f7b70 100644
--- a/src/webengine/webview.cpp
+++ b/src/webengine/webview.cpp
@@ -128,20 +128,31 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
buttonsLayout->setSpacing(2);
auto *backButton = new QToolButton(this);
+ backButton->setEnabled(history()->canGoBack());
backButton->setIcon(style()->standardIcon(QStyle::SP_ArrowBack));
- connect(backButton, &QToolButton::clicked, this, &WebView::back);
+ connect(backButton, &QToolButton::clicked, this, [this, menu]() {
+ this->back();
+ menu->close();
+ });
buttonsLayout->addWidget(backButton);
auto *forwardButton = new QToolButton(this);
+ forwardButton->setEnabled(history()->canGoForward());
forwardButton->setIcon(style()->standardIcon(QStyle::SP_ArrowForward));
- connect(forwardButton, &QToolButton::clicked, this, &WebView::forward);
+ connect(forwardButton, &QToolButton::clicked, this, [this, menu]() {
+ this->forward();
+ menu->close();
+ });
buttonsLayout->addWidget(forwardButton);
buttonsLayout->addStretch();
auto *refreshButton = new QToolButton(this);
refreshButton->setIcon(style()->standardIcon(QStyle::SP_BrowserReload));
- connect(refreshButton, &QToolButton::clicked, this, &WebView::reload);
+ connect(refreshButton, &QToolButton::clicked, this, [this, menu]() {
+ this->reload();
+ menu->close();
+ });
buttonsLayout->addWidget(refreshButton);
buttons->setLayout(buttonsLayout);