]>
cloud.milkyroute.net Git - dolphin.git/blob - src/settings/generalsettingspage.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 "generalsettingspage.h"
23 #include "settings/dolphinsettings.h"
25 #include "dolphin_generalsettings.h"
34 #include <QVBoxLayout>
36 GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow
* mainWin
, QWidget
* parent
) :
37 SettingsPageBase(parent
),
38 m_confirmMoveToTrash(0),
40 m_showDeleteCommand(0),
41 m_showCopyMoveMenu(0),
44 m_browseThroughArchives(0),
46 m_autoExpandFolders(0)
50 const int spacing
= KDialog::spacingHint();
52 QVBoxLayout
* topLayout
= new QVBoxLayout(this);
53 KVBox
* vBox
= new KVBox(this);
54 vBox
->setSpacing(spacing
);
56 // create 'Ask Confirmation For' group
57 QGroupBox
* confirmBox
= new QGroupBox(i18nc("@title:group", "Ask For Confirmation When"), vBox
);
58 m_confirmMoveToTrash
= new QCheckBox(i18nc("@option:check Ask for Confirmation When",
59 "Moving files or folders to trash"), confirmBox
);
60 connect(m_confirmMoveToTrash
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
61 m_confirmDelete
= new QCheckBox(i18nc("@option:check Ask for Confirmation When",
62 "Deleting files or folders"), confirmBox
);
63 connect(m_confirmDelete
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
65 QVBoxLayout
* confirmBoxLayout
= new QVBoxLayout(confirmBox
);
66 confirmBoxLayout
->addWidget(m_confirmMoveToTrash
);
67 confirmBoxLayout
->addWidget(m_confirmDelete
);
69 QGroupBox
* contextMenuBox
= new QGroupBox(i18nc("@title:group", "Context Menu"), vBox
);
71 // create 'Show the command 'Delete' in context menu' checkbox
72 m_showDeleteCommand
= new QCheckBox(i18nc("@option:check", "Show 'Delete' command"), contextMenuBox
);
73 connect(m_showDeleteCommand
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
75 m_showCopyMoveMenu
= new QCheckBox(i18nc("@option:check", "Show 'Copy To' and 'Move To' commands"), contextMenuBox
);
76 connect(m_showCopyMoveMenu
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
78 QVBoxLayout
* contextMenuBoxLayout
= new QVBoxLayout(contextMenuBox
);
79 contextMenuBoxLayout
->addWidget(m_showDeleteCommand
);
80 contextMenuBoxLayout
->addWidget(m_showCopyMoveMenu
);
82 QGroupBox
* statusBarBox
= new QGroupBox(i18nc("@title:group", "Status Bar"), vBox
);
84 m_showZoomSlider
= new QCheckBox(i18nc("@option:check", "Show zoom slider"), statusBarBox
);
85 connect(m_showZoomSlider
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
87 m_showSpaceInfo
= new QCheckBox(i18nc("@option:check", "Show space information"), statusBarBox
);
88 connect(m_showSpaceInfo
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
90 QVBoxLayout
* statusBarBoxLayout
= new QVBoxLayout(statusBarBox
);
91 statusBarBoxLayout
->addWidget(m_showZoomSlider
);
92 statusBarBoxLayout
->addWidget(m_showSpaceInfo
);
94 m_browseThroughArchives
= new QCheckBox(i18nc("@option:check", "Browse through archives"), vBox
);
95 connect(m_browseThroughArchives
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
97 m_renameInline
= new QCheckBox(i18nc("@option:check", "Rename inline"), vBox
);
98 connect(m_renameInline
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
100 m_autoExpandFolders
= new QCheckBox(i18nc("option:check", "Open folders during drag operations"), vBox
);
101 connect(m_autoExpandFolders
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
103 // Add a dummy widget with no restriction regarding
104 // a vertical resizing. This assures that the dialog layout
105 // is not stretched vertically.
108 topLayout
->addWidget(vBox
);
113 GeneralSettingsPage::~GeneralSettingsPage()
117 void GeneralSettingsPage::applySettings()
119 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
121 KSharedConfig::Ptr kioConfig
= KSharedConfig::openConfig("kiorc", KConfig::NoGlobals
);
122 KConfigGroup
confirmationGroup(kioConfig
, "Confirmations");
123 confirmationGroup
.writeEntry("ConfirmTrash", m_confirmMoveToTrash
->isChecked());
124 confirmationGroup
.writeEntry("ConfirmDelete", m_confirmDelete
->isChecked());
125 confirmationGroup
.sync();
127 KSharedConfig::Ptr globalConfig
= KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals
);
128 KConfigGroup
configGroup(globalConfig
, "KDE");
129 configGroup
.writeEntry("ShowDeleteCommand", m_showDeleteCommand
->isChecked());
132 settings
->setShowCopyMoveMenu(m_showCopyMoveMenu
->isChecked());
133 settings
->setShowZoomSlider(m_showZoomSlider
->isChecked());
134 settings
->setShowSpaceInfo(m_showSpaceInfo
->isChecked());
135 settings
->setBrowseThroughArchives(m_browseThroughArchives
->isChecked());
136 settings
->setRenameInline(m_renameInline
->isChecked());
137 settings
->setAutoExpandFolders(m_autoExpandFolders
->isChecked());
140 void GeneralSettingsPage::restoreDefaults()
142 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
143 settings
->setDefaults();
145 // TODO: reset default settings for trash and show delete command...
150 void GeneralSettingsPage::loadSettings()
152 KSharedConfig::Ptr kioConfig
= KSharedConfig::openConfig("kiorc", KConfig::IncludeGlobals
);
153 const KConfigGroup
confirmationGroup(kioConfig
, "Confirmations");
154 m_confirmMoveToTrash
->setChecked(confirmationGroup
.readEntry("ConfirmTrash", false));
155 m_confirmDelete
->setChecked(confirmationGroup
.readEntry("ConfirmDelete", true));
157 KSharedConfig::Ptr globalConfig
= KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals
);
158 KConfigGroup
configGroup(globalConfig
, "KDE");
159 m_showDeleteCommand
->setChecked(configGroup
.readEntry("ShowDeleteCommand", false));
161 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
162 m_showCopyMoveMenu
->setChecked(settings
->showCopyMoveMenu());
163 m_showZoomSlider
->setChecked(settings
->showZoomSlider());
164 m_showSpaceInfo
->setChecked(settings
->showSpaceInfo());
165 m_browseThroughArchives
->setChecked(settings
->browseThroughArchives());
166 m_renameInline
->setChecked(settings
->renameInline());
167 m_autoExpandFolders
->setChecked(settings
->autoExpandFolders());
170 #include "generalsettingspage.moc"