]> cloud.milkyroute.net Git - dolphin.git/commitdiff
allow to reset all settings to default values
authorPeter Penz <peter.penz19@gmail.com>
Sat, 26 May 2007 09:16:56 +0000 (09:16 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sat, 26 May 2007 09:16:56 +0000 (09:16 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=668398

15 files changed:
src/columnviewsettingspage.cpp
src/columnviewsettingspage.h
src/detailsviewsettingspage.cpp
src/detailsviewsettingspage.h
src/dolphinsettingsdialog.cpp
src/dolphinsettingsdialog.h
src/generalsettingspage.cpp
src/generalsettingspage.h
src/generalviewsettingspage.cpp
src/generalviewsettingspage.h
src/iconsviewsettingspage.cpp
src/iconsviewsettingspage.h
src/settingspagebase.h
src/viewsettingspage.cpp
src/viewsettingspage.h

index f843ca0fa5c0c5307fcf9bb0e94883972ec023c3..ddc22972bc855d395632434dcc795efe5a694f77 100644 (file)
@@ -51,29 +51,13 @@ ColumnViewSettingsPage::ColumnViewSettingsPage(DolphinMainWindow* mainWindow,
     setSpacing(spacing);
     setMargin(margin);
 
     setSpacing(spacing);
     setMargin(margin);
 
-    ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
-    Q_ASSERT(settings != 0);
-
-    // Create "Icon" properties
+    // Create 'Icon' properties
     QGroupBox* iconSizeBox = new QGroupBox(i18n("Icon Size"), this);
     iconSizeBox->setSizePolicy(sizePolicy);
 
     m_smallIconSize  = new QRadioButton(i18n("Small"), this);
     m_mediumIconSize = new QRadioButton(i18n("Medium"), this);
     m_largeIconSize  = new QRadioButton(i18n("Large"), this);
     QGroupBox* iconSizeBox = new QGroupBox(i18n("Icon Size"), this);
     iconSizeBox->setSizePolicy(sizePolicy);
 
     m_smallIconSize  = new QRadioButton(i18n("Small"), this);
     m_mediumIconSize = new QRadioButton(i18n("Medium"), this);
     m_largeIconSize  = new QRadioButton(i18n("Large"), this);
-    switch (settings->iconSize()) {
-    case K3Icon::SizeLarge:
-        m_largeIconSize->setChecked(true);
-        break;
-
-    case K3Icon::SizeMedium:
-        m_mediumIconSize->setChecked(true);
-        break;
-
-    case K3Icon::SizeSmall:
-    default:
-        m_smallIconSize->setChecked(true);
-    }
 
     QButtonGroup* iconSizeGroup = new QButtonGroup(this);
     iconSizeGroup->addButton(m_smallIconSize);
 
     QButtonGroup* iconSizeGroup = new QButtonGroup(this);
     iconSizeGroup->addButton(m_smallIconSize);
@@ -91,11 +75,6 @@ ColumnViewSettingsPage::ColumnViewSettingsPage(DolphinMainWindow* mainWindow,
 
     QLabel* fontLabel = new QLabel(i18n("Font:"), textBox);
     m_fontRequester = new KFontRequester(textBox);
 
     QLabel* fontLabel = new QLabel(i18n("Font:"), textBox);
     m_fontRequester = new KFontRequester(textBox);
-    QFont font(settings->fontFamily(),
-               settings->fontSize());
-    font.setItalic(settings->italicFont());
-    font.setBold(settings->boldFont());
-    m_fontRequester->setFont(font);
 
     QHBoxLayout* textLayout = new QHBoxLayout(textBox);
     textLayout->addWidget(fontLabel);
 
     QHBoxLayout* textLayout = new QHBoxLayout(textBox);
     textLayout->addWidget(fontLabel);
@@ -105,6 +84,8 @@ ColumnViewSettingsPage::ColumnViewSettingsPage(DolphinMainWindow* mainWindow,
     // a vertical resizing. This assures that the dialog layout
     // is not stretched vertically.
     new QWidget(this);
     // a vertical resizing. This assures that the dialog layout
     // is not stretched vertically.
     new QWidget(this);
+
+    loadSettings();
 }
 
 ColumnViewSettingsPage::~ColumnViewSettingsPage()
 }
 
 ColumnViewSettingsPage::~ColumnViewSettingsPage()
@@ -114,7 +95,6 @@ ColumnViewSettingsPage::~ColumnViewSettingsPage()
 void ColumnViewSettingsPage::applySettings()
 {
     ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
 void ColumnViewSettingsPage::applySettings()
 {
     ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
-    Q_ASSERT(settings != 0);
 
     int iconSize = K3Icon::SizeSmall;
     if (m_mediumIconSize->isChecked()) {
 
     int iconSize = K3Icon::SizeSmall;
     if (m_mediumIconSize->isChecked()) {
@@ -131,4 +111,36 @@ void ColumnViewSettingsPage::applySettings()
     settings->setBoldFont(font.bold());
 }
 
     settings->setBoldFont(font.bold());
 }
 
+void ColumnViewSettingsPage::restoreDefaults()
+{
+    ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
+    settings->setDefaults();
+    loadSettings();
+}
+
+void ColumnViewSettingsPage::loadSettings()
+{
+    ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
+
+    switch (settings->iconSize()) {
+    case K3Icon::SizeLarge:
+        m_largeIconSize->setChecked(true);
+        break;
+
+    case K3Icon::SizeMedium:
+        m_mediumIconSize->setChecked(true);
+        break;
+
+    case K3Icon::SizeSmall:
+    default:
+        m_smallIconSize->setChecked(true);
+    }
+
+    QFont font(settings->fontFamily(),
+               settings->fontSize());
+    font.setItalic(settings->italicFont());
+    font.setBold(settings->boldFont());
+    m_fontRequester->setFont(font);
+}
+
 #include "columnviewsettingspage.moc"
 #include "columnviewsettingspage.moc"
index 270ee5ff44084ab591aecebad73df6eadd05e9e8..5bf25da9800a3e2385d3ce19d9604a04feba3def 100644 (file)
@@ -48,6 +48,12 @@ public:
      */
     void applySettings();
 
      */
     void applySettings();
 
+    /** Restores the settings to default values. */
+    void restoreDefaults();
+
+private:
+    void loadSettings();
+
 private:
     DolphinMainWindow* m_mainWindow;
     QRadioButton* m_smallIconSize;
 private:
     DolphinMainWindow* m_mainWindow;
     QRadioButton* m_smallIconSize;
index c7f4acf3e0a4cae99bc5eb44c01ffc1d7c565420..c84c8b61aa87fb32ba73b750adefb21c8437cd74 100644 (file)
@@ -55,27 +55,15 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
     setSpacing(spacing);
     setMargin(margin);
 
     setSpacing(spacing);
     setMargin(margin);
 
-    DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
-    Q_ASSERT(settings != 0);
-
     // create "Columns" properties
     QGroupBox* columnsBox = new QGroupBox(i18n("Columns"), this);
     columnsBox->setSizePolicy(sizePolicy);
 
     m_dateBox = new QCheckBox(i18n("Date"), this);
     // create "Columns" properties
     QGroupBox* columnsBox = new QGroupBox(i18n("Columns"), this);
     columnsBox->setSizePolicy(sizePolicy);
 
     m_dateBox = new QCheckBox(i18n("Date"), this);
-    m_dateBox->setChecked(settings->showDate());
-
     m_permissionsBox = new QCheckBox(i18n("Permissions"), this);
     m_permissionsBox = new QCheckBox(i18n("Permissions"), this);
-    m_permissionsBox->setChecked(settings->showPermissions());
-
     m_ownerBox = new QCheckBox(i18n("Owner"), this);
     m_ownerBox = new QCheckBox(i18n("Owner"), this);
-    m_ownerBox->setChecked(settings->showOwner());
-
     m_groupBox = new QCheckBox(i18n("Group"), this);
     m_groupBox = new QCheckBox(i18n("Group"), this);
-    m_groupBox->setChecked(settings->showGroup());
-
     m_typeBox = new QCheckBox(i18n("Type"), this);
     m_typeBox = new QCheckBox(i18n("Type"), this);
-    m_typeBox->setChecked(settings->showType());
 
     QHBoxLayout* columnsLayout = new QHBoxLayout(columnsBox);
     columnsLayout->addWidget(m_dateBox);
 
     QHBoxLayout* columnsLayout = new QHBoxLayout(columnsBox);
     columnsLayout->addWidget(m_dateBox);
@@ -91,19 +79,6 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
     m_smallIconSize  = new QRadioButton(i18n("Small"), this);
     m_mediumIconSize = new QRadioButton(i18n("Medium"), this);
     m_largeIconSize  = new QRadioButton(i18n("Large"), this);
     m_smallIconSize  = new QRadioButton(i18n("Small"), this);
     m_mediumIconSize = new QRadioButton(i18n("Medium"), this);
     m_largeIconSize  = new QRadioButton(i18n("Large"), this);
-    switch (settings->iconSize()) {
-    case K3Icon::SizeLarge:
-        m_largeIconSize->setChecked(true);
-        break;
-
-    case K3Icon::SizeMedium:
-        m_mediumIconSize->setChecked(true);
-        break;
-
-    case K3Icon::SizeSmall:
-    default:
-        m_smallIconSize->setChecked(true);
-    }
 
     QButtonGroup* iconSizeGroup = new QButtonGroup(this);
     iconSizeGroup->addButton(m_smallIconSize);
 
     QButtonGroup* iconSizeGroup = new QButtonGroup(this);
     iconSizeGroup->addButton(m_smallIconSize);
@@ -121,11 +96,6 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
 
     QLabel* fontLabel = new QLabel(i18n("Font:"), textBox);
     m_fontRequester = new KFontRequester(textBox);
 
     QLabel* fontLabel = new QLabel(i18n("Font:"), textBox);
     m_fontRequester = new KFontRequester(textBox);
-    QFont font(settings->fontFamily(),
-               settings->fontSize());
-    font.setItalic(settings->italicFont());
-    font.setBold(settings->boldFont());
-    m_fontRequester->setFont(font);
 
     QHBoxLayout* textLayout = new QHBoxLayout(textBox);
     textLayout->addWidget(fontLabel);
 
     QHBoxLayout* textLayout = new QHBoxLayout(textBox);
     textLayout->addWidget(fontLabel);
@@ -135,6 +105,8 @@ DetailsViewSettingsPage::DetailsViewSettingsPage(DolphinMainWindow* mainWindow,
     // a vertical resizing. This assures that the dialog layout
     // is not stretched vertically.
     new QWidget(this);
     // a vertical resizing. This assures that the dialog layout
     // is not stretched vertically.
     new QWidget(this);
+
+    loadSettings();
 }
 
 DetailsViewSettingsPage::~DetailsViewSettingsPage()
 }
 
 DetailsViewSettingsPage::~DetailsViewSettingsPage()
@@ -144,7 +116,6 @@ DetailsViewSettingsPage::~DetailsViewSettingsPage()
 void DetailsViewSettingsPage::applySettings()
 {
     DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
 void DetailsViewSettingsPage::applySettings()
 {
     DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
-    Q_ASSERT(settings != 0);
 
     settings->setShowDate(m_dateBox->isChecked());
     settings->setShowPermissions(m_permissionsBox->isChecked());
 
     settings->setShowDate(m_dateBox->isChecked());
     settings->setShowPermissions(m_permissionsBox->isChecked());
@@ -167,4 +138,42 @@ void DetailsViewSettingsPage::applySettings()
     settings->setBoldFont(font.bold());
 }
 
     settings->setBoldFont(font.bold());
 }
 
+void DetailsViewSettingsPage::restoreDefaults()
+{
+    DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+    settings->setDefaults();
+    loadSettings();
+}
+
+void DetailsViewSettingsPage::loadSettings()
+{
+    DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+
+    m_dateBox->setChecked(settings->showDate());
+    m_permissionsBox->setChecked(settings->showPermissions());
+    m_ownerBox->setChecked(settings->showOwner());
+    m_groupBox->setChecked(settings->showGroup());
+    m_typeBox->setChecked(settings->showType());
+
+    switch (settings->iconSize()) {
+    case K3Icon::SizeLarge:
+        m_largeIconSize->setChecked(true);
+        break;
+
+    case K3Icon::SizeMedium:
+        m_mediumIconSize->setChecked(true);
+        break;
+
+    case K3Icon::SizeSmall:
+    default:
+        m_smallIconSize->setChecked(true);
+    }
+
+    QFont font(settings->fontFamily(),
+               settings->fontSize());
+    font.setItalic(settings->italicFont());
+    font.setBold(settings->boldFont());
+    m_fontRequester->setFont(font);
+}
+
 #include "detailsviewsettingspage.moc"
 #include "detailsviewsettingspage.moc"
index 95a83fdc5e7d001f8a3de7530dede8ebf09525c6..7880527ab2baeeb4f8434a17cdf937f5137f495f 100644 (file)
@@ -48,6 +48,12 @@ public:
      */
     void applySettings();
 
      */
     void applySettings();
 
+    /** Restores the settings to default values. */
+    void restoreDefaults();
+
+private:
+    void loadSettings();
+
 private:
     DolphinMainWindow* m_mainWindow;
     QCheckBox* m_dateBox;
 private:
     DolphinMainWindow* m_mainWindow;
     QCheckBox* m_dateBox;
index 88b97d057a4d61f5cec3b626f8dff057cd7f25f2..998f6b4d26cd3c7a750528c9b20a749893ef97e0 100644 (file)
  ***************************************************************************/
 
 #include "dolphinsettingsdialog.h"
  ***************************************************************************/
 
 #include "dolphinsettingsdialog.h"
-#include <klocale.h>
-#include <kicon.h>
-#include "generalsettingspage.h"
-#include "viewsettingspage.h"
+
 #include "dolphinapplication.h"
 #include "dolphinmainwindow.h"
 #include "dolphinapplication.h"
 #include "dolphinmainwindow.h"
+#include "generalsettingspage.h"
+#include "viewsettingspage.h"
+
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kicon.h>
 
 DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) :
     KPageDialog(),
 
 DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) :
     KPageDialog(),
@@ -35,7 +38,7 @@ DolphinSettingsDialog::DolphinSettingsDialog(DolphinMainWindow* mainWindow) :
 
     setFaceType(List);
     setCaption(i18n("Dolphin Preferences"));
 
     setFaceType(List);
     setCaption(i18n("Dolphin Preferences"));
-    setButtons(Ok | Apply | Cancel);
+    setButtons(Ok | Apply | Cancel | Default);
     setDefaultButton(Ok);
 
     m_generalSettingsPage = new GeneralSettingsPage(mainWindow, this);
     setDefaultButton(Ok);
 
     m_generalSettingsPage = new GeneralSettingsPage(mainWindow, this);
@@ -58,9 +61,15 @@ DolphinSettingsDialog::~DolphinSettingsDialog()
 
 void DolphinSettingsDialog::slotButtonClicked(int button)
 {
 
 void DolphinSettingsDialog::slotButtonClicked(int button)
 {
-    if (button == Ok || button == Apply) {
+    if ((button == Ok) || (button == Apply)) {
         applySettings();
         applySettings();
+    } else if (button == Default) {
+        const QString text(i18n("All settings will be reset to default values. Do you want to continue?"));
+        if (KMessageBox::questionYesNo(this, text) == KMessageBox::Yes) {
+            restoreDefaults();
+        }
     }
     }
+
     KPageDialog::slotButtonClicked(button);
 }
 
     KPageDialog::slotButtonClicked(button);
 }
 
@@ -71,4 +80,11 @@ void DolphinSettingsDialog::applySettings()
     DolphinApplication::app()->refreshMainWindows();
 }
 
     DolphinApplication::app()->refreshMainWindows();
 }
 
+void DolphinSettingsDialog::restoreDefaults()
+{
+    m_generalSettingsPage->restoreDefaults();
+    m_viewSettingsPage->restoreDefaults();
+    DolphinApplication::app()->refreshMainWindows();
+}
+
 #include "dolphinsettingsdialog.moc"
 #include "dolphinsettingsdialog.moc"
index 22d01b02e53b8b88d112267c82154315a530b0cf..612baa3c2380c7bbd0a3ba7e26868b940424405d 100644 (file)
@@ -43,10 +43,12 @@ public:
     virtual ~DolphinSettingsDialog();
 
 protected slots:
     virtual ~DolphinSettingsDialog();
 
 protected slots:
+    /** @see KDialog::slotButtonClicked() */
     virtual void slotButtonClicked(int button);
 
 private:
     void applySettings();
     virtual void slotButtonClicked(int button);
 
 private:
     void applySettings();
+    void restoreDefaults();
 
 private:
     DolphinMainWindow* m_mainWindow;
 
 private:
     DolphinMainWindow* m_mainWindow;
index 87c8a24c30681a7bfdedc6bd13130e10c74cd694..ee4832e571f1e3dae52a49852202565d8a7f87ef 100644 (file)
@@ -50,7 +50,6 @@ GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin, QWidget* pa
     m_confirmDelete(0)
 {
     const int spacing = KDialog::spacingHint();
     m_confirmDelete(0)
 {
     const int spacing = KDialog::spacingHint();
-    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
 
     QVBoxLayout* topLayout = new QVBoxLayout(this);
     KVBox* vBox = new KVBox(this);
 
     QVBoxLayout* topLayout = new QVBoxLayout(this);
     KVBox* vBox = new KVBox(this);
@@ -63,7 +62,7 @@ GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin, QWidget* pa
     homeUrlBox->setSpacing(spacing);
 
     new QLabel(i18n("Location:"), homeUrlBox);
     homeUrlBox->setSpacing(spacing);
 
     new QLabel(i18n("Location:"), homeUrlBox);
-    m_homeUrl = new QLineEdit(settings->homeUrl(), homeUrlBox);
+    m_homeUrl = new QLineEdit(homeUrlBox);
 
     QPushButton* selectHomeUrlButton = new QPushButton(KIcon("folder-open"), QString(), homeUrlBox);
     connect(selectHomeUrlButton, SIGNAL(clicked()),
 
     QPushButton* selectHomeUrlButton = new QPushButton(KIcon("folder-open"), QString(), homeUrlBox);
     connect(selectHomeUrlButton, SIGNAL(clicked()),
@@ -85,17 +84,10 @@ GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin, QWidget* pa
 
     QGroupBox* startBox = new QGroupBox(i18n("Start"), vBox);
 
 
     QGroupBox* startBox = new QGroupBox(i18n("Start"), vBox);
 
-    // create 'Split view' checkbox
+    // create 'Split view', 'Editable location' and 'Filter bar' checkboxes
     m_splitView = new QCheckBox(i18n("Split view"), startBox);
     m_splitView = new QCheckBox(i18n("Split view"), startBox);
-    m_splitView->setChecked(settings->splitView());
-
-    // create 'Editable location' checkbox
     m_editableUrl = new QCheckBox(i18n("Editable location"), startBox);
     m_editableUrl = new QCheckBox(i18n("Editable location"), startBox);
-    m_editableUrl->setChecked(settings->editableUrl());
-
-    // create 'Filter bar' checkbox
     m_filterBar = new QCheckBox(i18n("Filter bar"),startBox);
     m_filterBar = new QCheckBox(i18n("Filter bar"),startBox);
-    m_filterBar->setChecked(settings->filterBar());
 
     QVBoxLayout* startBoxLayout = new QVBoxLayout(startBox);
     startBoxLayout->addWidget(m_splitView);
 
     QVBoxLayout* startBoxLayout = new QVBoxLayout(startBox);
     startBoxLayout->addWidget(m_splitView);
@@ -130,6 +122,8 @@ GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin, QWidget* pa
     new QWidget(vBox);
 
     topLayout->addWidget(vBox);
     new QWidget(vBox);
 
     topLayout->addWidget(vBox);
+
+    loadSettings();
 }
 
 GeneralSettingsPage::~GeneralSettingsPage()
 }
 
 GeneralSettingsPage::~GeneralSettingsPage()
@@ -161,6 +155,20 @@ void GeneralSettingsPage::applySettings()
     kdeConfig.sync();
 }
 
     kdeConfig.sync();
 }
 
+void GeneralSettingsPage::restoreDefaults()
+{
+    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
+    settings->setDefaults();
+
+    // TODO: reset default settings for trash and show delete command...
+    //KSharedConfig::Ptr konqConfig = KSharedConfig::openConfig("konquerorrc", KConfig::IncludeGlobals);
+    //KConfigGroup trashConfig(konqConfig, "Trash");
+    //KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals);
+    //KConfigGroup kdeConfig(globalConfig, "KDE");
+
+    loadSettings();
+}
+
 void GeneralSettingsPage::selectHomeUrl()
 {
     const QString homeUrl(m_homeUrl->text());
 void GeneralSettingsPage::selectHomeUrl()
 {
     const QString homeUrl(m_homeUrl->text());
@@ -181,4 +189,13 @@ void GeneralSettingsPage::useDefaultLocation()
     m_homeUrl->setText("file://" + QDir::homePath());
 }
 
     m_homeUrl->setText("file://" + QDir::homePath());
 }
 
+void GeneralSettingsPage::loadSettings()
+{
+    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
+    m_homeUrl->setText(settings->homeUrl());
+    m_splitView->setChecked(settings->splitView());
+    m_editableUrl->setChecked(settings->editableUrl());
+    m_filterBar->setChecked(settings->filterBar());
+}
+
 #include "generalsettingspage.moc"
 #include "generalsettingspage.moc"
index 83d4b0dba9d61e3ec3d65048c1a16cadc84e6123..90f510c28cca0e8cfb19721e3a6745402c4a4ebe 100644 (file)
@@ -30,8 +30,8 @@ class QCheckBox;
 /**
  * @brief Page for the 'General' settings of the Dolphin settings dialog.
  *
 /**
  * @brief Page for the 'General' settings of the Dolphin settings dialog.
  *
- * The general settings allow to set the home Url, the default view mode
- * and the split view mode.
+ * The general settings allow to set the home URL and to configure the
+ * state of the view mode, split mode and the filter bar when starting Dolphin.
  */
 class GeneralSettingsPage : public SettingsPageBase
 {
  */
 class GeneralSettingsPage : public SettingsPageBase
 {
@@ -41,14 +41,20 @@ public:
     GeneralSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
     virtual ~GeneralSettingsPage();
 
     GeneralSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
     virtual ~GeneralSettingsPage();
 
-    /** @see SettingsPageBase::applySettings */
+    /** @see SettingsPageBase::applySettings() */
     virtual void applySettings();
 
     virtual void applySettings();
 
+    /** @see SettingsPageBase::restoreDefaults() */
+    virtual void restoreDefaults();
+
 private slots:
     void selectHomeUrl();
     void useCurrentLocation();
     void useDefaultLocation();
 
 private slots:
     void selectHomeUrl();
     void useCurrentLocation();
     void useDefaultLocation();
 
+private:
+    void loadSettings();
+
 private:
     DolphinMainWindow* m_mainWindow;
     QLineEdit* m_homeUrl;
 private:
     DolphinMainWindow* m_mainWindow;
     QLineEdit* m_homeUrl;
index 7b4eba16987593f1fa8f25c460841fd957b5b046..48b9b653bea0769578c3f17be6d54d6d76341af8 100644 (file)
@@ -42,11 +42,9 @@ GeneralViewSettingsPage::GeneralViewSettingsPage(DolphinMainWindow* mainWindow,
     m_mainWindow(mainWindow),
     m_localProps(0),
     m_globalProps(0),
     m_mainWindow(mainWindow),
     m_localProps(0),
     m_globalProps(0),
-    m_maxPreviewSize(0)
+    m_maxPreviewSize(0),
+    m_spinBox(0)
 {
 {
-    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
-    Q_ASSERT(settings != 0);
-
     const int spacing = KDialog::spacingHint();
     const int margin = KDialog::marginHint();
     const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
     const int spacing = KDialog::spacingHint();
     const int margin = KDialog::marginHint();
     const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
@@ -58,11 +56,6 @@ GeneralViewSettingsPage::GeneralViewSettingsPage(DolphinMainWindow* mainWindow,
 
     m_localProps = new QRadioButton(i18n("Remember view properties for each folder"), propsBox);
     m_globalProps = new QRadioButton(i18n("Use common view properties for all folders"), propsBox);
 
     m_localProps = new QRadioButton(i18n("Remember view properties for each folder"), propsBox);
     m_globalProps = new QRadioButton(i18n("Use common view properties for all folders"), propsBox);
-    if (settings->globalViewProps()) {
-        m_globalProps->setChecked(true);
-    } else {
-        m_localProps->setChecked(true);
-    }
 
     QVBoxLayout* propsBoxLayout = new QVBoxLayout(propsBox);
     propsBoxLayout->addWidget(m_localProps);
 
     QVBoxLayout* propsBoxLayout = new QVBoxLayout(propsBox);
     propsBoxLayout->addWidget(m_localProps);
@@ -75,34 +68,13 @@ GeneralViewSettingsPage::GeneralViewSettingsPage(DolphinMainWindow* mainWindow,
 
     KHBox* vBox = new KHBox(previewBox);
     vBox->setSpacing(spacing);
 
     KHBox* vBox = new KHBox(previewBox);
     vBox->setSpacing(spacing);
-
-    const int min = 1;   // MB
-    const int max = 100; // MB
     m_maxPreviewSize = new QSlider(Qt::Horizontal, vBox);
     m_maxPreviewSize = new QSlider(Qt::Horizontal, vBox);
-    m_maxPreviewSize->setRange(min, max);
-    m_maxPreviewSize->setPageStep(10);
-    m_maxPreviewSize->setSingleStep(1);
-    m_maxPreviewSize->setTickPosition(QSlider::TicksBelow);
-
-    KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings");
-    const int maxByteSize = globalConfig.readEntry("MaximumSize", 1024 * 1024 /* 1 MB */);
-    int maxMByteSize = maxByteSize / (1024 * 1024);
-    if (maxMByteSize < 1) {
-        maxMByteSize = 1;
-    } else if (maxMByteSize > max) {
-        maxMByteSize = max;
-    }
-    m_maxPreviewSize->setValue(maxMByteSize);
 
 
-    QSpinBox* spinBox = new QSpinBox(vBox);
-    spinBox->setRange(min, max);
-    spinBox->setSingleStep(1);
-    spinBox->setSuffix(" MB");
-    spinBox->setValue(m_maxPreviewSize->value());
+    m_spinBox = new QSpinBox(vBox);
 
     connect(m_maxPreviewSize, SIGNAL(valueChanged(int)),
 
     connect(m_maxPreviewSize, SIGNAL(valueChanged(int)),
-            spinBox, SLOT(setValue(int)));
-    connect(spinBox, SIGNAL(valueChanged(int)),
+            m_spinBox, SLOT(setValue(int)));
+    connect(m_spinBox, SIGNAL(valueChanged(int)),
             m_maxPreviewSize, SLOT(setValue(int)));
 
     QVBoxLayout* previewBoxLayout = new QVBoxLayout(previewBox);
             m_maxPreviewSize, SLOT(setValue(int)));
 
     QVBoxLayout* previewBoxLayout = new QVBoxLayout(previewBox);
@@ -113,11 +85,18 @@ GeneralViewSettingsPage::GeneralViewSettingsPage(DolphinMainWindow* mainWindow,
     // a vertical resizing. This assures that the dialog layout
     // is not stretched vertically.
     new QWidget(this);
     // a vertical resizing. This assures that the dialog layout
     // is not stretched vertically.
     new QWidget(this);
+
+    loadSettings();
 }
 
 
 GeneralViewSettingsPage::~GeneralViewSettingsPage()
 }
 
 
 GeneralViewSettingsPage::~GeneralViewSettingsPage()
-{}
+{
+    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
+    settings->setDefaults();
+
+    loadSettings();
+}
 
 void GeneralViewSettingsPage::applySettings()
 {
 
 void GeneralViewSettingsPage::applySettings()
 {
@@ -127,7 +106,6 @@ void GeneralViewSettingsPage::applySettings()
     const bool useGlobalProps = m_globalProps->isChecked();
 
     GeneralSettings* settings = DolphinSettings::instance().generalSettings();
     const bool useGlobalProps = m_globalProps->isChecked();
 
     GeneralSettings* settings = DolphinSettings::instance().generalSettings();
-    Q_ASSERT(settings != 0);
     settings->setGlobalViewProps(useGlobalProps);
 
     if (useGlobalProps) {
     settings->setGlobalViewProps(useGlobalProps);
 
     if (useGlobalProps) {
@@ -147,4 +125,43 @@ void GeneralViewSettingsPage::applySettings()
     globalConfig.sync();
 }
 
     globalConfig.sync();
 }
 
+void GeneralViewSettingsPage::restoreDefaults()
+{
+    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
+    settings->setDefaults();
+    loadSettings();
+}
+
+void GeneralViewSettingsPage::loadSettings()
+{
+    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
+    if (settings->globalViewProps()) {
+        m_globalProps->setChecked(true);
+    } else {
+        m_localProps->setChecked(true);
+    }
+
+    const int min = 1;   // MB
+    const int max = 100; // MB
+    m_maxPreviewSize->setRange(min, max);
+    m_maxPreviewSize->setPageStep(10);
+    m_maxPreviewSize->setSingleStep(1);
+    m_maxPreviewSize->setTickPosition(QSlider::TicksBelow);
+
+    KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings");
+    const int maxByteSize = globalConfig.readEntry("MaximumSize", 1024 * 1024 /* 1 MB */);
+    int maxMByteSize = maxByteSize / (1024 * 1024);
+    if (maxMByteSize < 1) {
+        maxMByteSize = 1;
+    } else if (maxMByteSize > max) {
+        maxMByteSize = max;
+    }
+    m_maxPreviewSize->setValue(maxMByteSize);
+
+    m_spinBox->setRange(min, max);
+    m_spinBox->setSingleStep(1);
+    m_spinBox->setSuffix(" MB");
+    m_spinBox->setValue(m_maxPreviewSize->value());
+}
+
 #include "generalviewsettingspage.moc"
 #include "generalviewsettingspage.moc"
index ad9a687612ce2b3054daaff23ee1a8c968bb66e3..9c5edecf3a8c2e1a7e87cdcce03067a2bfd7510a 100644 (file)
@@ -25,6 +25,7 @@
 class DolphinMainWindow;
 class QRadioButton;
 class QSlider;
 class DolphinMainWindow;
 class QRadioButton;
 class QSlider;
+class QSpinBox;
 
 /**
  * @brief Represents the page from the Dolphin Settings which allows
 
 /**
  * @brief Represents the page from the Dolphin Settings which allows
@@ -45,11 +46,18 @@ public:
      */
     void applySettings();
 
      */
     void applySettings();
 
+    /** Restores the settings to default values. */
+    void restoreDefaults();
+
+private:
+    void loadSettings();
+
 private:
     DolphinMainWindow* m_mainWindow;
     QRadioButton* m_localProps;
     QRadioButton* m_globalProps;
     QSlider* m_maxPreviewSize;
 private:
     DolphinMainWindow* m_mainWindow;
     QRadioButton* m_localProps;
     QRadioButton* m_globalProps;
     QSlider* m_maxPreviewSize;
+    QSpinBox* m_spinBox;
 };
 
 #endif
 };
 
 #endif
index 86823ede05c66de72f5cc0f3cd4f4a2bc805f99a..378ced540eb712d973a078bc5a30d22630f86cf2 100644 (file)
@@ -59,11 +59,6 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
     setSpacing(spacing);
     setMargin(margin);
 
     setSpacing(spacing);
     setMargin(margin);
 
-    IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
-    Q_ASSERT(settings != 0);
-    m_iconSize = settings->iconSize();
-    m_previewSize = settings->previewSize();
-
     m_iconSizeButton = new QPushButton(i18n("Change Icon && Preview Size..."), this);
     connect(m_iconSizeButton, SIGNAL(clicked()),
             this, SLOT(openIconSizeDialog()));
     m_iconSizeButton = new QPushButton(i18n("Change Icon && Preview Size..."), this);
     connect(m_iconSizeButton, SIGNAL(clicked()),
             this, SLOT(openIconSizeDialog()));
@@ -75,15 +70,9 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
 
     QLabel* fontLabel = new QLabel(i18n("Font:"), textGroup);
     m_fontRequester = new KFontRequester(textGroup);
 
     QLabel* fontLabel = new QLabel(i18n("Font:"), textGroup);
     m_fontRequester = new KFontRequester(textGroup);
-    QFont font(settings->fontFamily(),
-               settings->fontSize());
-    font.setItalic(settings->italicFont());
-    font.setBold(settings->boldFont());
-    m_fontRequester->setFont(font);
 
     QLabel* textlinesCountLabel = new QLabel(i18n("Number of lines:"), textGroup);
     m_textlinesCountBox = new QSpinBox(1, 5, 1, textGroup);
 
     QLabel* textlinesCountLabel = new QLabel(i18n("Number of lines:"), textGroup);
     m_textlinesCountBox = new QSpinBox(1, 5, 1, textGroup);
-    m_textlinesCountBox->setValue(settings->numberOfTextlines());
 
     QLabel* textWidthLabel = new QLabel(i18n("Text width:"), textGroup);
     m_textWidthBox = new QComboBox(textGroup);
 
     QLabel* textWidthLabel = new QLabel(i18n("Text width:"), textGroup);
     m_textWidthBox = new QComboBox(textGroup);
@@ -91,20 +80,6 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
     m_textWidthBox->addItem(i18n("Medium"));
     m_textWidthBox->addItem(i18n("Large"));
 
     m_textWidthBox->addItem(i18n("Medium"));
     m_textWidthBox->addItem(i18n("Large"));
 
-    const bool leftToRightArrangement = (settings->arrangement() == QListView::LeftToRight);
-    int textWidthIndex = 0;
-    const int remainingWidth = settings->itemWidth() - settings->iconSize();
-    if (leftToRightArrangement) {
-        textWidthIndex = (remainingWidth - LeftToRightBase) / LeftToRightInc;
-    } else {
-        textWidthIndex = (remainingWidth - TopToBottomBase) / TopToBottomInc;
-    }
-    // ensure that chosen index is always valid
-    textWidthIndex = qMax(textWidthIndex, 0);
-    textWidthIndex = qMin(textWidthIndex, m_textWidthBox->count() - 1);
-
-    m_textWidthBox->setCurrentIndex(textWidthIndex);
-
     QGridLayout* textGroupLayout = new QGridLayout(textGroup);
     textGroupLayout->addWidget(fontLabel, 0, 0);
     textGroupLayout->addWidget(m_fontRequester, 0, 1);
     QGridLayout* textGroupLayout = new QGridLayout(textGroup);
     textGroupLayout->addWidget(fontLabel, 0, 0);
     textGroupLayout->addWidget(m_fontRequester, 0, 1);
@@ -121,14 +96,12 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
     m_arrangementBox = new QComboBox(gridGroup);
     m_arrangementBox->addItem(i18n("Left to Right"));
     m_arrangementBox->addItem(i18n("Top to Bottom"));
     m_arrangementBox = new QComboBox(gridGroup);
     m_arrangementBox->addItem(i18n("Left to Right"));
     m_arrangementBox->addItem(i18n("Top to Bottom"));
-    m_arrangementBox->setCurrentIndex(leftToRightArrangement ? 0 : 1);
 
     QLabel* gridSpacingLabel = new QLabel(i18n("Grid spacing:"), gridGroup);
     m_gridSpacingBox = new QComboBox(gridGroup);
     m_gridSpacingBox->addItem(i18n("Small"));
     m_gridSpacingBox->addItem(i18n("Medium"));
     m_gridSpacingBox->addItem(i18n("Large"));
 
     QLabel* gridSpacingLabel = new QLabel(i18n("Grid spacing:"), gridGroup);
     m_gridSpacingBox = new QComboBox(gridGroup);
     m_gridSpacingBox->addItem(i18n("Small"));
     m_gridSpacingBox->addItem(i18n("Medium"));
     m_gridSpacingBox->addItem(i18n("Large"));
-    m_gridSpacingBox->setCurrentIndex((settings->gridSpacing() - GridSpacingBase) / GridSpacingInc);
 
     QGridLayout* gridGroupLayout = new QGridLayout(gridGroup);
     gridGroupLayout->addWidget(arrangementLabel, 0, 0);
 
     QGridLayout* gridGroupLayout = new QGridLayout(gridGroup);
     gridGroupLayout->addWidget(arrangementLabel, 0, 0);
@@ -140,6 +113,8 @@ IconsViewSettingsPage::IconsViewSettingsPage(DolphinMainWindow* mainWindow,
     // a vertical resizing. This assures that the dialog layout
     // is not stretched vertically.
     new QWidget(this);
     // a vertical resizing. This assures that the dialog layout
     // is not stretched vertically.
     new QWidget(this);
+
+    loadSettings();
 }
 
 IconsViewSettingsPage::~IconsViewSettingsPage()
 }
 
 IconsViewSettingsPage::~IconsViewSettingsPage()
@@ -148,7 +123,6 @@ IconsViewSettingsPage::~IconsViewSettingsPage()
 void IconsViewSettingsPage::applySettings()
 {
     IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
 void IconsViewSettingsPage::applySettings()
 {
     IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
-    Q_ASSERT(settings != 0);
 
     settings->setIconSize(m_iconSize);
     settings->setPreviewSize(m_previewSize);
 
     settings->setIconSize(m_iconSize);
     settings->setPreviewSize(m_previewSize);
@@ -188,6 +162,13 @@ void IconsViewSettingsPage::applySettings()
                              m_gridSpacingBox->currentIndex() * GridSpacingInc);
 }
 
                              m_gridSpacingBox->currentIndex() * GridSpacingInc);
 }
 
+void IconsViewSettingsPage::restoreDefaults()
+{
+    IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+    settings->setDefaults();
+    loadSettings();
+}
+
 void IconsViewSettingsPage::openIconSizeDialog()
 {
     IconSizeDialog dialog(this);
 void IconsViewSettingsPage::openIconSizeDialog()
 {
     IconSizeDialog dialog(this);
@@ -197,4 +178,36 @@ void IconsViewSettingsPage::openIconSizeDialog()
     }
 }
 
     }
 }
 
+void IconsViewSettingsPage::loadSettings()
+{
+    IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+
+    m_iconSize = settings->iconSize();
+    m_previewSize = settings->previewSize();
+
+    QFont font(settings->fontFamily(),
+               settings->fontSize());
+    font.setItalic(settings->italicFont());
+    font.setBold(settings->boldFont());
+    m_fontRequester->setFont(font);
+
+    m_textlinesCountBox->setValue(settings->numberOfTextlines());
+
+    const bool leftToRightArrangement = (settings->arrangement() == QListView::LeftToRight);
+    int textWidthIndex = 0;
+    const int remainingWidth = settings->itemWidth() - settings->iconSize();
+    if (leftToRightArrangement) {
+        textWidthIndex = (remainingWidth - LeftToRightBase) / LeftToRightInc;
+    } else {
+        textWidthIndex = (remainingWidth - TopToBottomBase) / TopToBottomInc;
+    }
+    // ensure that chosen index is always valid
+    textWidthIndex = qMax(textWidthIndex, 0);
+    textWidthIndex = qMin(textWidthIndex, m_textWidthBox->count() - 1);
+
+    m_textWidthBox->setCurrentIndex(textWidthIndex);
+    m_arrangementBox->setCurrentIndex(leftToRightArrangement ? 0 : 1);
+    m_gridSpacingBox->setCurrentIndex((settings->gridSpacing() - GridSpacingBase) / GridSpacingInc);
+}
+
 #include "iconsviewsettingspage.moc"
 #include "iconsviewsettingspage.moc"
index 817620e289607d2d4983df4ca37c310d6b8de583..3080b3b2892e37582a9f11d400871b206d798c2a 100644 (file)
@@ -61,9 +61,15 @@ public:
      */
     void applySettings();
 
      */
     void applySettings();
 
+    /** Restores the settings to default values. */
+    void restoreDefaults();
+
 private slots:
     void openIconSizeDialog();
 
 private slots:
     void openIconSizeDialog();
 
+private:
+    void loadSettings();
+
 private:
     enum
     {
 private:
     enum
     {
index d8626feb3b2da2e15a0c8fbbe8ccec18c5e95210..d785e5dcdf14dbe96bd6457880a65e0df71ab8fb 100644 (file)
@@ -41,6 +41,12 @@ public:
      * persistently store the settings.
      */
     virtual void applySettings() = 0;
      * persistently store the settings.
      */
     virtual void applySettings() = 0;
+
+    /**
+     * Must be implemented by a derived class to
+     * restored the settings to default values.
+     */
+    virtual void restoreDefaults() = 0;
 };
 
 #endif
 };
 
 #endif
index 9791588d6de139a6e2050058c4c61c2f8cda0bab..b52dfc78d7fdcdae872599a1dc670a2d30b82f4e 100644 (file)
@@ -68,7 +68,8 @@ ViewSettingsPage::ViewSettingsPage(DolphinMainWindow* mainWindow,
 }
 
 ViewSettingsPage::~ViewSettingsPage()
 }
 
 ViewSettingsPage::~ViewSettingsPage()
-{}
+{
+}
 
 void ViewSettingsPage::applySettings()
 {
 
 void ViewSettingsPage::applySettings()
 {
@@ -78,4 +79,12 @@ void ViewSettingsPage::applySettings()
     m_columnPage->applySettings();
 }
 
     m_columnPage->applySettings();
 }
 
+void ViewSettingsPage::restoreDefaults()
+{
+    m_generalPage->restoreDefaults();
+    m_iconsPage->restoreDefaults();
+    m_detailsPage->restoreDefaults();
+    m_columnPage->restoreDefaults();
+}
+
 #include "viewsettingspage.moc"
 #include "viewsettingspage.moc"
index da80f26feba877df8838a833f7e8e66d601f7476..46671cb0c3c43adb97a2ad111c230dc34918a741 100644 (file)
@@ -43,9 +43,12 @@ public:
     ViewSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
     virtual ~ViewSettingsPage();
 
     ViewSettingsPage(DolphinMainWindow* mainWindow, QWidget* parent);
     virtual ~ViewSettingsPage();
 
-    /** @see SettingsPageBase::applySettings */
+    /** @see SettingsPageBase::applySettings() */
     virtual void applySettings();
 
     virtual void applySettings();
 
+    /** @see SettingsPageBase::restoreDefaults() */
+    virtual void restoreDefaults();
+
 private:
     GeneralViewSettingsPage* m_generalPage;
     IconsViewSettingsPage* m_iconsPage;
 private:
     GeneralViewSettingsPage* m_generalPage;
     IconsViewSettingsPage* m_iconsPage;