summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-10-21 23:28:53 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-10-21 23:28:53 +0200
commit8d8f29078b2e7fd07e8b21fe238a76f9eb134492 (patch)
tree25c88c6e67541010d147a06fad2e3785102e171b /src
parentadd comment to string (diff)
downloadrekonq-8d8f29078b2e7fd07e8b21fe238a76f9eb134492.tar.xz
This commit fixes icons handling for "rekonq pages" (eg: about urls).
It also contains a cleaned version of the WebTab::url() method (the previous one was not working on loading pages. And also immediately after the loadFinished signal) This should also fix some "bad" handling on back/forward buttons. Finally, it contains some unrelated QLatin1String --> QL1S changes. Benjamin, I spoke too early about those. I squashed merged my work and removed previous branch :(
Diffstat (limited to 'src')
-rw-r--r--src/mainview.cpp7
-rw-r--r--src/mainwindow.cpp2
-rw-r--r--src/newtabpage.cpp54
-rw-r--r--src/protocolhandler.cpp4
-rw-r--r--src/webpage.cpp3
-rw-r--r--src/webpage.h2
-rw-r--r--src/webtab.cpp25
7 files changed, 45 insertions, 52 deletions
diff --git a/src/mainview.cpp b/src/mainview.cpp
index 4ccbe937..beaf4e21 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -562,10 +562,13 @@ void MainView::webViewLoadFinished(bool ok)
void MainView::webViewIconChanged()
{
WebView *view = qobject_cast<WebView *>(sender());
- int index = indexOf(view->parentWidget());
+ WebTab *tab = qobject_cast<WebTab *>(view->parent());
+ int index = indexOf(tab);
+
if (-1 != index)
{
- KIcon icon = Application::iconManager()->iconForUrl(view->url());
+ kDebug() << "TAB URL: " << tab->url();
+ KIcon icon = Application::iconManager()->iconForUrl(tab->url());
QLabel *label = animatedLoading(index, false);
QMovie *movie = label->movie();
delete movie;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 4d3dfc91..555e58ae 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1284,7 +1284,7 @@ void MainWindow::populateEncodingMenu()
QList<int> mibs = QTextCodec::availableMibs();
Q_FOREACH (const int &mib, mibs)
{
- QString codec = QLatin1String(QTextCodec::codecForMib(mib)->name());
+ QString codec = QL1S(QTextCodec::codecForMib(mib)->name());
codecs.append(codec);
}
codecs.sort();
diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp
index f5c9c186..36462f8c 100644
--- a/src/newtabpage.cpp
+++ b/src/newtabpage.cpp
@@ -171,8 +171,8 @@ void NewTabPage::favoritesPage()
m_root.addClass("favorites");
const QWebElement add = createLinkItem(i18n("Add Favorite"),
- QLatin1String("about:preview/add"),
- QLatin1String("list-add"),
+ QL1S("about:preview/add"),
+ QL1S("list-add"),
KIconLoader::Toolbar);
m_root.document().findFirst("#actions").appendInside(add);
@@ -344,44 +344,44 @@ void NewTabPage::browsingMenu(const KUrl &currentUrl)
// Favorites
navItems.append(createLinkItem(i18n("Favorites"),
- QLatin1String("about:favorites"),
- QLatin1String("emblem-favorite"),
+ QL1S("about:favorites"),
+ QL1S("emblem-favorite"),
KIconLoader::Toolbar));
// Closed Tabs
navItems.append(createLinkItem(i18n("Closed Tabs"),
- QLatin1String("about:closedTabs"),
- QLatin1String("tab-close"),
+ QL1S("about:closedTabs"),
+ QL1S("tab-close"),
KIconLoader::Toolbar));
// Bookmarks
navItems.append(createLinkItem(i18n("Bookmarks"),
- QLatin1String("about:bookmarks"),
- QLatin1String("bookmarks"),
+ QL1S("about:bookmarks"),
+ QL1S("bookmarks"),
KIconLoader::Toolbar));
// History
navItems.append(createLinkItem(i18n("History"),
- QLatin1String("about:history"),
- QLatin1String("view-history"),
+ QL1S("about:history"),
+ QL1S("view-history"),
KIconLoader::Toolbar));
// Downloads
navItems.append(createLinkItem(i18n("Downloads"),
- QLatin1String("about:downloads"),
- QLatin1String("download"),
+ QL1S("about:downloads"),
+ QL1S("download"),
KIconLoader::Toolbar));
foreach(QWebElement it, navItems)
{
const QString aTagString('a');
- const QString hrefAttributeString(QLatin1String("href"));
+ const QString hrefAttributeString(QL1S("href"));
if (it.findFirst(aTagString).attribute(hrefAttributeString) == currentUrl.toMimeDataString())
- it.addClass(QLatin1String("current"));
- else if (currentUrl == QLatin1String("about:home") && it.findFirst(aTagString).attribute(hrefAttributeString) == QLatin1String("about:favorites"))
- it.addClass(QLatin1String("current"));
- m_root.document().findFirst(QLatin1String("#navigation")).appendInside(it);
+ it.addClass(QL1S("current"));
+ else if (currentUrl == QL1S("about:home") && it.findFirst(aTagString).attribute(hrefAttributeString) == QL1S("about:favorites"))
+ it.addClass(QL1S("current"));
+ m_root.document().findFirst(QL1S("#navigation")).appendInside(it);
}
}
@@ -391,8 +391,8 @@ void NewTabPage::historyPage()
m_root.addClass("history");
const QWebElement clearData = createLinkItem(i18n("Clear Private Data"),
- QLatin1String("about:history/clear"),
- QLatin1String("edit-clear"),
+ QL1S("about:history/clear"),
+ QL1S("edit-clear"),
KIconLoader::Toolbar);
m_root.document().findFirst("#actions").appendInside(clearData);
@@ -436,8 +436,8 @@ void NewTabPage::bookmarksPage()
m_root.addClass("bookmarks");
const QWebElement editBookmarks = createLinkItem(i18n("Edit Bookmarks"),
- QLatin1String("about:bookmarks/edit"),
- QLatin1String("bookmarks-organize"),
+ QL1S("about:bookmarks/edit"),
+ QL1S("bookmarks-organize"),
KIconLoader::Toolbar);
m_root.document().findFirst("#actions").appendInside(editBookmarks);
@@ -536,8 +536,8 @@ void NewTabPage::downloadsPage()
m_root.addClass("downloads");
const QWebElement clearData = createLinkItem(i18n("Clear Private Data"),
- QLatin1String("about:downloads/clear"),
- QLatin1String("edit-clear"),
+ QL1S("about:downloads/clear"),
+ QL1S("edit-clear"),
KIconLoader::Toolbar);
m_root.document().findFirst("#actions").appendInside(clearData);
@@ -592,10 +592,10 @@ QWebElement NewTabPage::createLinkItem(const QString &title, const QString &urlS
{
const KIconLoader * const loader = KIconLoader::global();
- QWebElement nav = markup(QLatin1String(".link"));
- nav.findFirst(QString('a')).setAttribute(QLatin1String("href"), urlString);
- nav.findFirst(QLatin1String("img")).setAttribute(QLatin1String("src"),
+ QWebElement nav = markup(QL1S(".link"));
+ nav.findFirst(QString('a')).setAttribute(QL1S("href"), urlString);
+ nav.findFirst(QL1S("img")).setAttribute(QL1S("src"),
QString::fromLatin1("file://") + loader->iconPath(iconPath, groupOrSize));
- nav.findFirst(QLatin1String("span")).appendInside(title);
+ nav.findFirst(QL1S("span")).appendInside(title);
return nav;
}
diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp
index 16af1f32..a595394a 100644
--- a/src/protocolhandler.cpp
+++ b/src/protocolhandler.cpp
@@ -153,8 +153,12 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra
}
}
+ WebPage *page = qobject_cast<WebPage *>(frame->page());
+ page->setIsOnRekonqPage(true);
+
NewTabPage p(frame);
p.generate(_url);
+
return true;
}
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 61c6a325..2347b6d8 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -418,7 +418,6 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
if (!isLocal)
{
-
KParts::BrowserOpenOrSaveQuestion dlg(Application::instance()->mainWindow(), replyUrl, mimeType);
if(!suggestedFileName.isEmpty())
dlg.setSuggestedFileName(suggestedFileName);
@@ -509,6 +508,8 @@ void WebPage::loadFinished(bool ok)
{
wallet()->fillFormData(mainFrame());
}
+ kDebug() << "rekonq page: " << _isOnRekonqPage;
+ kDebug() << "loading url: " << _loadingUrl;
}
diff --git a/src/webpage.h b/src/webpage.h
index b6e0c531..41ddd877 100644
--- a/src/webpage.h
+++ b/src/webpage.h
@@ -58,6 +58,8 @@ public:
inline bool isOnRekonqPage() const { return _isOnRekonqPage; };
inline void setIsOnRekonqPage(bool b) { _isOnRekonqPage = b; };
+ inline KUrl loadingUrl() { return _loadingUrl; };
+
public Q_SLOTS:
void downloadAllContentsWithKGet(QPoint);
diff --git a/src/webtab.cpp b/src/webtab.cpp
index 2289726c..9ed43d45 100644
--- a/src/webtab.cpp
+++ b/src/webtab.cpp
@@ -84,29 +84,12 @@ WebTab::~WebTab()
}
-// TODO:
-// Import the "about" check and the one in protocolhandler
-// in some (static?) methods in NewTabPage
KUrl WebTab::url()
{
- KUrl u = KUrl(view()->url());
- if (u.scheme() == QL1S("about"))
- {
- QWebElement rootElement = page()->mainFrame()->documentElement();
- if (rootElement.document().findAll("#rekonq-newtabpage").count() == 0)
- return u;
- if (rootElement.findAll(".favorites").count() > 0)
- return KUrl("about:favorites");
- if (rootElement.findAll(".closedTabs").count() > 0)
- return KUrl("about:closedTabs");
- if (rootElement.findAll(".history").count() > 0)
- return KUrl("about:history");
- if (rootElement.findAll(".bookmarks").count() > 0)
- return KUrl("about:bookmarks");
- if (rootElement.findAll(".downloads").count() > 0)
- return KUrl("about:downloads");
- }
- return u;
+ if(page()->isOnRekonqPage())
+ return page()->loadingUrl();
+
+ return view()->url();
}