diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-08-01 18:46:43 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-12-10 02:48:04 +0100 |
commit | 8c9f6a822fca90779b121670479f5171bd673aca (patch) | |
tree | b94ac2a654e4915677b1f9e9fd213a07e1f1c96d /src | |
parent | Port WebWindow to use Urlbar class. Easier testing changes... (diff) | |
download | rekonq-8c9f6a822fca90779b121670479f5171bd673aca.tar.xz |
Fix urlbar widget show
Diffstat (limited to 'src')
-rw-r--r-- | src/urlbar/urlbar.cpp | 76 | ||||
-rw-r--r-- | src/urlbar/urlbar.h | 3 | ||||
-rw-r--r-- | src/webtab/webpage.cpp | 18 | ||||
-rw-r--r-- | src/webtab/webpage.h | 1 |
4 files changed, 98 insertions, 0 deletions
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp index c6159594..7224a1b7 100644 --- a/src/urlbar/urlbar.cpp +++ b/src/urlbar/urlbar.cpp @@ -45,6 +45,9 @@ #include "completionwidget.h" #include "bookmarkwidget.h" #include "favoritewidget.h" +#include "rsswidget.h" +#include "webshortcutwidget.h" + #include "urlsuggester.h" #include "webtab.h" @@ -107,6 +110,24 @@ QString guessUrlWithCustomFirstLevel(const QString &str1, const QString &str2) return url.toString(); } + +KUrl extractOpensearchUrl(const KUrl &tabUrl, QWebElement e) +{ + QString href = e.attribute(QL1S("href")); + KUrl url = KUrl(href); + if (!href.contains(":")) + { + QString host = tabUrl.scheme() + "://" + tabUrl.host(); + if (tabUrl.port() != -1) + { + host += QL1C(':') + QString::number(tabUrl.port()); + } + url = KUrl(tabUrl, href); + } + return url; +} + + // ----------------------------------------------------------------------------------------------------------- @@ -774,3 +795,58 @@ void UrlBar::updateRightIconPosition(IconButton *icon, int iconsCount) icon->move(iconWidth, iconHeight); } + + +void UrlBar::showRSSInfo(const QPoint &pos) +{ + QWebElementCollection col = _tab->page()->mainFrame()->findAllElements("link[type=\"application/rss+xml\"]"); + col.append(_tab->page()->mainFrame()->findAllElements("link[type=\"application/atom+xml\"]")); + + QMap<KUrl, QString> map; + + Q_FOREACH(const QWebElement & el, col) + { + QString urlString; + if (el.attribute("href").startsWith(QL1S("http"))) + urlString = el.attribute("href"); + else + { + KUrl u = _tab->url(); + // NOTE + // cd() is probably better than setPath() here, + // for all those url sites just having a path + if (u.cd(el.attribute("href"))) + urlString = u.toMimeDataString(); + } + + QString title = el.attribute("title"); + if (title.isEmpty()) + title = el.attribute("href"); + + map.insert(KUrl(urlString), title); + } + + RSSWidget *widget = new RSSWidget(map, window()); + widget->showAt(pos); +} + + +void UrlBar::showSearchEngine(const QPoint &pos) +{ + QWebElement e = _tab->page()->mainFrame()->findFirstElement( + QL1S("head >link[rel=\"search\"][ type=\"application/opensearchdescription+xml\"]")); + QString title = e.attribute(QL1S("title")); + if (!title.isEmpty()) + { + WebShortcutWidget *widget = new WebShortcutWidget(window()); + widget->setWindowFlags(Qt::Popup); + +// FIXME connect(widget, SIGNAL(webShortcutSet(KUrl, QString, QString)), +// rApp->opensearchManager(), SLOT(addOpenSearchEngine(KUrl, QString, QString))); +// connect(rApp->opensearchManager(), SIGNAL(openSearchEngineAdded(QString)), +// this, SLOT(openSearchEngineAdded())); + + KUrl u = extractOpensearchUrl(_tab->url(), e); + widget->show(u, title, pos); + } +} diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h index b2cf44ac..ffa0c1bc 100644 --- a/src/urlbar/urlbar.h +++ b/src/urlbar/urlbar.h @@ -126,6 +126,9 @@ private Q_SLOTS: */ void loadDigitedUrl(); + void showRSSInfo(const QPoint &); + void showSearchEngine(const QPoint &); + protected: void paintEvent(QPaintEvent *event); void keyPressEvent(QKeyEvent *event); diff --git a/src/webtab/webpage.cpp b/src/webtab/webpage.cpp index c2b6bdde..385a6ac3 100644 --- a/src/webtab/webpage.cpp +++ b/src/webtab/webpage.cpp @@ -47,6 +47,7 @@ #include "websnap.h" #include "webtab.h" #include "sslinfodialog.h" +#include "sslwidget.h" #include "searchengine.h" #include "webwindow.h" @@ -727,3 +728,20 @@ bool WebPage::hasSslValid() const return true; } + + +void WebPage::showSSLInfo(QPoint pos) +{ + if (mainFrame()->url().scheme() == QL1S("https")) + { + SSLWidget *widget = new SSLWidget(mainFrame()->url(), _sslInfo, view()); + widget->showAt(pos); + } + else + { + KMessageBox::information(view(), + i18n("This site does not contain SSL information."), + i18nc("Secure Sockets Layer", "SSL") + ); + } +} diff --git a/src/webtab/webpage.h b/src/webtab/webpage.h index 79a8e8f4..1985e047 100644 --- a/src/webtab/webpage.h +++ b/src/webtab/webpage.h @@ -81,6 +81,7 @@ private Q_SLOTS: void manageNetworkErrors(QNetworkReply *reply); void loadStarted(); void loadFinished(bool); + void showSSLInfo(QPoint); void copyToTempFileResult(KJob*); |