]>
cloud.milkyroute.net Git - dolphin.git/blob - src/settings/general/behaviorsettingspage.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) and *
3 * and Patrice Tremblay *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
21 #include "behaviorsettingspage.h"
23 #include "dolphin_generalsettings.h"
31 #include <QHBoxLayout>
33 #include <QRadioButton>
34 #include <QVBoxLayout>
36 #include <views/viewproperties.h>
38 BehaviorSettingsPage::BehaviorSettingsPage(const KUrl
& url
, QWidget
* parent
) :
39 SettingsPageBase(parent
),
44 m_showSelectionToggle(0),
47 QVBoxLayout
* topLayout
= new QVBoxLayout(this);
50 QGroupBox
* viewPropsBox
= new QGroupBox(i18nc("@title:group", "View"), this);
51 viewPropsBox
->setSizePolicy(QSizePolicy::Preferred
, QSizePolicy::Maximum
);
53 m_localViewProps
= new QRadioButton(i18nc("@option:radio", "Remember properties for each folder"), viewPropsBox
);
54 m_globalViewProps
= new QRadioButton(i18nc("@option:radio", "Use common properties for all folders"), viewPropsBox
);
56 QVBoxLayout
* viewPropsLayout
= new QVBoxLayout(viewPropsBox
);
57 viewPropsLayout
->addWidget(m_localViewProps
);
58 viewPropsLayout
->addWidget(m_globalViewProps
);
61 m_showToolTips
= new QCheckBox(i18nc("@option:check", "Show tooltips"), this);
63 // 'Show selection marker'
64 m_showSelectionToggle
= new QCheckBox(i18nc("@option:check", "Show selection marker"), this);
66 // 'Natural sorting of items'
67 m_naturalSorting
= new QCheckBox(i18nc("option:check", "Natural sorting of items"), this);
69 topLayout
->addWidget(viewPropsBox
);
70 topLayout
->addWidget(m_showToolTips
);
71 topLayout
->addWidget(m_showSelectionToggle
);
72 topLayout
->addWidget(m_naturalSorting
);
73 topLayout
->addStretch();
77 connect(m_localViewProps
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
78 connect(m_globalViewProps
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
79 connect(m_showToolTips
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
80 connect(m_showSelectionToggle
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
81 connect(m_naturalSorting
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
84 BehaviorSettingsPage::~BehaviorSettingsPage()
88 void BehaviorSettingsPage::applySettings()
90 GeneralSettings
* settings
= GeneralSettings::self();
91 ViewProperties
props(m_url
); // read current view properties
93 const bool useGlobalViewProps
= m_globalViewProps
->isChecked();
94 settings
->setGlobalViewProps(useGlobalViewProps
);
96 settings
->setShowToolTips(m_showToolTips
->isChecked());
97 settings
->setShowSelectionToggle(m_showSelectionToggle
->isChecked());
98 settings
->writeConfig();
100 if (useGlobalViewProps
) {
101 // Remember the global view properties by applying the current view properties.
102 // It is important that GeneralSettings::globalViewProps() is set before
103 // the class ViewProperties is used, as ViewProperties uses this setting
104 // to find the destination folder for storing the view properties.
105 ViewProperties
globalProps(m_url
);
106 globalProps
.setDirProperties(props
);
109 const bool naturalSorting
= m_naturalSorting
->isChecked();
110 if (KGlobalSettings::naturalSorting() != naturalSorting
) {
111 KConfigGroup
group(KGlobal::config(), "KDE");
112 group
.writeEntry("NaturalSorting", naturalSorting
, KConfig::Persistent
| KConfig::Global
);
113 KGlobalSettings::emitChange(KGlobalSettings::NaturalSortingChanged
);
117 void BehaviorSettingsPage::restoreDefaults()
119 GeneralSettings
* settings
= GeneralSettings::self();
120 settings
->useDefaults(true);
122 settings
->useDefaults(false);
125 void BehaviorSettingsPage::loadSettings()
127 const bool useGlobalViewProps
= GeneralSettings::globalViewProps();
128 m_localViewProps
->setChecked(!useGlobalViewProps
);
129 m_globalViewProps
->setChecked(useGlobalViewProps
);
131 m_showToolTips
->setChecked(GeneralSettings::showToolTips());
132 m_showSelectionToggle
->setChecked(GeneralSettings::showSelectionToggle());
133 m_naturalSorting
->setChecked(KGlobalSettings::naturalSorting());
136 #include "behaviorsettingspage.moc"