1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
/***************************************************************************
* Copyright (C) 2006 by Peter Penz ([email protected]) and *
* and Patrice Tremblay *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "behaviorsettingspage.h"
#include "dolphinsettings.h"
#include "dolphin_generalsettings.h"
#include <viewproperties.h>
#include <kdialog.h>
#include <klocale.h>
#include <kvbox.h>
#include <QCheckBox>
#include <QGroupBox>
#include <QLabel>
#include <QRadioButton>
#include <QVBoxLayout>
const bool CONFIRM_TRASH = false;
const bool CONFIRM_DELETE = true;
BehaviorSettingsPage::BehaviorSettingsPage(const KUrl& url, QWidget* parent) :
SettingsPageBase(parent),
m_url(url),
m_localProps(0),
m_globalProps(0),
m_confirmMoveToTrash(0),
m_confirmDelete(0),
m_renameInline(0),
m_showToolTips(0),
m_showSelectionToggle(0)
{
const int spacing = KDialog::spacingHint();
QVBoxLayout* topLayout = new QVBoxLayout(this);
KVBox* vBox = new KVBox(this);
vBox->setSpacing(spacing);
// 'View Properties' box
QGroupBox* propsBox = new QGroupBox(i18nc("@title:group", "View Properties"), vBox);
propsBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
m_localProps = new QRadioButton(i18nc("@option:radio", "Remember view properties for each folder"), propsBox);
connect(m_localProps, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
m_globalProps = new QRadioButton(i18nc("@option:radio", "Use common view properties for all folders"), propsBox);
connect(m_globalProps, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
QVBoxLayout* propsBoxLayout = new QVBoxLayout(propsBox);
propsBoxLayout->addWidget(m_localProps);
propsBoxLayout->addWidget(m_globalProps);
// 'Ask Confirmation For' box
QGroupBox* confirmBox = new QGroupBox(i18nc("@title:group", "Ask For Confirmation When"), vBox);
confirmBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
m_confirmMoveToTrash = new QCheckBox(i18nc("@option:check Ask for Confirmation When",
"Moving files or folders to trash"), confirmBox);
connect(m_confirmMoveToTrash, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
m_confirmDelete = new QCheckBox(i18nc("@option:check Ask for Confirmation When",
"Deleting files or folders"), confirmBox);
connect(m_confirmDelete, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
m_confirmClosingMultipleTabs = new QCheckBox(i18nc("@option:check Ask for Confirmation When",
"Closing windows with multiple tabs"), confirmBox);
connect(m_confirmClosingMultipleTabs, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
QVBoxLayout* confirmBoxLayout = new QVBoxLayout(confirmBox);
confirmBoxLayout->addWidget(m_confirmMoveToTrash);
confirmBoxLayout->addWidget(m_confirmDelete);
confirmBoxLayout->addWidget(m_confirmClosingMultipleTabs);
m_renameInline = new QCheckBox(i18nc("@option:check", "Rename inline"), vBox);
connect(m_renameInline, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
m_showToolTips = new QCheckBox(i18nc("@option:check", "Show tooltips"), vBox);
connect(m_showToolTips, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
m_showSelectionToggle = new QCheckBox(i18nc("@option:check", "Show selection marker"), vBox);
connect(m_showSelectionToggle, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
// Add a dummy widget with no restriction regarding
// a vertical resizing. This assures that the dialog layout
// is not stretched vertically.
new QWidget(vBox);
topLayout->addWidget(vBox);
loadSettings();
}
BehaviorSettingsPage::~BehaviorSettingsPage()
{
}
void BehaviorSettingsPage::applySettings()
{
ViewProperties props(m_url); // read current view properties
const bool useGlobalProps = m_globalProps->isChecked();
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
settings->setGlobalViewProps(useGlobalProps);
if (useGlobalProps) {
// Remember the global view properties by applying the current view properties.
// It is important that GeneralSettings::globalViewProps() is set before
// the class ViewProperties is used, as ViewProperties uses this setting
// to find the destination folder for storing the view properties.
ViewProperties globalProps(m_url);
globalProps.setDirProperties(props);
}
KSharedConfig::Ptr kioConfig = KSharedConfig::openConfig("kiorc", KConfig::NoGlobals);
KConfigGroup confirmationGroup(kioConfig, "Confirmations");
confirmationGroup.writeEntry("ConfirmTrash", m_confirmMoveToTrash->isChecked());
confirmationGroup.writeEntry("ConfirmDelete", m_confirmDelete->isChecked());
confirmationGroup.sync();
settings->setConfirmClosingMultipleTabs(m_confirmClosingMultipleTabs->isChecked());
settings->setRenameInline(m_renameInline->isChecked());
settings->setShowToolTips(m_showToolTips->isChecked());
settings->setShowSelectionToggle(m_showSelectionToggle->isChecked());
settings->writeConfig();
}
void BehaviorSettingsPage::restoreDefaults()
{
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
settings->useDefaults(true);
loadSettings();
settings->useDefaults(false);
m_confirmMoveToTrash->setChecked(CONFIRM_TRASH);
m_confirmDelete->setChecked(CONFIRM_DELETE);
}
void BehaviorSettingsPage::loadSettings()
{
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
if (settings->globalViewProps()) {
m_globalProps->setChecked(true);
} else {
m_localProps->setChecked(true);
}
KSharedConfig::Ptr kioConfig = KSharedConfig::openConfig("kiorc", KConfig::IncludeGlobals);
const KConfigGroup confirmationGroup(kioConfig, "Confirmations");
m_confirmMoveToTrash->setChecked(confirmationGroup.readEntry("ConfirmTrash", CONFIRM_TRASH));
m_confirmDelete->setChecked(confirmationGroup.readEntry("ConfirmDelete", CONFIRM_DELETE));
m_confirmClosingMultipleTabs->setChecked(settings->confirmClosingMultipleTabs());
m_renameInline->setChecked(settings->renameInline());
m_showToolTips->setChecked(settings->showToolTips());
m_showSelectionToggle->setChecked(settings->showSelectionToggle());
}
#include "behaviorsettingspage.moc"
|