From 5424f5b7a49d29a5d2aba0c9dc6165779442796c Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 10 Nov 2011 01:03:40 +0100 Subject: Web app's icon on kwebapp window Heavily based on Furkan's patch on rbo REVIEW: 103087 --- kwebapp/kwebmain.cpp | 3 +-- kwebapp/webview.cpp | 22 ++++++++++++++-------- kwebapp/webview.h | 5 ++++- 3 files changed, 19 insertions(+), 11 deletions(-) (limited to 'kwebapp') diff --git a/kwebapp/kwebmain.cpp b/kwebapp/kwebmain.cpp index 3de5b182..639d1533 100644 --- a/kwebapp/kwebmain.cpp +++ b/kwebapp/kwebmain.cpp @@ -55,9 +55,8 @@ int main(int argc, char **argv) return 0; } - WebView *widg = new WebView; + WebView *widg = new WebView(QUrl::fromUserInput(args->arg(0))); widg->show(); - widg->load(QUrl::fromUserInput(args->arg(0))); args->clear(); return app.exec(); diff --git a/kwebapp/webview.cpp b/kwebapp/webview.cpp index 7a5ba4c1..dbda6d59 100644 --- a/kwebapp/webview.cpp +++ b/kwebapp/webview.cpp @@ -46,21 +46,27 @@ #include -WebView::WebView(QWidget *parent) +WebView::WebView(const QUrl &url, QWidget *parent) : KWebView(parent) { page()->setForwardUnsupportedContent(true); connect(page(), SIGNAL(unsupportedContent(QNetworkReply *)), page(), SLOT(downloadResponse(QNetworkReply *))); connect(page(), SIGNAL(downloadRequested(const QNetworkRequest &)), page(), SLOT(downloadRequest(const QNetworkRequest &))); connect(this, SIGNAL(linkShiftClicked(const KUrl &)), page(), SLOT(downloadUrl(const KUrl &))); - - QWebSettings::setIconDatabasePath( KStandardDirs::locateLocal("cache","kwebapp.favicons") ); - + + QWebSettings::setIconDatabasePath(KStandardDirs::locateLocal("cache", "kwebapp.favicons")); + setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(titleChanged(const QString &)), this, SLOT(setTitle(const QString &))); connect(this, SIGNAL(iconChanged()), this, SLOT(setIcon())); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(menuRequested(const QPoint &))); + + const QString iconPath = KStandardDirs::locateLocal("cache" , "favicons/" , true) + url.host() + "_WEBAPPICON.png"; + setWindowIcon(QIcon(iconPath)); + + // last... + load(url); } @@ -72,7 +78,7 @@ void WebView::setTitle(const QString &t) void WebView::setIcon() { - setWindowIcon(icon()); + setWindowIcon(icon()); } @@ -95,13 +101,13 @@ void WebView::menuRequested(const QPoint &pos) menu.addAction(pageAction(KWebPage::CopyLinkToClipboard)); menu.addSeparator(); } - - if(history()->canGoBack()) + + if (history()->canGoBack()) { menu.addAction(pageAction(KWebPage::Back)); } - if(history()->canGoBack()) + if (history()->canGoBack()) { menu.addAction(pageAction(KWebPage::Forward)); } diff --git a/kwebapp/webview.h b/kwebapp/webview.h index 536dba8c..a53010ed 100644 --- a/kwebapp/webview.h +++ b/kwebapp/webview.h @@ -27,13 +27,16 @@ // KDE Includes #include +// Qt Includes +#include + class WebView : public KWebView { Q_OBJECT public: - WebView(QWidget *parent = 0); + WebView(const QUrl &url, QWidget *parent = 0); private Q_SLOTS: void setTitle(const QString &); -- cgit v1.2.1