From 4338a19c4b1feb3136a4a61c22c495c036f5b5cf Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 19 May 2010 00:34:41 +0200 Subject: This patch is based on Cedric's idea about fixing history with error pages and use it to fix back/forward buttons also on kparts and so on :) --- src/mainwindow.cpp | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1aa4374a..1488980f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1016,13 +1016,22 @@ void MainWindow::openPrevious(Qt::MouseButtons mouseButtons, Qt::KeyboardModifie QWebHistory *history = currentTab()->view()->history(); if (history->canGoBack()) { + QWebHistoryItem *item; + if (currentTab()->view()->page()->isOnRekonqPage()) + { + item = new QWebHistoryItem(history->currentItem()); + currentTab()->view()->page()->setIsOnRekonqPage(false); + } + else + item = new QWebHistoryItem(history->backItem()); + if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) { - Application::instance()->loadUrl(history->backItem().url(), Rekonq::SettingOpenTab); + Application::instance()->loadUrl(item->url(), Rekonq::SettingOpenTab); } else { - history->goToItem(history->backItem()); + history->goToItem(*item); } updateActions(); @@ -1036,13 +1045,22 @@ void MainWindow::openNext(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers k QWebHistory *history = currentTab()->view()->history(); if (history->canGoForward()) { + QWebHistoryItem *item; + if (currentTab()->view()->page()->isOnRekonqPage()) + { + item = new QWebHistoryItem(history->currentItem()); + currentTab()->view()->page()->setIsOnRekonqPage(false); + } + else + item = new QWebHistoryItem(history->forwardItem()); + if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) { - Application::instance()->loadUrl(history->forwardItem().url(), Rekonq::SettingOpenTab); + Application::instance()->loadUrl(item->url(), Rekonq::SettingOpenTab); } else { - history->goToItem(history->forwardItem()); + history->goToItem(*item); } updateActions(); } @@ -1253,6 +1271,22 @@ void MainWindow::aboutToShowBackMenu() if (pivot >= 8) offset = pivot - 8; + /* + * Need a bug report upstream. + * Seems setHtml() do some garbage in history + * Here history->currentItem() have backItem url and currentItem (error page) title + */ + if (currentTab()->view()->page()->isOnRekonqPage()) + { + QWebHistoryItem item = history->currentItem(); + KAction *action = new KAction(this); + action->setData(listCount + offset++); + KIcon icon = Application::icon(item.url()); + action->setIcon(icon); + action->setText(item.title()); + m_historyBackMenu->addAction(action); + } + for (int i = listCount - 1; i >= 0; --i) { QWebHistoryItem item = historyList.at(i); -- cgit v1.2.1