From 04a0850cb6f7750859a10ea3fe3c7a48e94728dc Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 11 Nov 2009 02:14:26 +0100 Subject: Moving to kdewebkit. First step --- src/CMakeLists.txt | 4 +- src/application.cpp | 21 --------- src/application.h | 5 -- src/cookiejar.cpp | 110 ------------------------------------------- src/cookiejar.h | 56 ---------------------- src/mainwindow.cpp | 10 ++-- src/networkaccessmanager.cpp | 64 ------------------------- src/networkaccessmanager.h | 47 ------------------ src/settings.cpp | 1 - src/webpage.cpp | 38 ++------------- src/webpage.h | 14 +++--- src/webpluginfactory.cpp | 6 +-- src/webpluginfactory.h | 6 ++- src/webview.cpp | 16 +------ src/webview.h | 7 ++- 15 files changed, 28 insertions(+), 377 deletions(-) delete mode 100644 src/cookiejar.cpp delete mode 100644 src/cookiejar.h delete mode 100644 src/networkaccessmanager.cpp delete mode 100644 src/networkaccessmanager.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9c0ace58..3fa889c5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,13 +9,11 @@ SET( rekonq_KDEINIT_SRCS newtabpage.cpp previewimage.cpp websnap.cpp - networkaccessmanager.cpp autosaver.cpp application.cpp mainwindow.cpp mainview.cpp tabbar.cpp - cookiejar.cpp history.cpp historymodels.cpp bookmarks.cpp @@ -66,8 +64,8 @@ KDE4_ADD_KDEINIT_EXECUTABLE( rekonq ${rekonq_KDEINIT_SRCS} main.cpp ) TARGET_LINK_LIBRARIES ( kdeinit_rekonq ${QT_LIBRARIES} - ${QT_QTNETWORK_LIBRARY} ${QT_QTWEBKIT_LIBRARY} + ${KDE4_KDEWEBKIT_LIBS} ${KDE4_KUTILS_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} diff --git a/src/application.cpp b/src/application.cpp index 0dfc478f..9616688f 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -35,9 +35,7 @@ // Local Includes #include "mainwindow.h" -#include "cookiejar.h" #include "history.h" -#include "networkaccessmanager.h" #include "mainview.h" #include "webview.h" #include "urlbar.h" @@ -61,7 +59,6 @@ QPointer Application::s_historyManager; -QPointer Application::s_networkAccessManager; QPointer Application::s_bookmarkProvider; QPointer Application::s_sessionManager; @@ -77,7 +74,6 @@ Application::~Application() { qDeleteAll(m_mainWindows); delete s_bookmarkProvider; - delete s_networkAccessManager; delete s_historyManager; } @@ -209,23 +205,6 @@ MainWindow *Application::mainWindow() } -CookieJar *Application::cookieJar() -{ - return (CookieJar *)networkAccessManager()->cookieJar(); -} - - -NetworkAccessManager *Application::networkAccessManager() -{ - if (!s_networkAccessManager) - { - s_networkAccessManager = new NetworkAccessManager(); - s_networkAccessManager->setCookieJar(new CookieJar); - } - return s_networkAccessManager; -} - - HistoryManager *Application::historyManager() { if (!s_historyManager) diff --git a/src/application.h b/src/application.h index 0f256a45..786e5173 100644 --- a/src/application.h +++ b/src/application.h @@ -45,10 +45,8 @@ class KIcon; class KUrl; class BookmarkProvider; -class CookieJar; class HistoryManager; class MainWindow; -class NetworkAccessManager; class SessionManager; @@ -105,8 +103,6 @@ public: static KIcon icon(const KUrl &url); static HistoryManager *historyManager(); - static CookieJar *cookieJar(); - static NetworkAccessManager *networkAccessManager(); static BookmarkProvider *bookmarkProvider(); static SessionManager *sessionManager(); @@ -141,7 +137,6 @@ private: KUrl guessUrlFromString(const QString &url); static QPointer s_historyManager; - static QPointer s_networkAccessManager; static QPointer s_bookmarkProvider; static QPointer s_sessionManager; diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp deleted file mode 100644 index 05ffb987..00000000 --- a/src/cookiejar.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2009 by Andrea Diamantini -* Copyright (C) 2009 by Lionel Chauvin -* -* -* 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 . -* -* ============================================================ */ - - -// Self Includes -#include "cookiejar.h" -#include "cookiejar.moc" - -// Auto Includes -#include "rekonq.h" - -// Local Includes -#include "application.h" -#include "mainwindow.h" - -// KDE Includes -#include -#include -#include - -// Qt Includes -#include -#include -#include - -#include -#include - - -CookieJar::CookieJar(QObject* parent) - : QNetworkCookieJar(parent) - , m_windowId(-1) -{ -} - - -CookieJar::~CookieJar() -{ -} - - -QList CookieJar::cookiesForUrl(const QUrl & url) const -{ - - QDBusInterface kcookiejar("org.kde.kded", "/modules/kcookiejar", "org.kde.KCookieServer"); - QList cookieList; - QDBusReply reply = kcookiejar.call("findDOMCookies", url.toString() ); - - if (reply.isValid()) - { - cookieList << reply.value().toUtf8(); - } - else - { - kWarning() << "Unable to communicate with the cookiejar!"; - } - - return cookieList; -} - - -bool CookieJar::setCookiesFromUrl(const QList & cookieList, const QUrl & url) -{ - QDBusInterface kcookiejar("org.kde.kded", "/modules/kcookiejar", "org.kde.KCookieServer"); - QByteArray cookieHeader; - Q_FOREACH(const QNetworkCookie& cookie, cookieList) - { - cookieHeader = "Set-Cookie: "; - cookieHeader += cookie.toRawForm(); - kcookiejar.call("addCookies", url.toString(), cookieHeader, m_windowId ); - } - - return !kcookiejar.lastError().isValid(); -} - - -void CookieJar::clear() -{ - QDBusInterface kcookiejar("org.kde.kded", "/modules/kcookiejar", "org.kde.KCookieServer"); - - QDBusReply reply = kcookiejar.call( "deleteAllCookies" ); - if (!reply.isValid()) - { - kWarning() << "Unable to delete all the cookies as requested."; - } - return; -} diff --git a/src/cookiejar.h b/src/cookiejar.h deleted file mode 100644 index 9ae24409..00000000 --- a/src/cookiejar.h +++ /dev/null @@ -1,56 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2009 by Andrea Diamantini -* Copyright (C) 2009 by Lionel Chauvin -* -* -* 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 . -* -* ============================================================ */ - - -#ifndef RECOOKIEJAR_H -#define RECOOKIEJAR_H - - -// Qt Includes -#include - -// Forward Declarations -class QUrl; - - -class CookieJar : public QNetworkCookieJar -{ - Q_OBJECT - -public: - CookieJar(QObject* parent = 0); - virtual ~CookieJar(); - - virtual QList cookiesForUrl(const QUrl & url) const; - virtual bool setCookiesFromUrl(const QList & cookieList, const QUrl & url); - - void clear(); - -private: - qlonglong m_windowId; -}; - -#endif // RECOOKIEJAR_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7a9e3ad6..43031446 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -37,8 +37,6 @@ #include "application.h" #include "settings.h" #include "history.h" -#include "cookiejar.h" -#include "networkaccessmanager.h" #include "bookmarks.h" #include "webview.h" #include "mainview.h" @@ -89,6 +87,9 @@ #include #include +#include +#include + #include @@ -1033,12 +1034,13 @@ void MainWindow::clearPrivateData() if(clearWidget.clearCookies->isChecked()) { - Application::cookieJar()->clear(); + QDBusInterface kcookiejar("org.kde.kded", "/modules/kcookiejar", "org.kde.KCookieServer"); + QDBusReply reply = kcookiejar.call( "deleteAllCookies" ); } if(clearWidget.clearCachedPages->isChecked()) { - Application::networkAccessManager()->resetDiskCache(); + // TODO implement me! } if(clearWidget.clearWebIcons->isChecked()) diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp deleted file mode 100644 index 38f4c8c4..00000000 --- a/src/networkaccessmanager.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2007-2008 Trolltech ASA. All rights reserved -* Copyright (C) 2008-2009 by Andrea Diamantini * -* -* 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 . -* -* ============================================================ */ - - -// Self Includes -#include "networkaccessmanager.h" -#include "networkaccessmanager.moc" - -// Local Includes -#include "application.h" -#include "mainwindow.h" - -// Auto Includes -#include "rekonq.h" - -// KDE Includes -#include - -// Qt Includes -#include - - -NetworkAccessManager::NetworkAccessManager(QObject *parent) - : AccessManager(parent) -{ - // resetting disk cache - resetDiskCache(); -} - - -void NetworkAccessManager::resetDiskCache() -{ - if(!cache()) - { - QNetworkDiskCache *diskCache = new QNetworkDiskCache(this); - setCache(diskCache); - } - else - { - cache()->clear(); - } -} diff --git a/src/networkaccessmanager.h b/src/networkaccessmanager.h deleted file mode 100644 index 6cade7fe..00000000 --- a/src/networkaccessmanager.h +++ /dev/null @@ -1,47 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2007-2008 Trolltech ASA. All rights reserved -* Copyright (C) 2008-2009 by Andrea Diamantini * -* -* 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 . -* -* ============================================================ */ - - -#ifndef NETWORKACCESSMANAGER_H -#define NETWORKACCESSMANAGER_H - - -// KDE Includes -#include - - -using namespace KIO; - - -class NetworkAccessManager : public AccessManager -{ - Q_OBJECT - -public: - NetworkAccessManager(QObject *parent = 0); - void resetDiskCache(); -}; - -#endif // NETWORKACCESSMANAGER_H diff --git a/src/settings.cpp b/src/settings.cpp index 5696995c..110aaa08 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -36,7 +36,6 @@ // Local Includes #include "application.h" #include "mainwindow.h" -#include "networkaccessmanager.h" #include "webview.h" //Ui Includes diff --git a/src/webpage.cpp b/src/webpage.cpp index 56865eb7..e75e898c 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -39,8 +39,6 @@ #include "application.h" #include "mainwindow.h" #include "mainview.h" -#include "cookiejar.h" -#include "networkaccessmanager.h" #include "webview.h" #include "webpluginfactory.h" @@ -66,8 +64,8 @@ #include -WebPage::WebPage(QObject *parent) - : QWebPage(parent) +WebPage::WebPage(QObject *parent, qlonglong windowId) + : KWebPage(parent, windowId) , m_keyboardModifiers(Qt::NoModifier) , m_pressedButtons(Qt::NoButton) { @@ -75,8 +73,7 @@ WebPage::WebPage(QObject *parent) setForwardUnsupportedContent(true); - setNetworkAccessManager(Application::networkAccessManager()); - connect(networkAccessManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*))); + connect(this, SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*))); connect(this, SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(downloadRequested(const QNetworkRequest &))); connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *))); @@ -122,7 +119,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r m_requestedUrl = request.url(); - return QWebPage::acceptNavigationRequest(frame, request, type); + return KWebPage::acceptNavigationRequest(frame, request, type); } @@ -258,30 +255,3 @@ QString WebPage::errorPage(QNetworkReply *reply) ; return html; } - - -// TODO FIXME: sometimes url.fileName() fails to retrieve url file name -void WebPage::downloadRequested(const QNetworkRequest &request) -{ - const KUrl url(request.url()); - - const QString destUrl = KFileDialog::getSaveFileName(url.fileName(), QString(), view()); - if (destUrl.isEmpty()) return; - KIO::Job *job = KIO::file_copy(url, KUrl(destUrl), -1, KIO::Overwrite); - //job->setMetaData(metadata); //TODO: add metadata from request - job->addMetaData( QLatin1String("MaxCacheSize"), QLatin1String("0") ); // Don't store in http cache. - job->addMetaData( QLatin1String("cache"), QLatin1String("cache") ); // Use entry from cache if available. - job->uiDelegate()->setAutoErrorHandlingEnabled(true); -} - - -QString WebPage::userAgentForUrl(const QUrl& _url) const -{ - const KUrl url(_url); - QString userAgent = KProtocolManager::userAgentForHost((url.isLocalFile() ? "localhost" : url.host())); - - if (userAgent == KProtocolManager::defaultUserAgent()) - return QWebPage::userAgentForUrl(_url); - - return userAgent; -} diff --git a/src/webpage.h b/src/webpage.h index 45fc0c51..725788ee 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -32,22 +32,23 @@ #define WEBPAGE_H +// KDE Includes +#include + // Qt Includes -#include #include // Forward Declarations class QWebFrame; class QNetworkReply; -class QUrl; -class WebPage : public QWebPage +class WebPage : public KWebPage { Q_OBJECT public: - explicit WebPage(QObject *parent = 0); + explicit WebPage(QObject *parent = 0, qlonglong windowId = 0); ~WebPage(); public slots: @@ -59,13 +60,10 @@ protected: virtual bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, - NavigationType type); - - virtual QString userAgentForUrl(const QUrl& url) const; + NavigationType type);// protected Q_SLOTS: virtual void handleUnsupportedContent(QNetworkReply *reply); - virtual void downloadRequested(const QNetworkRequest &request); private: friend class WebView; diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp index 3daffbb6..bc79c60b 100644 --- a/src/webpluginfactory.cpp +++ b/src/webpluginfactory.cpp @@ -38,7 +38,7 @@ WebPluginFactory::WebPluginFactory(QObject *parent) - : QWebPluginFactory(parent) + : KWebPluginFactory(parent) { } @@ -78,13 +78,13 @@ QObject *WebPluginFactory::create(const QString &mimeType, // this let QtWebKit using builtin plugins // to load in example flash contents and so on.. kDebug() << "No plugins found for" << mimeType << ". Falling back to QtWebKit ones..."; - return 0; + return KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); } QList WebPluginFactory::plugins() const { - QList plugins; + QList plugins = KWebPluginFactory::plugins(); QWebPluginFactory::Plugin p; p.name = "application/image-preview"; diff --git a/src/webpluginfactory.h b/src/webpluginfactory.h index 738605db..30a366d4 100644 --- a/src/webpluginfactory.h +++ b/src/webpluginfactory.h @@ -28,13 +28,15 @@ #define WEB_PLUGIN_FACTORY_H +// KDE Includes +#include + // Qt Includes -#include #include #include -class WebPluginFactory : public QWebPluginFactory +class WebPluginFactory : public KWebPluginFactory { Q_OBJECT diff --git a/src/webview.cpp b/src/webview.cpp index 1dd5ad6a..4d3df502 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -53,7 +53,7 @@ WebView::WebView(QWidget* parent) - : QWebView(parent) + : KWebView(parent, false) , m_page(new WebPage(this)) , m_progress(0) , m_mousePos(QPoint(0,0)) @@ -378,20 +378,6 @@ QPoint WebView::mousePos() } -void WebView::wheelEvent(QWheelEvent *event) -{ - if (QApplication::keyboardModifiers() & Qt::ControlModifier) - { - int numDegrees = event->delta() / 8; - int numSteps = numDegrees / 15; - setTextSizeMultiplier(textSizeMultiplier() + numSteps * 0.1); - event->accept(); - return; - } - QWebView::wheelEvent(event); -} - - void WebView::search() { KAction *a = qobject_cast(sender()); diff --git a/src/webview.h b/src/webview.h index e860b8c8..a753736c 100644 --- a/src/webview.h +++ b/src/webview.h @@ -33,13 +33,13 @@ #include // Qt Includes -#include +#include // Forward Declarations class WebPage; -class WebView : public QWebView +class WebView : public KWebView { Q_OBJECT @@ -55,9 +55,8 @@ public: protected: void contextMenuEvent(QContextMenuEvent *event); - void mousePressEvent(QMouseEvent *event); + void mousePressEvent(QMouseEvent *event);// need to be ported void mouseMoveEvent(QMouseEvent *event); - void wheelEvent(QWheelEvent *event); void keyPressEvent(QKeyEvent *event); private slots: -- cgit v1.2.1 From 1c093e9d52f14f0510829b9f8b866178c06f9da8 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 11 Nov 2009 02:19:38 +0100 Subject: comments -- --- src/webpluginfactory.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp index bc79c60b..af799905 100644 --- a/src/webpluginfactory.cpp +++ b/src/webpluginfactory.cpp @@ -75,9 +75,6 @@ QObject *WebPluginFactory::create(const QString &mimeType, return new PreviewImage(url, title, number, isFavorite); } - // this let QtWebKit using builtin plugins - // to load in example flash contents and so on.. - kDebug() << "No plugins found for" << mimeType << ". Falling back to QtWebKit ones..."; return KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues); } -- cgit v1.2.1 From 150be558c9512674d9172782549a2d211b7c8b42 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 11 Nov 2009 02:27:40 +0100 Subject: KIO cache settings --- src/settings.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/settings.cpp b/src/settings.cpp index 110aaa08..9c95bb9c 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -69,6 +69,7 @@ private: KCModuleProxy *proxyModule; KCModuleProxy *ebrowsingModule; KCModuleProxy *cookiesModule; + KCModuleProxy *cacheModule; KShortcutsEditor *shortcutsEditor; Private(SettingsDialog *parent); @@ -109,7 +110,12 @@ Private::Private(SettingsDialog *parent) proxyModule = new KCModuleProxy(proxyInfo,parent); pageItem = parent->addPage(proxyModule, i18n(proxyInfo.moduleName().toLocal8Bit())); pageItem->setIcon(KIcon(proxyInfo.icon())); - + + KCModuleInfo cacheInfo("cache.desktop"); + cacheModule = new KCModuleProxy(cacheInfo,parent); + pageItem = parent->addPage(cacheModule, i18n(cacheInfo.moduleName().toLocal8Bit())); + pageItem->setIcon(KIcon(cacheInfo.icon())); + widget = new QWidget; webkitUi.setupUi(widget); widget->layout()->setMargin(0); @@ -152,6 +158,8 @@ SettingsDialog::SettingsDialog(QWidget *parent) connect(d->ebrowsingModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); connect(d->cookiesModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); connect(d->proxyModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); + connect(d->cacheModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); + connect(d->shortcutsEditor, SIGNAL(keyChange()), this, SLOT(updateButtons())); connect(this, SIGNAL(applyClicked()), this, SLOT(saveSettings())); @@ -199,6 +207,7 @@ void SettingsDialog::saveSettings() d->ebrowsingModule->save(); d->cookiesModule->save(); d->proxyModule->save(); + d->cacheModule->save(); d->shortcutsEditor->save(); } @@ -209,6 +218,7 @@ bool SettingsDialog::hasChanged() || d->ebrowsingModule->changed() || d->cookiesModule->changed() || d->proxyModule->changed() + || d->cacheModule->changed() || d->shortcutsEditor->isModified(); ; } -- cgit v1.2.1 From e0ee3c0b910ef9222668600ba3f5ffc8265aadbf Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 11 Nov 2009 02:52:20 +0100 Subject: Moving to KWebPage (page) actions --- src/webview.cpp | 72 +++++++++++++++------------------------------------------ 1 file changed, 19 insertions(+), 53 deletions(-) (limited to 'src') diff --git a/src/webview.cpp b/src/webview.cpp index 4d3df502..700c526e 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -129,14 +129,8 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewWindow())); menu.addAction(a); - a = pageAction(QWebPage::DownloadLinkToDisk); - a->setIcon(KIcon("document-save")); - menu.addAction(a); - - a = pageAction(QWebPage::CopyLinkToClipboard); - a->setIcon(KIcon("edit-copy")); - menu.addAction(a); - + menu.addAction(pageAction(KWebPage::DownloadLinkToDisk)); + menu.addAction(pageAction(KWebPage::CopyLinkToClipboard)); menu.addSeparator(); } @@ -144,33 +138,24 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) if (result.isContentEditable() && result.isContentSelected()) { // actions for text selected in field - a = pageAction(QWebPage::Cut); - a->setIcon(KIcon("edit-cut")); - a->setShortcut(KStandardShortcut::cut().primary()); - menu.addAction(a); + menu.addAction(pageAction(KWebPage::Cut)); } // is content selected) Add COPY if(result.isContentSelected()) { - a = pageAction(QWebPage::Copy); - a->setIcon(KIcon("edit-copy")); - a->setShortcut(KStandardShortcut::copy().primary()); - a->setText(i18n("Copy")); + a = pageAction(KWebPage::Copy); if(!result.linkUrl().isEmpty()) - a->setText(i18n("Copy Text")); //for link + a->setText(i18n("Copy Text")); //for link else - a->setText(i18n("Copy")); + a->setText(i18n("Copy")); menu.addAction(a); } // is content editable? Add PASTE if(result.isContentEditable()) { - a = pageAction(QWebPage::Paste); - a->setIcon(KIcon("edit-paste")); - a->setShortcut(KStandardShortcut::paste().primary()); - menu.addAction(a); + menu.addAction(pageAction(KWebPage::Paste)); } // is content selected? Add SEARCH actions @@ -225,14 +210,8 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) connect(a, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(viewImage(Qt::MouseButtons, Qt::KeyboardModifiers))); menu.addAction(a); - a = pageAction(QWebPage::DownloadImageToDisk); - a->setIcon(KIcon("document-save")); - menu.addAction(a); - - a = pageAction(QWebPage::CopyImageToClipboard); - a->setIcon(KIcon("edit-copy")); - menu.addAction(a); - + menu.addAction(pageAction(KWebPage::DownloadImageToDisk)); + menu.addAction(pageAction(KWebPage::CopyImageToClipboard)); menu.addSeparator(); } @@ -278,16 +257,12 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) QWebHistory *history = page()->history(); if(history->canGoBack()) { - a = pageAction(QWebPage::Back); - a->setIcon(KIcon("go-previous")); - menu.addAction(a); + menu.addAction(pageAction(KWebPage::Back)); } if(history->canGoForward()) { - a = pageAction(QWebPage::Forward); - a->setIcon(KIcon("go-next")); - menu.addAction(a); + menu.addAction(pageAction(KWebPage::Forward)); } menu.addAction(mainwindow->actionByName("view_redisplay")); @@ -302,10 +277,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) //Frame KActionMenu *frameMenu = new KActionMenu(i18n("Current Frame"), this); - a = pageAction(QWebPage::OpenFrameInNewWindow); - a->setText(i18n("Open Frame in New Tab")); - a->setIcon(KIcon("view-right-new")); - frameMenu->addAction(a); + frameMenu->addAction(pageAction(KWebPage::OpenFrameInNewWindow)); a = new KAction( KIcon("document-print-frame"), i18n("Print Frame"), this); connect(a, SIGNAL(triggered()), this, SLOT(printFrame())); @@ -315,12 +287,8 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) menu.addSeparator(); - //Page - a = pageAction(QWebPage::SelectAll); - a->setIcon(KIcon("edit-select-all")); - a->setShortcut(KStandardShortcut::selectAll().primary()); - a->setText(i18n("Select All")); - menu.addAction(a); + // Page Actions + menu.addAction(pageAction(KWebPage::SelectAll)); menu.addAction(mainwindow->actionByName(KStandardAction::name(KStandardAction::SaveAs))); menu.addAction(mainwindow->actionByName("page_source")); @@ -331,9 +299,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled)) { // Developer Extras actions - a = pageAction(QWebPage::InspectElement); - a->setIcon(KIcon("view-process-all")); - menu.addAction(a); + menu.addAction(pageAction(KWebPage::InspectElement)); } if(mainwindow->isFullScreen()) @@ -354,10 +320,10 @@ void WebView::mousePressEvent(QMouseEvent *event) switch(event->button()) { case Qt::XButton1: - triggerPageAction(QWebPage::Back); + triggerPageAction(KWebPage::Back); break; case Qt::XButton2: - triggerPageAction(QWebPage::Forward); + triggerPageAction(KWebPage::Forward); break; default: QWebView::mousePressEvent(event); @@ -441,13 +407,13 @@ void WebView::keyPressEvent(QKeyEvent *event) { if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_C)) { - triggerPageAction(QWebPage::Copy); + triggerPageAction(KWebPage::Copy); return; } if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_A)) { - triggerPageAction(QWebPage::SelectAll); + triggerPageAction(KWebPage::SelectAll); return; } -- cgit v1.2.1 From 7c747bbf76444533cea6035f572c934689c1528b Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 11 Nov 2009 15:01:47 +0100 Subject: Moved data dir to src --- src/CMakeLists.txt | 3 +- src/data/CMakeLists.txt | 19 +++++ src/data/bg.png | Bin 0 -> 15218 bytes src/data/bg2.png | Bin 0 -> 1898 bytes src/data/bot.gif | Bin 0 -> 644 bytes src/data/busywidget.gif | Bin 0 -> 11611 bytes src/data/button.png | Bin 0 -> 740 bytes src/data/category.png | Bin 0 -> 334 bytes src/data/closed.png | Bin 0 -> 118 bytes src/data/defaultbookmarks.xbel | 22 ++++++ src/data/home.html | 157 +++++++++++++++++++++++++++++++++++++++++ src/data/loading.mng | Bin 0 -> 3332 bytes src/data/notfound.html | 65 +++++++++++++++++ src/data/open.png | Bin 0 -> 120 bytes src/data/rekonq.desktop | 24 +++++++ src/data/tile.gif | Bin 0 -> 304 bytes src/data/top.png | Bin 0 -> 786 bytes src/data/webkit-icon.png | Bin 0 -> 25694 bytes 18 files changed, 289 insertions(+), 1 deletion(-) create mode 100644 src/data/CMakeLists.txt create mode 100644 src/data/bg.png create mode 100644 src/data/bg2.png create mode 100644 src/data/bot.gif create mode 100644 src/data/busywidget.gif create mode 100644 src/data/button.png create mode 100644 src/data/category.png create mode 100644 src/data/closed.png create mode 100644 src/data/defaultbookmarks.xbel create mode 100644 src/data/home.html create mode 100644 src/data/loading.mng create mode 100644 src/data/notfound.html create mode 100644 src/data/open.png create mode 100644 src/data/rekonq.desktop create mode 100644 src/data/tile.gif create mode 100644 src/data/top.png create mode 100644 src/data/webkit-icon.png (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3fa889c5..2e6c5d66 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,6 @@ -### ------- tests sub dir ------- +### ------- sub dirs ------- +ADD_SUBDIRECTORY( data ) ADD_SUBDIRECTORY( tests ) diff --git a/src/data/CMakeLists.txt b/src/data/CMakeLists.txt new file mode 100644 index 00000000..bf01a44d --- /dev/null +++ b/src/data/CMakeLists.txt @@ -0,0 +1,19 @@ +INSTALL( + FILES bg2.png bg.png bot.gif busywidget.gif closed.png loading.mng open.png tile.gif top.png webkit-icon.png category.png button.png + DESTINATION ${DATA_INSTALL_DIR}/rekonq/pics +) + +INSTALL( + FILES defaultbookmarks.xbel + DESTINATION ${DATA_INSTALL_DIR}/rekonq +) + +INSTALL( + FILES rekonq.desktop + DESTINATION ${XDG_APPS_INSTALL_DIR} +) + +INSTALL( + FILES notfound.html home.html + DESTINATION ${DATA_INSTALL_DIR}/rekonq/htmls +) diff --git a/src/data/bg.png b/src/data/bg.png new file mode 100644 index 00000000..5ec669ac Binary files /dev/null and b/src/data/bg.png differ diff --git a/src/data/bg2.png b/src/data/bg2.png new file mode 100644 index 00000000..1ded2690 Binary files /dev/null and b/src/data/bg2.png differ diff --git a/src/data/bot.gif b/src/data/bot.gif new file mode 100644 index 00000000..2f9abde4 Binary files /dev/null and b/src/data/bot.gif differ diff --git a/src/data/busywidget.gif b/src/data/busywidget.gif new file mode 100644 index 00000000..600b9d44 Binary files /dev/null and b/src/data/busywidget.gif differ diff --git a/src/data/button.png b/src/data/button.png new file mode 100644 index 00000000..22ef7643 Binary files /dev/null and b/src/data/button.png differ diff --git a/src/data/category.png b/src/data/category.png new file mode 100644 index 00000000..796875d4 Binary files /dev/null and b/src/data/category.png differ diff --git a/src/data/closed.png b/src/data/closed.png new file mode 100644 index 00000000..2b1bf01e Binary files /dev/null and b/src/data/closed.png differ diff --git a/src/data/defaultbookmarks.xbel b/src/data/defaultbookmarks.xbel new file mode 100644 index 00000000..b4919c5c --- /dev/null +++ b/src/data/defaultbookmarks.xbel @@ -0,0 +1,22 @@ + + + + + QtSoftware + + + WebKit.org + + + rekonq site + + + Trolltech Labs + + + KDE-Apps.org + + + KDE site + + diff --git a/src/data/home.html b/src/data/home.html new file mode 100644 index 00000000..f99d0df1 --- /dev/null +++ b/src/data/home.html @@ -0,0 +1,157 @@ + + + + +%1 + + + + + + +
+ +
%4
+
+ + + diff --git a/src/data/loading.mng b/src/data/loading.mng new file mode 100644 index 00000000..0e490c4b Binary files /dev/null and b/src/data/loading.mng differ diff --git a/src/data/notfound.html b/src/data/notfound.html new file mode 100644 index 00000000..e34bfc6d --- /dev/null +++ b/src/data/notfound.html @@ -0,0 +1,65 @@ + + + +%1 + + + + + + +
%3
+ + + diff --git a/src/data/open.png b/src/data/open.png new file mode 100644 index 00000000..fee6f3fb Binary files /dev/null and b/src/data/open.png differ diff --git a/src/data/rekonq.desktop b/src/data/rekonq.desktop new file mode 100644 index 00000000..62998336 --- /dev/null +++ b/src/data/rekonq.desktop @@ -0,0 +1,24 @@ +[Desktop Entry] +Name=rekonq +Name[sv]=Rekonq +Name[tr]=Rekonq +Name[x-test]=xxrekonqxx +GenericName=Webkit KDE Browser +GenericName[de]=Webkit-Browser für KDE +GenericName[et]=KDE Webkiti veebibrauser +GenericName[km]=កម្មវិធី​រុករក​ Webkit KDE +GenericName[pt]=Navegador Web com WebKit +GenericName[pt_BR]=Navegador Webkit do KDE +GenericName[sv]=Webkit webbläsare för KDE +GenericName[tr]=Webkit KDE Tarayıcı +GenericName[uk]=Переглядач мережі на WebKit для KDE +GenericName[x-test]=xxWebkit KDE Browserxx +Icon=rekonq +Type=Application +Exec=rekonq %u +X-DocPath=rekonq/index.html +Categories=Qt;KDE;Network;WebBrowser; +Terminal=false +MimeType=text/html;application/xhtml+xml;application/xml; +X-DBUS-StartupType=Unique +X-DBUS-ServiceName=net.sourceforge.rekonq diff --git a/src/data/tile.gif b/src/data/tile.gif new file mode 100644 index 00000000..32e06fff Binary files /dev/null and b/src/data/tile.gif differ diff --git a/src/data/top.png b/src/data/top.png new file mode 100644 index 00000000..9ebf0234 Binary files /dev/null and b/src/data/top.png differ diff --git a/src/data/webkit-icon.png b/src/data/webkit-icon.png new file mode 100644 index 00000000..b3ec677a Binary files /dev/null and b/src/data/webkit-icon.png differ -- cgit v1.2.1 From 9fff1383205279a747c09bf07af84cfa37dd3403 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 11 Nov 2009 15:32:59 +0100 Subject: cleaning home :) In Italy we say "Pulizie di Pasqua". Just some changes to reorganize things better --- src/CMakeLists.txt | 40 +++--- src/mainwindow.cpp | 2 +- src/mainwindow.h | 1 - src/newtabpage.cpp | 285 --------------------------------------- src/newtabpage.h | 72 ---------- src/rekonqpage/newtabpage.cpp | 285 +++++++++++++++++++++++++++++++++++++++ src/rekonqpage/newtabpage.h | 72 ++++++++++ src/settings.cpp | 235 -------------------------------- src/settings.h | 62 --------- src/settings/settings_fonts.ui | 97 +++++++++++++ src/settings/settings_general.ui | 244 +++++++++++++++++++++++++++++++++ src/settings/settings_tabs.ui | 81 +++++++++++ src/settings/settings_webkit.ui | 161 ++++++++++++++++++++++ src/settings/settingsdialog.cpp | 235 ++++++++++++++++++++++++++++++++ src/settings/settingsdialog.h | 62 +++++++++ src/settings_fonts.ui | 97 ------------- src/settings_general.ui | 244 --------------------------------- src/settings_tabs.ui | 81 ----------- src/settings_webkit.ui | 161 ---------------------- 19 files changed, 1259 insertions(+), 1258 deletions(-) delete mode 100644 src/newtabpage.cpp delete mode 100644 src/newtabpage.h create mode 100644 src/rekonqpage/newtabpage.cpp create mode 100644 src/rekonqpage/newtabpage.h delete mode 100644 src/settings.cpp delete mode 100644 src/settings.h create mode 100644 src/settings/settings_fonts.ui create mode 100644 src/settings/settings_general.ui create mode 100644 src/settings/settings_tabs.ui create mode 100644 src/settings/settings_webkit.ui create mode 100644 src/settings/settingsdialog.cpp create mode 100644 src/settings/settingsdialog.h delete mode 100644 src/settings_fonts.ui delete mode 100644 src/settings_general.ui delete mode 100644 src/settings_tabs.ui delete mode 100644 src/settings_webkit.ui (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2e6c5d66..56bc0ebd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,36 +7,36 @@ ADD_SUBDIRECTORY( tests ) ### ------- SETTING REKONQ FILES.. SET( rekonq_KDEINIT_SRCS - newtabpage.cpp - previewimage.cpp - websnap.cpp - autosaver.cpp application.cpp - mainwindow.cpp - mainview.cpp - tabbar.cpp + autosaver.cpp + bookmarks.cpp + findbar.cpp history.cpp historymodels.cpp - bookmarks.cpp + lineedit.cpp + mainview.cpp + mainwindow.cpp modelmenu.cpp - urlbar.cpp - findbar.cpp - settings.cpp - webview.cpp - sidepanel.cpp panelhistory.cpp - lineedit.cpp - webpage.cpp + previewimage.cpp sessionmanager.cpp + sidepanel.cpp + tabbar.cpp + urlbar.cpp + webpage.cpp webpluginfactory.cpp + websnap.cpp + webview.cpp + rekonqpage/newtabpage.cpp + settings/settingsdialog.cpp ) KDE4_ADD_UI_FILES( rekonq_KDEINIT_SRCS - settings_general.ui - settings_tabs.ui - settings_fonts.ui - settings_webkit.ui + settings/settings_general.ui + settings/settings_tabs.ui + settings/settings_fonts.ui + settings/settings_webkit.ui cleardata.ui ) @@ -46,6 +46,8 @@ KDE4_ADD_KCFG_FILES( rekonq_KDEINIT_SRCS rekonq.kcfgc ) ### ------------- INCLUDING DIRECTORIES... INCLUDE_DIRECTORIES ( ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/rekonqpage + ${CMAKE_CURRENT_SOURCE_DIR}/settings ${CMAKE_CURRENT_BINARY_DIR} ${KDE4_INCLUDES} ${QT4_INCLUDES} diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 43031446..8caa6fbc 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -35,7 +35,7 @@ // Local Includes #include "application.h" -#include "settings.h" +#include "settingsdialog.h" #include "history.h" #include "bookmarks.h" #include "webview.h" diff --git a/src/mainwindow.h b/src/mainwindow.h index 5071cdb2..0ee1c3c2 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -32,7 +32,6 @@ // Local Includes #include "bookmarks.h" -// #include "mainview.h" #include "webview.h" // KDE Includes diff --git a/src/newtabpage.cpp b/src/newtabpage.cpp deleted file mode 100644 index b34990fc..00000000 --- a/src/newtabpage.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2009 by Andrea Diamantini -* -* -* 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 . -* -* ============================================================ */ - - -// Self Includes -#include "newtabpage.h" - -// Auto Includes -#include "rekonq.h" - -// Local Includes -#include "historymodels.h" -#include "bookmarks.h" -#include "application.h" -#include "mainwindow.h" -#include "mainview.h" - -// KDE Includes -#include -#include -#include -#include -#include - -// Qt Includes -#include - - -NewTabPage::NewTabPage() -{ - m_htmlFilePath = KStandardDirs::locate("data", "rekonq/htmls/home.html"); -} - - -NewTabPage::~NewTabPage() -{ -} - - -QString NewTabPage::newTabPageCode(const KUrl &url) -{ - QFile file(m_htmlFilePath); - bool isOpened = file.open(QIODevice::ReadOnly); - if (!isOpened) - { - kWarning() << "Couldn't open the home.html file"; - return QString(""); - } - QString imagesPath = QString("file://") + KGlobal::dirs()->findResourceDir("data", "rekonq/pics/bg.png") + QString("rekonq/pics"); - QString menu = browsingMenu(url); - - QString speed; - QString title; - if(url == KUrl("about:closedTabs")) - { - speed = closedTabsPage(); - title = i18n("Closed Tabs"); - } - if(url == KUrl("about:history")) - { - speed = historyPage(); - title = i18n("History"); - } - if(url == KUrl("about:bookmarks")) - { - speed = bookmarksPage(); - title = i18n("Bookmarks"); - } - if(url == KUrl("about:home") || url == KUrl("about:favorites")) - { - speed = favoritesPage(); - title = i18n("Favorites"); - } - - QString html = QString(QLatin1String(file.readAll())) - .arg(title) - .arg(imagesPath) - .arg(menu) - .arg(speed) - ; - - return html; -} - - -QString NewTabPage::favoritesPage() -{ - QStringList names = ReKonfig::previewNames(); - QStringList urls = ReKonfig::previewUrls(); - - QString speed = "
"; - for(int i=0; i<8; ++i) - { - speed += "
"; - speed += ""; - speed += ""; - speed += ""; - speed += ""; - speed += ""; - speed += "
"; - } - - speed += "
"; - return speed; -} - - -// FIXME : port to new PreviewImage API to use... -QString NewTabPage::lastVisitedPage() -{ - QString last; - QList history = Application::historyManager()->history(); - for (int i = 0; i < 8 && i < history.size(); ++i) - { - HistoryItem it = history.at(i); - last += "
"; - last += ""; - last += ""; - last += "
"; - last += "" + it.title + "
"; - } - - return last; - -} - - -QString NewTabPage::browsingMenu(const KUrl ¤tUrl) -{ - QString menu; - - KIconLoader *loader = KIconLoader::global(); - - menu += ""; - - menu += ""; - - menu += ""; - - menu += ""; - - return menu; -} - - -QString NewTabPage::historyPage() -{ - HistoryTreeModel *model = Application::historyManager()->historyTreeModel(); - - QString history; - int i = 0; - do - { - QModelIndex index = model->index(i, 0, QModelIndex() ); - if(model->hasChildren(index)) - { - history += "

" + index.data().toString() + "

"; - for(int j=0; j< model->rowCount(index); ++j) - { - QModelIndex son = model->index(j, 0, index ); - history += son.data(HistoryModel::DateTimeRole).toDateTime().toString("hh:mm"); - history += ' '; - history += QString("") + - son.data().toString() + QString(""); - history += "
"; - } - } - i++; - } - while( model->hasIndex( i , 0 , QModelIndex() ) ); - - history += ""; - return history; -} - - -QString NewTabPage::bookmarksPage() -{ - KBookmarkGroup bookGroup = Application::bookmarkProvider()->rootGroup(); - if (bookGroup.isNull()) - { - return QString("Error retrieving bookmarks!"); - } - - QString str; - KBookmark bookmark = bookGroup.first(); - while (!bookmark.isNull()) - { - str += createBookItem(bookmark); - bookmark = bookGroup.next(bookmark); - } - return str; -} - - -QString NewTabPage::createBookItem(const KBookmark &bookmark) -{ - if (bookmark.isGroup()) - { - QString result; - KBookmarkGroup group = bookmark.toGroup(); - KBookmark bm = group.first(); - result += "

" + bookmark.text() + "

"; - result += "

"; - while (!bm.isNull()) - { - result += createBookItem(bm); - bm = group.next(bm); - } - result += "

"; - return result; - } - - if(bookmark.isSeparator()) - { - return QString("
"); - } - - QString books = "" + bookmark.text() + "
"; - return books; -} - - -QString NewTabPage::closedTabsPage() -{ - QList links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs(); - QString closed; - - Q_FOREACH( const HistoryItem &item, links) - { - closed += "
"; - closed += ""; - closed += ""; - closed += ""; - closed += "
"; - } - - return closed; -} diff --git a/src/newtabpage.h b/src/newtabpage.h deleted file mode 100644 index 2d8d50bd..00000000 --- a/src/newtabpage.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2009 by Andrea Diamantini -* -* -* 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 . -* -* ============================================================ */ - - -#ifndef REKONQ_NEW_TAB_PAGE -#define REKONQ_NEW_TAB_PAGE - - -// KDE Includes -#include - -// Qt Includes -#include -#include - -// Forward Includes -class KBookmark; - - -class NewTabPage -{ - -public: - NewTabPage(); - ~NewTabPage(); - - /** - * This is the unique NewTabPage public method. It takes an - * about: url and loads the corresponding part of the - * new tab page - */ - QString newTabPageCode(const KUrl &url = KUrl("about:home")); - -protected: // these are the function to build the new tab page - - QString browsingMenu(const KUrl ¤tUrl); - - QString favoritesPage(); - QString lastVisitedPage(); - QString historyPage(); - QString bookmarksPage(); - QString closedTabsPage(); - -private: - QString createBookItem(const KBookmark &bookmark); - - QString m_htmlFilePath; -}; - -#endif // REKONQ_NEW_TAB_PAGE diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp new file mode 100644 index 00000000..b34990fc --- /dev/null +++ b/src/rekonqpage/newtabpage.cpp @@ -0,0 +1,285 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009 by Andrea Diamantini +* +* +* 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 . +* +* ============================================================ */ + + +// Self Includes +#include "newtabpage.h" + +// Auto Includes +#include "rekonq.h" + +// Local Includes +#include "historymodels.h" +#include "bookmarks.h" +#include "application.h" +#include "mainwindow.h" +#include "mainview.h" + +// KDE Includes +#include +#include +#include +#include +#include + +// Qt Includes +#include + + +NewTabPage::NewTabPage() +{ + m_htmlFilePath = KStandardDirs::locate("data", "rekonq/htmls/home.html"); +} + + +NewTabPage::~NewTabPage() +{ +} + + +QString NewTabPage::newTabPageCode(const KUrl &url) +{ + QFile file(m_htmlFilePath); + bool isOpened = file.open(QIODevice::ReadOnly); + if (!isOpened) + { + kWarning() << "Couldn't open the home.html file"; + return QString(""); + } + QString imagesPath = QString("file://") + KGlobal::dirs()->findResourceDir("data", "rekonq/pics/bg.png") + QString("rekonq/pics"); + QString menu = browsingMenu(url); + + QString speed; + QString title; + if(url == KUrl("about:closedTabs")) + { + speed = closedTabsPage(); + title = i18n("Closed Tabs"); + } + if(url == KUrl("about:history")) + { + speed = historyPage(); + title = i18n("History"); + } + if(url == KUrl("about:bookmarks")) + { + speed = bookmarksPage(); + title = i18n("Bookmarks"); + } + if(url == KUrl("about:home") || url == KUrl("about:favorites")) + { + speed = favoritesPage(); + title = i18n("Favorites"); + } + + QString html = QString(QLatin1String(file.readAll())) + .arg(title) + .arg(imagesPath) + .arg(menu) + .arg(speed) + ; + + return html; +} + + +QString NewTabPage::favoritesPage() +{ + QStringList names = ReKonfig::previewNames(); + QStringList urls = ReKonfig::previewUrls(); + + QString speed = "
"; + for(int i=0; i<8; ++i) + { + speed += "
"; + speed += ""; + speed += ""; + speed += ""; + speed += ""; + speed += ""; + speed += "
"; + } + + speed += "
"; + return speed; +} + + +// FIXME : port to new PreviewImage API to use... +QString NewTabPage::lastVisitedPage() +{ + QString last; + QList history = Application::historyManager()->history(); + for (int i = 0; i < 8 && i < history.size(); ++i) + { + HistoryItem it = history.at(i); + last += "
"; + last += ""; + last += ""; + last += "
"; + last += "" + it.title + "
"; + } + + return last; + +} + + +QString NewTabPage::browsingMenu(const KUrl ¤tUrl) +{ + QString menu; + + KIconLoader *loader = KIconLoader::global(); + + menu += ""; + + menu += ""; + + menu += ""; + + menu += ""; + + return menu; +} + + +QString NewTabPage::historyPage() +{ + HistoryTreeModel *model = Application::historyManager()->historyTreeModel(); + + QString history; + int i = 0; + do + { + QModelIndex index = model->index(i, 0, QModelIndex() ); + if(model->hasChildren(index)) + { + history += "

" + index.data().toString() + "

"; + for(int j=0; j< model->rowCount(index); ++j) + { + QModelIndex son = model->index(j, 0, index ); + history += son.data(HistoryModel::DateTimeRole).toDateTime().toString("hh:mm"); + history += ' '; + history += QString("") + + son.data().toString() + QString(""); + history += "
"; + } + } + i++; + } + while( model->hasIndex( i , 0 , QModelIndex() ) ); + + history += ""; + return history; +} + + +QString NewTabPage::bookmarksPage() +{ + KBookmarkGroup bookGroup = Application::bookmarkProvider()->rootGroup(); + if (bookGroup.isNull()) + { + return QString("Error retrieving bookmarks!"); + } + + QString str; + KBookmark bookmark = bookGroup.first(); + while (!bookmark.isNull()) + { + str += createBookItem(bookmark); + bookmark = bookGroup.next(bookmark); + } + return str; +} + + +QString NewTabPage::createBookItem(const KBookmark &bookmark) +{ + if (bookmark.isGroup()) + { + QString result; + KBookmarkGroup group = bookmark.toGroup(); + KBookmark bm = group.first(); + result += "

" + bookmark.text() + "

"; + result += "

"; + while (!bm.isNull()) + { + result += createBookItem(bm); + bm = group.next(bm); + } + result += "

"; + return result; + } + + if(bookmark.isSeparator()) + { + return QString("
"); + } + + QString books = "" + bookmark.text() + "
"; + return books; +} + + +QString NewTabPage::closedTabsPage() +{ + QList links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs(); + QString closed; + + Q_FOREACH( const HistoryItem &item, links) + { + closed += "
"; + closed += ""; + closed += ""; + closed += ""; + closed += "
"; + } + + return closed; +} diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h new file mode 100644 index 00000000..2d8d50bd --- /dev/null +++ b/src/rekonqpage/newtabpage.h @@ -0,0 +1,72 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2009 by Andrea Diamantini +* +* +* 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 . +* +* ============================================================ */ + + +#ifndef REKONQ_NEW_TAB_PAGE +#define REKONQ_NEW_TAB_PAGE + + +// KDE Includes +#include + +// Qt Includes +#include +#include + +// Forward Includes +class KBookmark; + + +class NewTabPage +{ + +public: + NewTabPage(); + ~NewTabPage(); + + /** + * This is the unique NewTabPage public method. It takes an + * about: url and loads the corresponding part of the + * new tab page + */ + QString newTabPageCode(const KUrl &url = KUrl("about:home")); + +protected: // these are the function to build the new tab page + + QString browsingMenu(const KUrl ¤tUrl); + + QString favoritesPage(); + QString lastVisitedPage(); + QString historyPage(); + QString bookmarksPage(); + QString closedTabsPage(); + +private: + QString createBookItem(const KBookmark &bookmark); + + QString m_htmlFilePath; +}; + +#endif // REKONQ_NEW_TAB_PAGE diff --git a/src/settings.cpp b/src/settings.cpp deleted file mode 100644 index 9c95bb9c..00000000 --- a/src/settings.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2007-2008 Trolltech ASA. All rights reserved -* Copyright (C) 2008-2009 by Andrea Diamantini -* Copyright (C) 2009 by Lionel Chauvin -* -* -* 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 . -* -* ============================================================ */ - - -// Self Includes -#include "settings.h" -#include "settings.moc" - -// Auto Includes -#include "rekonq.h" - -// Local Includes -#include "application.h" -#include "mainwindow.h" -#include "webview.h" - -//Ui Includes -#include "ui_settings_general.h" -#include "ui_settings_tabs.h" -#include "ui_settings_fonts.h" -#include "ui_settings_webkit.h" - -// KDE Includes -#include -#include -#include -#include -#include -#include - -// Qt Includes -#include -#include - - -class Private -{ -private: - - Ui::general generalUi; - Ui::tabs tabsUi; - Ui::fonts fontsUi; - Ui::webkit webkitUi; - - KCModuleProxy *proxyModule; - KCModuleProxy *ebrowsingModule; - KCModuleProxy *cookiesModule; - KCModuleProxy *cacheModule; - KShortcutsEditor *shortcutsEditor; - - Private(SettingsDialog *parent); - - friend class SettingsDialog; -}; - - -Private::Private(SettingsDialog *parent) -{ - QWidget *widget; - KPageWidgetItem *pageItem; - - widget = new QWidget; - generalUi.setupUi(widget); - widget->layout()->setMargin(0); - pageItem = parent->addPage(widget , i18n("General")); - pageItem->setIcon(KIcon("rekonq")); - - widget = new QWidget; - tabsUi.setupUi(widget); - widget->layout()->setMargin(0); - pageItem = parent->addPage(widget , i18n("Tabs")); - pageItem->setIcon(KIcon("tab-duplicate")); - - widget = new QWidget; - fontsUi.setupUi(widget); - widget->layout()->setMargin(0); - pageItem = parent->addPage(widget , i18n("Fonts")); - pageItem->setIcon(KIcon("preferences-desktop-font")); - - KCModuleInfo cookiesInfo("cookies.desktop"); - cookiesModule = new KCModuleProxy(cookiesInfo,parent); - pageItem = parent->addPage(cookiesModule, i18n(cookiesInfo.moduleName().toLocal8Bit())); - pageItem->setIcon(KIcon(cookiesInfo.icon())); - - KCModuleInfo proxyInfo("proxy.desktop"); - proxyModule = new KCModuleProxy(proxyInfo,parent); - pageItem = parent->addPage(proxyModule, i18n(proxyInfo.moduleName().toLocal8Bit())); - pageItem->setIcon(KIcon(proxyInfo.icon())); - - KCModuleInfo cacheInfo("cache.desktop"); - cacheModule = new KCModuleProxy(cacheInfo,parent); - pageItem = parent->addPage(cacheModule, i18n(cacheInfo.moduleName().toLocal8Bit())); - pageItem->setIcon(KIcon(cacheInfo.icon())); - - widget = new QWidget; - webkitUi.setupUi(widget); - widget->layout()->setMargin(0); - pageItem = parent->addPage(widget , i18n("WebKit")); - QString webkitIconPath = KStandardDirs::locate("appdata", "pics/webkit-icon.png"); - KIcon webkitIcon = KIcon(QIcon(webkitIconPath)); - pageItem->setIcon(webkitIcon); - - shortcutsEditor = new KShortcutsEditor(Application::instance()->mainWindow()->actionCollection(), parent); - pageItem = parent->addPage(shortcutsEditor , i18n("Shortcuts")); - pageItem->setIcon(KIcon("configure-shortcuts")); - - KCModuleInfo ebrowsingInfo("ebrowsing.desktop"); - ebrowsingModule = new KCModuleProxy(ebrowsingInfo,parent); - pageItem = parent->addPage(ebrowsingModule, i18n(ebrowsingInfo.moduleName().toLocal8Bit())); - pageItem->setIcon(KIcon(ebrowsingInfo.icon())); - - parent->setMinimumSize(700,500); -} - - -// ----------------------------------------------------------------------------------------------------- - - -SettingsDialog::SettingsDialog(QWidget *parent) - : KConfigDialog(parent, "rekonfig", ReKonfig::self()) - , d(new Private(this)) -{ - setFaceType(KPageDialog::Tree); - showButtonSeparator(true); - - setWindowTitle(i18n("rekonfig...")); - setModal(true); - - readConfig(); - - - connect(d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT(setHomeToCurrentPage())); - - connect(d->ebrowsingModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); - connect(d->cookiesModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); - connect(d->proxyModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); - connect(d->cacheModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); - - connect(d->shortcutsEditor, SIGNAL(keyChange()), this, SLOT(updateButtons())); - - connect(this, SIGNAL(applyClicked()), this, SLOT(saveSettings())); - connect(this, SIGNAL(okClicked()), this, SLOT(saveSettings())); - - setWebSettingsToolTips(); -} - - -SettingsDialog::~SettingsDialog() -{ - delete d; -} - - -void SettingsDialog::setWebSettingsToolTips() -{ - d->webkitUi.kcfg_autoLoadImages->setToolTip(i18n("Specifies whether images are automatically loaded in web pages.")); - d->webkitUi.kcfg_javascriptEnabled->setToolTip(i18n("Enables the execution of JavaScript programs.")); - d->webkitUi.kcfg_javaEnabled->setToolTip(i18n("Enables support for Java applets.")); - d->webkitUi.kcfg_pluginsEnabled->setToolTip(i18n("Enables support for plugins in web pages.")); - d->webkitUi.kcfg_javascriptCanOpenWindows->setToolTip(i18n("If enabled, JavaScript programs are allowed to open new windows.")); - d->webkitUi.kcfg_javascriptCanAccessClipboard->setToolTip(i18n("If enabled, JavaScript programs are allowed to read from and to write to the clipboard.")); - d->webkitUi.kcfg_linksIncludedInFocusChain->setToolTip(i18n("If enabled, hyperlinks are included in the keyboard focus chain.")); - d->webkitUi.kcfg_zoomTextOnly->setToolTip(i18n("If enabled, the zoom factor on a frame is only applied to the text.")); - d->webkitUi.kcfg_printElementBackgrounds->setToolTip(i18n("If enabled, background colors and images are also drawn when the page is printed.")); - d->webkitUi.kcfg_offlineStorageDatabaseEnabled->setToolTip(i18n("Enables support for the HTML 5 offline storage feature.")); - d->webkitUi.kcfg_offlineWebApplicationCacheEnabled->setToolTip(i18n("Enables support for the HTML 5 web application cache feature.")); - d->webkitUi.kcfg_localStorageDatabaseEnabled->setToolTip(i18n("Enables support for the HTML 5 local storage feature.")); -} - - -// we need this function to UPDATE the config widget data.. -void SettingsDialog::readConfig() -{ - // ======= Fonts - d->fontsUi.kcfg_fixedFont->setOnlyFixed(true); -} - - -// we need this function to SAVE settings in rc file.. -void SettingsDialog::saveSettings() -{ - ReKonfig::self()->writeConfig(); - d->ebrowsingModule->save(); - d->cookiesModule->save(); - d->proxyModule->save(); - d->cacheModule->save(); - d->shortcutsEditor->save(); -} - - -bool SettingsDialog::hasChanged() -{ - return KConfigDialog::hasChanged() - || d->ebrowsingModule->changed() - || d->cookiesModule->changed() - || d->proxyModule->changed() - || d->cacheModule->changed() - || d->shortcutsEditor->isModified(); - ; -} - - -void SettingsDialog::setHomeToCurrentPage() -{ - MainWindow *mw = static_cast(parent()); - WebView *webView = mw->currentTab(); - if (webView) - { - d->generalUi.kcfg_homePage->setText(webView->url().prettyUrl()); - } -} diff --git a/src/settings.h b/src/settings.h deleted file mode 100644 index 3aa943c7..00000000 --- a/src/settings.h +++ /dev/null @@ -1,62 +0,0 @@ -/* ============================================================ -* -* This file is a part of the rekonq project -* -* Copyright (C) 2007-2008 Trolltech ASA. All rights reserved -* Copyright (C) 2008-2009 by Andrea Diamantini -* Copyright (C) 2009 by Lionel Chauvin -* -* -* 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 . -* -* ============================================================ */ - - -#ifndef SETTINGS_H -#define SETTINGS_H - - -// KDE Includes -#include - -// Forward Declarations -class QWidget; -class Private; - - -class SettingsDialog : public KConfigDialog -{ - Q_OBJECT - -public: - SettingsDialog(QWidget *parent = 0); - ~SettingsDialog(); - - virtual bool hasChanged(); - -private: - Private* const d; - void setWebSettingsToolTips(); - -private slots: - void readConfig(); - void saveSettings(); - - void setHomeToCurrentPage(); -}; - -#endif // SETTINGS_H diff --git a/src/settings/settings_fonts.ui b/src/settings/settings_fonts.ui new file mode 100644 index 00000000..98efce16 --- /dev/null +++ b/src/settings/settings_fonts.ui @@ -0,0 +1,97 @@ + + + fonts + + + + 0 + 0 + 414 + 298 + + + + Appearance + + + + + + Fonts + + + + + + + + Standard font: + + + + + + + Fixed font: + + + + + + + + + + + + + + + + + + Dimension + + + + + + + + Font size: + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + KFontComboBox + KComboBox +
kfontcombobox.h
+
+
+ + +
diff --git a/src/settings/settings_general.ui b/src/settings/settings_general.ui new file mode 100644 index 00000000..57d293e6 --- /dev/null +++ b/src/settings/settings_general.ui @@ -0,0 +1,244 @@ + + + general + + + + 0 + 0 + 751 + 523 + + + + General + + + + + + Startup + + + + + + + 0 + 0 + + + + + 120 + 0 + + + + + 0 + 0 + + + + Qt::LeftToRight + + + When starting rekonq: + + + + + + + + 0 + 0 + + + + + Open the Home Page + + + + + Open the New Tab Page + + + + + Restore the Last Opened Tabs + + + + + + + + + + + Home Page + + + + + + + 0 + 0 + + + + + 120 + 0 + + + + + 120 + 0 + + + + Home page URL: + + + + + + + true + + + + 0 + 0 + + + + + + + + + + Set to Current Page + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + New Tabs Behaviour + + + + + + + 0 + 0 + + + + + 120 + 0 + + + + + 120 + 0 + + + + New tab opens: + + + + + + + true + + + + 0 + 0 + + + + + New Tab Page + + + + + Blank Page + + + + + Home Page + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + + KLineEdit + QLineEdit +
klineedit.h
+
+ + KComboBox + QComboBox +
kcombobox.h
+
+
+ + +
diff --git a/src/settings/settings_tabs.ui b/src/settings/settings_tabs.ui new file mode 100644 index 00000000..ba903ff4 --- /dev/null +++ b/src/settings/settings_tabs.ui @@ -0,0 +1,81 @@ + + + tabs + + + + 0 + 0 + 456 + 329 + + + + Tabs + + + + + + Tabbed Browsing + + + + + + Open links in new tab instead of in new window + + + + + + + Always show tab bar + + + + + + + Open new tabs in the background + + + + + + + Open new tabs after currently active one + + + + + + + Show preview when hovering tab + + + false + + + + + + + + + + Qt::Vertical + + + + 20 + 142 + + + + + + + + + diff --git a/src/settings/settings_webkit.ui b/src/settings/settings_webkit.ui new file mode 100644 index 00000000..129bcf03 --- /dev/null +++ b/src/settings/settings_webkit.ui @@ -0,0 +1,161 @@ + + + webkit + + + + 0 + 0 + 622 + 360 + + + + + + + WebKit Settings + + + + + + Autoload images + + + + + + + Qt::Vertical + + + + + + + Links included in focus chain + + + + + + + JavaScript support + + + + + + + Zoom text only + + + + + + + Java support + + + + + + + Print element backgrounds + + + + + + + Plugins + + + + + + + Offline storage database + + + + + + + JavaScript can open windows + + + + + + + Offline web application cache + + + + + + + JavaScript can access clipboard + + + + + + + Local storage database + + + + + + + + + + User Style Sheet + + + + + + User CSS path: + + + + + + + *.css + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + KUrlRequester + QFrame +
kurlrequester.h
+
+
+ + +
diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp new file mode 100644 index 00000000..1db38b96 --- /dev/null +++ b/src/settings/settingsdialog.cpp @@ -0,0 +1,235 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2007-2008 Trolltech ASA. All rights reserved +* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2009 by Lionel Chauvin +* +* +* 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 . +* +* ============================================================ */ + + +// Self Includes +#include "settingsdialog.h" +#include "settingsdialog.moc" + +// Auto Includes +#include "rekonq.h" + +// Local Includes +#include "application.h" +#include "mainwindow.h" +#include "webview.h" + +//Ui Includes +#include "ui_settings_general.h" +#include "ui_settings_tabs.h" +#include "ui_settings_fonts.h" +#include "ui_settings_webkit.h" + +// KDE Includes +#include +#include +#include +#include +#include +#include + +// Qt Includes +#include +#include + + +class Private +{ +private: + + Ui::general generalUi; + Ui::tabs tabsUi; + Ui::fonts fontsUi; + Ui::webkit webkitUi; + + KCModuleProxy *proxyModule; + KCModuleProxy *ebrowsingModule; + KCModuleProxy *cookiesModule; + KCModuleProxy *cacheModule; + KShortcutsEditor *shortcutsEditor; + + Private(SettingsDialog *parent); + + friend class SettingsDialog; +}; + + +Private::Private(SettingsDialog *parent) +{ + QWidget *widget; + KPageWidgetItem *pageItem; + + widget = new QWidget; + generalUi.setupUi(widget); + widget->layout()->setMargin(0); + pageItem = parent->addPage(widget , i18n("General")); + pageItem->setIcon(KIcon("rekonq")); + + widget = new QWidget; + tabsUi.setupUi(widget); + widget->layout()->setMargin(0); + pageItem = parent->addPage(widget , i18n("Tabs")); + pageItem->setIcon(KIcon("tab-duplicate")); + + widget = new QWidget; + fontsUi.setupUi(widget); + widget->layout()->setMargin(0); + pageItem = parent->addPage(widget , i18n("Fonts")); + pageItem->setIcon(KIcon("preferences-desktop-font")); + + KCModuleInfo cookiesInfo("cookies.desktop"); + cookiesModule = new KCModuleProxy(cookiesInfo,parent); + pageItem = parent->addPage(cookiesModule, i18n(cookiesInfo.moduleName().toLocal8Bit())); + pageItem->setIcon(KIcon(cookiesInfo.icon())); + + KCModuleInfo proxyInfo("proxy.desktop"); + proxyModule = new KCModuleProxy(proxyInfo,parent); + pageItem = parent->addPage(proxyModule, i18n(proxyInfo.moduleName().toLocal8Bit())); + pageItem->setIcon(KIcon(proxyInfo.icon())); + + KCModuleInfo cacheInfo("cache.desktop"); + cacheModule = new KCModuleProxy(cacheInfo,parent); + pageItem = parent->addPage(cacheModule, i18n(cacheInfo.moduleName().toLocal8Bit())); + pageItem->setIcon(KIcon(cacheInfo.icon())); + + widget = new QWidget; + webkitUi.setupUi(widget); + widget->layout()->setMargin(0); + pageItem = parent->addPage(widget , i18n("WebKit")); + QString webkitIconPath = KStandardDirs::locate("appdata", "pics/webkit-icon.png"); + KIcon webkitIcon = KIcon(QIcon(webkitIconPath)); + pageItem->setIcon(webkitIcon); + + shortcutsEditor = new KShortcutsEditor(Application::instance()->mainWindow()->actionCollection(), parent); + pageItem = parent->addPage(shortcutsEditor , i18n("Shortcuts")); + pageItem->setIcon(KIcon("configure-shortcuts")); + + KCModuleInfo ebrowsingInfo("ebrowsing.desktop"); + ebrowsingModule = new KCModuleProxy(ebrowsingInfo,parent); + pageItem = parent->addPage(ebrowsingModule, i18n(ebrowsingInfo.moduleName().toLocal8Bit())); + pageItem->setIcon(KIcon(ebrowsingInfo.icon())); + + parent->setMinimumSize(700,500); +} + + +// ----------------------------------------------------------------------------------------------------- + + +SettingsDialog::SettingsDialog(QWidget *parent) + : KConfigDialog(parent, "rekonfig", ReKonfig::self()) + , d(new Private(this)) +{ + setFaceType(KPageDialog::Tree); + showButtonSeparator(true); + + setWindowTitle(i18n("rekonfig...")); + setModal(true); + + readConfig(); + + + connect(d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT(setHomeToCurrentPage())); + + connect(d->ebrowsingModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); + connect(d->cookiesModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); + connect(d->proxyModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); + connect(d->cacheModule, SIGNAL(changed(bool)), this, SLOT(updateButtons())); + + connect(d->shortcutsEditor, SIGNAL(keyChange()), this, SLOT(updateButtons())); + + connect(this, SIGNAL(applyClicked()), this, SLOT(saveSettings())); + connect(this, SIGNAL(okClicked()), this, SLOT(saveSettings())); + + setWebSettingsToolTips(); +} + + +SettingsDialog::~SettingsDialog() +{ + delete d; +} + + +void SettingsDialog::setWebSettingsToolTips() +{ + d->webkitUi.kcfg_autoLoadImages->setToolTip(i18n("Specifies whether images are automatically loaded in web pages.")); + d->webkitUi.kcfg_javascriptEnabled->setToolTip(i18n("Enables the execution of JavaScript programs.")); + d->webkitUi.kcfg_javaEnabled->setToolTip(i18n("Enables support for Java applets.")); + d->webkitUi.kcfg_pluginsEnabled->setToolTip(i18n("Enables support for plugins in web pages.")); + d->webkitUi.kcfg_javascriptCanOpenWindows->setToolTip(i18n("If enabled, JavaScript programs are allowed to open new windows.")); + d->webkitUi.kcfg_javascriptCanAccessClipboard->setToolTip(i18n("If enabled, JavaScript programs are allowed to read from and to write to the clipboard.")); + d->webkitUi.kcfg_linksIncludedInFocusChain->setToolTip(i18n("If enabled, hyperlinks are included in the keyboard focus chain.")); + d->webkitUi.kcfg_zoomTextOnly->setToolTip(i18n("If enabled, the zoom factor on a frame is only applied to the text.")); + d->webkitUi.kcfg_printElementBackgrounds->setToolTip(i18n("If enabled, background colors and images are also drawn when the page is printed.")); + d->webkitUi.kcfg_offlineStorageDatabaseEnabled->setToolTip(i18n("Enables support for the HTML 5 offline storage feature.")); + d->webkitUi.kcfg_offlineWebApplicationCacheEnabled->setToolTip(i18n("Enables support for the HTML 5 web application cache feature.")); + d->webkitUi.kcfg_localStorageDatabaseEnabled->setToolTip(i18n("Enables support for the HTML 5 local storage feature.")); +} + + +// we need this function to UPDATE the config widget data.. +void SettingsDialog::readConfig() +{ + // ======= Fonts + d->fontsUi.kcfg_fixedFont->setOnlyFixed(true); +} + + +// we need this function to SAVE settings in rc file.. +void SettingsDialog::saveSettings() +{ + ReKonfig::self()->writeConfig(); + d->ebrowsingModule->save(); + d->cookiesModule->save(); + d->proxyModule->save(); + d->cacheModule->save(); + d->shortcutsEditor->save(); +} + + +bool SettingsDialog::hasChanged() +{ + return KConfigDialog::hasChanged() + || d->ebrowsingModule->changed() + || d->cookiesModule->changed() + || d->proxyModule->changed() + || d->cacheModule->changed() + || d->shortcutsEditor->isModified(); + ; +} + + +void SettingsDialog::setHomeToCurrentPage() +{ + MainWindow *mw = static_cast(parent()); + WebView *webView = mw->currentTab(); + if (webView) + { + d->generalUi.kcfg_homePage->setText(webView->url().prettyUrl()); + } +} diff --git a/src/settings/settingsdialog.h b/src/settings/settingsdialog.h new file mode 100644 index 00000000..360fe246 --- /dev/null +++ b/src/settings/settingsdialog.h @@ -0,0 +1,62 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2007-2008 Trolltech ASA. All rights reserved +* Copyright (C) 2008-2009 by Andrea Diamantini +* Copyright (C) 2009 by Lionel Chauvin +* +* +* 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 . +* +* ============================================================ */ + + +#ifndef SETTINGS_DIALOG_H +#define SETTINGS_DIALOG_H + + +// KDE Includes +#include + +// Forward Declarations +class QWidget; +class Private; + + +class SettingsDialog : public KConfigDialog +{ + Q_OBJECT + +public: + SettingsDialog(QWidget *parent = 0); + ~SettingsDialog(); + + virtual bool hasChanged(); + +private: + Private* const d; + void setWebSettingsToolTips(); + +private slots: + void readConfig(); + void saveSettings(); + + void setHomeToCurrentPage(); +}; + +#endif // SETTINGS_DIALOG_H diff --git a/src/settings_fonts.ui b/src/settings_fonts.ui deleted file mode 100644 index 98efce16..00000000 --- a/src/settings_fonts.ui +++ /dev/null @@ -1,97 +0,0 @@ - - - fonts - - - - 0 - 0 - 414 - 298 - - - - Appearance - - - - - - Fonts - - - - - - - - Standard font: - - - - - - - Fixed font: - - - - - - - - - - - - - - - - - - Dimension - - - - - - - - Font size: - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - KFontComboBox - KComboBox -
kfontcombobox.h
-
-
- - -
diff --git a/src/settings_general.ui b/src/settings_general.ui deleted file mode 100644 index 57d293e6..00000000 --- a/src/settings_general.ui +++ /dev/null @@ -1,244 +0,0 @@ - - - general - - - - 0 - 0 - 751 - 523 - - - - General - - - - - - Startup - - - - - - - 0 - 0 - - - - - 120 - 0 - - - - - 0 - 0 - - - - Qt::LeftToRight - - - When starting rekonq: - - - - - - - - 0 - 0 - - - - - Open the Home Page - - - - - Open the New Tab Page - - - - - Restore the Last Opened Tabs - - - - - - - - - - - Home Page - - - - - - - 0 - 0 - - - - - 120 - 0 - - - - - 120 - 0 - - - - Home page URL: - - - - - - - true - - - - 0 - 0 - - - - - - - - - - Set to Current Page - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - New Tabs Behaviour - - - - - - - 0 - 0 - - - - - 120 - 0 - - - - - 120 - 0 - - - - New tab opens: - - - - - - - true - - - - 0 - 0 - - - - - New Tab Page - - - - - Blank Page - - - - - Home Page - - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 40 - - - - - - - - - KLineEdit - QLineEdit -
klineedit.h
-
- - KComboBox - QComboBox -
kcombobox.h
-
-
- - -
diff --git a/src/settings_tabs.ui b/src/settings_tabs.ui deleted file mode 100644 index ba903ff4..00000000 --- a/src/settings_tabs.ui +++ /dev/null @@ -1,81 +0,0 @@ - - - tabs - - - - 0 - 0 - 456 - 329 - - - - Tabs - - - - - - Tabbed Browsing - - - - - - Open links in new tab instead of in new window - - - - - - - Always show tab bar - - - - - - - Open new tabs in the background - - - - - - - Open new tabs after currently active one - - - - - - - Show preview when hovering tab - - - false - - - - - - - - - - Qt::Vertical - - - - 20 - 142 - - - - - - - - - diff --git a/src/settings_webkit.ui b/src/settings_webkit.ui deleted file mode 100644 index 129bcf03..00000000 --- a/src/settings_webkit.ui +++ /dev/null @@ -1,161 +0,0 @@ - - - webkit - - - - 0 - 0 - 622 - 360 - - - - - - - WebKit Settings - - - - - - Autoload images - - - - - - - Qt::Vertical - - - - - - - Links included in focus chain - - - - - - - JavaScript support - - - - - - - Zoom text only - - - - - - - Java support - - - - - - - Print element backgrounds - - - - - - - Plugins - - - - - - - Offline storage database - - - - - - - JavaScript can open windows - - - - - - - Offline web application cache - - - - - - - JavaScript can access clipboard - - - - - - - Local storage database - - - - - - - - - - User Style Sheet - - - - - - User CSS path: - - - - - - - *.css - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - KUrlRequester - QFrame -
kurlrequester.h
-
-
- - -
-- cgit v1.2.1 From 06d7bc99ae16724d9b23bf0a589a6583dfdb0b46 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 12 Nov 2009 02:50:14 +0100 Subject: Fixes and improvements in rekonq web classes --- src/webpage.cpp | 61 ++++++++++++++++++++++++++++++--------------------------- src/webpage.h | 5 +++-- src/webview.cpp | 2 +- 3 files changed, 36 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/webpage.cpp b/src/webpage.cpp index e75e898c..b19b1ff2 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -49,7 +49,8 @@ #include #include -#include +#include + #include #include #include @@ -73,9 +74,9 @@ WebPage::WebPage(QObject *parent, qlonglong windowId) setForwardUnsupportedContent(true); - connect(this, SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*))); + connect(networkAccessManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*))); - connect(this, SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(downloadRequested(const QNetworkRequest &))); + connect(this, SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(downloadRequest(const QNetworkRequest &))); connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *))); } @@ -126,12 +127,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r WebPage *WebPage::createWindow(QWebPage::WebWindowType type) { kDebug() << "WebPage createWindow slot"; - return newWindow(type); -} - -WebPage *WebPage::newWindow(WebWindowType type) -{ // added to manage web modal dialogs if (type == QWebPage::WebModalDialog) kDebug() << "Modal Dialog"; @@ -154,34 +150,32 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) if (reply->error() == QNetworkReply::NoError) { const KUrl url(reply->request().url()); - QString filename = url.fileName(); - QString mimetype = reply->header(QNetworkRequest::ContentTypeHeader).toString(); - KService::Ptr offer = KMimeTypeTrader::self()->preferredService(mimetype); + + QString mimeType = reply->header(QNetworkRequest::ContentTypeHeader).toString(); + KService::Ptr offer = KMimeTypeTrader::self()->preferredService(mimeType); if( offer.isNull() ) // no service can handle this. We can just download it.. { - downloadRequested(reply->request()); + downloadRequest(reply->request()); + return; } - else + + KParts::BrowserOpenOrSaveQuestion dlg(Application::instance()->mainWindow(), url, mimeType); + switch ( dlg.askEmbedOrSave() ) { - // WARNING switch to BrowserOpenOrSaveQuestion for 4.4 - switch ( KParts::BrowserRun::askSave( url, offer, mimetype, filename ) ) - { - case KParts::BrowserRun::Save: - downloadRequested(reply->request()); - return; - case KParts::BrowserRun::Cancel: - return; - default: // non extant case - break; - } - // case KParts::BrowserRun::Open - KUrl::List list; - list.append(url); - KRun::run(*offer,url,0); + case KParts::BrowserOpenOrSaveQuestion::Save: + downloadRequested(reply->request()); + return; + case KParts::BrowserOpenOrSaveQuestion::Cancel: + return; + default: // non extant case + break; } + // case KParts::BrowserRun::Embed + KUrl::List list; + list.append(url); + KRun::run(*offer,url,0); } - return; } @@ -255,3 +249,12 @@ QString WebPage::errorPage(QNetworkReply *reply) ; return html; } + + +bool WebPage::authorizedRequest(const QUrl &url) const +{ + Q_UNUSED(url) + // TODO implement ad-block here + return true; +} + diff --git a/src/webpage.h b/src/webpage.h index 725788ee..fed877ae 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -50,13 +50,14 @@ class WebPage : public KWebPage public: explicit WebPage(QObject *parent = 0, qlonglong windowId = 0); ~WebPage(); - + + virtual bool authorizedRequest(const QUrl &url) const; + public slots: void manageNetworkErrors(QNetworkReply* reply); protected: WebPage *createWindow(WebWindowType type); - virtual WebPage *newWindow(WebWindowType type); virtual bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, diff --git a/src/webview.cpp b/src/webview.cpp index 700c526e..b4b71f64 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -76,7 +76,7 @@ WebPage *WebView::page() { if(!m_page) { - m_page = new WebPage(); + m_page = new WebPage(this); setPage(m_page); } return m_page; -- cgit v1.2.1 From fc7a75bb35a60060a1b8c103cbe352b5c5ef6635 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 12 Nov 2009 03:16:15 +0100 Subject: Connecting new KWebView signals to some proper slots --- src/webview.cpp | 9 +++++++++ src/webview.h | 2 ++ 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/webview.cpp b/src/webview.cpp index b4b71f64..2c96f532 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -64,6 +64,8 @@ WebView::WebView(QWidget* parent) connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&))); connect(this, SIGNAL(loadProgress(int)), this, SLOT(updateProgress(int))); connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); + + connect(this, SIGNAL(linkMiddleOrCtrlClicked(const KUrl &)), this, SLOT(loadInNewTab(const KUrl &)) ); } @@ -419,3 +421,10 @@ void WebView::keyPressEvent(QKeyEvent *event) QWebView::keyPressEvent(event); } + + +void WebView::loadInNewTab(const KUrl &url) +{ + Application::instance()->loadUrl(url, Rekonq::NewCurrentTab); +} + \ No newline at end of file diff --git a/src/webview.h b/src/webview.h index a753736c..e4a0cc59 100644 --- a/src/webview.h +++ b/src/webview.h @@ -71,6 +71,8 @@ private slots: void openLinkInNewWindow(); void openLinkInNewTab(); + void loadInNewTab(const KUrl &url); + private: WebPage *m_page; int m_progress; -- cgit v1.2.1 From c50290e8fdbce0e7736a717cf44c8ab8b062fe77 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 12 Nov 2009 15:35:05 +0100 Subject: KIO download system ported to kdewebkit signals and functions --- src/webpage.cpp | 2 -- src/webpage.h | 4 ++-- src/webview.cpp | 16 +++++++++++++++- src/webview.h | 3 +++ 4 files changed, 20 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/webpage.cpp b/src/webpage.cpp index b19b1ff2..94ecbe09 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -76,7 +76,6 @@ WebPage::WebPage(QObject *parent, qlonglong windowId) connect(networkAccessManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*))); - connect(this, SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(downloadRequest(const QNetworkRequest &))); connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *))); } @@ -257,4 +256,3 @@ bool WebPage::authorizedRequest(const QUrl &url) const // TODO implement ad-block here return true; } - diff --git a/src/webpage.h b/src/webpage.h index fed877ae..eb558220 100644 --- a/src/webpage.h +++ b/src/webpage.h @@ -54,14 +54,14 @@ public: virtual bool authorizedRequest(const QUrl &url) const; public slots: - void manageNetworkErrors(QNetworkReply* reply); + void manageNetworkErrors(QNetworkReply *reply); protected: WebPage *createWindow(WebWindowType type); virtual bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, - NavigationType type);// + NavigationType type); protected Q_SLOTS: virtual void handleUnsupportedContent(QNetworkReply *reply); diff --git a/src/webview.cpp b/src/webview.cpp index 2c96f532..f38d363e 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -66,6 +66,9 @@ WebView::WebView(QWidget* parent) connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); connect(this, SIGNAL(linkMiddleOrCtrlClicked(const KUrl &)), this, SLOT(loadInNewTab(const KUrl &)) ); + + connect(this, SIGNAL(linkShiftClicked(const KUrl &)), this, SLOT(downloadRequest(const KUrl &))); + connect(page(), SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(downloadRequest(const QNetworkRequest &r))); } @@ -427,4 +430,15 @@ void WebView::loadInNewTab(const KUrl &url) { Application::instance()->loadUrl(url, Rekonq::NewCurrentTab); } - \ No newline at end of file + + +void WebView::downloadRequest(const KUrl &url) +{ + m_page->downloadRequest(QNetworkRequest(url)); +} + + +void WebView::downloadRequest(const QNetworkRequest &request) +{ + m_page->downloadRequest(request); +} diff --git a/src/webview.h b/src/webview.h index e4a0cc59..4fa87978 100644 --- a/src/webview.h +++ b/src/webview.h @@ -73,6 +73,9 @@ private slots: void loadInNewTab(const KUrl &url); + void downloadRequest(const KUrl &url); + void downloadRequest(const QNetworkRequest &request); + private: WebPage *m_page; int m_progress; -- cgit v1.2.1