diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2009-01-19 02:26:13 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2009-01-19 02:26:13 +0100 |
commit | 76d30285358bedd8b2fc6caf48d2a871f7546685 (patch) | |
tree | 28ee333ad33eeeb4f6edd9f647702fc2522db122 | |
parent | m_tabWidget --> m_view (diff) | |
download | rekonq-76d30285358bedd8b2fc6caf48d2a871f7546685.tar.xz |
Ported tons of code to KConfigXT. To merge kcfg branch we need just to
port cookie settings..
-rw-r--r-- | src/cookiejar.cpp | 57 | ||||
-rw-r--r-- | src/cookiejar.h | 15 | ||||
-rw-r--r-- | src/history.cpp | 29 | ||||
-rw-r--r-- | src/history.h | 2 | ||||
-rw-r--r-- | src/mainwindow.cpp | 33 | ||||
-rw-r--r-- | src/mainwindow.h | 3 | ||||
-rw-r--r-- | src/networkaccessmanager.cpp | 30 | ||||
-rw-r--r-- | src/rekonq.kcfg | 11 | ||||
-rw-r--r-- | src/settings.cpp | 267 | ||||
-rw-r--r-- | src/settings.h | 11 | ||||
-rw-r--r-- | src/settings_fonts.ui | 4 | ||||
-rw-r--r-- | src/settings_general.ui | 2 | ||||
-rw-r--r-- | src/webview.cpp | 20 |
13 files changed, 138 insertions, 346 deletions
diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp index 87d84def..ef829ffd 100644 --- a/src/cookiejar.cpp +++ b/src/cookiejar.cpp @@ -18,9 +18,14 @@ * * ============================================================ */ +// Self Includes +#include "cookiejar.h" +#include "cookiejar.moc" + +// Auto Includes +#include "rekonq.h" // Local Includes -#include "cookiejar.h" #include "autosaver.h" // KDE Includes @@ -46,6 +51,7 @@ QDataStream &operator<<(QDataStream &stream, const QList<QNetworkCookie> &list) return stream; } + QDataStream &operator>>(QDataStream &stream, QList<QNetworkCookie> &list) { list.clear(); @@ -76,6 +82,7 @@ QDataStream &operator>>(QDataStream &stream, QList<QNetworkCookie> &list) } QT_END_NAMESPACE + CookieJar::CookieJar(QObject *parent) : QNetworkCookieJar(parent) , m_loaded(false) @@ -84,6 +91,7 @@ CookieJar::CookieJar(QObject *parent) { } + CookieJar::~CookieJar() { if (m_keepCookies == KeepUntilExit) @@ -91,6 +99,7 @@ CookieJar::~CookieJar() m_saveTimer->saveIfNeccessary(); } + void CookieJar::clear() { setAllCookies(QList<QNetworkCookie>()); @@ -98,6 +107,7 @@ void CookieJar::clear() emit cookiesChanged(); } + void CookieJar::load() { if (m_loaded) @@ -130,6 +140,7 @@ void CookieJar::load() loadSettings(); } + void CookieJar::loadSettings() { KConfig config("rekonqrc"); @@ -153,6 +164,7 @@ void CookieJar::loadSettings() emit cookiesChanged(); } + void CookieJar::save() { if (!m_loaded) @@ -200,6 +212,7 @@ void CookieJar::save() group.writeEntry( QString("keepCookiesUntil"), QString( keepPolicyEnum.valueToKey(m_keepCookies) ) ); } + void CookieJar::purgeOldCookies() { QList<QNetworkCookie> cookies = allCookies(); @@ -218,6 +231,7 @@ void CookieJar::purgeOldCookies() emit cookiesChanged(); } + QList<QNetworkCookie> CookieJar::cookiesForUrl(const QUrl &url) const { CookieJar *that = const_cast<CookieJar*>(this); @@ -234,6 +248,7 @@ QList<QNetworkCookie> CookieJar::cookiesForUrl(const QUrl &url) const return QNetworkCookieJar::cookiesForUrl(url); } + bool CookieJar::setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const QUrl &url) { if (!m_loaded) @@ -297,7 +312,6 @@ bool CookieJar::setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const } - CookieJar::AcceptPolicy CookieJar::acceptPolicy() const { if (!m_loaded) @@ -306,7 +320,6 @@ CookieJar::AcceptPolicy CookieJar::acceptPolicy() const } - void CookieJar::setAcceptPolicy(AcceptPolicy policy) { if (!m_loaded) @@ -318,7 +331,6 @@ void CookieJar::setAcceptPolicy(AcceptPolicy policy) } - CookieJar::KeepPolicy CookieJar::keepPolicy() const { if (!m_loaded) @@ -327,7 +339,6 @@ CookieJar::KeepPolicy CookieJar::keepPolicy() const } - void CookieJar::setKeepPolicy(KeepPolicy policy) { if (!m_loaded) @@ -339,7 +350,6 @@ void CookieJar::setKeepPolicy(KeepPolicy policy) } - QStringList CookieJar::blockedCookies() const { if (!m_loaded) @@ -348,7 +358,6 @@ QStringList CookieJar::blockedCookies() const } - QStringList CookieJar::allowedCookies() const { if (!m_loaded) @@ -357,7 +366,6 @@ QStringList CookieJar::allowedCookies() const } - QStringList CookieJar::allowForSessionCookies() const { if (!m_loaded) @@ -366,7 +374,6 @@ QStringList CookieJar::allowForSessionCookies() const } - void CookieJar::setBlockedCookies(const QStringList &list) { if (!m_loaded) @@ -377,7 +384,6 @@ void CookieJar::setBlockedCookies(const QStringList &list) } - void CookieJar::setAllowedCookies(const QStringList &list) { if (!m_loaded) @@ -388,7 +394,6 @@ void CookieJar::setAllowedCookies(const QStringList &list) } - void CookieJar::setAllowForSessionCookies(const QStringList &list) { if (!m_loaded) @@ -399,9 +404,7 @@ void CookieJar::setAllowForSessionCookies(const QStringList &list) } - -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - +// ------------------------------------------------------------------------------------------- CookieModel::CookieModel(CookieJar *cookieJar, QObject *parent) @@ -412,6 +415,7 @@ CookieModel::CookieModel(CookieJar *cookieJar, QObject *parent) m_cookieJar->load(); } + QVariant CookieModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role == Qt::SizeHintRole) { @@ -447,6 +451,7 @@ QVariant CookieModel::headerData(int section, Qt::Orientation orientation, int r return QAbstractTableModel::headerData(section, orientation, role); } + QVariant CookieModel::data(const QModelIndex &index, int role) const { QList<QNetworkCookie> lst; @@ -484,16 +489,19 @@ QVariant CookieModel::data(const QModelIndex &index, int role) const return QVariant(); } + int CookieModel::columnCount(const QModelIndex &parent) const { return (parent.isValid()) ? 0 : 6; } + int CookieModel::rowCount(const QModelIndex &parent) const { return (parent.isValid() || !m_cookieJar) ? 0 : m_cookieJar->allCookies().count(); } + bool CookieModel::removeRows(int row, int count, const QModelIndex &parent) { if (parent.isValid() || !m_cookieJar) @@ -509,6 +517,7 @@ bool CookieModel::removeRows(int row, int count, const QModelIndex &parent) return true; } + void CookieModel::cookiesChanged() { reset(); @@ -516,8 +525,7 @@ void CookieModel::cookiesChanged() -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - +// ------------------------------------------------------------------------------------------------ CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) @@ -566,9 +574,7 @@ CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) } - -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - +// --------------------------------------------------------------------------------------------------- CookieExceptionsModel::CookieExceptionsModel(CookieJar *cookiejar, QObject *parent) @@ -580,6 +586,7 @@ CookieExceptionsModel::CookieExceptionsModel(CookieJar *cookiejar, QObject *pare m_sessionCookies = m_cookieJar->allowForSessionCookies(); } + QVariant CookieExceptionsModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role == Qt::SizeHintRole) { @@ -603,6 +610,7 @@ QVariant CookieExceptionsModel::headerData(int section, Qt::Orientation orientat return QAbstractTableModel::headerData(section, orientation, role); } + QVariant CookieExceptionsModel::data(const QModelIndex &index, int role) const { if (index.row() < 0 || index.row() >= rowCount()) @@ -648,16 +656,19 @@ QVariant CookieExceptionsModel::data(const QModelIndex &index, int role) const return QVariant(); } + int CookieExceptionsModel::columnCount(const QModelIndex &parent) const { return (parent.isValid()) ? 0 : 2; } + int CookieExceptionsModel::rowCount(const QModelIndex &parent) const { return (parent.isValid() || !m_cookieJar) ? 0 : m_allowedCookies.count() + m_blockedCookies.count() + m_sessionCookies.count(); } + bool CookieExceptionsModel::removeRows(int row, int count, const QModelIndex &parent) { if (parent.isValid() || !m_cookieJar) @@ -689,9 +700,7 @@ bool CookieExceptionsModel::removeRows(int row, int count, const QModelIndex &pa } - -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - +// ---------------------------------------------------------------------------------------------------------------- CookiesExceptionsDialog::CookiesExceptionsDialog(CookieJar *cookieJar, QWidget *parent) @@ -746,6 +755,7 @@ CookiesExceptionsDialog::CookiesExceptionsDialog(CookieJar *cookieJar, QWidget * } } + void CookiesExceptionsDialog::textChanged(const QString &text) { bool enabled = !text.isEmpty(); @@ -754,6 +764,7 @@ void CookiesExceptionsDialog::textChanged(const QString &text) allowForSessionButton->setEnabled(enabled); } + void CookiesExceptionsDialog::block() { if (domainLineEdit->text().isEmpty()) @@ -763,6 +774,7 @@ void CookiesExceptionsDialog::block() m_exceptionsModel->reset(); } + void CookiesExceptionsDialog::allow() { if (domainLineEdit->text().isEmpty()) @@ -772,6 +784,7 @@ void CookiesExceptionsDialog::allow() m_exceptionsModel->reset(); } + void CookiesExceptionsDialog::allowForSession() { if (domainLineEdit->text().isEmpty()) diff --git a/src/cookiejar.h b/src/cookiejar.h index 835700f1..d4868f21 100644 --- a/src/cookiejar.h +++ b/src/cookiejar.h @@ -25,7 +25,6 @@ // KDE Includes #include <QDialog> - // Qt Includes #include <QNetworkCookieJar> #include <QAbstractItemModel> @@ -109,9 +108,7 @@ private: }; - - // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - +// ------------------------------------------------------------------------------------------------------------- class CookieModel : public QAbstractTableModel @@ -134,9 +131,7 @@ private: }; - -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - +// ---------------------------------------------------------------------------------------------------------------------- #include "ui_cookies.h" @@ -175,10 +170,7 @@ private: }; - - -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - +// ----------------------------------------------------------------------------------------------------------------- #include "ui_cookiesexceptions.h" @@ -203,4 +195,3 @@ private: }; #endif // COOKIEJAR_H - diff --git a/src/history.cpp b/src/history.cpp index dedabfdd..652ee962 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -22,12 +22,14 @@ #include "history.h" #include "history.moc" +// Auto Includes +#include "rekonq.h" + // Local Includes #include "autosaver.h" #include "browserapplication.h" // KDE Includes -#include <KConfig> #include <KDebug> // Qt Includes @@ -219,10 +221,19 @@ void HistoryManager::clear() void HistoryManager::loadSettings() { - // load settings - KConfig config("rekonqrc"); - KConfigGroup group = config.group("history"); - m_historyLimit = group.readEntry( QString("historyLimit"), 30 ); + int historyExpire = ReKonfig::expireHistory(); + int days; + switch (historyExpire) + { + case 0: days = 1; break; + case 1: days = 7; break; + case 2: days = 14; break; + case 3: days = 30; break; + case 4: days = 365; break; + case 5: days = -1; break; + default: days = -1; + } + m_historyLimit = days; } @@ -297,9 +308,9 @@ void HistoryManager::load() void HistoryManager::save() { - KConfig config("rekonqrc"); - KConfigGroup group = config.group("history"); - group.writeEntry( QString("historyLimit"), m_historyLimit ); +// KConfig config("rekonqrc"); +// KConfigGroup group = config.group("history"); +// group.writeEntry( QString("historyLimit"), m_historyLimit ); bool saveAll = m_lastSavedUrl.isEmpty(); int first = m_history.count() - 1; @@ -369,7 +380,7 @@ void HistoryManager::save() } -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +// -------------------------------------------------------------------------------------------------------------------------- HistoryModel::HistoryModel(HistoryManager *history, QObject *parent) diff --git a/src/history.h b/src/history.h index f3813855..a6b68ffb 100644 --- a/src/history.h +++ b/src/history.h @@ -64,7 +64,7 @@ public: -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +// --------------------------------------------------------------------------------------------------------------- class AutoSaver; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bdf2120d..629899e4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -66,7 +66,8 @@ MainWindow::MainWindow() setAcceptDrops(true); // updating rekonq configuration - updateConfiguration(); + slotUpdateConf(); +// QTimer::singleShot(0, this, SLOT( postLaunch() ) ); // creating a new tab m_view->newTab(); @@ -118,7 +119,6 @@ MainWindow::MainWindow() // Find Bar m_findBar = new FindBar( this ); connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) ); - } @@ -282,28 +282,11 @@ void MainWindow::setupCustomMenu() // TODO FIXME -void MainWindow::updateConfiguration() +void MainWindow::slotUpdateConf() { // ============== General ================== m_homePage = ReKonfig::homePage(); -// int historyExpire = ReKonfig::expireHistory(); -// int days; -// switch (historyExpire) -// { -// case 0: days = 1; break; -// case 1: days = 7; break; -// case 2: days = 14; break; -// case 3: days = 30; break; -// case 4: days = 365; break; -// case 5: days = -1; break; -// default: days = -1; -// } -// m_historyExpire = days; -// -// m_downloadDir = ReKonfig::downloadDir(); - - // =========== Fonts ============== QFont standardFont = ReKonfig::standardFont(); QFont fixedFont = ReKonfig::fixedFont(); @@ -454,7 +437,17 @@ void MainWindow::slotFileSaveAs() void MainWindow::slotPreferences() { + // an instance the dialog could be already created and could be cached, + // in which case you want to display the cached dialog + if ( SettingsDialog::showDialog( "settings" ) ) + return; + + // we didn't find an instance of this dialog, so lets create it SettingsDialog *s = new SettingsDialog(this); + + // keep us informed when the user changes settings + connect( s, SIGNAL(settingsChanged(const QString&)), this, SLOT(slotUpdateConf()) ); + s->show(); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 816597ee..86a3e30d 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -65,12 +65,11 @@ private: void setupTabBar(); public slots: - void updateConfiguration(); - void slotHome(); void loadUrl(const KUrl &url); private slots: + void slotUpdateConf(); void slotLoadProgress(int); void slotUpdateStatusbar(const QString &string); void slotUpdateWindowTitle(const QString &title = QString()); diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 7390cd22..1d601440 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -18,17 +18,22 @@ * * ============================================================ */ +// Self Includes +#include "networkaccessmanager.h" +#include "networkaccessmanager.moc" // Local Includes -#include "networkaccessmanager.h" #include "browserapplication.h" #include "mainwindow.h" +// Auto Includes +#include "rekonq.h" + +// Ui Includes #include "ui_passworddialog.h" #include "ui_proxy.h" // KDE Includes -#include <KConfig> #include <KMessageBox> // Qt Includes @@ -58,13 +63,10 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) void NetworkAccessManager::loadSettings() { - KConfig config("rekonqrc"); - KConfigGroup group = config.group("proxy"); - QNetworkProxy proxy; - if ( group.readEntry( QString("enabled"), false) ) + if ( ReKonfig::enableProxy() ) { - if ( group.readEntry( QString("type"), 0) == 0 ) + if ( ReKonfig::proxyType() == 0 ) { proxy.setType(QNetworkProxy::Socks5Proxy); } @@ -72,10 +74,10 @@ void NetworkAccessManager::loadSettings() { proxy.setType(QNetworkProxy::HttpProxy); } - proxy.setHostName( group.readEntry( QString("hostName"), QString() ) ); - proxy.setPort( group.readEntry( QString("port"), 1080 ) ); - proxy.setUser( group.readEntry( QString("userName"), QString() ) ); - proxy.setPassword( group.readEntry( QString("password"), QString() ) ); + proxy.setHostName( ReKonfig::proxyHostName() ); + proxy.setPort( ReKonfig::proxyPort() ); + proxy.setUser( ReKonfig::proxyUserName() ); + proxy.setPassword( ReKonfig::proxyPassword() ); } setProxy(proxy); } @@ -95,7 +97,8 @@ void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthent passwordDialog.iconLabel->setText(QString()); passwordDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32)); - QString introMessage = i18n("<qt>Enter username and password for ") + Qt::escape(reply->url().toString()) + i18n(" at ") + Qt::escape(reply->url().toString()) + "</qt>"; + QString introMessage = i18n("<qt>Enter username and password for ") + + Qt::escape(reply->url().toString()) + i18n(" at ") + Qt::escape(reply->url().toString()) + "</qt>"; passwordDialog.introLabel->setText(introMessage); passwordDialog.introLabel->setWordWrap(true); @@ -139,8 +142,7 @@ void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QList<QSslError for (int i = 0; i < error.count(); ++i) errorStrings += error.at(i).errorString(); QString errors = errorStrings.join(QLatin1String("\n")); - int ret = KMessageBox::warningYesNo( mainWindow, - i18n("SSL Errors:\n\n") + reply->url().toString() + "\n\n" + QString(errors) + "\n\n"); + int ret = KMessageBox::warningYesNo( mainWindow, i18n("SSL Errors:\n\n") + reply->url().toString() + "\n\n" + QString(errors) + "\n\n"); if (ret == KMessageBox::Yes) reply->ignoreSslErrors(); } diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index 4e91847b..f55f8d67 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -11,7 +11,7 @@ <!-- General Settings --> <group name="General"> - <entry name="homePage" type="Path"> + <entry name="homePage" type="String"> <default>http://www.kde.org/</default> </entry> <entry name="downloadDir" type="Path"> @@ -53,20 +53,17 @@ <entry name="enableProxy" type="Bool"> <default>false</default> </entry> - <entry name="proxyType" type="String"> - <default>Socks5</default> + <entry name="proxyType" type="Int"> + <default>0</default> </entry> <entry name="proxyHostName" type="String"> - <default></default> </entry> <entry name="proxyPort" type="Int"> - <default>1080</default> + <default>8080</default> </entry> <entry name="proxyUserName" type="String"> - <default></default> </entry> <entry name="proxyPassword" type="Password"> - <default></default> </entry> </group> diff --git a/src/settings.cpp b/src/settings.cpp index c06cbc85..462874f9 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -76,7 +76,6 @@ Private::Private(SettingsDialog *parent) widget->layout()->setMargin(0); pageItem = parent->addPage( widget , i18n("General") ); pageItem->setIcon( KIcon("rekonq") ); - generalUi.kcfg_downloadDir->setMode( KFile::Directory ); widget = new QWidget; fontsUi.setupUi( widget ); @@ -104,15 +103,12 @@ SettingsDialog::SettingsDialog(QWidget *parent) , d(new Private(this) ) { setFaceType(KPageDialog::List); - setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply); showButtonSeparator(true); setWindowTitle( i18n("rekonfig..") ); setModal(true); - connect(this, SIGNAL(settingsChanged(const QString&)), parent, SLOT(updateConfiguration())); -// connect(this, SIGNAL(settingsChanged(const QString&)), this, SLOT(loadFromSettings())); - + readConfig(); connect( d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT( setHomeToCurrentPage() ) ); connect( d->privacyUi.exceptionsButton, SIGNAL(clicked()), this, SLOT( showExceptions() ) ); @@ -126,205 +122,35 @@ SettingsDialog::~SettingsDialog() delete d; } +// we need this function to UPDATE the config widget data.. +void SettingsDialog::readConfig() +{ + // ======= General + d->generalUi.downloadDirUrlRequester->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly); + d->generalUi.downloadDirUrlRequester->setUrl( ReKonfig::downloadDir() ); + connect(d->generalUi.downloadDirUrlRequester, SIGNAL(textChanged(QString)),this, SLOT(saveSettings())); + + // ======= Fonts + d->fontsUi.standardFontChooser->setFont(ReKonfig::standardFont(), false); + connect(d->fontsUi.standardFontChooser, SIGNAL(fontSelected(QFont)),this, SLOT(saveSettings())); + d->fontsUi.fixedFontChooser->setFont(ReKonfig::fixedFont(), true); + connect(d->fontsUi.fixedFontChooser, SIGNAL(fontSelected(QFont)),this, SLOT(saveSettings())); +} + -//void SettingsDialog::loadDefaults() -//{ -// QWebSettings *defaultSettings = QWebSettings::globalSettings(); -// QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont); -// int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize); -// m_standardFont = QFont(standardFontFamily, standardFontSize); -// d->fontsUi.standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() )); -// -// QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont); -// int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize); -// m_fixedFont = QFont(fixedFontFamily, fixedFontSize); -// d->fontsUi.fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() )); -// -// d->generalUi.kurlrequester->setUrl( KUrl( "~" ) ); // QDesktopServices::storageLocation(QDesktopServices::DesktopLocation) ); -// -// d->privacyUi.enableJavascript->setChecked(defaultSettings->testAttribute(QWebSettings::JavascriptEnabled)); -// d->privacyUi.enablePlugins->setChecked(defaultSettings->testAttribute(QWebSettings::PluginsEnabled)); -// } -// -// - -/*void SettingsDialog::loadFromSettings() +// we need this function to SAVE settings in rc file.. +void SettingsDialog::saveSettings() { - KConfig config("rekonqrc"); -// KConfigGroup group1 = config.group("Global Settings"); -// -// QString defaultHome = QString("http://www.kde.org"); -// d->generalUi.homeLineEdit->setText( group1.readEntry(QString("home"), defaultHome) ); -// -// int historyExpire = group1.readEntry( QString("historyExpire"), QString().toInt() ); -// int idx = 0; -// switch (historyExpire) -// { -// case 1: idx = 0; break; -// case 7: idx = 1; break; -// case 14: idx = 2; break; -// case 30: idx = 3; break; -// case 365: idx = 4; break; -// case -1: idx = 5; break; -// default: idx = 5; -// } -// d->generalUi.expireHistory->setCurrentIndex(idx); -// -// QString downloadDirectory = group1.readEntry( QString("downloadDirectory") , QString() ); -// d->generalUi.kurlrequester->setUrl( KUrl(downloadDirectory) ); -// -// d->generalUi.openLinksIn->setCurrentIndex( group1.readEntry( QString("openLinksIn"), d->generalUi.openLinksIn->currentIndex() ) ); -// -// - - // ===== Fonts - KConfigGroup fontsGroup = config.group("Fonts Settings"); - - m_standardFont = fontsGroup.readEntry( QString("standardFont"), m_standardFont ); - d->fontsUi.kcfg_standardFont->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() ) ); - - m_fixedFont = fontsGroup.readEntry( QString("fixedFont"), m_fixedFont ); - d->fontsUi.kcfg_fixedFont->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() ) ); -// -// // Privacy -// KConfigGroup group3 = config.group("Privacy Settings"); -// -// d->privacyUi.enableJavascript->setChecked( group3.readEntry( QString("enableJavascript"), d->privacyUi.enableJavascript->isChecked() ) ); -// d->privacyUi.enablePlugins->setChecked( group3.readEntry( QString("enablePlugins"), d->privacyUi.enablePlugins->isChecked() ) ); -// -// CookieJar *jar = BrowserApplication::cookieJar(); -// QString value = group3.readEntry( QString("acceptCookies"), QString("AcceptOnlyFromSitesNavigatedTo") ) ; -// QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy")); -// CookieJar::AcceptPolicy acceptCookies = acceptPolicyEnum.keyToValue( value.toLocal8Bit() ) == -1 ? -// CookieJar::AcceptOnlyFromSitesNavigatedTo : -// static_cast<CookieJar::AcceptPolicy>(acceptPolicyEnum.keyToValue( value.toLocal8Bit() ) ); -// switch(acceptCookies) -// { -// case CookieJar::AcceptAlways: -// d->privacyUi.acceptCombo->setCurrentIndex(0); -// break; -// case CookieJar::AcceptNever: -// d->privacyUi.acceptCombo->setCurrentIndex(1); -// break; -// case CookieJar::AcceptOnlyFromSitesNavigatedTo: -// d->privacyUi.acceptCombo->setCurrentIndex(2); -// break; -// } -// -// value = group3.readEntry( QString("keepCookiesUntil"), QString("Expire") ); -// QMetaEnum keepPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("KeepPolicy")); -// CookieJar::KeepPolicy keepCookies = keepPolicyEnum.keyToValue( value.toLocal8Bit() ) == -1 ? -// CookieJar::KeepUntilExpire : -// static_cast<CookieJar::KeepPolicy>(keepPolicyEnum.keyToValue( value.toLocal8Bit() ) ); -// switch(keepCookies) -// { -// case CookieJar::KeepUntilExpire: -// d->privacyUi.keepUntilCombo->setCurrentIndex(0); -// break; -// case CookieJar::KeepUntilExit: -// d->privacyUi.keepUntilCombo->setCurrentIndex(1); -// break; -// case CookieJar::KeepUntilTimeLimit: -// d->privacyUi.keepUntilCombo->setCurrentIndex(2); -// break; -// } -// -// // Proxy -// KConfigGroup group4 = config.group("Proxy Settings"); -// -// d->proxyUi.proxySupport->setChecked( group4.readEntry( QString("enabled"), false ) ); -// d->proxyUi.proxyType->setCurrentIndex( group4.readEntry( QString("type"), 0) ); -// d->proxyUi.proxyHostName->setText( group4.readEntry( QString("hostName"), QString() ) ); -// d->proxyUi.proxyPort->setValue( group4.readEntry( QString("port"), QString().toInt() ) ); -// d->proxyUi.proxyUserName->setText( group4.readEntry( QString("userName") , QString() ) ); -// d->proxyUi.proxyPassword->setText( group4.readEntry( QString("password") , QString() ) ); -// -}*/ -// -// -// void SettingsDialog::saveToSettings() -// { -// KConfig config("rekonqrc"); -// KConfigGroup group1 = config.group("Global Settings"); -// -// group1.writeEntry(QString("home"), d->generalUi.homeLineEdit->text() ); -// group1.writeEntry(QString("openLinksIn"), d->generalUi.openLinksIn->currentIndex() ); -// group1.writeEntry(QString("downloadDirectory"), d->generalUi.kurlrequester->url().path() ); -// -// int historyExpire = d->generalUi.expireHistory->currentIndex(); -// int idx = -1; -// switch (historyExpire) -// { -// case 0: idx = 1; break; -// case 1: idx = 7; break; -// case 2: idx = 14; break; -// case 3: idx = 30; break; -// case 4: idx = 365; break; -// case 5: idx = -1; break; -// } -// group1.writeEntry(QString("historyExpire"), idx ); -// -// KConfigGroup group2 = config.group("Fonts Settings"); -// group2.writeEntry(QString("fixedFont"), m_fixedFont); -// group2.writeEntry(QString("standardFont"), m_standardFont); -// -// KConfigGroup group3 = config.group("Privacy Settings"); -// group3.writeEntry(QString("enableJavascript"), d->privacyUi.enableJavascript->isChecked() ); -// group3.writeEntry(QString("enablePlugins"), d->privacyUi.enablePlugins->isChecked() ); -// -// CookieJar::KeepPolicy keepCookies; -// switch( d->privacyUi.acceptCombo->currentIndex() ) -// { -// default: -// case 0: -// keepCookies = CookieJar::KeepUntilExpire; -// break; -// case 1: -// keepCookies = CookieJar::KeepUntilExit; -// break; -// case 2: -// keepCookies = CookieJar::KeepUntilTimeLimit; -// break; -// } -// CookieJar *jar = BrowserApplication::cookieJar(); -// QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy")); -// group3.writeEntry(QString("acceptCookies"), QString(acceptPolicyEnum.valueToKey(keepCookies) ) ); -// -// CookieJar::KeepPolicy keepPolicy; -// switch( d->privacyUi.keepUntilCombo->currentIndex() ) -// { -// default: -// case 0: -// keepPolicy = CookieJar::KeepUntilExpire; -// break; -// case 1: -// keepPolicy = CookieJar::KeepUntilExit; -// break; -// case 2: -// keepPolicy = CookieJar::KeepUntilTimeLimit; -// break; -// } -// -// QMetaEnum keepPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("KeepPolicy")); -// group3.writeEntry(QString("keepCookiesUntil"), QString(keepPolicyEnum.valueToKey(keepPolicy) ) ); -// -// -// KConfigGroup group4 = config.group("Proxy Settings"); -// group4.writeEntry(QString("enabled"), d->proxyUi.proxySupport->isChecked() ); -// group4.writeEntry(QString("type"), d->proxyUi.proxyType->currentIndex() ); -// group4.writeEntry(QString("hostName"), d->proxyUi.proxyHostName->text() ); -// group4.writeEntry(QString("port"), d->proxyUi.proxyPort->text() ); -// group4.writeEntry(QString("userName"), d->proxyUi.proxyUserName->text() ); -// group4.writeEntry(QString("password"), d->proxyUi.proxyPassword->text() ); -// -// config.sync(); -// -// // --- -// BrowserApplication::instance()->loadSettings(); -// BrowserApplication::networkAccessManager()->loadSettings(); -// BrowserApplication::cookieJar()->loadSettings(); -// BrowserApplication::historyManager()->loadSettings(); -// } + // General + ReKonfig::setDownloadDir( d->generalUi.downloadDirUrlRequester->url().prettyUrl() ); + + // Fonts + ReKonfig::setStandardFont( d->fontsUi.standardFontChooser->font() ); + ReKonfig::setFixedFont( d->fontsUi.standardFontChooser->font() ); +} + + +// ---------------------------------------------------------------------------------------------- void SettingsDialog::showCookies() @@ -341,31 +167,6 @@ void SettingsDialog::showExceptions() } -// void SettingsDialog::chooseStandardFont() -// { -// QFont myFont( m_standardFont ); -// int result = KFontDialog::getFont( myFont ); -// if ( result == KFontDialog::Accepted ) -// { -// m_standardFont = myFont; -// d->fontsUi.kcfg_standardFont->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() ) ); -// } -// } -// -// -// void SettingsDialog::chooseFixedFont() -// { -// -// QFont myFont( m_fixedFont ); -// int result = KFontDialog::getFont( myFont , KFontChooser::FixedFontsOnly ); -// if ( result == KFontDialog::Accepted ) -// { -// m_fixedFont = myFont; -// d->fontsUi.kcfg_fixedFont->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() ) ); -// } -// } - - void SettingsDialog::setHomeToCurrentPage() { MainWindow *mw = static_cast<MainWindow*>(parent()); @@ -375,15 +176,3 @@ void SettingsDialog::setHomeToCurrentPage() d->generalUi.kcfg_homePage->setText( webView->url().prettyUrl() ); } } -/* - -void SettingsDialog::slotOk() -{ - slotApply(); - close(); -} - -void SettingsDialog::slotApply() -{ - saveToSettings(); -}*/ diff --git a/src/settings.h b/src/settings.h index f9ae6828..109e3111 100644 --- a/src/settings.h +++ b/src/settings.h @@ -41,17 +41,12 @@ private: Private* const d; private slots: -// void loadFromSettings(); + void readConfig(); + void saveSettings(); + void setHomeToCurrentPage(); void showCookies(); void showExceptions(); -/* - void chooseStandardFont(); - void chooseFixedFont(); - -private: - QFont m_standardFont; - QFont m_fixedFont;*/ }; #endif // SETTINGS_H diff --git a/src/settings_fonts.ui b/src/settings_fonts.ui index beaa3afe..2d7168b0 100644 --- a/src/settings_fonts.ui +++ b/src/settings_fonts.ui @@ -20,7 +20,7 @@ </property> <layout class="QHBoxLayout" name="horizontalLayout" > <item> - <widget class="KFontRequester" name="kcfg_standardFont" /> + <widget class="KFontRequester" name="standardFontChooser" /> </item> </layout> </widget> @@ -32,7 +32,7 @@ </property> <layout class="QHBoxLayout" name="horizontalLayout_2" > <item> - <widget class="KFontRequester" name="kcfg_fixedFont" /> + <widget class="KFontRequester" name="fixedFontChooser" /> </item> </layout> </widget> diff --git a/src/settings_general.ui b/src/settings_general.ui index 47dbad81..b155ed56 100644 --- a/src/settings_general.ui +++ b/src/settings_general.ui @@ -108,7 +108,7 @@ </widget> </item> <item row="3" column="1" colspan="2" > - <widget class="KUrlRequester" name="kcfg_downloadDir" /> + <widget class="KUrlRequester" name="downloadDirUrlRequester" /> </item> <item row="4" column="1" colspan="2" > <spacer name="spacer" > diff --git a/src/webview.cpp b/src/webview.cpp index df629fc8..adfeab97 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -18,19 +18,27 @@ * * ============================================================ */ +// Local Includes +#include "webview.h" +#include "webview.moc" + +// Auto Includes +#include "rekonq.h" +// Local Includes #include "browserapplication.h" #include "mainwindow.h" #include "mainview.h" #include "cookiejar.h" #include "downloadmanager.h" #include "networkaccessmanager.h" -#include "webview.h" +// KDE Includes #include <KStandardDirs> #include <KDebug> #include <kio/netaccess.h> +// Qt Includes #include <QClipboard> #include <QMenu> #include <QMouseEvent> @@ -297,17 +305,11 @@ void WebView::setStatusBarText(const QString &string) } +// FIXME: use KIO transfer job instead!! void WebView::downloadRequested(const QNetworkRequest &request) { -// BrowserApplication::downloadManager()->download(request); - - // FIXME --- FIXME --- FIXME --- FIXME --- FIXME const KUrl url = KUrl( request.url() ); - - KConfig config("rekonqrc"); - KConfigGroup group = config.group("General"); - QString path = group.readEntry(QString("downloadDir")) + QString("/") + url.fileName(); - + QString path = ReKonfig::downloadDir() + QString("/") + url.fileName(); KIO::NetAccess::download( url , path , this ); } |