summaryrefslogtreecommitdiff
path: root/src/settings.cpp
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-01-19 02:26:13 +0100
committerAndrea Diamantini <adjam7@gmail.com>2009-01-19 02:26:13 +0100
commit76d30285358bedd8b2fc6caf48d2a871f7546685 (patch)
tree28ee333ad33eeeb4f6edd9f647702fc2522db122 /src/settings.cpp
parentm_tabWidget --> m_view (diff)
downloadrekonq-76d30285358bedd8b2fc6caf48d2a871f7546685.tar.xz
Ported tons of code to KConfigXT. To merge kcfg branch we need just to
port cookie settings..
Diffstat (limited to 'src/settings.cpp')
-rw-r--r--src/settings.cpp267
1 files changed, 28 insertions, 239 deletions
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();
-}*/