]>
cloud.milkyroute.net Git - dolphin.git/blob - src/settings/previewssettingspage.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 "previewssettingspage.h"
21 #include "dolphinsettings.h"
23 #include "dolphin_generalsettings.h"
28 #include <QRadioButton>
33 #include <kconfiggroup.h>
40 PreviewsSettingsPage::PreviewsSettingsPage(QWidget
* parent
) :
41 SettingsPageBase(parent
),
44 m_useFileThumbnails(0)
46 KVBox
* vBox
= new KVBox(this);
47 vBox
->setSpacing(KDialog::spacingHint());
48 vBox
->setMargin(KDialog::marginHint());
50 new QLabel("TODO: a major rewrite of this dialog will be done in 4.3", vBox
);
52 KHBox
* hBox
= new KHBox(vBox
);
53 hBox
->setSpacing(KDialog::spacingHint());
55 new QLabel(i18nc("@label:slider", "Maximum file size:"), hBox
);
56 m_maxPreviewSize
= new QSlider(Qt::Horizontal
, hBox
);
57 m_maxPreviewSize
->setPageStep(10);
58 m_maxPreviewSize
->setSingleStep(1);
59 m_maxPreviewSize
->setTickPosition(QSlider::TicksBelow
);
60 m_maxPreviewSize
->setRange(1, 100); /* MB */
62 m_spinBox
= new QSpinBox(hBox
);
63 m_spinBox
->setSingleStep(1);
64 m_spinBox
->setSuffix(" MB");
65 m_spinBox
->setRange(1, 100); /* MB */
67 connect(m_maxPreviewSize
, SIGNAL(valueChanged(int)),
68 m_spinBox
, SLOT(setValue(int)));
69 connect(m_spinBox
, SIGNAL(valueChanged(int)),
70 m_maxPreviewSize
, SLOT(setValue(int)));
72 connect(m_maxPreviewSize
, SIGNAL(valueChanged(int)),
73 this, SIGNAL(changed()));
74 connect(m_spinBox
, SIGNAL(valueChanged(int)),
75 this, SIGNAL(changed()));
77 m_useFileThumbnails
= new QCheckBox(i18nc("@option:check", "Use thumbnails embedded in files"), vBox
);
78 connect(m_useFileThumbnails
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
80 // Add a dummy widget with no restriction regarding
81 // a vertical resizing. This assures that the dialog layout
82 // is not stretched vertically.
89 PreviewsSettingsPage::~PreviewsSettingsPage()
93 void PreviewsSettingsPage::applySettings()
95 KConfigGroup
globalConfig(KGlobal::config(), "PreviewSettings");
96 const int byteCount
= m_maxPreviewSize
->value() * 1024 * 1024; // value() returns size in MB
97 globalConfig
.writeEntry("MaximumSize",
99 KConfigBase::Normal
| KConfigBase::Global
);
100 globalConfig
.writeEntry("UseFileThumbnails",
101 m_useFileThumbnails
->isChecked(),
102 KConfigBase::Normal
| KConfigBase::Global
);
106 void PreviewsSettingsPage::restoreDefaults()
108 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
109 settings
->useDefaults(true);
111 settings
->useDefaults(false);
114 void PreviewsSettingsPage::loadSettings()
116 const int min
= 1; // MB
117 const int max
= 100; // MB
119 KConfigGroup
globalConfig(KGlobal::config(), "PreviewSettings");
120 // TODO: The default value of 5 MB must match with the default value inside
121 // kdelibs/kio/kio/previewjob.cpp. Maybe a static getter method in PreviewJob
122 // should be added for getting the default size?
123 const int maxByteSize
= globalConfig
.readEntry("MaximumSize", 5 * 1024 * 1024 /* 5 MB */);
124 int maxMByteSize
= maxByteSize
/ (1024 * 1024);
125 if (maxMByteSize
< min
) {
127 } else if (maxMByteSize
> max
) {
130 m_maxPreviewSize
->setValue(maxMByteSize
);
132 const bool useFileThumbnails
= globalConfig
.readEntry("UseFileThumbnails", true);
133 m_useFileThumbnails
->setChecked(useFileThumbnails
);
136 #include "previewssettingspage.moc"