┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/settings/viewmodes
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2011-09-02 19:48:57 +0200
committerPeter Penz <[email protected]>2011-09-02 19:49:49 +0200
commit8266e456a10670fe5ef855680d61e0b6ab0d6292 (patch)
treee9b2192ddea90781a072f69f0a751c699171751d /src/settings/viewmodes
parentd2a3510cc372685ad491a0b653587bf569a132aa (diff)
Simplified code for the viewmode settings
Diffstat (limited to 'src/settings/viewmodes')
-rw-r--r--src/settings/viewmodes/detailsviewsettingspage.cpp135
-rw-r--r--src/settings/viewmodes/dolphinfontrequester.cpp17
-rw-r--r--src/settings/viewmodes/dolphinfontrequester.h7
-rw-r--r--src/settings/viewmodes/iconsizegroupbox.cpp119
-rw-r--r--src/settings/viewmodes/iconsizegroupbox.h66
-rw-r--r--src/settings/viewmodes/iconsviewsettingspage.cpp153
-rw-r--r--src/settings/viewmodes/iconsviewsettingspage.h69
-rw-r--r--src/settings/viewmodes/viewsettingspage.cpp40
-rw-r--r--src/settings/viewmodes/viewsettingspage.h4
-rw-r--r--src/settings/viewmodes/viewsettingspagebase.cpp31
-rw-r--r--src/settings/viewmodes/viewsettingspagebase.h55
-rw-r--r--src/settings/viewmodes/viewsettingstab.cpp215
-rw-r--r--src/settings/viewmodes/viewsettingstab.h (renamed from src/settings/viewmodes/detailsviewsettingspage.h)45
13 files changed, 279 insertions, 677 deletions
diff --git a/src/settings/viewmodes/detailsviewsettingspage.cpp b/src/settings/viewmodes/detailsviewsettingspage.cpp
deleted file mode 100644
index b2338dc9b..000000000
--- a/src/settings/viewmodes/detailsviewsettingspage.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2006 by Peter Penz <[email protected]> *
- * *
- * 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"
diff --git a/src/settings/viewmodes/dolphinfontrequester.cpp b/src/settings/viewmodes/dolphinfontrequester.cpp
index 09bc63e61..32e3ce65e 100644
--- a/src/settings/viewmodes/dolphinfontrequester.cpp
+++ b/src/settings/viewmodes/dolphinfontrequester.cpp
@@ -25,16 +25,18 @@
#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()
diff --git a/src/settings/viewmodes/dolphinfontrequester.h b/src/settings/viewmodes/dolphinfontrequester.h
index 263548555..57cddc5cd 100644
--- a/src/settings/viewmodes/dolphinfontrequester.h
+++ b/src/settings/viewmodes/dolphinfontrequester.h
@@ -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
index 6538a74d5..000000000
--- a/src/settings/viewmodes/iconsizegroupbox.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2008 by Peter Penz <[email protected]> *
- * *
- * 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
index a98085b25..000000000
--- a/src/settings/viewmodes/iconsizegroupbox.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2008 by Peter Penz <[email protected]> *
- * *
- * 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
index 41438fb22..000000000
--- a/src/settings/viewmodes/iconsviewsettingspage.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2006 by Peter Penz <[email protected]> *
- * *
- * 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
index ad829f131..000000000
--- a/src/settings/viewmodes/iconsviewsettingspage.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2006 by Peter Penz <[email protected]> *
- * *
- * 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
diff --git a/src/settings/viewmodes/viewsettingspage.cpp b/src/settings/viewmodes/viewsettingspage.cpp
index ac4ed9296..4f8a3f00d 100644
--- a/src/settings/viewmodes/viewsettingspage.cpp
+++ b/src/settings/viewmodes/viewsettingspage.cpp
@@ -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();
}
}
diff --git a/src/settings/viewmodes/viewsettingspage.h b/src/settings/viewmodes/viewsettingspage.h
index 56e9f910d..446403182 100644
--- a/src/settings/viewmodes/viewsettingspage.h
+++ b/src/settings/viewmodes/viewsettingspage.h
@@ -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
index 315d566cd..000000000
--- a/src/settings/viewmodes/viewsettingspagebase.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2008 by Peter Penz <[email protected]> *
- * *
- * 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
index 71111f653..000000000
--- a/src/settings/viewmodes/viewsettingspagebase.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2008 by Peter Penz <[email protected]> *
- * *
- * 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
index 000000000..743f042ca
--- /dev/null
+++ b/src/settings/viewmodes/viewsettingstab.cpp
@@ -0,0 +1,215 @@
+/***************************************************************************
+ * Copyright (C) 2008-2011 by Peter Penz <[email protected]> *
+ * *
+ * 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"
diff --git a/src/settings/viewmodes/detailsviewsettingspage.h b/src/settings/viewmodes/viewsettingstab.h
index 9532241aa..1561df6c9 100644
--- a/src/settings/viewmodes/detailsviewsettingspage.h
+++ b/src/settings/viewmodes/viewsettingstab.h
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006 by Peter Penz <[email protected]> *
+ * Copyright (C) 2008-2011 by Peter Penz <[email protected]> *
* *
* 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 *
@@ -17,42 +17,49 @@
* 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