]>
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>
41 const bool USE_THUMBNAILS
= true;
42 const int MAX_PREVIEW_SIZE
= 5; // 5 MB
44 PreviewsSettingsPage::PreviewsSettingsPage(QWidget
* parent
) :
45 SettingsPageBase(parent
),
48 m_useFileThumbnails(0)
50 KVBox
* vBox
= new KVBox(this);
51 vBox
->setSpacing(KDialog::spacingHint());
52 vBox
->setMargin(KDialog::marginHint());
54 new QLabel("TODO: a major rewrite of this dialog will be done in 4.3", vBox
);
56 KHBox
* hBox
= new KHBox(vBox
);
57 hBox
->setSpacing(KDialog::spacingHint());
59 new QLabel(i18nc("@label:slider", "Maximum file size:"), hBox
);
60 m_maxPreviewSize
= new QSlider(Qt::Horizontal
, hBox
);
61 m_maxPreviewSize
->setPageStep(10);
62 m_maxPreviewSize
->setSingleStep(1);
63 m_maxPreviewSize
->setTickPosition(QSlider::TicksBelow
);
64 m_maxPreviewSize
->setRange(1, 100); /* MB */
66 m_spinBox
= new QSpinBox(hBox
);
67 m_spinBox
->setSingleStep(1);
68 m_spinBox
->setSuffix(" MB");
69 m_spinBox
->setRange(1, 100); /* MB */
71 connect(m_maxPreviewSize
, SIGNAL(valueChanged(int)),
72 m_spinBox
, SLOT(setValue(int)));
73 connect(m_spinBox
, SIGNAL(valueChanged(int)),
74 m_maxPreviewSize
, SLOT(setValue(int)));
76 connect(m_maxPreviewSize
, SIGNAL(valueChanged(int)),
77 this, SIGNAL(changed()));
78 connect(m_spinBox
, SIGNAL(valueChanged(int)),
79 this, SIGNAL(changed()));
81 m_useFileThumbnails
= new QCheckBox(i18nc("@option:check", "Use thumbnails embedded in files"), vBox
);
82 connect(m_useFileThumbnails
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
84 // Add a dummy widget with no restriction regarding
85 // a vertical resizing. This assures that the dialog layout
86 // is not stretched vertically.
93 PreviewsSettingsPage::~PreviewsSettingsPage()
97 void PreviewsSettingsPage::applySettings()
99 KConfigGroup
globalConfig(KGlobal::config(), "PreviewSettings");
100 const int byteCount
= m_maxPreviewSize
->value() * 1024 * 1024; // value() returns size in MB
101 globalConfig
.writeEntry("MaximumSize",
103 KConfigBase::Normal
| KConfigBase::Global
);
104 globalConfig
.writeEntry("UseFileThumbnails",
105 m_useFileThumbnails
->isChecked(),
106 KConfigBase::Normal
| KConfigBase::Global
);
110 void PreviewsSettingsPage::restoreDefaults()
112 m_maxPreviewSize
->setValue(MAX_PREVIEW_SIZE
);
113 m_useFileThumbnails
->setChecked(USE_THUMBNAILS
);
116 void PreviewsSettingsPage::loadSettings()
118 const int min
= 1; // MB
119 const int max
= 100; // MB
121 KConfigGroup
globalConfig(KGlobal::config(), "PreviewSettings");
122 // TODO: The default value of 5 MB must match with the default value inside
123 // kdelibs/kio/kio/previewjob.cpp. Maybe a static getter method in PreviewJob
124 // should be added for getting the default size?
125 const int maxByteSize
= globalConfig
.readEntry("MaximumSize", MAX_PREVIEW_SIZE
* 1024 * 1024);
126 int maxMByteSize
= maxByteSize
/ (1024 * 1024);
127 if (maxMByteSize
< min
) {
129 } else if (maxMByteSize
> max
) {
132 m_maxPreviewSize
->setValue(maxMByteSize
);
134 const bool useFileThumbnails
= globalConfig
.readEntry("UseFileThumbnails", USE_THUMBNAILS
);
135 m_useFileThumbnails
->setChecked(useFileThumbnails
);
138 #include "previewssettingspage.moc"