From 195641eb0e7972b32756e95340ebd48c21a7feaf Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 18 Jan 2009 02:10:22 +0100 Subject: Partially ported rekonq to KConfigXT technology.. Perhaps ~50%..going on!! --- src/CMakeLists.txt | 9 +- src/browserapplication.cpp | 46 +---- src/browserapplication.h | 2 +- src/findbar.cpp | 2 +- src/mainview.cpp | 5 +- src/mainwindow.cpp | 105 +++++++++- src/mainwindow.h | 4 + src/rekonq.kcfg | 73 +++++++ src/rekonq.kcfgc | 5 + src/rekonqui.rc | 14 +- src/settings.cpp | 472 +++++++++++++++++++++++---------------------- src/settings.h | 14 +- src/settings_appearance.ui | 98 ---------- src/settings_fonts.ui | 64 ++++++ src/settings_general.ui | 39 ++-- src/settings_privacy.ui | 23 ++- src/settings_proxy.ui | 15 +- src/webview.cpp | 4 +- 18 files changed, 539 insertions(+), 455 deletions(-) create mode 100644 src/rekonq.kcfg create mode 100644 src/rekonq.kcfgc delete mode 100644 src/settings_appearance.ui create mode 100644 src/settings_fonts.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 83297551..25c8e3cb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,12 +30,14 @@ KDE4_ADD_UI_FILES( rekonq_SRCS passworddialog.ui proxy.ui settings_general.ui - settings_appearance.ui + settings_fonts.ui settings_privacy.ui settings_proxy.ui ) -# include(${QT_USE_FILE}) +KDE4_ADD_KCFG_FILES( rekonq_SRCS rekonq.kcfgc ) + +### ------------------------------------------ ADD_DEFINITIONS( ${KDE4_DEFINITIONS} ) @@ -47,12 +49,11 @@ TARGET_LINK_LIBRARIES( rekonq ${QT_QTWEBKIT_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} -# ${QT_QTUITOOLS_LIBRARY} ) INSTALL( TARGETS rekonq ${INSTALL_TARGETS_DEFAULT_ARGS} ) ########### install files ############### -#INSTALL( FILES rekonq.kcfg DESTINATION ${KCFG_INSTALL_DIR} ) +INSTALL( FILES rekonq.kcfg DESTINATION ${KCFG_INSTALL_DIR} ) INSTALL( FILES rekonqui.rc DESTINATION ${DATA_INSTALL_DIR}/rekonq ) diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index bb8c76b1..bbd4b8b1 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -127,8 +127,6 @@ void BrowserApplication::postLaunch() } QWebSettings::setIconDatabasePath(directory); - loadSettings(); - // newMainWindow() needs to be called in main() for this to happen if (m_mainWindows.count() > 0) { @@ -148,36 +146,6 @@ void BrowserApplication::postLaunch() } - -void BrowserApplication::loadSettings() -{ - KConfig config("rekonqrc"); - KConfigGroup group = config.group("Appearance Settings"); - - QWebSettings *defaultSettings = QWebSettings::globalSettings(); - QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont); - int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize); - QFont standardFont = QFont(standardFontFamily, standardFontSize); - standardFont = qVariantValue( group.readEntry( QString("standardFont"), standardFont ) ); - - defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family()); - defaultSettings->setFontSize(QWebSettings::DefaultFontSize, standardFont.pointSize()); - - QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont); - int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize); - QFont fixedFont = QFont(fixedFontFamily, fixedFontSize); - fixedFont = qVariantValue(group.readEntry( QString("fixedFont"), fixedFont ) ); - - defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family()); - defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fixedFont.pointSize()); - - defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, group.readEntry( QString("enableJavascript"), true ) ); - defaultSettings->setAttribute(QWebSettings::PluginsEnabled, group.readEntry( QString("enablePlugins"), true ) ); -} - - - - QList BrowserApplication::mainWindows() { clean(); @@ -190,8 +158,6 @@ QList BrowserApplication::mainWindows() } - - void BrowserApplication::clean() { // cleanup any deleted main windows first @@ -311,17 +277,7 @@ void BrowserApplication::newLocalSocketConnection() stream >> url; if (!url.isEmpty()) { - KConfig config("rekonqrc"); - KConfigGroup group = config.group("Global Settings"); - int openLinksIn = group.readEntry( QString("openLinksIn"), QString().toInt() ); - if (openLinksIn == 1) - { - newMainWindow(); - } - else - { - mainWindow()->tabWidget()->newTab(); - } + mainWindow()->tabWidget()->newTab(); openUrl(url); } delete socket; diff --git a/src/browserapplication.h b/src/browserapplication.h index 8d33883e..4ec2cca6 100644 --- a/src/browserapplication.h +++ b/src/browserapplication.h @@ -49,7 +49,7 @@ public: BrowserApplication(KCmdLineArgs*, const QString &); ~BrowserApplication(); static BrowserApplication *instance(); - void loadSettings(); +// void loadSettings(); bool isTheOnlyBrowser() const; MainWindow *mainWindow(); diff --git a/src/findbar.cpp b/src/findbar.cpp index a1c867c2..6ba310ca 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -34,7 +34,7 @@ FindBar::FindBar(KXmlGuiWindow *parent) - : KToolBar( "Find Bar" , parent, Qt::BottomToolBarArea, true, false, false) + : KToolBar( "findBar" , parent, Qt::BottomToolBarArea, true, false, false) , m_lineEdit(0) { KAction *close = new KAction(KIcon("dialog-close") , "close" , this); diff --git a/src/mainview.cpp b/src/mainview.cpp index 4236d5d0..328d3dd1 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -175,7 +175,7 @@ void MainView::slotWebSelectAll() { WebView *webView = currentWebView(); QWebPage *currentParent = webView->webPage(); - // FIXME + // TODO } @@ -618,6 +618,3 @@ void MainView::previousTab() next = count() - 1; setCurrentIndex(next); } - - -// ---------------------------------------------------------------------------------------------------------------------------- diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d1f60b5d..6c177103 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -23,11 +23,14 @@ #include "mainwindow.h" #include "mainwindow.moc" +// Auto Includes +#include "rekonq.h" + // Local Includes #include "browserapplication.h" #include "downloadmanager.h" -#include "history.h" #include "settings.h" +#include "history.h" #include "bookmarks.h" #include "webview.h" @@ -62,17 +65,21 @@ MainWindow::MainWindow() // accept dnd setAcceptDrops(true); + // updating rekonq configuration + updateConfiguration(); + + // creating a new tab m_tabWidget->newTab(); // tell the KXmlGuiWindow that this is indeed the main widget setCentralWidget(m_tabWidget); + // connect signals and slots connect(m_tabWidget, SIGNAL( loadUrlPage(const KUrl &) ), this, SLOT( loadUrl(const KUrl &) ) ); connect(m_tabWidget, SIGNAL( setCurrentTitle(const QString &)), this, SLOT( slotUpdateWindowTitle(const QString &) ) ); connect(m_tabWidget, SIGNAL( showStatusBarMessage(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); connect(m_tabWidget, SIGNAL( linkHovered(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); connect(m_tabWidget, SIGNAL( loadProgress(int)), this, SLOT( slotLoadProgress(int) ) ); -// connect(m_tabWidget, SIGNAL( tabsChanged()), m_autoSaver, SLOT( changeOccurred() ) ); connect(m_tabWidget, SIGNAL( geometryChangeRequested(const QRect &)), this, SLOT( geometryChangeRequested(const QRect &) ) ); connect(m_tabWidget, SIGNAL( printRequested(QWebFrame *)), this, SLOT( printRequested(QWebFrame *) ) ); connect(m_tabWidget, SIGNAL( menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT( setVisible(bool) ) ); @@ -80,8 +87,6 @@ MainWindow::MainWindow() connect(m_tabWidget, SIGNAL( lastTabClosed() ), m_tabWidget, SLOT(newTab() ) ); slotUpdateWindowTitle(); -// -------------------------------------------------------------------------------------------------------------------------------- - // then, setup our actions setupActions(); @@ -276,6 +281,93 @@ void MainWindow::setupCustomMenu() } +// TODO FIXME +void MainWindow::updateConfiguration() +{ + // ============== 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(); + + QWebSettings *defaultSettings = QWebSettings::globalSettings(); + defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family()); + defaultSettings->setFontSize(QWebSettings::DefaultFontSize, standardFont.pointSize()); + defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family()); + defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fixedFont.pointSize()); + + + // =========== Privacy ============== + + bool arePluginsEnabled = ReKonfig::enablePlugins(); + bool isJavascriptEnabled = ReKonfig::enableJavascript(); + + defaultSettings->setAttribute(QWebSettings::PluginsEnabled, arePluginsEnabled); + defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, isJavascriptEnabled); + +// int canAcceptCookies = ReKonfig::acceptCookies(); +// int canKeepCookiesUntil = ReKonfig::keepCookiesUntil(); +// +// CookieJar::KeepPolicy keepCookies; +// switch(canAcceptCookies) +// { +// 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")); +// +// CookieJar::KeepPolicy keepPolicy; +// switch(canKeepCookiesUntil) +// { +// 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")); +// // --- +// BrowserApplication::instance()->loadSettings(); +// BrowserApplication::networkAccessManager()->loadSettings(); +// BrowserApplication::cookieJar()->loadSettings(); +// BrowserApplication::historyManager()->loadSettings(); + +} + + KUrl MainWindow::guessUrlFromString(const QString &string) { QString urlStr = string.trimmed(); @@ -576,10 +668,7 @@ void MainWindow::slotViewPageSource() void MainWindow::slotHome() { - KConfig config("rekonqrc"); - KConfigGroup group = config.group("Global Settings"); - QString home = group.readEntry( QString("home"), QString("http://www.kde.org/") ); - loadUrl( KUrl(home) ); + loadUrl( KUrl(m_homePage) ); } diff --git a/src/mainwindow.h b/src/mainwindow.h index fd7f13d6..e666e405 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -65,6 +65,8 @@ private: void setupTabBar(); public slots: + void updateConfiguration(); + void slotHome(); void loadUrl(const KUrl &url); @@ -126,6 +128,8 @@ private: QString m_lastSearch; MainView *m_tabWidget; + + QString m_homePage; }; #endif // MAINWINDOW_H diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg new file mode 100644 index 00000000..4e91847b --- /dev/null +++ b/src/rekonq.kcfg @@ -0,0 +1,73 @@ + + + + + +QtWebKit +KUrl + + + + + http://www.kde.org/ + + + $HOME + + + 1 + + + + + + + QFont( QWebSettings::globalSettings()->fontFamily(QWebSettings::StandardFont) ) + + + QFont( QWebSettings::globalSettings()->fontFamily(QWebSettings::FixedFont) ) + + + + + + + true + + + true + + + 0 + + + 0 + + + + + + + false + + + Socks5 + + + + + + 1080 + + + + + + + + + + diff --git a/src/rekonq.kcfgc b/src/rekonq.kcfgc new file mode 100644 index 00000000..50a9817d --- /dev/null +++ b/src/rekonq.kcfgc @@ -0,0 +1,5 @@ +File=rekonq.kcfg +ClassName=ReKonfig +Singleton=true +Mutators=true +UseEnumTypes=true diff --git a/src/rekonqui.rc b/src/rekonqui.rc index 323e775b..3a9ab682 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -1,5 +1,5 @@ - + &File @@ -57,13 +57,17 @@ -&Settings - - + + &Settings + + - + diff --git a/src/settings.cpp b/src/settings.cpp index 23b04c83..c06cbc85 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -19,10 +19,14 @@  * ============================================================ */ -// Local Includes +// Self Includes #include "settings.h" #include "settings.moc" +// Auto Includes +#include "rekonq.h" + +// Local Includes #include "browserapplication.h" #include "mainwindow.h" #include "cookiejar.h" @@ -32,7 +36,7 @@ //Ui Includes #include "ui_settings_general.h" -#include "ui_settings_appearance.h" +#include "ui_settings_fonts.h" #include "ui_settings_privacy.h" #include "ui_settings_proxy.h" @@ -52,7 +56,7 @@ class Private { private: Ui::general generalUi; - Ui::appearance appearanceUi; + Ui::fonts fontsUi; Ui::privacy privacyUi; Ui::proxy proxyUi; @@ -72,10 +76,10 @@ Private::Private(SettingsDialog *parent) widget->layout()->setMargin(0); pageItem = parent->addPage( widget , i18n("General") ); pageItem->setIcon( KIcon("rekonq") ); - generalUi.kurlrequester->setMode( KFile::Directory ); + generalUi.kcfg_downloadDir->setMode( KFile::Directory ); widget = new QWidget; - appearanceUi.setupUi( widget ); + fontsUi.setupUi( widget ); widget->layout()->setMargin(0); pageItem = parent->addPage( widget , i18n("Fonts") ); pageItem->setIcon( KIcon("preferences-desktop-font") ); @@ -96,7 +100,7 @@ Private::Private(SettingsDialog *parent) // ----------------------------------------------------------------------------------------------------- SettingsDialog::SettingsDialog(QWidget *parent) - : KConfigDialog(parent, "Settings", new KConfigSkeleton("rekonqrc") ) + : KConfigDialog(parent, "settings", ReKonfig::self() ) , d(new Private(this) ) { setFaceType(KPageDialog::List); @@ -106,223 +110,221 @@ SettingsDialog::SettingsDialog(QWidget *parent) setWindowTitle( i18n("rekonfig..") ); setModal(true); - connect(this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) ); - connect(this, SIGNAL( closeClicked() ), this, SLOT( close() ) ); - connect(this, SIGNAL( applyClicked() ), this, SLOT( slotApply() ) ); + connect(this, SIGNAL(settingsChanged(const QString&)), parent, SLOT(updateConfiguration())); +// connect(this, SIGNAL(settingsChanged(const QString&)), this, SLOT(loadFromSettings())); + connect( d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT( setHomeToCurrentPage() ) ); connect( d->privacyUi.exceptionsButton, SIGNAL(clicked()), this, SLOT( showExceptions() ) ); connect( d->privacyUi.cookiesButton, SIGNAL(clicked()), this, SLOT( showCookies() ) ); - connect( d->appearanceUi.standardFontButton, SIGNAL(clicked()), this, SLOT( chooseFont() ) ); - connect( d->appearanceUi.fixedFontButton, SIGNAL(clicked()), this, SLOT( chooseFixedFont() ) ); - - loadDefaults(); - loadFromSettings(); } + SettingsDialog::~SettingsDialog() { delete d; } -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->appearanceUi.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->appearanceUi.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() -{ - 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() ) ); - - - // Appearance - KConfigGroup group2 = config.group("Fonts Settings"); - - m_fixedFont = group2.readEntry( QString("fixedFont"), m_fixedFont ); - m_standardFont = group2.readEntry( QString("standardFont"), m_standardFont ); - - d->appearanceUi.standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() ) ); - d->appearanceUi.fixedLabel->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(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(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() +//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() { - 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(); -} + 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(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(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(); +// } void SettingsDialog::showCookies() @@ -339,29 +341,29 @@ void SettingsDialog::showExceptions() } -void SettingsDialog::chooseFont() -{ - QFont myFont( m_standardFont ); - int result = KFontDialog::getFont( myFont ); - if ( result == KFontDialog::Accepted ) - { - m_standardFont = myFont; - d->appearanceUi.standardLabel->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->appearanceUi.fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() ) ); - } -} +// 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() @@ -370,10 +372,10 @@ void SettingsDialog::setHomeToCurrentPage() WebView *webView = mw->currentTab(); if (webView) { - d->generalUi.homeLineEdit->setText( webView->url().prettyUrl() ); + d->generalUi.kcfg_homePage->setText( webView->url().prettyUrl() ); } } - +/* void SettingsDialog::slotOk() { @@ -384,4 +386,4 @@ void SettingsDialog::slotOk() void SettingsDialog::slotApply() { saveToSettings(); -} +}*/ diff --git a/src/settings.h b/src/settings.h index 79059ed6..f9ae6828 100644 --- a/src/settings.h +++ b/src/settings.h @@ -41,23 +41,17 @@ private: Private* const d; private slots: - void loadDefaults(); - void loadFromSettings(); - void saveToSettings(); - +// void loadFromSettings(); void setHomeToCurrentPage(); void showCookies(); void showExceptions(); - - void chooseFont(); +/* + void chooseStandardFont(); void chooseFixedFont(); - void slotOk(); - void slotApply(); - private: QFont m_standardFont; - QFont m_fixedFont; + QFont m_fixedFont;*/ }; #endif // SETTINGS_H diff --git a/src/settings_appearance.ui b/src/settings_appearance.ui deleted file mode 100644 index ec82297c..00000000 --- a/src/settings_appearance.ui +++ /dev/null @@ -1,98 +0,0 @@ - - appearance - - - - 0 - 0 - 445 - 92 - - - - Appearance - - - - - - - - Standard font: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Fixed-width font: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - Times 16 - - - Qt::AlignCenter - - - - - - - QFrame::StyledPanel - - - Courier 13 - - - Qt::AlignCenter - - - - - - - - - - - Select... - - - - - - - Select... - - - - - - - - - - diff --git a/src/settings_fonts.ui b/src/settings_fonts.ui new file mode 100644 index 00000000..beaa3afe --- /dev/null +++ b/src/settings_fonts.ui @@ -0,0 +1,64 @@ + + fonts + + + + 0 + 0 + 391 + 179 + + + + Appearance + + + + + + Standard Font + + + + + + + + + + + + Fixed Font + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + KFontRequester + QWidget +
kfontrequester.h
+
+
+ + +
diff --git a/src/settings_general.ui b/src/settings_general.ui index 4857488a..47dbad81 100644 --- a/src/settings_general.ui +++ b/src/settings_general.ui @@ -5,7 +5,7 @@ 0 0 - 575 + 500 209 @@ -24,7 +24,14 @@ - + + + + 0 + 0 + + + @@ -57,7 +64,7 @@ - + After one day @@ -101,33 +108,9 @@ - - - - - - Open links from applications: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + - - - - In a tab in the current window - - - - - In a new window - - - - - Qt::Vertical diff --git a/src/settings_privacy.ui b/src/settings_privacy.ui index dfa61998..19e7f088 100644 --- a/src/settings_privacy.ui +++ b/src/settings_privacy.ui @@ -6,7 +6,7 @@ 0 0 461 - 212 + 313 @@ -20,7 +20,7 @@ - + Enable Plugins @@ -30,7 +30,7 @@ - + Enable Javascript @@ -59,7 +59,7 @@ - + Always @@ -95,7 +95,7 @@ - + They expire @@ -123,6 +123,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + diff --git a/src/settings_proxy.ui b/src/settings_proxy.ui index c02dad27..a7dd6073 100644 --- a/src/settings_proxy.ui +++ b/src/settings_proxy.ui @@ -14,13 +14,10 @@ - + Enable proxy - - true - @@ -33,7 +30,7 @@ - + Socks5 @@ -57,7 +54,7 @@ - + @@ -70,7 +67,7 @@ - + 10000 @@ -103,7 +100,7 @@ - + @@ -116,7 +113,7 @@ - + diff --git a/src/webview.cpp b/src/webview.cpp index 62acbba6..df629fc8 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -305,8 +305,8 @@ void WebView::downloadRequested(const QNetworkRequest &request) const KUrl url = KUrl( request.url() ); KConfig config("rekonqrc"); - KConfigGroup group1 = config.group("Global Settings"); - QString path = group1.readEntry(QString("downloadDirectory")) + QString("/") + url.fileName(); + KConfigGroup group = config.group("General"); + QString path = group.readEntry(QString("downloadDir")) + QString("/") + url.fileName(); KIO::NetAccess::download( url , path , this ); } -- cgit v1.2.1