Commit cb71de60 authored by kh's avatar kh
Browse files

No need to bookmark empty pages, also disable menu item in case of.

Reviewed-by: dt
parent 78af9c16
...@@ -520,6 +520,10 @@ void CentralWidget::showTabBarContextMenu(const QPoint &point) ...@@ -520,6 +520,10 @@ void CentralWidget::showTabBarContextMenu(const QPoint &point)
close_pages->setEnabled(false); 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)); QAction *picked_action = menu.exec(tabBar->mapToGlobal(point));
if (!picked_action) if (!picked_action)
return; return;
...@@ -547,19 +551,19 @@ void CentralWidget::showTabBarContextMenu(const QPoint &point) ...@@ -547,19 +551,19 @@ void CentralWidget::showTabBarContextMenu(const QPoint &point)
} }
if (picked_action == newBookmark) 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 // If we have a current help viewer then this is the 'focus proxy', otherwise
// it's the tab widget itself // it's the tab widget itself. This is needed, so an embedding program can just
// this is needed, so an embedding program can just set the focus to the central widget // set the focus to the central widget and it does TheRightThing(TM)
// and it does TheRightThing
void CentralWidget::focusInEvent(QFocusEvent * /* event */) void CentralWidget::focusInEvent(QFocusEvent * /* event */)
{ {
QObject *receiver = tabWidget;
if (currentHelpViewer()) if (currentHelpViewer())
QTimer::singleShot(1, currentHelpViewer(), SLOT(setFocus())); receiver = currentHelpViewer();
else
QTimer::singleShot(1, tabWidget, SLOT(setFocus())); QTimer::singleShot(1, receiver, SLOT(setFocus()));
} }
bool CentralWidget::eventFilter(QObject *object, QEvent *e) bool CentralWidget::eventFilter(QObject *object, QEvent *e)
......
...@@ -743,12 +743,13 @@ void HelpPlugin::filterDocumentation(const QString &customFilter) ...@@ -743,12 +743,13 @@ void HelpPlugin::filterDocumentation(const QString &customFilter)
void HelpPlugin::addBookmark() 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) void HelpPlugin::addNewBookmark(const QString &title, const QString &url)
{ {
if (url.isEmpty()) if (url.isEmpty() || url == QLatin1String("about:blank"))
return; return;
m_bookmarkManager->showBookmarkDialog(m_centralWidget, title, url); m_bookmarkManager->showBookmarkDialog(m_centralWidget, title, url);
...@@ -765,9 +766,8 @@ void HelpPlugin::openHelpPage(const QString& url) ...@@ -765,9 +766,8 @@ void HelpPlugin::openHelpPage(const QString& url)
if (m_helpEngine->findFile(url).isValid()) if (m_helpEngine->findFile(url).isValid())
m_centralWidget->setSource(url); m_centralWidget->setSource(url);
else { else {
QString page = url.mid(url.lastIndexOf('/')+1); QDesktopServices::openUrl(QLatin1String("http://doc.trolltech.com/latest/")
qDebug() << url << page << url.lastIndexOf('/'); + url.mid(url.lastIndexOf('/') + 1));
QDesktopServices::openUrl(QLatin1String("http://doc.trolltech.com/latest/")+page);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment