diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index be19021..cb29e64 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -32,6 +32,8 @@ #include <QFileDialog> +#include <QWebEngineHistory> + MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), @@ -78,10 +80,37 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) : backButton->setIcon(style()->standardIcon(QStyle::SP_ArrowBack)); connect(backButton, SIGNAL(clicked()), tabBar->signalMapper(), SLOT(map())); tabBar->signalMapper()->setMapping(backButton, WebViewTabBar::Back); + + QMenu *backMenu = new QMenu(this); + connect(backMenu, &QMenu::aboutToShow, [backMenu, this]() { + backMenu->clear(); + for(QWebEngineHistoryItem i : m_currentView->history()->backItems(10)) { + QAction *a = backMenu->addAction(i.title()); + connect(a, &QAction::triggered, [i, this]() { + m_currentView->history()->goToItem(i); + }); + } + }); + backButton->setMenu(backMenu); + QToolButton *forwardButton = new QToolButton(this); forwardButton->setIcon(style()->standardIcon(QStyle::SP_ArrowForward)); connect(forwardButton, SIGNAL(clicked()), tabBar->signalMapper(), SLOT(map())); tabBar->signalMapper()->setMapping(forwardButton, WebViewTabBar::Forward); + + + QMenu *forwardMenu = new QMenu(this); + connect(forwardMenu, &QMenu::aboutToShow, [forwardMenu, this]() { + forwardMenu->clear(); + for(QWebEngineHistoryItem i : m_currentView->history()->forwardItems(10)) { + QAction *a = forwardMenu->addAction(i.title()); + connect(a, &QAction::triggered, [i, this]() { + m_currentView->history()->goToItem(i); + }); + } + }); + forwardButton->setMenu(forwardMenu); + QToolButton *reloadButton = new QToolButton(this); reloadButton->setIcon(style()->standardIcon(QStyle::SP_BrowserReload)); connect(reloadButton, SIGNAL(clicked()), tabBar->signalMapper(), SLOT(map())); |