Commit 99ae7ef4 authored by kh's avatar kh
Browse files

Sync with Assistant source, fixes empty tab title.

parent 86f55d7e
......@@ -153,7 +153,11 @@ CentralWidget *CentralWidget::instance()
void CentralWidget::newTab()
{
HelpViewer* viewer = currentHelpViewer();
#if !defined(QT_NO_WEBKIT)
if (viewer && viewer->hasLoadFinished())
#else
if (viewer)
#endif
setSourceInNewTab(viewer->source());
}
......@@ -500,26 +504,22 @@ void CentralWidget::activateTab(bool onlyHelpViewer)
void CentralWidget::setTabTitle(const QUrl& url)
{
int tab = lastTabPage;
HelpViewer* viewer = currentHelpViewer();
Q_UNUSED(url)
#if !defined(QT_NO_WEBKIT)
if (!viewer || viewer->source() != url) {
QTabBar *tabBar = qFindChild<QTabBar*>(tabWidget);
for (tab = 0; tab < tabBar->count(); ++tab) {
viewer = qobject_cast<HelpViewer*>(tabWidget->widget(tab));
if (viewer && viewer->source() == url)
break;
for (int i = 0; i < tabBar->count(); ++i) {
HelpViewer* view = qobject_cast<HelpViewer*>(tabWidget->widget(i));
if (view) {
tabWidget->setTabText(i,
quoteTabTitle(view->documentTitle().trimmed()));
}
}
}
#else
Q_UNUSED(url)
#endif
if (viewer) {
tabWidget->setTabText(tab,
if (HelpViewer* viewer = currentHelpViewer()) {
tabWidget->setTabText(lastTabPage,
quoteTabTitle(viewer->documentTitle().trimmed()));
}
#endif
}
void CentralWidget::currentPageChanged(int index)
......
......@@ -235,6 +235,7 @@ HelpViewer::HelpViewer(QHelpEngine *engine, Help::Internal::CentralWidget *paren
, helpEngine(engine)
, parentWidget(parent)
, multiTabsAllowed(true)
, loadFinished(false)
{
setPage(new HelpPage(parent, helpEngine, this));
settings()->setAttribute(QWebSettings::PluginsEnabled, false);
......@@ -262,11 +263,13 @@ HelpViewer::HelpViewer(QHelpEngine *engine, Help::Internal::CentralWidget *paren
connect(page(), SIGNAL(linkHovered(QString, QString, QString)), this,
SIGNAL(highlighted(QString)));
connect(this, SIGNAL(urlChanged(QUrl)), this, SIGNAL(sourceChanged(QUrl)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(setLoadFinished(bool)));
setAcceptDrops(false);
}
void HelpViewer::setSource(const QUrl &url)
{
loadFinished = false;
if (!homeUrl.isValid())
homeUrl = url;
load(url);
......@@ -356,6 +359,12 @@ void HelpViewer::mousePressEvent(QMouseEvent *event)
QWebView::mousePressEvent(event);
}
void HelpViewer::setLoadFinished(bool ok)
{
loadFinished = ok;
emit sourceChanged(url());
}
#else // !defined(QT_NO_WEBKIT)
HelpViewer::HelpViewer(QHelpEngine *engine, Help::Internal::CentralWidget *parent)
......
......@@ -90,6 +90,8 @@ public:
{ return pageAction(QWebPage::Forward)->isEnabled(); }
inline bool isBackwardAvailable() const
{ return pageAction(QWebPage::Back)->isEnabled(); }
inline bool hasLoadFinished() const
{ return loadFinished; }
public Q_SLOTS:
void home();
......@@ -109,12 +111,14 @@ protected:
private Q_SLOTS:
void actionChanged();
void setLoadFinished(bool ok);
private:
QHelpEngine *helpEngine;
Help::Internal::CentralWidget* parentWidget;
QUrl homeUrl;
bool multiTabsAllowed;
bool loadFinished;
};
#else
......
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