1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

When title of page is empty, we first try to find path and set title to

path, when the path is empty we then try to find url host, when host is
empty then No Named Page will be shown
This commit is contained in:
nowrep 2011-03-18 15:01:01 +01:00
parent 2e9586474f
commit ec72689985
2 changed files with 10 additions and 9 deletions

View File

@ -57,7 +57,7 @@ WebView::WebView(QupZilla* mainClass, QWidget* parent)
connect(this, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClicked(QUrl))); connect(this, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClicked(QUrl)));
connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl))); connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(urlChanged(QUrl)));
connect(this, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged(QString))); connect(this, SIGNAL(titleChanged(QString)), this, SLOT(titleChanged()));
connect(this, SIGNAL(statusBarMessage(QString)), p_QupZilla->statusBar(), SLOT(showMessage(QString))); connect(this, SIGNAL(statusBarMessage(QString)), p_QupZilla->statusBar(), SLOT(showMessage(QString)));
@ -203,23 +203,22 @@ void WebView::loadFinished(bool state)
if (icon().isNull()) if (icon().isNull())
QTimer::singleShot(1000, this, SLOT(iconChanged())); QTimer::singleShot(1000, this, SLOT(iconChanged()));
titleChanged(title()); titleChanged();
mApp->autoFill()->completePage(this); mApp->autoFill()->completePage(this);
QHostInfo::lookupHost(url().host(), this, SLOT(setIp(QHostInfo))); QHostInfo::lookupHost(url().host(), this, SLOT(setIp(QHostInfo)));
} }
void WebView::titleChanged(QString title) void WebView::titleChanged()
{ {
if (title.isEmpty()) title = url().host(); QString title_ = title();
if (title.isEmpty()) title = tr("No Named Page"); QString title2 = title_;
QString title2 = title;
tabWidget()->setTabToolTip(tabIndex(),title2); tabWidget()->setTabToolTip(tabIndex(),title2);
title2+=" - QupZilla"; title2+=" - QupZilla";
if (isCurrent()) if (isCurrent())
p_QupZilla->setWindowTitle(title2); p_QupZilla->setWindowTitle(title2);
tabWidget()->setTabText(tabIndex(),title); tabWidget()->setTabText(tabIndex(),title_);
} }
void WebView::iconChanged() void WebView::iconChanged()
@ -688,6 +687,8 @@ QUrl WebView::url() const
QString WebView::title() const QString WebView::title() const
{ {
QString title = QWebView::title(); QString title = QWebView::title();
if (title.isEmpty()) title = url().path();
if (title.isEmpty()) title = url().host();
if (title.isEmpty()) if (title.isEmpty())
return tr("No Named Page"); return tr("No Named Page");
return title; return title;

View File

@ -87,7 +87,7 @@ private slots:
void loadFinished(bool state); void loadFinished(bool state);
void linkClicked(const QUrl &url); void linkClicked(const QUrl &url);
void urlChanged(const QUrl &url); void urlChanged(const QUrl &url);
void titleChanged(QString title); void titleChanged();
void linkHovered(const QString &link, const QString &title, const QString &content); void linkHovered(const QString &link, const QString &title, const QString &content);
void openUrlInNewWindow(); void openUrlInNewWindow();
void openUrlInNewTab(); void openUrlInNewTab();