diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/homepage.cpp | 3 | ||||
-rw-r--r-- | src/mainview.cpp | 1 | ||||
-rw-r--r-- | src/rekonq.kcfg | 4 | ||||
-rw-r--r-- | src/settings.cpp | 1 | ||||
-rw-r--r-- | src/webpage.cpp | 6 | ||||
-rw-r--r-- | src/webpluginfactory.cpp | 76 | ||||
-rw-r--r-- | src/webpluginfactory.h (renamed from src/websnap.h) | 43 | ||||
-rw-r--r-- | src/websnap.cpp | 91 | ||||
-rw-r--r-- | src/webview.h | 4 |
10 files changed, 102 insertions, 129 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9b24e2ec..755ae33d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,6 @@ ### ------- SETTING REKONQ FILES.. SET( rekonq_SRCS - websnap.cpp homepage.cpp networkaccessmanager.cpp autosaver.cpp @@ -24,6 +23,7 @@ SET( rekonq_SRCS lineedit.cpp webpage.cpp sessionmanager.cpp + webpluginfactory.cpp ) diff --git a/src/homepage.cpp b/src/homepage.cpp index 0cd966f4..f6867c7e 100644 --- a/src/homepage.cpp +++ b/src/homepage.cpp @@ -37,7 +37,6 @@ #include "application.h" #include "mainwindow.h" #include "mainview.h" -#include "websnap.h" // KDE Includes #include <KStandardDirs> @@ -99,7 +98,7 @@ QString HomePage::speedDial() speed += "<div class=\"thumbnail\">"; speed += "<a href=\"" + urls.at(i) + "\">"; - speed += "<object type=\"application/x-qt-plugin\"; classId=\"WebView\" name=\"" + pageName + "\" width=\"200\">"; + speed += "<object type=\"application/x-qt-plugin\" data=\"" + urls.at(i) + "\" classId=\"WebView\" name=\"" + pageName + "\" width=\"200\">"; speed += "<param name=\"load\" value=\"" + urls.at(i) + "\">"; speed += "</object>"; // speed += "<img src=\"" + path + "\" width=\"200\" alt=\"" + names.at(i) + "\" />"; diff --git a/src/mainview.cpp b/src/mainview.cpp index 038562e8..accc1610 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -42,7 +42,6 @@ #include "webview.h" #include "sessionmanager.h" #include "homepage.h" -#include "websnap.h" // KDE Includes #include <KUrl> diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index 6b57a9fa..417b7fbc 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -12,10 +12,10 @@ <!-- New Tab Page Settings --> <group name="NewTabPage"> <entry name="previewNames" type="StringList"> - <default>KDE site,Google,rekonq,SourceForge,kde-apps,kernel, wikipedia,wordpress,adjam site</default> + <default>KDE site,Google,rekonq</default> </entry> <entry name="previewUrls" type="StringList"> - <default>http://www.kde.org,http://www.google.com,http://rekonq.sourceforge.net,http://sourceforge.net,http://kde-apps.org,http://www.kernel.org,http://wikipedia.org,http://wordpress.com,http://www.adjam.org</default> + <default>http://www.kde.org,http://www.google.com,http://rekonq.sourceforge.net</default> </entry> <entry name="useRecentlyClosedTabs" type="Bool"> <default>false</default> diff --git a/src/settings.cpp b/src/settings.cpp index 9767b676..504e2460 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -38,7 +38,6 @@ #include "mainwindow.h" #include "networkaccessmanager.h" #include "webview.h" -#include "websnap.h" //Ui Includes #include "ui_settings_general.h" diff --git a/src/webpage.cpp b/src/webpage.cpp index ea902932..697cf448 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -42,6 +42,7 @@ #include "cookiejar.h" #include "networkaccessmanager.h" #include "webview.h" +#include "webpluginfactory.h" // KDE Includes #include <KStandardDirs> @@ -73,9 +74,8 @@ WebPage::WebPage(QObject *parent) , m_pressedButtons(Qt::NoButton) , m_requestedUrl() { - // Enable plugin support - settings()->setAttribute(QWebSettings::PluginsEnabled, true); - + setPluginFactory(new WebPluginFactory(this)); + setForwardUnsupportedContent(true); setNetworkAccessManager(Application::networkAccessManager()); diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp new file mode 100644 index 00000000..1ff1b783 --- /dev/null +++ b/src/webpluginfactory.cpp @@ -0,0 +1,76 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009 by Andrea Diamantini <adjam7 at gmail dot 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 the Free Software Foundation; either version 2 of +* the License or (at your option) version 3 or any later version +* accepted by the membership of KDE e.V. (or its successor approved +* by the membership of KDE e.V.), which shall act as a proxy +* defined in Section 14 of version 3 of the license. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +* +* ============================================================ */ + + +// Self Includes +#include "webpluginfactory.h" +#include "webpluginfactory.moc" + +#include "webview.h" +#include "webpage.h" + +#include <QWebFrame> + +#include "application.h" +#include "mainwindow.h" + +WebPluginFactory::WebPluginFactory(QObject *parent) + : QWebPluginFactory(parent) +{ +} + + +WebPluginFactory::~WebPluginFactory() +{ +} + + +QObject *WebPluginFactory::create(const QString &mimeType, + const QUrl &url, + const QStringList &argumentNames, + const QStringList &argumentValues) const +{ + Q_UNUSED(mimeType) + Q_UNUSED(argumentNames) + Q_UNUSED(argumentValues) + + WebView* w = new WebView( Application::instance()->mainWindow()->currentTab() ); + w->load(url); +// w->page()->setViewportSize(w->page()->mainFrame()->contentsSize()); + return w; +} + + +QList<QWebPluginFactory::Plugin> WebPluginFactory::plugins() const +{ + QList<QWebPluginFactory::Plugin> plugins; + + QWebPluginFactory::Plugin p; + p.name = "WebView"; + p.description = "plugin for embedding WebViews"; + plugins.append(p); + + return plugins; +} diff --git a/src/websnap.h b/src/webpluginfactory.h index 8993fd08..c63b0ce3 100644 --- a/src/websnap.h +++ b/src/webpluginfactory.h @@ -2,7 +2,6 @@ * * This file is a part of the rekonq project * -* Copyright (C) 2009 Nokia Corporation <qt-info@nokia.com> * Copyright (C) 2009 by Andrea Diamantini <adjam7 at gmail dot com> * * @@ -24,42 +23,30 @@ * * ============================================================ */ -#ifndef WEB_SNAP_H -#define WEB_SNAP_H +#ifndef WEB_PLUGIN_FACTORY_H +#define WEB_PLUGIN_FACTORY_H -#include <KUrl> -#include <QtCore/QObject> -#include <QImage> -#include <QWebPage> +#include <QtWebKit/QWebPluginFactory> +#include <QtCore/QList> +#include <QtGui/QWidget> -/** - * This class renders a site producing an image based - * on that. - * Heavily based on Graphics-Dojo WebSnap example (thanks!) - */ -class WebSnap : public QObject +class WebPluginFactory : public QWebPluginFactory { - Q_OBJECT +Q_OBJECT public: - WebSnap(const KUrl &url, const QString &fileName); - -signals: - void finished(); + WebPluginFactory(QObject *parent); + ~WebPluginFactory(); -private slots: - void load(); - void saveResult(bool ok); + virtual QObject *create(const QString &mimeType, + const QUrl &url, + const QStringList &argumentNames, + const QStringList &argumentValues) const; -private: - QWebPage m_page; - KUrl m_url; - QImage m_image; - QString m_fileName; - QSize m_targetSize; + virtual QList<Plugin> plugins() const; }; -#endif // WEB_SNAP_H +#endif // WEB_PLUGIN_FACTORY_H diff --git a/src/websnap.cpp b/src/websnap.cpp deleted file mode 100644 index 1f564223..00000000 --- a/src/websnap.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2009 Nokia Corporation <qt-info@nokia.com> -* Copyright (C) 2009 by Andrea Diamantini <adjam7 at gmail dot 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 the Free Software Foundation; either version 2 of -* the License or (at your option) version 3 or any later version -* accepted by the membership of KDE e.V. (or its successor approved -* by the membership of KDE e.V.), which shall act as a proxy -* defined in Section 14 of version 3 of the license. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. -* -* ============================================================ */ - - -#include "websnap.h" -#include "websnap.moc" - -#include <KDebug> -#include <KStandardDirs> - -#include <QSize> -#include <QWebFrame> -#include <QWebSettings> -#include <QPainter> -#include <QTimer> - - -WebSnap::WebSnap(const KUrl &url, const QString &fileName) - : QObject() - , m_url(url) - , m_image(QImage()) - , m_fileName(fileName) -{ - // this to not register websnap history - m_page.settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); - - m_targetSize = QSize(200, 150); - connect(&m_page, SIGNAL(loadFinished(bool)), this, SLOT(saveResult(bool))); - QTimer::singleShot(0, this, SLOT(load())); -} - - -void WebSnap::load() -{ - m_page.mainFrame()->load(m_url); -} - - -void WebSnap::saveResult(bool ok) -{ - // crude error-checking - if (!ok) - { - kDebug() << "Error loading site.."; - return; - } - - // find proper size, we stick to sensible aspect ratio - QSize size = m_page.mainFrame()->contentsSize(); - size.setHeight(size.width() * m_targetSize.height() / m_targetSize.width()); - - // create the target surface - m_image = QImage( size , QImage::Format_ARGB32_Premultiplied); - m_image.fill(Qt::transparent); - - // render and rescale - QPainter p(&m_image); - m_page.setViewportSize(m_page.mainFrame()->contentsSize()); - m_page.mainFrame()->render(&p); - p.end(); - m_image = m_image.scaled(m_targetSize, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); - - QString path = KStandardDirs::locateLocal("cache", QString("thumbs/") + m_fileName, true); - if( m_image.save(path) ) - { - emit finished(); - } -} diff --git a/src/webview.h b/src/webview.h index f1e5272c..16b199ff 100644 --- a/src/webview.h +++ b/src/webview.h @@ -45,6 +45,9 @@ class WebView : public QWebView public: explicit WebView(QWidget *parent = 0); + + // Q_DECLARE_METATYPE requires a copy-constructor + WebView(const WebView &); WebPage *page(); KUrl url() const; @@ -82,5 +85,6 @@ private: int m_progress; QString m_statusBarText; }; +Q_DECLARE_METATYPE(WebView) #endif |