From 5024ada69625f9155cd25219361c6365ad0f8569 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Wed, 14 Oct 2015 19:37:01 +0200 Subject: [PATCH] Fix showing speed dials in bookmarks icon --- src/lib/bookmarks/bookmarksicon.cpp | 2 +- src/lib/plugins/speeddial.cpp | 11 ++++++++--- src/lib/plugins/speeddial.h | 4 ++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/lib/bookmarks/bookmarksicon.cpp b/src/lib/bookmarks/bookmarksicon.cpp index 57a10dbd2..2af875e35 100644 --- a/src/lib/bookmarks/bookmarksicon.cpp +++ b/src/lib/bookmarks/bookmarksicon.cpp @@ -59,7 +59,7 @@ void BookmarksIcon::checkBookmark(const QUrl &url, bool forceCheck) QList items = mApp->bookmarks()->searchBookmarks(url); m_bookmark = items.isEmpty() ? 0 : items.first(); - if (m_bookmark /*|| !mApp->plugins()->speedDial()->pageForUrl(url).url.isEmpty()*/) { + if (m_bookmark || mApp->plugins()->speedDial()->pageForUrl(url).isValid()) { setBookmarkSaved(); } else { diff --git a/src/lib/plugins/speeddial.cpp b/src/lib/plugins/speeddial.cpp index f1621e083..f21b2879a 100644 --- a/src/lib/plugins/speeddial.cpp +++ b/src/lib/plugins/speeddial.cpp @@ -101,7 +101,9 @@ SpeedDial::Page SpeedDial::pageForUrl(const QUrl &url) { ENSURE_LOADED; - const QString urlString = url.toString(); + QString urlString = url.toString(); + if (urlString.endsWith(QL1C('/'))) + urlString = urlString.left(urlString.size() - 1); foreach (const Page &page, m_pages) { if (page.url == urlString) { @@ -145,7 +147,7 @@ void SpeedDial::removePage(const Page &page) { ENSURE_LOADED; - if (page.url.isEmpty()) { + if (!page.isValid()) { return; } @@ -213,7 +215,7 @@ QString SpeedDial::initialScript() if (!QFile(imgSource).exists()) { imgSource = "qrc:html/loading.gif"; - if (page.url.isEmpty()) { + if (!page.isValid()) { imgSource.clear(); } } @@ -250,6 +252,9 @@ void SpeedDial::changed(const QString &allPages) page.url = tmp.at(0).mid(5); page.title = tmp.at(1).mid(7); + if (page.url.endsWith(QL1C('/'))) + page.url = page.url.left(page.url.size() - 1); + m_pages.append(page); } diff --git a/src/lib/plugins/speeddial.h b/src/lib/plugins/speeddial.h index 380f28511..494b0f9cc 100644 --- a/src/lib/plugins/speeddial.h +++ b/src/lib/plugins/speeddial.h @@ -38,6 +38,10 @@ public: QString title; QString url; + bool isValid() const { + return !url.isEmpty(); + } + bool operator==(const Page &other) { return (this->title == other.title && this->url == other.url);