aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-09-10 22:59:47 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2017-09-10 22:59:47 +0200
commitc114e8df178f19064c0b90ae162f062b25668fff (patch)
tree37c82c07b353ed9cd2db271f02d7f8dddd7b508c /src/mainwindow.cpp
parentBack and forward history menus (diff)
downloadsmolbote-c114e8df178f19064c0b90ae162f062b25668fff.tar.xz
Back/Forward NavigationButton class
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp39
1 files changed, 5 insertions, 34 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index cb29e64..68afa40 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -76,40 +76,9 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
navigationToolBar->setMovable(sSettings->value("window.ui.navtoolbarMovable").toBool());
// page actions
- QToolButton *backButton = new QToolButton(this);
- 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);
+ backButton = new NavigationButton(NavigationButton::BackButton, this);
+
+ forwardButton = new NavigationButton(NavigationButton::ForwardButton, this);
QToolButton *reloadButton = new QToolButton(this);
reloadButton->setIcon(style()->standardIcon(QStyle::SP_BrowserReload));
@@ -270,6 +239,8 @@ void MainWindow::handleTabChanged(WebView *view)
setCentralWidget(view);
// connect signals
+ backButton->setView(view);
+ forwardButton->setView(view);
m_addressBar->setWebView(view);
connect(view, SIGNAL(titleChanged(QString)), this, SLOT(handleTitleUpdated(QString)));
connect(view, SIGNAL(linkHovered(QString)), ui->statusBar, SLOT(showMessage(QString)));