]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Simplified code for the viewmode settings
authorPeter Penz <peter.penz19@gmail.com>
Fri, 2 Sep 2011 17:48:57 +0000 (19:48 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Fri, 2 Sep 2011 17:49:49 +0000 (19:49 +0200)
19 files changed:
src/CMakeLists.txt
src/dolphinmainwindow.cpp
src/settings/kcm/kcmdolphinviewmodes.cpp
src/settings/kcm/kcmdolphinviewmodes.h
src/settings/viewmodes/detailsviewsettingspage.cpp [deleted file]
src/settings/viewmodes/dolphinfontrequester.cpp
src/settings/viewmodes/dolphinfontrequester.h
src/settings/viewmodes/iconsizegroupbox.cpp [deleted file]
src/settings/viewmodes/iconsizegroupbox.h [deleted file]
src/settings/viewmodes/iconsviewsettingspage.cpp [deleted file]
src/settings/viewmodes/iconsviewsettingspage.h [deleted file]
src/settings/viewmodes/viewsettingspage.cpp
src/settings/viewmodes/viewsettingspage.h
src/settings/viewmodes/viewsettingspagebase.cpp [deleted file]
src/settings/viewmodes/viewsettingspagebase.h [deleted file]
src/settings/viewmodes/viewsettingstab.cpp [new file with mode: 0644]
src/settings/viewmodes/viewsettingstab.h [moved from src/settings/viewmodes/detailsviewsettingspage.h with 65% similarity]
src/settings/viewpropertiesdialog.cpp
src/views/dolphinviewactionhandler.cpp

index b443aa773f617da9b1e927aec455725a39dc1614..7826ee00fa5f460e403f6627b59a0906b2538d4c 100644 (file)
@@ -140,12 +140,9 @@ set(dolphin_SRCS
     settings/servicemodel.cpp
     settings/startup/startupsettingspage.cpp
     settings/trash/trashsettingspage.cpp
-    settings/viewmodes/detailsviewsettingspage.cpp
     settings/viewmodes/dolphinfontrequester.cpp
-    settings/viewmodes/iconsizegroupbox.cpp
-    settings/viewmodes/iconsviewsettingspage.cpp
     settings/viewmodes/viewsettingspage.cpp
-    settings/viewmodes/viewsettingspagebase.cpp
+    settings/viewmodes/viewsettingstab.cpp
     statusbar/dolphinstatusbar.cpp
     statusbar/statusbarspaceinfo.cpp
     views/zoomlevelinfo.cpp
@@ -204,11 +201,8 @@ install(TARGETS dolphin ${INSTALL_TARGETS_DEFAULT_ARGS})
 
 set(kcm_dolphinviewmodes_PART_SRCS
     settings/kcm/kcmdolphinviewmodes.cpp
-    settings/viewmodes/detailsviewsettingspage.cpp
     settings/viewmodes/dolphinfontrequester.cpp
-    settings/viewmodes/iconsizegroupbox.cpp
-    settings/viewmodes/iconsviewsettingspage.cpp
-    settings/viewmodes/viewsettingspagebase.cpp
+    settings/viewmodes/viewsettingstab.cpp
     views/zoomlevelinfo.cpp)
 
 set(kcm_dolphinnavigation_PART_SRCS
index 76d61978f7b049f79a721b7375db2dbf886f0112..3def8d88cc1ce3d78404f9dbd3584525d6322d36 100644 (file)
@@ -49,7 +49,6 @@
 #endif
 
 #include "dolphin_generalsettings.h"
-#include "dolphin_iconsmodesettings.h"
 #include "dolphin_searchsettings.h"
 
 #include <KAcceleratorManager>
index 4e49257cea3a2b85d1863c53b9e9fffedb8505da..5441b78da18dee0455c867f2193cefd77f1a157c 100644 (file)
@@ -25,8 +25,7 @@
 #include <KPluginFactory>
 #include <KPluginLoader>
 
-#include <settings/viewmodes/detailsviewsettingspage.h>
-#include <settings/viewmodes/iconsviewsettingspage.h>
+#include <settings/viewmodes/viewsettingstab.h>
 
 #include <QDBusConnection>
 #include <QDBusMessage>
@@ -39,7 +38,7 @@ K_EXPORT_PLUGIN(KCMDolphinViewModesConfigFactory("kcmdolphinviewmodes"))
 
 DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget* parent, const QVariantList& args) :
     KCModule(KCMDolphinViewModesConfigFactory::componentData(), parent),
-    m_pages()
+    m_tabs()
 {
     Q_UNUSED(args);
 
@@ -53,20 +52,24 @@ DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget* parent, cons
 
     KTabWidget* tabWidget = new KTabWidget(this);
 
-    // initialize 'Icons' tab
-    IconsViewSettingsPage* iconsPage = new IconsViewSettingsPage(tabWidget);
-    tabWidget->addTab(iconsPage, KIcon("view-list-icons"), i18nc("@title:tab", "Icons"));
-    connect(iconsPage, SIGNAL(changed()), this, SLOT(changed()));
+    // Initialize 'Icons' tab
+    ViewSettingsTab* iconsTab = new ViewSettingsTab(ViewSettingsTab::IconsMode, tabWidget);
+    tabWidget->addTab(iconsTab, KIcon("view-list-icons"), i18nc("@title:tab", "Icons"));
+    connect(iconsTab, SIGNAL(changed()), this, SIGNAL(changed()));
 
-    // TODO: initialize 'Compact' tab
+    // Initialize 'Compact' tab
+    ViewSettingsTab* compactTab = new ViewSettingsTab(ViewSettingsTab::CompactMode, tabWidget);
+    tabWidget->addTab(compactTab, KIcon("view-list-details"), i18nc("@title:tab", "Compact"));
+    connect(compactTab, SIGNAL(changed()), this, SIGNAL(changed()));
 
-    // initialize 'Details' tab
-    DetailsViewSettingsPage* detailsPage = new DetailsViewSettingsPage(tabWidget);
-    tabWidget->addTab(detailsPage, KIcon("view-list-text"), i18nc("@title:tab", "Details"));
-    connect(detailsPage, SIGNAL(changed()), this, SLOT(changed()));
+    // Initialize 'Details' tab
+    ViewSettingsTab* detailsTab = new ViewSettingsTab(ViewSettingsTab::DetailsMode, tabWidget);
+    tabWidget->addTab(detailsTab, KIcon("view-list-tree"), i18nc("@title:tab", "Details"));
+    connect(detailsTab, SIGNAL(changed()), this, SIGNAL(changed()));
 
-    m_pages.append(iconsPage);
-    m_pages.append(detailsPage);
+    m_tabs.append(iconsTab);
+    m_tabs.append(compactTab);
+    m_tabs.append(detailsTab);
 
     topLayout->addWidget(tabWidget, 0, 0);
 }
@@ -77,16 +80,16 @@ DolphinViewModesConfigModule::~DolphinViewModesConfigModule()
 
 void DolphinViewModesConfigModule::save()
 {
-    foreach (ViewSettingsPageBase* page, m_pages) {
-        page->applySettings();
+    foreach (ViewSettingsTab* tab, m_tabs) {
+        tab->applySettings();
     }
     reparseConfiguration();
 }
 
 void DolphinViewModesConfigModule::defaults()
 {
-    foreach (ViewSettingsPageBase* page, m_pages) {
-        page->restoreDefaults();
+    foreach (ViewSettingsTab* tab, m_tabs) {
+        tab->restoreDefaultSettings();
     }
     reparseConfiguration();
 }
index d3554c39c3d32918efc9237f5c6a50aa89c72b35..4ec29db356c6fc680c88836be0cfb0f61292a44b 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <kcmodule.h>
 
-class ViewSettingsPageBase;
+class ViewSettingsTab;
 
 /**
  * @brief Allow to configure the Dolphin views.
@@ -42,7 +42,7 @@ private:
     void reparseConfiguration();
 
 private:
-    QList<ViewSettingsPageBase*> m_pages;
+    QList<ViewSettingsTab*> m_tabs;
 };
 
 #endif
diff --git a/src/settings/viewmodes/detailsviewsettingspage.cpp b/src/settings/viewmodes/detailsviewsettingspage.cpp
deleted file mode 100644 (file)
index b2338dc..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#include "detailsviewsettingspage.h"
-
-#include "iconsizegroupbox.h"
-#include "dolphinfontrequester.h"
-#include "dolphin_detailsmodesettings.h"
-
-#include <KDialog>
-#include <KLocale>
-
-#include <QButtonGroup>
-#include <QCheckBox>
-#include <QComboBox>
-#include <QGroupBox>
-#include <QGridLayout>
-#include <QLabel>
-#include <QRadioButton>
-#include <QSpinBox>
-
-#include <views/zoomlevelinfo.h>
-
-DetailsViewSettingsPage::DetailsViewSettingsPage(QWidget* parent) :
-    ViewSettingsPageBase(parent),
-    m_iconSizeGroupBox(0),
-    m_fontRequester(0)
-{
-    const int spacing = KDialog::spacingHint();
-    const int margin = KDialog::marginHint();
-    const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
-
-    setSpacing(spacing);
-    setMargin(margin);
-
-    // Create "Icon" properties
-    m_iconSizeGroupBox = new IconSizeGroupBox(this);
-    m_iconSizeGroupBox->setSizePolicy(sizePolicy);
-
-    const int min = ZoomLevelInfo::minimumLevel();
-    const int max = ZoomLevelInfo::maximumLevel();
-    m_iconSizeGroupBox->setDefaultSizeRange(min, max);
-    m_iconSizeGroupBox->setPreviewSizeRange(min, max);
-
-    // create "Text" properties
-    QWidget* textGroup = new QGroupBox(i18nc("@title:group", "Text"), this);
-    textGroup->setSizePolicy(sizePolicy);
-
-    QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textGroup);
-    m_fontRequester = new DolphinFontRequester(textGroup);
-
-    QHBoxLayout* textLayout = new QHBoxLayout(textGroup);
-    textLayout->addWidget(fontLabel, 0, Qt::AlignRight);
-    textLayout->addWidget(m_fontRequester);
-
-    // Add a dummy widget with no restriction regarding
-    // a vertical resizing. This assures that the dialog layout
-    // is not stretched vertically.
-    new QWidget(this);
-
-    loadSettings();
-
-    connect(m_iconSizeGroupBox, SIGNAL(defaultSizeChanged(int)), this, SIGNAL(changed()));
-    connect(m_iconSizeGroupBox, SIGNAL(previewSizeChanged(int)), this, SIGNAL(changed()));
-    connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed()));
-}
-
-DetailsViewSettingsPage::~DetailsViewSettingsPage()
-{
-}
-
-void DetailsViewSettingsPage::applySettings()
-{
-    const int iconSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->defaultSizeValue());
-    const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->previewSizeValue());
-    DetailsModeSettings::setIconSize(iconSize);
-    DetailsModeSettings::setPreviewSize(previewSize);
-
-    const QFont font = m_fontRequester->font();
-    DetailsModeSettings::setUseSystemFont(m_fontRequester->mode() == DolphinFontRequester::SystemFont);
-    DetailsModeSettings::setFontFamily(font.family());
-    DetailsModeSettings::setFontSize(font.pointSizeF());
-    DetailsModeSettings::setItalicFont(font.italic());
-    DetailsModeSettings::setFontWeight(font.weight());
-
-    DetailsModeSettings::self()->writeConfig();
-}
-
-void DetailsViewSettingsPage::restoreDefaults()
-{
-    DetailsModeSettings::self()->useDefaults(true);
-    loadSettings();
-    DetailsModeSettings::self()->useDefaults(false);
-}
-
-void DetailsViewSettingsPage::loadSettings()
-{
-    const QSize iconSize(DetailsModeSettings::iconSize(), DetailsModeSettings::iconSize());
-    const int iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize);
-    m_iconSizeGroupBox->setDefaultSizeValue(iconSizeValue);
-
-    const QSize previewSize(DetailsModeSettings::previewSize(), DetailsModeSettings::previewSize());
-    const int previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize);
-    m_iconSizeGroupBox->setPreviewSizeValue(previewSizeValue);
-
-    if (DetailsModeSettings::useSystemFont()) {
-        m_fontRequester->setMode(DolphinFontRequester::SystemFont);
-    } else {
-        QFont font(DetailsModeSettings::fontFamily(),
-                   qRound(DetailsModeSettings::fontSize()));
-        font.setItalic(DetailsModeSettings::italicFont());
-        font.setWeight(DetailsModeSettings::fontWeight());
-        font.setPointSizeF(DetailsModeSettings::fontSize());
-        m_fontRequester->setMode(DolphinFontRequester::CustomFont);
-        m_fontRequester->setCustomFont(font);
-    }
-}
-
-#include "detailsviewsettingspage.moc"
index 09bc63e6158613af11de5194b11ac2e62ed7787a..32e3ce65ed96e7c0ccfc4f05cf9fa7d0abc71898 100644 (file)
 #include <KComboBox>
 
 #include <QEvent>
+#include <QHBoxLayout>
 #include <QPushButton>
 
 DolphinFontRequester::DolphinFontRequester(QWidget* parent) :
-    KHBox(parent),
+    QWidget(parent),
     m_modeCombo(0),
     m_chooseFontButton(0),
     m_mode(SystemFont),
     m_customFont()
 {
-    setSpacing(KDialog::spacingHint());
+    QHBoxLayout* topLayout = new QHBoxLayout(this);
+    topLayout->setMargin(0);
 
     m_modeCombo = new KComboBox(this);
     m_modeCombo->addItem(i18nc("@item:inlistbox Font", "System Font"));
@@ -47,6 +49,9 @@ DolphinFontRequester::DolphinFontRequester(QWidget* parent) :
             this, SLOT(openFontDialog()));
 
     changeMode(m_modeCombo->currentIndex());
+
+    topLayout->addWidget(m_modeCombo);
+    topLayout->addWidget(m_chooseFontButton);
 }
 
 DolphinFontRequester::~DolphinFontRequester()
@@ -57,7 +62,7 @@ void DolphinFontRequester::setMode(Mode mode)
 {
     m_mode = mode;
     m_modeCombo->setCurrentIndex(m_mode);
-    m_modeCombo->setFont(font());
+    m_modeCombo->setFont(customFont());
     m_chooseFontButton->setEnabled(m_mode == CustomFont);
 }
 
@@ -66,7 +71,7 @@ DolphinFontRequester::Mode DolphinFontRequester::mode() const
     return m_mode;
 }
 
-QFont DolphinFontRequester::font() const
+QFont DolphinFontRequester::currentFont() const
 {
     return (m_mode == CustomFont) ? m_customFont : KGlobalSettings::generalFont();
 }
@@ -84,9 +89,9 @@ QFont DolphinFontRequester::customFont() const
 bool DolphinFontRequester::event(QEvent* event)
 {
     if (event->type() == QEvent::Polish) {
-        m_modeCombo->setFont(font());
+        m_modeCombo->setFont(customFont());
     }
-    return KHBox::event(event);
+    return QWidget::event(event);
 }
 
 void DolphinFontRequester::openFontDialog()
index 263548555069a1b544bbe5e42f1e2ed186b4240e..57cddc5cd46f727aa904e6d0ecb32672cd8b528e 100644 (file)
@@ -20,9 +20,8 @@
 #ifndef DOLPHINFONTREQUESTER_H
 #define DOLPHINFONTREQUESTER_H
 
-#include <khbox.h>
-
 #include <QFont>
+#include <QWidget>
 
 class KComboBox;
 class QPushButton;
@@ -30,7 +29,7 @@ class QPushButton;
 /**
  * @brief Allows to select between using the system font or a custom font.
  */
-class DolphinFontRequester : public KHBox
+class DolphinFontRequester : public QWidget
 {
     Q_OBJECT
 
@@ -52,7 +51,7 @@ public:
      * if the mode is \a CustomFont, otherwise the system font is
      * returned.
      */
-    QFont font() const;
+    QFont currentFont() const;
 
     void setCustomFont(const QFont& font);
     QFont customFont() const;
diff --git a/src/settings/viewmodes/iconsizegroupbox.cpp b/src/settings/viewmodes/iconsizegroupbox.cpp
deleted file mode 100644 (file)
index 6538a74..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#include "iconsizegroupbox.h"
-
-#include <KLocale>
-
-#include <QApplication>
-#include <QGridLayout>
-#include <QHelpEvent>
-#include <QLabel>
-#include <QPoint>
-#include <QRect>
-#include <QSlider>
-
-#include <views/zoomlevelinfo.h>
-
-IconSizeGroupBox::IconSizeGroupBox(QWidget* parent) :
-    QGroupBox(i18nc("@title:group", "Icon Size"), parent),
-    m_defaultSizeSlider(0),
-    m_previewSizeSlider(0)
-{
-    QLabel* defaultLabel = new QLabel(i18nc("@label:listbox", "Default:"), this);
-    m_defaultSizeSlider = new QSlider(Qt::Horizontal, this);
-    m_defaultSizeSlider->setPageStep(1);
-    m_defaultSizeSlider->setTickPosition(QSlider::TicksBelow);
-    connect(m_defaultSizeSlider, SIGNAL(valueChanged(int)),
-            this, SLOT(slotDefaultSliderMoved(int)));
-
-    QLabel* previewLabel = new QLabel(i18nc("@label:listbox", "Preview:"), this);
-    m_previewSizeSlider = new QSlider(Qt::Horizontal, this);
-    m_previewSizeSlider->setPageStep(1);
-    m_previewSizeSlider->setTickPosition(QSlider::TicksBelow);
-    connect(m_previewSizeSlider, SIGNAL(valueChanged(int)),
-            this, SLOT(slotPreviewSliderMoved(int)));
-
-    QGridLayout* layout = new QGridLayout(this);
-    layout->addWidget(defaultLabel, 0, 0, Qt::AlignRight);
-    layout->addWidget(m_defaultSizeSlider, 0, 1);
-    layout->addWidget(previewLabel, 1, 0, Qt::AlignRight);
-    layout->addWidget(m_previewSizeSlider, 1, 1);
-}
-
-IconSizeGroupBox::~IconSizeGroupBox()
-{
-}
-
-void IconSizeGroupBox::setDefaultSizeRange(int min, int max)
-{
-    m_defaultSizeSlider->setRange(min, max);
-}
-
-void IconSizeGroupBox::setPreviewSizeRange(int min, int max)
-{
-    m_previewSizeSlider->setRange(min, max);
-}
-
-void IconSizeGroupBox::setDefaultSizeValue(int value)
-{
-    m_defaultSizeSlider->setValue(value);
-}
-
-int IconSizeGroupBox::defaultSizeValue() const
-{
-    return m_defaultSizeSlider->value();
-}
-
-void IconSizeGroupBox::setPreviewSizeValue(int value)
-{
-    m_previewSizeSlider->setValue(value);
-}
-
-int IconSizeGroupBox::previewSizeValue() const
-{
-    return m_previewSizeSlider->value();
-}
-
-void IconSizeGroupBox::slotDefaultSliderMoved(int value)
-{
-    showToolTip(m_defaultSizeSlider, value);
-    emit defaultSizeChanged(value);
-}
-
-void IconSizeGroupBox::slotPreviewSliderMoved(int value)
-{
-    showToolTip(m_previewSizeSlider, value);
-    emit previewSizeChanged(value);
-}
-
-void IconSizeGroupBox::showToolTip(QSlider* slider, int value)
-{
-    const int size = ZoomLevelInfo::iconSizeForZoomLevel(value);
-    slider->setToolTip(i18ncp("@info:tooltip", "Size: 1 pixel", "Size: %1 pixels", size));
-    if (!slider->isVisible()) {
-        return;
-    }
-    QPoint global = slider->rect().topLeft();
-    global.ry() += slider->height() / 2;
-    QHelpEvent toolTipEvent(QEvent::ToolTip, QPoint(0, 0), slider->mapToGlobal(global));
-    QApplication::sendEvent(slider, &toolTipEvent);
-}
-
-#include "iconsizegroupbox.moc"
diff --git a/src/settings/viewmodes/iconsizegroupbox.h b/src/settings/viewmodes/iconsizegroupbox.h
deleted file mode 100644 (file)
index a98085b..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#ifndef ICONSIZEGROUPBOX_H
-#define ICONSIZEGROUPBOX_H
-
-#include <QGroupBox>
-
-class QSlider;
-
-/**
- * @short Provides a group box for adjusting the icon sizes.
- *
- * It is possible to adjust the default icon size and the icon
- * size when previews are used.
- */
-class IconSizeGroupBox : public QGroupBox
-{
-    Q_OBJECT
-
-public:
-    explicit IconSizeGroupBox(QWidget* parent);
-    virtual ~IconSizeGroupBox();
-
-    void setDefaultSizeRange(int min, int max);
-    void setPreviewSizeRange(int min, int max);
-
-    void setDefaultSizeValue(int value);
-    int defaultSizeValue() const;
-
-    void setPreviewSizeValue(int value);
-    int previewSizeValue() const;
-
-signals:
-    void defaultSizeChanged(int value);
-    void previewSizeChanged(int value);
-
-private slots:
-    void slotDefaultSliderMoved(int value);
-    void slotPreviewSliderMoved(int value);
-
-private:
-    void showToolTip(QSlider* slider, int value);
-
-private:
-    QSlider* m_defaultSizeSlider;
-    QSlider* m_previewSizeSlider;
-};
-
-#endif
diff --git a/src/settings/viewmodes/iconsviewsettingspage.cpp b/src/settings/viewmodes/iconsviewsettingspage.cpp
deleted file mode 100644 (file)
index 41438fb..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#include "iconsviewsettingspage.h"
-
-#include "dolphinfontrequester.h"
-#include "iconsizegroupbox.h"
-
-#include "dolphin_iconsmodesettings.h"
-
-#include <KDialog>
-#include <KIconLoader>
-#include <KGlobalSettings>
-#include <KLocale>
-#include <KComboBox>
-#include <KNumInput>
-
-#include <QCheckBox>
-#include <QGroupBox>
-#include <QLabel>
-#include <QPushButton>
-#include <QGridLayout>
-
-#include <views/zoomlevelinfo.h>
-
-IconsViewSettingsPage::IconsViewSettingsPage(QWidget* parent) :
-    ViewSettingsPageBase(parent),
-    m_iconSizeGroupBox(0),
-    m_textWidthBox(0),
-    m_fontRequester(0)
-{
-    const int spacing = KDialog::spacingHint();
-    const int margin = KDialog::marginHint();
-    const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
-
-    setSpacing(spacing);
-    setMargin(margin);
-
-    // Create "Icon" properties
-    m_iconSizeGroupBox = new IconSizeGroupBox(this);
-    m_iconSizeGroupBox->setSizePolicy(sizePolicy);
-
-    const int min = ZoomLevelInfo::minimumLevel();
-    const int max = ZoomLevelInfo::maximumLevel();
-    m_iconSizeGroupBox->setDefaultSizeRange(min, max);
-    m_iconSizeGroupBox->setPreviewSizeRange(min, max);
-
-    // Create 'Text' group for selecting the font, the number of lines
-    // and the text width
-    QGroupBox* textGroup = new QGroupBox(i18nc("@title:group", "Text"), this);
-    textGroup->setSizePolicy(sizePolicy);
-
-    QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textGroup);
-    m_fontRequester = new DolphinFontRequester(textGroup);
-
-    QLabel* textWidthLabel = new QLabel(i18nc("@label:listbox", "Text width:"), textGroup);
-    m_textWidthBox = new KComboBox(textGroup);
-    m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Small"));
-    m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Medium"));
-    m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Large"));
-    m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Huge"));
-
-    QGridLayout* textGroupLayout = new QGridLayout(textGroup);
-    textGroupLayout->addWidget(fontLabel, 0, 0, Qt::AlignRight);
-    textGroupLayout->addWidget(m_fontRequester, 0, 1);
-    textGroupLayout->addWidget(textWidthLabel, 2, 0, Qt::AlignRight);
-    textGroupLayout->addWidget(m_textWidthBox, 2, 1);
-
-    // Add a dummy widget with no restriction regarding
-    // a vertical resizing. This assures that the dialog layout
-    // is not stretched vertically.
-    new QWidget(this);
-
-    loadSettings();
-
-    connect(m_iconSizeGroupBox, SIGNAL(defaultSizeChanged(int)), this, SIGNAL(changed()));
-    connect(m_iconSizeGroupBox, SIGNAL(previewSizeChanged(int)), this, SIGNAL(changed()));
-    connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed()));
-    connect(m_textWidthBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
-}
-
-IconsViewSettingsPage::~IconsViewSettingsPage()
-{
-}
-
-void IconsViewSettingsPage::applySettings()
-{
-    const int iconSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->defaultSizeValue());
-    const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->previewSizeValue());
-    IconsModeSettings::setIconSize(iconSize);
-    IconsModeSettings::setPreviewSize(previewSize);
-
-    const QFont font = m_fontRequester->font();
-    IconsModeSettings::setUseSystemFont(m_fontRequester->mode() == DolphinFontRequester::SystemFont);
-    IconsModeSettings::setFontFamily(font.family());
-    IconsModeSettings::setFontSize(font.pointSizeF());
-    IconsModeSettings::setItalicFont(font.italic());
-    IconsModeSettings::setFontWeight(font.weight());
-
-    IconsModeSettings::setTextWidthIndex(m_textWidthBox->currentIndex());
-
-    IconsModeSettings::self()->writeConfig();
-}
-
-void IconsViewSettingsPage::restoreDefaults()
-{
-    IconsModeSettings::self()->useDefaults(true);
-    loadSettings();
-    IconsModeSettings::self()->useDefaults(false);
-}
-
-void IconsViewSettingsPage::loadSettings()
-{
-    const QSize iconSize(IconsModeSettings::iconSize(), IconsModeSettings::iconSize());
-    const int iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize);
-    m_iconSizeGroupBox->setDefaultSizeValue(iconSizeValue);
-
-    const QSize previewSize(IconsModeSettings::previewSize(), IconsModeSettings::previewSize());
-    const int previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize);
-    m_iconSizeGroupBox->setPreviewSizeValue(previewSizeValue);
-
-    if (IconsModeSettings::useSystemFont()) {
-        m_fontRequester->setMode(DolphinFontRequester::SystemFont);
-    } else {
-        QFont font(IconsModeSettings::fontFamily(),
-                   qRound(IconsModeSettings::fontSize()));
-        font.setItalic(IconsModeSettings::italicFont());
-        font.setWeight(IconsModeSettings::fontWeight());
-        font.setPointSizeF(IconsModeSettings::fontSize());
-        m_fontRequester->setMode(DolphinFontRequester::CustomFont);
-        m_fontRequester->setCustomFont(font);
-    }
-
-    m_textWidthBox->setCurrentIndex(IconsModeSettings::textWidthIndex());
-}
-
-#include "iconsviewsettingspage.moc"
diff --git a/src/settings/viewmodes/iconsviewsettingspage.h b/src/settings/viewmodes/iconsviewsettingspage.h
deleted file mode 100644 (file)
index ad829f1..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#ifndef ICONSVIEWSETTINGSPAGE_H
-#define ICONSVIEWSETTINGSPAGE_H
-
-#include "viewsettingspagebase.h"
-
-class DolphinFontRequester;
-class IconSizeGroupBox;
-class KComboBox;
-class KIntSpinBox;
-
-/**
- * @brief Tab page for the 'Icons Mode' settings
- * of the Dolphin settings dialog.
- *
- * Allows to set:
- * - icon size
- * - preview size
- * - text width
- * - font
- *
- * @see DolphinIconsViewSettings
- */
-class IconsViewSettingsPage : public ViewSettingsPageBase
-{
-    Q_OBJECT
-
-public:
-    IconsViewSettingsPage(QWidget* parent);
-    virtual ~IconsViewSettingsPage();
-
-    /**
-     * Applies the settings for the icons view.
-     * The settings are persisted automatically when
-     * closing Dolphin.
-     */
-    virtual void applySettings();
-
-    /** Restores the settings to default values. */
-    virtual void restoreDefaults();
-
-private:
-    void loadSettings();
-
-private:
-    IconSizeGroupBox* m_iconSizeGroupBox;
-    KComboBox* m_textWidthBox;
-    DolphinFontRequester* m_fontRequester;
-};
-
-#endif
index ac4ed929678fd0662cb54b3d4661840f6cc37d82..4f8a3f00d393248319c407fffecd1bbadcea2b9c 100644 (file)
@@ -20,8 +20,8 @@
 
 #include "viewsettingspage.h"
 
-#include "iconsviewsettingspage.h"
-#include "detailsviewsettingspage.h"
+#include <views/dolphinview.h>
+#include "viewsettingstab.h"
 
 #include <QVBoxLayout>
 
@@ -32,7 +32,7 @@
 
 ViewSettingsPage::ViewSettingsPage(QWidget* parent) :
     SettingsPageBase(parent),
-    m_pages()
+    m_tabs()
 {
     QVBoxLayout* topLayout = new QVBoxLayout(this);
     topLayout->setMargin(0);
@@ -40,20 +40,24 @@ ViewSettingsPage::ViewSettingsPage(QWidget* parent) :
 
     KTabWidget* tabWidget = new KTabWidget(this);
 
-    // initialize 'Icons' tab
-    IconsViewSettingsPage* iconsPage = new IconsViewSettingsPage(tabWidget);
-    tabWidget->addTab(iconsPage, KIcon("view-list-icons"), i18nc("@title:tab", "Icons"));
-    connect(iconsPage, SIGNAL(changed()), this, SIGNAL(changed()));
+    // Initialize 'Icons' tab
+    ViewSettingsTab* iconsTab = new ViewSettingsTab(ViewSettingsTab::IconsMode, tabWidget);
+    tabWidget->addTab(iconsTab, KIcon("view-list-icons"), i18nc("@title:tab", "Icons"));
+    connect(iconsTab, SIGNAL(changed()), this, SIGNAL(changed()));
 
-    // TODO: initialize 'Compact' tab
+    // Initialize 'Compact' tab
+    ViewSettingsTab* compactTab = new ViewSettingsTab(ViewSettingsTab::CompactMode, tabWidget);
+    tabWidget->addTab(compactTab, KIcon("view-list-details"), i18nc("@title:tab", "Compact"));
+    connect(compactTab, SIGNAL(changed()), this, SIGNAL(changed()));
 
-    // initialize 'Details' tab
-    DetailsViewSettingsPage* detailsPage = new DetailsViewSettingsPage(tabWidget);
-    tabWidget->addTab(detailsPage, KIcon("view-list-text"), i18nc("@title:tab", "Details"));
-    connect(detailsPage, SIGNAL(changed()), this, SIGNAL(changed()));
+    // Initialize 'Details' tab
+    ViewSettingsTab* detailsTab = new ViewSettingsTab(ViewSettingsTab::DetailsMode, tabWidget);
+    tabWidget->addTab(detailsTab, KIcon("view-list-tree"), i18nc("@title:tab", "Details"));
+    connect(detailsTab, SIGNAL(changed()), this, SIGNAL(changed()));
 
-    m_pages.append(iconsPage);
-    m_pages.append(detailsPage);
+    m_tabs.append(iconsTab);
+    m_tabs.append(compactTab);
+    m_tabs.append(detailsTab);
 
     topLayout->addWidget(tabWidget, 0, 0);
 }
@@ -64,15 +68,15 @@ ViewSettingsPage::~ViewSettingsPage()
 
 void ViewSettingsPage::applySettings()
 {
-    foreach (ViewSettingsPageBase* page, m_pages) {
-        page->applySettings();
+    foreach (ViewSettingsTab* tab, m_tabs) {
+        tab->applySettings();
     }
 }
 
 void ViewSettingsPage::restoreDefaults()
 {
-    foreach (ViewSettingsPageBase* page, m_pages) {
-        page->restoreDefaults();
+    foreach (ViewSettingsTab* tab, m_tabs) {
+        tab->restoreDefaultSettings();
     }
 }
 
index 56e9f910dcb1488208880abbfc7810d59fddcce0..4464031823db05cb33cbddb6730e5e32d78a96a0 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <settings/settingspagebase.h>
 
-class ViewSettingsPageBase;
+class ViewSettingsTab;
 class QWidget;
 
 /**
@@ -46,7 +46,7 @@ public:
     virtual void restoreDefaults();
 
 private:
-    QList<ViewSettingsPageBase*> m_pages;
+    QList<ViewSettingsTab*> m_tabs;
 };
 
 #endif
diff --git a/src/settings/viewmodes/viewsettingspagebase.cpp b/src/settings/viewmodes/viewsettingspagebase.cpp
deleted file mode 100644 (file)
index 315d566..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#include "viewsettingspagebase.h"
-
-ViewSettingsPageBase::ViewSettingsPageBase(QWidget* parent) :
-    KVBox(parent)
-{
-}
-
-ViewSettingsPageBase::~ViewSettingsPageBase()
-{
-}
-
-#include "viewsettingspagebase.moc"
diff --git a/src/settings/viewmodes/viewsettingspagebase.h b/src/settings/viewmodes/viewsettingspagebase.h
deleted file mode 100644 (file)
index 71111f6..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#ifndef VIEWSETTINGSPAGEBASE_H
-#define VIEWSETTINGSPAGEBASE_H
-
-#include <KVBox>
-
-/**
- * @brief Base class for view settings configuration pages.
- *
- * @see GeneralViewSettingsPage;
- * @see IconViewSettingsPage
- * @see DetailsViewSettingsPage
- * @see ColumnViewSettingsPage
- */
-class ViewSettingsPageBase : public KVBox
-{
-    Q_OBJECT
-
-public:
-    ViewSettingsPageBase(QWidget* parent);
-    virtual ~ViewSettingsPageBase();
-
-    /**
-     * Applies the settings for the view.
-     * The settings are persisted automatically when
-     * closing Dolphin.
-     */
-    virtual void applySettings() = 0;
-
-    /** Restores the settings to default values. */
-    virtual void restoreDefaults() = 0;
-
-signals:
-    void changed();
-};
-
-#endif
diff --git a/src/settings/viewmodes/viewsettingstab.cpp b/src/settings/viewmodes/viewsettingstab.cpp
new file mode 100644 (file)
index 0000000..743f042
--- /dev/null
@@ -0,0 +1,215 @@
+/***************************************************************************
+ *   Copyright (C) 2008-2011 by Peter Penz <peter.penz19@gmail.com>        *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#include "viewsettingstab.h"
+
+#include "dolphinfontrequester.h"
+#include "dolphin_compactmodesettings.h"
+#include "dolphin_detailsmodesettings.h"
+#include "dolphin_iconsmodesettings.h"
+
+#include <KComboBox>
+#include <KLocale>
+
+#include <QGroupBox>
+#include <QLabel>
+#include <QSlider>
+#include <QVBoxLayout>
+
+#include <views/zoomlevelinfo.h>
+
+template<class T>
+void apply(int iconSizeValue, int previewSizeValue, const QFont& font, bool useSystemFont)
+{
+    const int iconSize = ZoomLevelInfo::iconSizeForZoomLevel(iconSizeValue);
+    const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(previewSizeValue);
+    T::setIconSize(iconSize);
+    T::setPreviewSize(previewSize);
+
+    T::setUseSystemFont(useSystemFont);
+    T::setFontFamily(font.family());
+    T::setFontSize(font.pointSizeF());
+    T::setItalicFont(font.italic());
+    T::setFontWeight(font.weight());
+
+    T::self()->writeConfig();
+}
+
+template<class T>
+void load(int* iconSizeValue, int* previewSizeValue, QFont* font, bool* useSystemFont)
+{
+    const QSize iconSize(T::iconSize(), T::iconSize());
+    *iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize);
+
+    const QSize previewSize(T::previewSize(), T::previewSize());
+    *previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize);
+
+    *useSystemFont = T::useSystemFont();
+
+    *font = QFont(T::fontFamily(), qRound(T::fontSize()));
+    font->setItalic(T::italicFont());
+    font->setWeight(T::fontWeight());
+    font->setPointSizeF(T::fontSize());
+}
+
+
+ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget* parent) :
+    QWidget(parent),
+    m_mode(mode),
+    m_defaultSizeSlider(0),
+    m_previewSizeSlider(0),
+    m_fontRequester(0),
+    m_textWidthBox(0)
+{
+    QVBoxLayout* topLayout = new QVBoxLayout(this);
+
+    // Create "Icon Size" group
+    QGroupBox* iconSizeGroup = new QGroupBox(this);
+    iconSizeGroup->setTitle(i18nc("@title:group", "Icon Size"));
+
+    const int minRange = ZoomLevelInfo::minimumLevel();
+    const int maxRange = ZoomLevelInfo::maximumLevel();
+
+    QLabel* defaultLabel = new QLabel(i18nc("@label:listbox", "Default:"), this);
+    m_defaultSizeSlider = new QSlider(Qt::Horizontal, this);
+    m_defaultSizeSlider->setPageStep(1);
+    m_defaultSizeSlider->setTickPosition(QSlider::TicksBelow);
+    m_defaultSizeSlider->setRange(minRange, maxRange);
+
+    QLabel* previewLabel = new QLabel(i18nc("@label:listbox", "Preview:"), this);
+    m_previewSizeSlider = new QSlider(Qt::Horizontal, this);
+    m_previewSizeSlider->setPageStep(1);
+    m_previewSizeSlider->setTickPosition(QSlider::TicksBelow);
+    m_previewSizeSlider->setRange(minRange, maxRange);
+
+    QGridLayout* layout = new QGridLayout(iconSizeGroup);
+    layout->addWidget(defaultLabel, 0, 0, Qt::AlignRight);
+    layout->addWidget(m_defaultSizeSlider, 0, 1);
+    layout->addWidget(previewLabel, 1, 0, Qt::AlignRight);
+    layout->addWidget(m_previewSizeSlider, 1, 1);
+
+    // Create "Text" group
+    QGroupBox* textGroup = new QGroupBox(i18nc("@title:group", "Text"), this);
+
+    QLabel* fontLabel = new QLabel(i18nc("@label:listbox", "Font:"), textGroup);
+    m_fontRequester = new DolphinFontRequester(textGroup);
+
+    QGridLayout* textGroupLayout = new QGridLayout(textGroup);
+    textGroupLayout->addWidget(fontLabel, 0, 0, Qt::AlignRight);
+    textGroupLayout->addWidget(m_fontRequester, 0, 1);
+
+    if (m_mode == IconsMode) {
+        QLabel* textWidthLabel = new QLabel(i18nc("@label:listbox", "Text width:"), textGroup);
+        m_textWidthBox = new KComboBox(textGroup);
+        m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Small"));
+        m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Medium"));
+        m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Large"));
+        m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Huge"));
+
+        textGroupLayout->addWidget(textWidthLabel, 2, 0, Qt::AlignRight);
+        textGroupLayout->addWidget(m_textWidthBox, 2, 1);
+    }
+
+    topLayout->addWidget(iconSizeGroup);
+    topLayout->addWidget(textGroup);
+    topLayout->addStretch(1);
+
+    loadSettings();
+
+    connect(m_defaultSizeSlider, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
+    connect(m_previewSizeSlider, SIGNAL(valueChanged(int)), this, SIGNAL(changed()));
+    connect(m_fontRequester, SIGNAL(changed()), this, SIGNAL(changed()));
+    if (m_mode == IconsMode) {
+        connect(m_textWidthBox, SIGNAL(currentIndexChanged(int)), this, SIGNAL(changed()));
+    }
+}
+
+ViewSettingsTab::~ViewSettingsTab()
+{
+}
+
+void ViewSettingsTab::applySettings()
+{
+    const int defaultSize = m_defaultSizeSlider->value();
+    const int previewSize = m_previewSizeSlider->value();
+    const QFont font = m_fontRequester->currentFont();
+    const bool useSystemFont = (m_fontRequester->mode() == DolphinFontRequester::SystemFont);
+
+    switch (m_mode) {
+    case IconsMode:
+        IconsModeSettings::setTextWidthIndex(m_textWidthBox->currentIndex());
+        apply<IconsModeSettings>(defaultSize, previewSize, font, useSystemFont);
+        break;
+    case CompactMode:
+        apply<CompactModeSettings>(defaultSize, previewSize, font, useSystemFont);
+        break;
+    case DetailsMode:
+        apply<DetailsModeSettings>(defaultSize, previewSize, font, useSystemFont);
+        break;
+    default:
+        Q_ASSERT(false);
+        break;
+    }
+}
+
+void ViewSettingsTab::restoreDefaultSettings()
+{
+    KConfigSkeleton* settings = 0;
+    switch (m_mode) {
+    case IconsMode:   settings = IconsModeSettings::self(); break;
+    case CompactMode: settings = CompactModeSettings::self(); break;
+    case DetailsMode: settings = DetailsModeSettings::self(); break;
+    default: Q_ASSERT(false); break;
+    }
+
+    settings->useDefaults(true);
+    loadSettings();
+    settings->useDefaults(false);
+}
+
+void ViewSettingsTab::loadSettings()
+{
+    int iconSizeValue = 0;
+    int previewSizeValue = 0;
+    QFont font;
+    bool useSystemFont = false;
+
+    switch (m_mode) {
+    case IconsMode:
+        m_textWidthBox->setCurrentIndex(IconsModeSettings::textWidthIndex());
+        load<IconsModeSettings>(&iconSizeValue, &previewSizeValue, &font, &useSystemFont);
+        break;
+    case CompactMode:
+        load<CompactModeSettings>(&iconSizeValue, &previewSizeValue, &font, &useSystemFont);
+        break;
+    case DetailsMode:
+        load<DetailsModeSettings>(&iconSizeValue, &previewSizeValue, &font, &useSystemFont);
+        break;
+    default:
+        Q_ASSERT(false);
+        break;
+    }
+
+    m_defaultSizeSlider->setValue(iconSizeValue);
+    m_previewSizeSlider->setValue(previewSizeValue);
+    m_fontRequester->setMode(useSystemFont ? DolphinFontRequester::SystemFont : DolphinFontRequester::CustomFont);
+    m_fontRequester->setCustomFont(font);
+}
+
+#include "viewsettingstab.moc"
similarity index 65%
rename from src/settings/viewmodes/detailsviewsettingspage.h
rename to src/settings/viewmodes/viewsettingstab.h
index 9532241aa8737c2156c0ab80e5afd37d935e27dd..1561df6c9e35a1057206692d6fe31dcc2782fb00 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz <peter.penz19@gmail.com>             *
+ *   Copyright (C) 2008-2011 by Peter Penz <peter.penz19@gmail.com>        *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
  ***************************************************************************/
 
-#ifndef DETAILSVIEWSETTINGSPAGE_H
-#define DETAILSVIEWSETTINGSPAGE_H
+#ifndef VIEWSETTINGSTAB_H
+#define VIEWSETTINGSTAB_H
 
-#include "viewsettingspagebase.h"
+#include <QWidget>
 
 class DolphinFontRequester;
-class IconSizeGroupBox;
+class KComboBox;
+class QSlider;
 
 /**
- * @brief Represents the page from the Dolphin Settings which allows
- *        to modify the settings for the details view.
+ * @brief Represents one tab of the view-settings page.
  */
-class DetailsViewSettingsPage : public ViewSettingsPageBase
+class ViewSettingsTab : public QWidget
 {
     Q_OBJECT
 
 public:
-    DetailsViewSettingsPage(QWidget* parent);
-    virtual ~DetailsViewSettingsPage();
+    enum Mode
+    {
+        IconsMode,
+        CompactMode,
+        DetailsMode
+    };
 
-    /**
-     * Applies the settings for the details view.
-     * The settings are persisted automatically when
-     * closing Dolphin.
-     */
-    virtual void applySettings();
+    explicit ViewSettingsTab(Mode mode, QWidget* parent = 0);
+    virtual ~ViewSettingsTab();
 
-    /** Restores the settings to default values. */
-    virtual void restoreDefaults();
+    void applySettings();
+    void restoreDefaultSettings();
+
+signals:
+    void changed();
 
 private:
     void loadSettings();
 
 private:
-    IconSizeGroupBox* m_iconSizeGroupBox;
+    Mode m_mode;
+    QSlider* m_defaultSizeSlider;
+    QSlider* m_previewSizeSlider;
+
     DolphinFontRequester* m_fontRequester;
+    KComboBox* m_textWidthBox;
 };
 
 #endif
index 5f57d6eb4fe50469de1540d0664a8d3c929f6e90..bc8599ad99f3c88ce88b367c22da250ce47c204c 100644 (file)
@@ -96,8 +96,8 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     QLabel* viewModeLabel = new QLabel(i18nc("@label:listbox", "View mode:"), propsGrid);
     m_viewMode = new KComboBox(propsGrid);
     m_viewMode->addItem(KIcon("view-list-icons"), i18nc("@item:inlistbox", "Icons"));
-    m_viewMode->addItem(KIcon("feffi"), i18nc("@item:inlistbox", "Compact")); // TODO: adjust icons
-    m_viewMode->addItem(KIcon("view-list-text"), i18nc("@item:inlistbox", "Details"));
+    m_viewMode->addItem(KIcon("view-list-details"), i18nc("@item:inlistbox", "Compact"));
+    m_viewMode->addItem(KIcon("view-list-tree"), i18nc("@item:inlistbox", "Details"));
 
     QLabel* sortingLabel = new QLabel(i18nc("@label:listbox", "Sorting:"), propsGrid);
     QWidget* sortingBox = new QWidget(propsGrid);
index fbace9cd1391de3dc099ba59eea42f1b191ea8eb..cdc9646c62a6ca099742e6f14443c9659e5a6412 100644 (file)
@@ -480,7 +480,7 @@ KToggleAction* DolphinViewActionHandler::detailsModeAction()
     detailsView->setText(i18nc("@action:inmenu View Mode", "Details"));
     detailsView->setToolTip(i18nc("@info", "Details view mode"));
     detailsView->setShortcut(Qt::CTRL | Qt::Key_3);
-    detailsView->setIcon(KIcon("view-list-text"));
+    detailsView->setIcon(KIcon("view-list-tree"));
     detailsView->setData(QVariant::fromValue(DolphinView::DetailsView));
     return detailsView;
 }