add more spacing
[personal-kdebase.git] / apps / dolphin / src / settings / columnviewsettingspage.cpp
blob5918eaf928e2b458c31cd98d2f5e64598494f295
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
3 * *
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. *
8 * *
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. *
13 * *
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 "columnviewsettingspage.h"
22 #include "dolphinfontrequester.h"
23 #include "dolphinsettings.h"
24 #include "dolphin_columnmodesettings.h"
25 #include "iconsizegroupbox.h"
26 #include "zoomlevelinfo.h"
28 #include <kdialog.h>
29 #include <klocale.h>
30 #include <kcombobox.h>
32 #include <QButtonGroup>
33 #include <QCheckBox>
34 #include <QGroupBox>
35 #include <QHBoxLayout>
36 #include <QLabel>
37 #include <QSlider>
38 #include <QRadioButton>
40 ColumnViewSettingsPage::ColumnViewSettingsPage(QWidget* parent) :
41 ViewSettingsPageBase(parent),
42 m_iconSizeGroupBox(0),
43 m_fontRequester(0),
44 m_textWidthBox(0)
46 const int spacing = KDialog::spacingHint();
47 const int margin = KDialog::marginHint();
48 const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
50 setSpacing(spacing);
51 setMargin(margin);
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 QGroupBox* 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 QLabel* textWidthLabel = new QLabel(i18nc("@label:listbox", "Text width:"), textGroup);
76 m_textWidthBox = new KComboBox(textGroup);
77 m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Small"));
78 m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Medium"));
79 m_textWidthBox->addItem(i18nc("@item:inlistbox Text width", "Large"));
80 connect(m_textWidthBox, SIGNAL(activated(int)), this, SIGNAL(changed()));
82 QGridLayout* textGroupLayout = new QGridLayout(textGroup);
83 textGroupLayout->addWidget(fontLabel, 0, 0, Qt::AlignRight);
84 textGroupLayout->addWidget(m_fontRequester, 0, 1);
85 textGroupLayout->addWidget(textWidthLabel, 1, 0, Qt::AlignRight);
86 textGroupLayout->addWidget(m_textWidthBox, 1, 1);
88 // Add a dummy widget with no restriction regarding
89 // a vertical resizing. This assures that the dialog layout
90 // is not stretched vertically.
91 new QWidget(this);
93 loadSettings();
96 ColumnViewSettingsPage::~ColumnViewSettingsPage()
100 void ColumnViewSettingsPage::applySettings()
102 ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
104 const int iconSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->defaultSizeValue());
105 const int previewSize = ZoomLevelInfo::iconSizeForZoomLevel(m_iconSizeGroupBox->previewSizeValue());
106 settings->setIconSize(iconSize);
107 settings->setPreviewSize(previewSize);
109 const QFont font = m_fontRequester->font();
110 settings->setUseSystemFont(m_fontRequester->mode() == DolphinFontRequester::SystemFont);
111 settings->setFontFamily(font.family());
112 settings->setFontSize(font.pointSize());
113 settings->setItalicFont(font.italic());
114 settings->setFontWeight(font.weight());
116 // TODO:
117 //const int columnWidth = 150 + (m_columnWidthSlider->value() * 50);
118 //settings->setColumnWidth(columnWidth);
121 void ColumnViewSettingsPage::restoreDefaults()
123 ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
124 settings->setDefaults();
125 loadSettings();
128 void ColumnViewSettingsPage::loadSettings()
130 ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
132 const QSize iconSize(settings->iconSize(), settings->iconSize());
133 const int iconSizeValue = ZoomLevelInfo::zoomLevelForIconSize(iconSize);
134 m_iconSizeGroupBox->setDefaultSizeValue(iconSizeValue);
136 const QSize previewSize(settings->previewSize(), settings->previewSize());
137 const int previewSizeValue = ZoomLevelInfo::zoomLevelForIconSize(previewSize);
138 m_iconSizeGroupBox->setPreviewSizeValue(previewSizeValue);
140 if (settings->useSystemFont()) {
141 m_fontRequester->setMode(DolphinFontRequester::SystemFont);
142 } else {
143 QFont font(settings->fontFamily(),
144 settings->fontSize());
145 font.setItalic(settings->italicFont());
146 font.setWeight(settings->fontWeight());
147 m_fontRequester->setMode(DolphinFontRequester::CustomFont);
148 m_fontRequester->setCustomFont(font);
151 // TODO:
152 //m_columnWidthSlider->setValue((settings->columnWidth() - 150) / 50);
155 #include "columnviewsettingspage.moc"