diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-08-19 11:18:45 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-08-19 11:35:08 +0200 |
commit | 6fba8c01d7f9cd734ceb51b901ed18e84d00576b (patch) | |
tree | 817231fc4168e2e970875f4f3e3ac07db4e9b2f8 | |
parent | Update readme (diff) | |
download | smolbote-6fba8c01d7f9cd734ceb51b901ed18e84d00576b.tar.xz |
Add back/forward/refresh buttons to page context menu
-rw-r--r-- | src/webengine/webview.cpp | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/webengine/webview.cpp b/src/webengine/webview.cpp index 14cb020..0e48703 100644 --- a/src/webengine/webview.cpp +++ b/src/webengine/webview.cpp @@ -7,20 +7,21 @@ */ #include "webview.h" +#include "profilemanager.h" #include "subwindow/subwindow.h" #include "webpage.h" #include "webprofile.h" #include <QContextMenuEvent> #include <QDialog> +#include <QMenu> #include <QSlider> #include <QStatusBar> +#include <QStyle> #include <QToolButton> #include <QVBoxLayout> #include <QWebEngineContextMenuData> #include <QWebEngineHistoryItem> #include <QWidgetAction> -#include "profilemanager.h" -#include <QMenu> inline QAction *historyAction(QWebEngineView *view, const QWebEngineHistoryItem &item) { @@ -118,6 +119,38 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) QMenu *menu = new QMenu(this); const auto ctxdata = page()->contextMenuData(); + { + auto *navButtons = new QWidgetAction(this); + + auto *buttons = new QWidget(this); + auto *buttonsLayout = new QHBoxLayout(); + buttonsLayout->setContentsMargins(8, 0, 8, 0); + buttonsLayout->setSpacing(2); + + auto *backButton = new QToolButton(this); + backButton->setIcon(style()->standardIcon(QStyle::SP_ArrowBack)); + connect(backButton, &QToolButton::clicked, this, &WebView::back); + buttonsLayout->addWidget(backButton); + + auto *forwardButton = new QToolButton(this); + forwardButton->setIcon(style()->standardIcon(QStyle::SP_ArrowForward)); + connect(forwardButton, &QToolButton::clicked, this, &WebView::forward); + buttonsLayout->addWidget(forwardButton); + + buttonsLayout->addStretch(); + + auto *refreshButton = new QToolButton(this); + refreshButton->setIcon(style()->standardIcon(QStyle::SP_BrowserReload)); + connect(refreshButton, &QToolButton::clicked, this, &WebView::reload); + buttonsLayout->addWidget(refreshButton); + + buttons->setLayout(buttonsLayout); + navButtons->setDefaultWidget(buttons); + + menu->addAction(navButtons); + menu->addSeparator(); + } + if(ctxdata.mediaType() == QWebEngineContextMenuData::MediaTypeNone) { auto *backMenu = new QMenu(tr("Back"), this); if(!history()->canGoBack()) { |