BrowserWindow: Don't show "Empty Page" in window title

remotes/origin/Falkon/3.0
David Rosca 8 years ago
parent 7dfce692d7
commit 059889ecfe
  1. 7
      src/lib/app/browserwindow.cpp
  2. 13
      src/lib/webengine/webview.cpp
  3. 4
      src/lib/webengine/webview.h
  4. 6
      src/lib/webtab/webtab.cpp
  5. 5
      src/lib/webtab/webtab.h

@ -968,7 +968,12 @@ void BrowserWindow::currentTabChanged()
return;
}
setWindowTitle(tr("%1 - Falkon").arg(view->webTab()->title()));
const QString title = view->webTab()->title(/*allowEmpty*/true);
if (title.isEmpty()) {
setWindowTitle(tr("Falkon"));
} else {
setWindowTitle(tr("%1 - Falkon").arg(title));
}
m_ipLabel->setText(view->getIp());
view->setFocus();

@ -114,26 +114,25 @@ QIcon WebView::icon(bool allowNull) const
return IconProvider::iconForUrl(url(), allowNull);
}
QString WebView::title() const
QString WebView::title(bool allowEmpty) const
{
QString title = QWebEngineView::title();
if (allowEmpty) {
return title;
}
if (title.isEmpty()) {
title = url().toString(QUrl::RemoveFragment);
}
if (title.isEmpty() || title == QLatin1String("about:blank")) {
if (title.isEmpty() || title == QL1S("about:blank")) {
return tr("Empty Page");
}
return title;
}
bool WebView::isTitleEmpty() const
{
return QWebEngineView::title().isEmpty();
}
WebPage* WebView::page() const
{
return m_page;

@ -38,9 +38,7 @@ public:
~WebView();
QIcon icon(bool allowNull = false) const;
QString title() const;
bool isTitleEmpty() const;
QString title(bool allowEmpty = false) const;
WebPage* page() const;
void setPage(WebPage* page);

@ -227,10 +227,10 @@ QUrl WebTab::url() const
}
}
QString WebTab::title() const
QString WebTab::title(bool allowEmpty) const
{
if (isRestored()) {
return m_webView->title();
return m_webView->title(allowEmpty);
}
else {
return m_savedTab.title;
@ -426,7 +426,7 @@ void WebTab::showNotification(QWidget* notif)
void WebTab::loadStarted()
{
if (m_tabBar && m_webView->isTitleEmpty()) {
if (m_tabBar && m_webView->title(/*allowEmpty*/true).isEmpty()) {
m_tabBar->setTabText(tabIndex(), tr("Loading..."));
}
}

@ -1,6 +1,6 @@
/* ============================================================
* Falkon - Qt web browser
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
* Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -64,7 +64,7 @@ public:
TabIcon* tabIcon() const;
QUrl url() const;
QString title() const;
QString title(bool allowEmpty = false) const;
QIcon icon(bool allowNull = false) const;
QWebEngineHistory* history() const;
int zoomLevel() const;
@ -128,7 +128,6 @@ private:
SavedTab m_savedTab;
bool m_isPinned;
};
#endif // WEBTAB_H

Loading…
Cancel
Save