]> cloud.milkyroute.net Git - dolphin.git/blob - src/detailsviewsettingspage.cpp
There are some extractable strings in subdirs too.
[dolphin.git] / src / detailsviewsettingspage.cpp
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 ***************************************************************************/
19
20 #include "detailsviewsettingspage.h"
21
22 #include "dolphinsettings.h"
23 #include "dolphin_detailsmodesettings.h"
24
25 #include <kdialog.h>
26 #include <dolphinfontrequester.h>
27 #include <klocale.h>
28
29 #include <QButtonGroup>
30 #include <QCheckBox>
31 #include <QComboBox>
32 #include <QGroupBox>
33 #include <QGridLayout>
34 #include <QLabel>
35 #include <QRadioButton>
36 #include <QtGui/QSpinBox>
37
38 DetailsViewSettingsPage::DetailsViewSettingsPage(QWidget* parent) :
39 ViewSettingsPageBase(parent),
40 m_smallIconSize(0),
41 m_mediumIconSize(0),
42 m_largeIconSize(0),
43 m_fontRequester(0),
44 m_expandableFolders(0)
45 {
46 const int spacing = KDialog::spacingHint();
47 const int margin = KDialog::marginHint();
48 const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
49
50 setSpacing(spacing);
51 setMargin(margin);
52
53 // Create "Icon" properties
54 QGroupBox* iconSizeBox = new QGroupBox(i18nc("@title:group", "Icon Size"), this);
55 iconSizeBox->setSizePolicy(sizePolicy);
56
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()));
63
64 QButtonGroup* iconSizeGroup = new QButtonGroup(this);
65 iconSizeGroup->addButton(m_smallIconSize);
66 iconSizeGroup->addButton(m_mediumIconSize);
67 iconSizeGroup->addButton(m_largeIconSize);
68
69 QHBoxLayout* iconSizeLayout = new QHBoxLayout(iconSizeBox);
70 iconSizeLayout->addWidget(m_smallIconSize);
71 iconSizeLayout->addWidget(m_mediumIconSize);
72 iconSizeLayout->addWidget(m_largeIconSize);
73
74 // create "Text" properties
75 QGroupBox* textBox = new QGroupBox(i18nc("@title:group", "Text"), this);
76 textBox->setSizePolicy(sizePolicy);
77
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()));
81
82 QHBoxLayout* textLayout = new QHBoxLayout(textBox);
83 textLayout->addWidget(fontLabel);
84 textLayout->addWidget(m_fontRequester);
85
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()));
89
90 // Add a dummy widget with no restriction regarding
91 // a vertical resizing. This assures that the dialog layout
92 // is not stretched vertically.
93 new QWidget(this);
94
95 loadSettings();
96 }
97
98 DetailsViewSettingsPage::~DetailsViewSettingsPage()
99 {
100 }
101
102 void DetailsViewSettingsPage::applySettings()
103 {
104 DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
105
106 int iconSize = KIconLoader::SizeSmall;
107 if (m_mediumIconSize->isChecked()) {
108 iconSize = KIconLoader::SizeMedium;
109 } else if (m_largeIconSize->isChecked()) {
110 iconSize = KIconLoader::SizeLarge;
111 }
112 settings->setIconSize(iconSize);
113
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());
120
121 settings->setExpandableFolders(m_expandableFolders->isChecked());
122 }
123
124 void DetailsViewSettingsPage::restoreDefaults()
125 {
126 DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
127 settings->setDefaults();
128 loadSettings();
129 }
130
131 void DetailsViewSettingsPage::loadSettings()
132 {
133 DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
134
135 switch (settings->iconSize()) {
136 case KIconLoader::SizeLarge:
137 m_largeIconSize->setChecked(true);
138 break;
139
140 case KIconLoader::SizeMedium:
141 m_mediumIconSize->setChecked(true);
142 break;
143
144 case KIconLoader::SizeSmall:
145 default:
146 m_smallIconSize->setChecked(true);
147 }
148
149 if (settings->useSystemFont()) {
150 m_fontRequester->setMode(DolphinFontRequester::SystemFont);
151 } else {
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);
158 }
159
160 m_expandableFolders->setChecked(settings->expandableFolders());
161 }
162
163 #include "detailsviewsettingspage.moc"