]>
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
);
60 propsBox
->setSizePolicy(QSizePolicy::Preferred
, QSizePolicy::Maximum
);
62 m_localProps
= new QRadioButton(i18nc("@option:radio", "Remember view properties for each folder"), propsBox
);
63 connect(m_localProps
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
65 m_globalProps
= new QRadioButton(i18nc("@option:radio", "Use common view properties for all folders"), propsBox
);
66 connect(m_globalProps
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
68 QVBoxLayout
* propsBoxLayout
= new QVBoxLayout(propsBox
);
69 propsBoxLayout
->addWidget(m_localProps
);
70 propsBoxLayout
->addWidget(m_globalProps
);
72 // 'Ask Confirmation For' box
73 QGroupBox
* confirmBox
= new QGroupBox(i18nc("@title:group", "Ask For Confirmation When"), vBox
);
74 confirmBox
->setSizePolicy(QSizePolicy::Preferred
, QSizePolicy::Maximum
);
75 m_confirmMoveToTrash
= new QCheckBox(i18nc("@option:check Ask for Confirmation When",
76 "Moving files or folders to trash"), confirmBox
);
77 connect(m_confirmMoveToTrash
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
78 m_confirmDelete
= new QCheckBox(i18nc("@option:check Ask for Confirmation When",
79 "Deleting files or folders"), confirmBox
);
80 connect(m_confirmDelete
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
82 QVBoxLayout
* confirmBoxLayout
= new QVBoxLayout(confirmBox
);
83 confirmBoxLayout
->addWidget(m_confirmMoveToTrash
);
84 confirmBoxLayout
->addWidget(m_confirmDelete
);
86 m_renameInline
= new QCheckBox(i18nc("@option:check", "Rename inline"), vBox
);
87 connect(m_renameInline
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
89 m_showToolTips
= new QCheckBox(i18nc("@option:check", "Show tooltips"), vBox
);
90 connect(m_showToolTips
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
92 m_showSelectionToggle
= new QCheckBox(i18nc("@option:check", "Show selection marker"), vBox
);
93 connect(m_showSelectionToggle
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
95 // Add a dummy widget with no restriction regarding
96 // a vertical resizing. This assures that the dialog layout
97 // is not stretched vertically.
100 topLayout
->addWidget(vBox
);
105 BehaviorSettingsPage::~BehaviorSettingsPage()
109 void BehaviorSettingsPage::applySettings()
111 ViewProperties
props(m_url
); // read current view properties
113 const bool useGlobalProps
= m_globalProps
->isChecked();
115 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
116 settings
->setGlobalViewProps(useGlobalProps
);
118 if (useGlobalProps
) {
119 // Remember the global view properties by applying the current view properties.
120 // It is important that GeneralSettings::globalViewProps() is set before
121 // the class ViewProperties is used, as ViewProperties uses this setting
122 // to find the destination folder for storing the view properties.
123 ViewProperties
globalProps(m_url
);
124 globalProps
.setDirProperties(props
);
127 KSharedConfig::Ptr kioConfig
= KSharedConfig::openConfig("kiorc", KConfig::NoGlobals
);
128 KConfigGroup
confirmationGroup(kioConfig
, "Confirmations");
129 confirmationGroup
.writeEntry("ConfirmTrash", m_confirmMoveToTrash
->isChecked());
130 confirmationGroup
.writeEntry("ConfirmDelete", m_confirmDelete
->isChecked());
131 confirmationGroup
.sync();
133 settings
->setRenameInline(m_renameInline
->isChecked());
134 settings
->setShowToolTips(m_showToolTips
->isChecked());
135 settings
->setShowSelectionToggle(m_showSelectionToggle
->isChecked());
138 void BehaviorSettingsPage::restoreDefaults()
140 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
141 settings
->useDefaults(true);
143 settings
->useDefaults(false);
144 m_confirmMoveToTrash
->setChecked(CONFIRM_TRASH
);
145 m_confirmDelete
->setChecked(CONFIRM_DELETE
);
148 void BehaviorSettingsPage::loadSettings()
150 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
151 if (settings
->globalViewProps()) {
152 m_globalProps
->setChecked(true);
154 m_localProps
->setChecked(true);
157 KSharedConfig::Ptr kioConfig
= KSharedConfig::openConfig("kiorc", KConfig::IncludeGlobals
);
158 const KConfigGroup
confirmationGroup(kioConfig
, "Confirmations");
159 m_confirmMoveToTrash
->setChecked(confirmationGroup
.readEntry("ConfirmTrash", CONFIRM_TRASH
));
160 m_confirmDelete
->setChecked(confirmationGroup
.readEntry("ConfirmDelete", CONFIRM_DELETE
));
162 m_renameInline
->setChecked(settings
->renameInline());
163 m_showToolTips
->setChecked(settings
->showToolTips());
164 m_showSelectionToggle
->setChecked(settings
->showSelectionToggle());
167 #include "behaviorsettingspage.moc"