1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include "detailsviewsettingspage.h"
22 #include "iconsizegroupbox.h"
23 #include "dolphinfontrequester.h"
24 #include "dolphinsettings.h"
25 #include "dolphin_detailsmodesettings.h"
26 #include "zoomlevelinfo.h"
31 #include <QButtonGroup>
35 #include <QGridLayout>
37 #include <QRadioButton>
38 #include <QtGui/QSpinBox>
40 DetailsViewSettingsPage::DetailsViewSettingsPage(QWidget
* parent
) :
41 ViewSettingsPageBase(parent
),
42 m_iconSizeGroupBox(0),
44 m_expandableFolders(0)
46 const int spacing
= KDialog::spacingHint();
47 const int margin
= KDialog::marginHint();
48 const QSizePolicy
sizePolicy(QSizePolicy::Preferred
, QSizePolicy::Fixed
);
53 // Create "Icon" properties
54 m_iconSizeGroupBox
= new IconSizeGroupBox(this);
55 m_iconSizeGroupBox
->setSizePolicy(sizePolicy
);
57 const int min
= ZoomLevelInfo::minimumLevel();
58 const int max
= ZoomLevelInfo::maximumLevel();
59 m_iconSizeGroupBox
->setDefaultSizeRange(min
, max
);
60 m_iconSizeGroupBox
->setPreviewSizeRange(min
, max
);
62 connect(m_iconSizeGroupBox
, SIGNAL(defaultSizeChanged(int)),
63 this, SIGNAL(changed()));
64 connect(m_iconSizeGroupBox
, SIGNAL(previewSizeChanged(int)),
65 this, SIGNAL(changed()));
67 // create "Text" properties
68 QWidget
* textGroup
= new QGroupBox(i18nc("@title:group", "Text"), this);
69 textGroup
->setSizePolicy(sizePolicy
);
71 QLabel
* fontLabel
= new QLabel(i18nc("@label:listbox", "Font:"), textGroup
);
72 m_fontRequester
= new DolphinFontRequester(textGroup
);
73 connect(m_fontRequester
, SIGNAL(changed()), this, SIGNAL(changed()));
75 QHBoxLayout
* textLayout
= new QHBoxLayout(textGroup
);
76 textLayout
->addWidget(fontLabel
, 0, Qt::AlignRight
);
77 textLayout
->addWidget(m_fontRequester
);
79 // create "Expandable Folders" checkbox
80 m_expandableFolders
= new QCheckBox(i18nc("@option:check", "Expandable folders"), this);
81 connect(m_expandableFolders
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
83 // Add a dummy widget with no restriction regarding
84 // a vertical resizing. This assures that the dialog layout
85 // is not stretched vertically.
91 DetailsViewSettingsPage::~DetailsViewSettingsPage()
95 void DetailsViewSettingsPage::applySettings()
97 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
99 const int iconSize
= ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox
->defaultSizeValue());
100 const int previewSize
= ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox
->previewSizeValue());
101 settings
->setIconSize(iconSize
);
102 settings
->setPreviewSize(previewSize
);
104 const QFont font
= m_fontRequester
->font();
105 settings
->setUseSystemFont(m_fontRequester
->mode() == DolphinFontRequester::SystemFont
);
106 settings
->setFontFamily(font
.family());
107 settings
->setFontSize(font
.pointSize());
108 settings
->setItalicFont(font
.italic());
109 settings
->setFontWeight(font
.weight());
111 settings
->setExpandableFolders(m_expandableFolders
->isChecked());
114 void DetailsViewSettingsPage::restoreDefaults()
116 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
117 settings
->setDefaults();
121 void DetailsViewSettingsPage::loadSettings()
123 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
125 const QSize
iconSize(settings
->iconSize(), settings
->iconSize());
126 const int iconSizeValue
= ZoomLevelInfo::zoomLevelForIconSize(iconSize
);
127 m_iconSizeGroupBox
->setDefaultSizeValue(iconSizeValue
);
129 const QSize
previewSize(settings
->previewSize(), settings
->previewSize());
130 const int previewSizeValue
= ZoomLevelInfo::zoomLevelForIconSize(previewSize
);
131 m_iconSizeGroupBox
->setPreviewSizeValue(previewSizeValue
);
133 if (settings
->useSystemFont()) {
134 m_fontRequester
->setMode(DolphinFontRequester::SystemFont
);
136 QFont
font(settings
->fontFamily(),
137 settings
->fontSize());
138 font
.setItalic(settings
->italicFont());
139 font
.setWeight(settings
->fontWeight());
140 m_fontRequester
->setMode(DolphinFontRequester::CustomFont
);
141 m_fontRequester
->setCustomFont(font
);
144 m_expandableFolders
->setChecked(settings
->expandableFolders());
147 #include "detailsviewsettingspage.moc"