]>
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"
25 #include <KLocalizedString>
29 #include <QRadioButton>
30 #include <QVBoxLayout>
32 #include <views/viewproperties.h>
34 BehaviorSettingsPage::BehaviorSettingsPage(const QUrl
& url
, QWidget
* parent
) :
35 SettingsPageBase(parent
),
40 m_showSelectionToggle(0),
44 QVBoxLayout
* topLayout
= new QVBoxLayout(this);
47 QGroupBox
* viewPropsBox
= new QGroupBox(i18nc("@title:group", "View"), this);
48 viewPropsBox
->setSizePolicy(QSizePolicy::Preferred
, QSizePolicy::Maximum
);
50 m_localViewProps
= new QRadioButton(i18nc("@option:radio", "Remember properties for each folder"), viewPropsBox
);
51 m_globalViewProps
= new QRadioButton(i18nc("@option:radio", "Use common properties for all folders"), viewPropsBox
);
53 QVBoxLayout
* viewPropsLayout
= new QVBoxLayout(viewPropsBox
);
54 viewPropsLayout
->addWidget(m_localViewProps
);
55 viewPropsLayout
->addWidget(m_globalViewProps
);
58 m_showToolTips
= new QCheckBox(i18nc("@option:check", "Show tooltips"), this);
60 // 'Show selection marker'
61 m_showSelectionToggle
= new QCheckBox(i18nc("@option:check", "Show selection marker"), this);
63 // 'Natural sorting of items'
64 m_naturalSorting
= new QCheckBox(i18nc("option:check", "Natural sorting of items"), this);
66 // 'Inline renaming of items'
67 m_renameInline
= new QCheckBox(i18nc("option:check", "Rename inline"), this);
69 topLayout
->addWidget(viewPropsBox
);
70 topLayout
->addWidget(m_showToolTips
);
71 topLayout
->addWidget(m_showSelectionToggle
);
72 topLayout
->addWidget(m_naturalSorting
);
73 topLayout
->addWidget(m_renameInline
);
74 topLayout
->addStretch();
78 connect(m_localViewProps
, &QRadioButton::toggled
, this, &BehaviorSettingsPage::changed
);
79 connect(m_globalViewProps
, &QRadioButton::toggled
, this, &BehaviorSettingsPage::changed
);
80 connect(m_showToolTips
, &QCheckBox::toggled
, this, &BehaviorSettingsPage::changed
);
81 connect(m_showSelectionToggle
, &QCheckBox::toggled
, this, &BehaviorSettingsPage::changed
);
82 connect(m_naturalSorting
, &QCheckBox::toggled
, this, &BehaviorSettingsPage::changed
);
83 connect(m_renameInline
, &QCheckBox::toggled
, this, &BehaviorSettingsPage::changed
);
86 BehaviorSettingsPage::~BehaviorSettingsPage()
90 void BehaviorSettingsPage::applySettings()
92 GeneralSettings
* settings
= GeneralSettings::self();
93 ViewProperties
props(m_url
); // read current view properties
95 const bool useGlobalViewProps
= m_globalViewProps
->isChecked();
96 settings
->setGlobalViewProps(useGlobalViewProps
);
98 settings
->setShowToolTips(m_showToolTips
->isChecked());
99 settings
->setShowSelectionToggle(m_showSelectionToggle
->isChecked());
100 settings
->setRenameInline(m_renameInline
->isChecked());
101 settings
->writeConfig();
103 if (useGlobalViewProps
) {
104 // Remember the global view properties by applying the current view properties.
105 // It is important that GeneralSettings::globalViewProps() is set before
106 // the class ViewProperties is used, as ViewProperties uses this setting
107 // to find the destination folder for storing the view properties.
108 ViewProperties
globalProps(m_url
);
109 globalProps
.setDirProperties(props
);
112 const bool naturalSorting
= m_naturalSorting
->isChecked();
113 if (KGlobalSettings::naturalSorting() != naturalSorting
) {
114 KConfigGroup
group(KSharedConfig::openConfig(), "KDE");
115 group
.writeEntry("NaturalSorting", naturalSorting
, KConfig::Persistent
| KConfig::Global
);
116 KGlobalSettings::emitChange(KGlobalSettings::NaturalSortingChanged
);
120 void BehaviorSettingsPage::restoreDefaults()
122 GeneralSettings
* settings
= GeneralSettings::self();
123 settings
->useDefaults(true);
125 settings
->useDefaults(false);
128 void BehaviorSettingsPage::loadSettings()
130 const bool useGlobalViewProps
= GeneralSettings::globalViewProps();
131 m_localViewProps
->setChecked(!useGlobalViewProps
);
132 m_globalViewProps
->setChecked(useGlobalViewProps
);
134 m_showToolTips
->setChecked(GeneralSettings::showToolTips());
135 m_showSelectionToggle
->setChecked(GeneralSettings::showSelectionToggle());
136 m_naturalSorting
->setChecked(KGlobalSettings::naturalSorting());
137 m_renameInline
->setChecked(GeneralSettings::renameInline());