From cb71de60dde435aaf188e3152eb987ac1463c9bc Mon Sep 17 00:00:00 2001 From: kh <qtc-committer@nokia.com> Date: Thu, 4 Jun 2009 13:12:20 +0200 Subject: [PATCH] No need to bookmark empty pages, also disable menu item in case of. Reviewed-by: dt --- src/plugins/help/centralwidget.cpp | 20 ++++++++++++-------- src/plugins/help/helpplugin.cpp | 10 +++++----- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/plugins/help/centralwidget.cpp b/src/plugins/help/centralwidget.cpp index 72574102f91..d13ef01b19f 100644 --- a/src/plugins/help/centralwidget.cpp +++ b/src/plugins/help/centralwidget.cpp @@ -520,6 +520,10 @@ void CentralWidget::showTabBarContextMenu(const QPoint &point) close_pages->setEnabled(false); } + const QString &url = viewer->source().toString(); + if (url.isEmpty() || url == QLatin1String("about:blank")) + newBookmark->setEnabled(false); + QAction *picked_action = menu.exec(tabBar->mapToGlobal(point)); if (!picked_action) return; @@ -547,19 +551,19 @@ void CentralWidget::showTabBarContextMenu(const QPoint &point) } if (picked_action == newBookmark) - emit addNewBookmark(viewer->documentTitle(), viewer->source().toString()); + emit addNewBookmark(viewer->documentTitle(), url); } -// if we have a current help viewer then this is the 'focus proxy', otherwise -// it's the tab widget itself -// this is needed, so an embedding program can just set the focus to the central widget -// and it does TheRightThing +// If we have a current help viewer then this is the 'focus proxy', otherwise +// it's the tab widget itself. This is needed, so an embedding program can just +// set the focus to the central widget and it does TheRightThing(TM) void CentralWidget::focusInEvent(QFocusEvent * /* event */) { + QObject *receiver = tabWidget; if (currentHelpViewer()) - QTimer::singleShot(1, currentHelpViewer(), SLOT(setFocus())); - else - QTimer::singleShot(1, tabWidget, SLOT(setFocus())); + receiver = currentHelpViewer(); + + QTimer::singleShot(1, receiver, SLOT(setFocus())); } bool CentralWidget::eventFilter(QObject *object, QEvent *e) diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index f5287afbd6f..726d3d47d12 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -743,12 +743,13 @@ void HelpPlugin::filterDocumentation(const QString &customFilter) void HelpPlugin::addBookmark() { - addNewBookmark(m_centralWidget->currentTitle(), m_centralWidget->currentSource().toString()); + addNewBookmark(m_centralWidget->currentTitle(), + m_centralWidget->currentSource().toString()); } void HelpPlugin::addNewBookmark(const QString &title, const QString &url) { - if (url.isEmpty()) + if (url.isEmpty() || url == QLatin1String("about:blank")) return; m_bookmarkManager->showBookmarkDialog(m_centralWidget, title, url); @@ -765,9 +766,8 @@ void HelpPlugin::openHelpPage(const QString& url) if (m_helpEngine->findFile(url).isValid()) m_centralWidget->setSource(url); else { - QString page = url.mid(url.lastIndexOf('/')+1); - qDebug() << url << page << url.lastIndexOf('/'); - QDesktopServices::openUrl(QLatin1String("http://doc.trolltech.com/latest/")+page); + QDesktopServices::openUrl(QLatin1String("http://doc.trolltech.com/latest/") + + url.mid(url.lastIndexOf('/') + 1)); } } -- GitLab