diff options
-rw-r--r-- | src/mainwindow.cpp | 36 | ||||
-rw-r--r-- | src/webview.cpp | 7 |
2 files changed, 25 insertions, 18 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b41b630f..f68a3880 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1054,22 +1054,22 @@ void MainWindow::slotAboutToShowBackMenu() return; QWebHistory *history = currentTab()->history(); int historyCount = history->count(); + // Limit history views in the menu to 8 - int limit = 0; + if(historyCount > 8) + historyCount = 8; + + kDebug() << "History Count: " << historyCount; for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) { - qDebug() << history->currentItemIndex(); QWebHistoryItem item = history->backItems(history->count()).at(i); KAction *action = new KAction(this); - action->setData(history->currentItemIndex() - (i + 1)); - QIcon icon = Application::icon(item.url()); + action->setData( i - history->currentItemIndex() ); + kDebug() << "Current Item Index: " << history->currentItemIndex(); + QIcon icon = Application::icon(item.url()); action->setIcon(icon); action->setText(item.title()); m_historyBackMenu->addAction(action); - ++limit; - if (limit >= 8) { - break; - } } } @@ -1077,20 +1077,26 @@ void MainWindow::slotAboutToShowBackMenu() void MainWindow::slotOpenActionUrl(QAction *action) { int offset = action->data().toInt(); + kDebug() << "Offset: " << offset; QWebHistory *history = currentTab()->history(); - qDebug() << offset; - qDebug() << history->itemAt(offset).isValid(); + + if(!history->itemAt(offset).isValid()) + { + kDebug() << "Invalid Offset!"; + return; + } + if (offset < 0) { history->goToItem(history->itemAt(offset)); // back + return; } - else + + if (offset > 0) { - if (offset > 0) - { - history->goToItem(history->forwardItems(history->count() - offset + 1).back()); // forward - } + history->goToItem(history->forwardItems(history->count() - offset).back()); // forward FIXME CRASH } + } diff --git a/src/webview.cpp b/src/webview.cpp index 834ddcd9..2fe3775b 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -70,11 +70,9 @@ WebView::WebView(QWidget* parent) connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&))); connect(this, SIGNAL(loadProgress(int)), this, SLOT(slotUpdateProgress(int))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool))); - connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChanged())); connect(m_scrollTimer, SIGNAL(timeout()), this, SLOT(scrollFrameChanged())); m_scrollTimer->setInterval(50); - } @@ -251,7 +249,10 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) { // page action QString text = selectedText(); - if (text.startsWith( QLatin1String("http://") ) || text.startsWith( QLatin1String("https://") ) || text.startsWith( QLatin1String("www.") ) ) + if (text.startsWith( QLatin1String("http://") ) + || text.startsWith( QLatin1String("https://") ) + || text.startsWith( QLatin1String("www.") ) + ) { QString truncatedURL = text; if (text.length() > 18) |