]>
cloud.milkyroute.net Git - dolphin.git/blob - src/settings/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 "dolphinsettings.h"
24 #include "dolphin_generalsettings.h"
26 #include <viewproperties.h>
35 #include <QRadioButton>
36 #include <QVBoxLayout>
38 const bool CONFIRM_TRASH
= false;
39 const bool CONFIRM_DELETE
= true;
41 BehaviorSettingsPage::BehaviorSettingsPage(const KUrl
& url
, QWidget
* parent
) :
42 SettingsPageBase(parent
),
46 m_confirmMoveToTrash(0),
50 m_showSelectionToggle(0)
52 const int spacing
= KDialog::spacingHint();
54 QVBoxLayout
* topLayout
= new QVBoxLayout(this);
55 KVBox
* vBox
= new KVBox(this);
56 vBox
->setSpacing(spacing
);
58 // 'View Properties' box
59 QGroupBox
* propsBox
= new QGroupBox(i18nc("@title:group", "View Properties"), vBox
);
61 m_localProps
= new QRadioButton(i18nc("@option:radio", "Remember view properties for each folder"), propsBox
);
62 connect(m_localProps
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
64 m_globalProps
= new QRadioButton(i18nc("@option:radio", "Use common view properties for all folders"), propsBox
);
65 connect(m_globalProps
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
67 QVBoxLayout
* propsBoxLayout
= new QVBoxLayout(propsBox
);
68 propsBoxLayout
->addWidget(m_localProps
);
69 propsBoxLayout
->addWidget(m_globalProps
);
71 // 'Ask Confirmation For' box
72 QGroupBox
* confirmBox
= new QGroupBox(i18nc("@title:group", "Ask For Confirmation When"), vBox
);
73 m_confirmMoveToTrash
= new QCheckBox(i18nc("@option:check Ask for Confirmation When",
74 "Moving files or folders to trash"), confirmBox
);
75 connect(m_confirmMoveToTrash
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
76 m_confirmDelete
= new QCheckBox(i18nc("@option:check Ask for Confirmation When",
77 "Deleting files or folders"), confirmBox
);
78 connect(m_confirmDelete
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
80 QVBoxLayout
* confirmBoxLayout
= new QVBoxLayout(confirmBox
);
81 confirmBoxLayout
->addWidget(m_confirmMoveToTrash
);
82 confirmBoxLayout
->addWidget(m_confirmDelete
);
84 m_renameInline
= new QCheckBox(i18nc("@option:check", "Rename inline"), vBox
);
85 connect(m_renameInline
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
87 m_showToolTips
= new QCheckBox(i18nc("@option:check", "Show tooltips"), vBox
);
88 connect(m_showToolTips
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
90 m_showSelectionToggle
= new QCheckBox(i18nc("@option:check", "Show selection marker"), vBox
);
91 connect(m_showSelectionToggle
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
93 // Add a dummy widget with no restriction regarding
94 // a vertical resizing. This assures that the dialog layout
95 // is not stretched vertically.
98 topLayout
->addWidget(vBox
);
103 BehaviorSettingsPage::~BehaviorSettingsPage()
107 void BehaviorSettingsPage::applySettings()
109 ViewProperties
props(m_url
); // read current view properties
111 const bool useGlobalProps
= m_globalProps
->isChecked();
113 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
114 settings
->setGlobalViewProps(useGlobalProps
);
116 if (useGlobalProps
) {
117 // Remember the global view properties by applying the current view properties.
118 // It is important that GeneralSettings::globalViewProps() is set before
119 // the class ViewProperties is used, as ViewProperties uses this setting
120 // to find the destination folder for storing the view properties.
121 ViewProperties
globalProps(m_url
);
122 globalProps
.setDirProperties(props
);
125 KSharedConfig::Ptr kioConfig
= KSharedConfig::openConfig("kiorc", KConfig::NoGlobals
);
126 KConfigGroup
confirmationGroup(kioConfig
, "Confirmations");
127 confirmationGroup
.writeEntry("ConfirmTrash", m_confirmMoveToTrash
->isChecked());
128 confirmationGroup
.writeEntry("ConfirmDelete", m_confirmDelete
->isChecked());
129 confirmationGroup
.sync();
131 settings
->setRenameInline(m_renameInline
->isChecked());
132 settings
->setShowToolTips(m_showToolTips
->isChecked());
133 settings
->setShowSelectionToggle(m_showSelectionToggle
->isChecked());
136 void BehaviorSettingsPage::restoreDefaults()
138 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
139 settings
->useDefaults(true);
141 settings
->useDefaults(false);
142 m_confirmMoveToTrash
->setChecked(CONFIRM_TRASH
);
143 m_confirmDelete
->setChecked(CONFIRM_DELETE
);
146 void BehaviorSettingsPage::loadSettings()
148 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
149 if (settings
->globalViewProps()) {
150 m_globalProps
->setChecked(true);
152 m_localProps
->setChecked(true);
155 KSharedConfig::Ptr kioConfig
= KSharedConfig::openConfig("kiorc", KConfig::IncludeGlobals
);
156 const KConfigGroup
confirmationGroup(kioConfig
, "Confirmations");
157 m_confirmMoveToTrash
->setChecked(confirmationGroup
.readEntry("ConfirmTrash", CONFIRM_TRASH
));
158 m_confirmDelete
->setChecked(confirmationGroup
.readEntry("ConfirmDelete", CONFIRM_DELETE
));
160 m_renameInline
->setChecked(settings
->renameInline());
161 m_showToolTips
->setChecked(settings
->showToolTips());
162 m_showSelectionToggle
->setChecked(settings
->showSelectionToggle());
165 #include "behaviorsettingspage.moc"