]>
cloud.milkyroute.net Git - dolphin.git/blob - src/detailsviewsettingspage.cpp
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 "dolphinsettings.h"
23 #include "dolphin_detailsmodesettings.h"
26 #include <dolphinfontrequester.h>
29 #include <QButtonGroup>
33 #include <QGridLayout>
35 #include <QRadioButton>
36 #include <QtGui/QSpinBox>
38 DetailsViewSettingsPage::DetailsViewSettingsPage(QWidget
* parent
) :
39 ViewSettingsPageBase(parent
),
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 QGroupBox
* iconSizeBox
= new QGroupBox(i18nc("@title:group", "Icon Size"), this);
55 iconSizeBox
->setSizePolicy(sizePolicy
);
57 m_smallIconSize
= new QRadioButton(i18nc("@option:radio Icon Size", "Small"), this);
58 m_mediumIconSize
= new QRadioButton(i18nc("@option:radio Icon Size", "Medium"), this);
59 m_largeIconSize
= new QRadioButton(i18nc("@option:radio Icon Size", "Large"), this);
60 connect(m_smallIconSize
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
61 connect(m_mediumIconSize
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
62 connect(m_largeIconSize
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
64 QButtonGroup
* iconSizeGroup
= new QButtonGroup(this);
65 iconSizeGroup
->addButton(m_smallIconSize
);
66 iconSizeGroup
->addButton(m_mediumIconSize
);
67 iconSizeGroup
->addButton(m_largeIconSize
);
69 QHBoxLayout
* iconSizeLayout
= new QHBoxLayout(iconSizeBox
);
70 iconSizeLayout
->addWidget(m_smallIconSize
);
71 iconSizeLayout
->addWidget(m_mediumIconSize
);
72 iconSizeLayout
->addWidget(m_largeIconSize
);
74 // create "Text" properties
75 QGroupBox
* textBox
= new QGroupBox(i18nc("@title:group", "Text"), this);
76 textBox
->setSizePolicy(sizePolicy
);
78 QLabel
* fontLabel
= new QLabel(i18nc("@label:listbox", "Font:"), textBox
);
79 m_fontRequester
= new DolphinFontRequester(textBox
);
80 connect(m_fontRequester
, SIGNAL(changed()), this, SIGNAL(changed()));
82 QHBoxLayout
* textLayout
= new QHBoxLayout(textBox
);
83 textLayout
->addWidget(fontLabel
);
84 textLayout
->addWidget(m_fontRequester
);
86 // create "Expandable Folders" checkbox
87 m_expandableFolders
= new QCheckBox(i18nc("@option:check", "Expandable Folders"), this);
88 connect(m_expandableFolders
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
90 // Add a dummy widget with no restriction regarding
91 // a vertical resizing. This assures that the dialog layout
92 // is not stretched vertically.
98 DetailsViewSettingsPage::~DetailsViewSettingsPage()
102 void DetailsViewSettingsPage::applySettings()
104 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
106 int iconSize
= KIconLoader::SizeSmall
;
107 if (m_mediumIconSize
->isChecked()) {
108 iconSize
= KIconLoader::SizeMedium
;
109 } else if (m_largeIconSize
->isChecked()) {
110 iconSize
= KIconLoader::SizeLarge
;
112 settings
->setIconSize(iconSize
);
114 const QFont font
= m_fontRequester
->font();
115 settings
->setUseSystemFont(m_fontRequester
->mode() == DolphinFontRequester::SystemFont
);
116 settings
->setFontFamily(font
.family());
117 settings
->setFontSize(font
.pointSize());
118 settings
->setItalicFont(font
.italic());
119 settings
->setFontWeight(font
.weight());
121 settings
->setExpandableFolders(m_expandableFolders
->isChecked());
124 void DetailsViewSettingsPage::restoreDefaults()
126 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
127 settings
->setDefaults();
131 void DetailsViewSettingsPage::loadSettings()
133 DetailsModeSettings
* settings
= DolphinSettings::instance().detailsModeSettings();
135 switch (settings
->iconSize()) {
136 case KIconLoader::SizeLarge
:
137 m_largeIconSize
->setChecked(true);
140 case KIconLoader::SizeMedium
:
141 m_mediumIconSize
->setChecked(true);
144 case KIconLoader::SizeSmall
:
146 m_smallIconSize
->setChecked(true);
149 if (settings
->useSystemFont()) {
150 m_fontRequester
->setMode(DolphinFontRequester::SystemFont
);
152 QFont
font(settings
->fontFamily(),
153 settings
->fontSize());
154 font
.setItalic(settings
->italicFont());
155 font
.setWeight(settings
->fontWeight());
156 m_fontRequester
->setMode(DolphinFontRequester::CustomFont
);
157 m_fontRequester
->setCustomFont(font
);
160 m_expandableFolders
->setChecked(settings
->expandableFolders());
163 #include "detailsviewsettingspage.moc"