diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/settings/adblockwidget.cpp | 36 | ||||
-rw-r--r-- | src/settings/adblockwidget.h | 10 | ||||
-rw-r--r-- | src/settings/networkwidget.cpp | 98 | ||||
-rw-r--r-- | src/settings/networkwidget.h | 63 | ||||
-rw-r--r-- | src/settings/settings_adblock.ui | 2 | ||||
-rw-r--r-- | src/settings/settingsdialog.cpp | 52 |
7 files changed, 226 insertions, 36 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f05bbbdb..7d0c1639 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,6 +35,7 @@ SET( rekonq_KDEINIT_SRCS #---------------------------------------- settings/settingsdialog.cpp settings/adblockwidget.cpp + settings/networkwidget.cpp #---------------------------------------- bookmarks/bookmarksmanager.cpp bookmarks/bookmarkspanel.cpp diff --git a/src/settings/adblockwidget.cpp b/src/settings/adblockwidget.cpp index 45e5fd5c..8aac3e8c 100644 --- a/src/settings/adblockwidget.cpp +++ b/src/settings/adblockwidget.cpp @@ -24,15 +24,19 @@ * ============================================================ */ +// Self Includes #include "adblockwidget.h" #include "adblockwidget.moc" +// Auto Includes #include "rekonq.h" +// KDE Includes #include <KSharedConfig> #include <KIcon> #include <KDebug> +// Qt Includes #include <QString> #include <QWhatsThis> #include <QListWidgetItem> @@ -40,6 +44,7 @@ AdBlockWidget::AdBlockWidget(QWidget *parent) : QWidget(parent) + , _changed(false) { setupUi(this); @@ -53,11 +58,18 @@ AdBlockWidget::AdBlockWidget(QWidget *parent) insertButton->setIcon( KIcon("list-add") ); connect( insertButton, SIGNAL( clicked() ), this, SLOT( insertRule() ) ); - + removeButton->setIcon( KIcon("list-remove") ); connect( removeButton, SIGNAL( clicked() ), this, SLOT( removeRule() ) ); load(); + + // emit changed signal + connect( insertButton, SIGNAL( clicked() ), this, SLOT( hasChanged() ) ); + connect( removeButton, SIGNAL( clicked() ), this, SLOT( hasChanged() ) ); + connect( checkEnableAdblock, SIGNAL( stateChanged(int) ), this, SLOT( hasChanged() ) ); + connect( checkHideAds, SIGNAL( stateChanged(int) ), this, SLOT( hasChanged() ) ); + connect( spinBox, SIGNAL( valueChanged(int) ), this, SLOT( hasChanged() ) ); } @@ -98,7 +110,10 @@ void AdBlockWidget::load() checkEnableAdblock->setChecked(isAdBlockEnabled); bool areImageFiltered = ReKonfig::hideAdsEnabled(); - checkHideImages->setChecked(areImageFiltered); + checkHideAds->setChecked(areImageFiltered); + + int days = ReKonfig::updateInterval(); + spinBox->setValue( days ); QStringList subscriptions = ReKonfig::subscriptionNames(); @@ -155,4 +170,21 @@ void AdBlockWidget::save() localRules << item->text(); } localGroup.writeEntry( "local-rules" , localRules ); + + ReKonfig::setAdBlockEnabled( checkEnableAdblock->isChecked() ); + ReKonfig::setHideAdsEnabled( checkHideAds->isChecked() ); + ReKonfig::setUpdateInterval( spinBox->value() ); +} + + +void AdBlockWidget::hasChanged() +{ + _changed = true; + emit changed(true); +} + + +bool AdBlockWidget::changed() +{ + return _changed; } diff --git a/src/settings/adblockwidget.h b/src/settings/adblockwidget.h index 67061800..7e641f3e 100644 --- a/src/settings/adblockwidget.h +++ b/src/settings/adblockwidget.h @@ -28,8 +28,10 @@ #define ADBLOCK_WIDGET_H +// Ui Includes #include "ui_settings_adblock.h" +// Qt Includes #include <QWidget> #include <QTreeWidgetItem> @@ -42,8 +44,14 @@ public: AdBlockWidget(QWidget *parent = 0); void save(); + bool changed(); + +signals: + void changed(bool); private slots: + void hasChanged(); + void slotInfoLinkActivated(const QString &); void insertRule(); void removeRule(); @@ -51,6 +59,8 @@ private slots: private: void load(); void loadRules(QTreeWidgetItem *item); + + bool _changed; }; #endif // ADBLOCK_WIDGET_H diff --git a/src/settings/networkwidget.cpp b/src/settings/networkwidget.cpp new file mode 100644 index 00000000..2f5948cf --- /dev/null +++ b/src/settings/networkwidget.cpp @@ -0,0 +1,98 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2010 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 "networkwidget.h" +#include "networkwidget.moc" + +// KDE Includes +#include <KTabWidget> +#include <KCModuleInfo> +#include <KDebug> + +// Qt Includes +#include <QVBoxLayout> + + +NetworkWidget::NetworkWidget(QWidget *parent) + : QWidget(parent) + , _cacheModule(0) + , _cookiesModule(0) + , _proxyModule(0) + , _changed(false) +{ + QVBoxLayout *l = new QVBoxLayout(this); + l->setMargin(0); + l->setSpacing(0); + + KTabWidget *tabWidget = new KTabWidget(this); + l->addWidget(tabWidget); + + KCModuleInfo cacheInfo("cache.desktop"); + _cacheModule = new KCModuleProxy(cacheInfo,parent); + tabWidget->addTab( _cacheModule, i18n(cacheInfo.moduleName().toLocal8Bit()) ); + + KCModuleInfo cookiesInfo("cookies.desktop"); + _cookiesModule = new KCModuleProxy(cookiesInfo,parent); + tabWidget->addTab( _cookiesModule, i18n(cookiesInfo.moduleName().toLocal8Bit()) ); + + KCModuleInfo proxyInfo("proxy.desktop"); + _proxyModule = new KCModuleProxy(proxyInfo,parent); + tabWidget->addTab( _proxyModule, i18n(proxyInfo.moduleName().toLocal8Bit()) ); + + connect(_cacheModule, SIGNAL( changed(bool) ), this, SLOT( hasChanged() ) ); + connect(_cookiesModule, SIGNAL( changed(bool) ), this, SLOT( hasChanged() ) ); + connect(_proxyModule, SIGNAL( changed(bool) ), this, SLOT( hasChanged() ) ); +} + + +NetworkWidget::~NetworkWidget() +{ + delete _cacheModule; + delete _cookiesModule; + delete _proxyModule; +} + + +void NetworkWidget::save() +{ + _cookiesModule->save(); + _proxyModule->save(); + _cacheModule->save(); +} + + +void NetworkWidget::hasChanged() +{ + _changed = true; + emit changed(true); +} + + +bool NetworkWidget::changed() +{ + return _changed; +} diff --git a/src/settings/networkwidget.h b/src/settings/networkwidget.h new file mode 100644 index 00000000..efdd1807 --- /dev/null +++ b/src/settings/networkwidget.h @@ -0,0 +1,63 @@ +/* ============================================================ +* +* This file is a part of the rekonq project +* +* Copyright (C) 2010 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/>. +* +* ============================================================ */ + + +#ifndef NETWORK_WIDGET_H +#define NETWORK_WIDGET_H + + +// KDE Includes +#include <KCModuleProxy> + +// Qt Includes +#include <QWidget> + + +class NetworkWidget : public QWidget +{ +Q_OBJECT + +public: + NetworkWidget(QWidget *parent = 0); + ~NetworkWidget(); + + void save(); + bool changed(); + +signals: + void changed(bool); + +private slots: + void hasChanged(); + +private: + KCModuleProxy *_cacheModule; + KCModuleProxy *_cookiesModule; + KCModuleProxy *_proxyModule; + + bool _changed; +}; + +#endif // NETWORK_WIDGET_H diff --git a/src/settings/settings_adblock.ui b/src/settings/settings_adblock.ui index 28e1f973..445431c5 100644 --- a/src/settings/settings_adblock.ui +++ b/src/settings/settings_adblock.ui @@ -22,7 +22,7 @@ </widget> </item> <item> - <widget class="QCheckBox" name="checkHideImages"> + <widget class="QCheckBox" name="checkHideAds"> <property name="text"> <string>&Hide filtered Elements</string> </property> diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp index fa1e8891..08d5ca6e 100644 --- a/src/settings/settingsdialog.cpp +++ b/src/settings/settingsdialog.cpp @@ -37,13 +37,13 @@ #include "mainwindow.h" #include "webtab.h" #include "adblockwidget.h" +#include "networkwidget.h" //Ui Includes #include "ui_settings_general.h" #include "ui_settings_tabs.h" #include "ui_settings_fonts.h" #include "ui_settings_webkit.h" -#include "ui_settings_adblock.h" // KDE Includes #include <KConfig> @@ -67,11 +67,9 @@ private: Ui::webkit webkitUi; AdBlockWidget *adBlockWidg; + NetworkWidget *networkWidg; - KCModuleProxy *proxyModule; KCModuleProxy *ebrowsingModule; - KCModuleProxy *cookiesModule; - KCModuleProxy *cacheModule; KShortcutsEditor *shortcutsEditor; @@ -103,21 +101,6 @@ Private::Private(SettingsDialog *parent) 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); @@ -127,6 +110,11 @@ Private::Private(SettingsDialog *parent) KIcon webkitIcon = KIcon(QIcon(webkitIconPath)); pageItem->setIcon(webkitIcon); + networkWidg = new NetworkWidget(parent); + networkWidg->layout()->setMargin(0); + pageItem = parent->addPage(networkWidg , i18n("Network")); + pageItem->setIcon( KIcon("preferences-system-network") ); + adBlockWidg = new AdBlockWidget(parent); adBlockWidg->layout()->setMargin(0); pageItem = parent->addPage(adBlockWidg , i18n("Ad Block")); @@ -162,15 +150,16 @@ SettingsDialog::SettingsDialog(QWidget *parent) connect(d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT(setHomeToCurrentPage())); + // update buttons + connect(d->adBlockWidg, SIGNAL(changed(bool)), this, SLOT(updateButtons())); + connect(d->networkWidg, SIGNAL(changed(bool)), this, SLOT(updateButtons())); 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(d->shortcutsEditor, SIGNAL(keyChange()), this, SLOT(updateButtons())); + + // save settings connect(this, SIGNAL(applyClicked()), this, SLOT(saveSettings())); - connect(this, SIGNAL(okClicked()), this, SLOT(saveSettings())); + connect(this, SIGNAL(okClicked()), this, SLOT(saveSettings())); setWebSettingsToolTips(); } @@ -212,21 +201,18 @@ void SettingsDialog::saveSettings() { ReKonfig::self()->writeConfig(); d->ebrowsingModule->save(); - d->cookiesModule->save(); - d->proxyModule->save(); - d->cacheModule->save(); d->shortcutsEditor->save(); d->adBlockWidg->save(); + d->networkWidg->save(); } bool SettingsDialog::hasChanged() { return KConfigDialog::hasChanged() - || d->ebrowsingModule->changed() - || d->cookiesModule->changed() - || d->proxyModule->changed() - || d->cacheModule->changed() + || d->adBlockWidg->changed() + || d->networkWidg->changed() + || d->ebrowsingModule->changed() || d->shortcutsEditor->isModified(); ; } |