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 "dolphinsettings.h"
25 #include "dolphin_generalsettings.h"
34 #include <QVBoxLayout>
36 GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow
* mainWin
, QWidget
* parent
) :
37 SettingsPageBase(parent
),
38 m_showDeleteCommand(0),
39 m_confirmMoveToTrash(0),
41 m_browseThroughArchives(0)
45 const int spacing
= KDialog::spacingHint();
47 QVBoxLayout
* topLayout
= new QVBoxLayout(this);
48 KVBox
* vBox
= new KVBox(this);
49 vBox
->setSpacing(spacing
);
51 // create 'Ask Confirmation For' group
52 QGroupBox
* confirmBox
= new QGroupBox(i18nc("@title:group", "Ask For Confirmation When"), vBox
);
53 m_confirmMoveToTrash
= new QCheckBox(i18nc("@option:check Ask for Confirmation When",
54 "Moving files or folders to trash"), confirmBox
);
55 m_confirmDelete
= new QCheckBox(i18nc("@option:check Ask for Confirmation When",
56 "Deleting files or folders"), confirmBox
);
58 QVBoxLayout
* confirmBoxLayout
= new QVBoxLayout(confirmBox
);
59 confirmBoxLayout
->addWidget(m_confirmMoveToTrash
);
60 confirmBoxLayout
->addWidget(m_confirmDelete
);
62 // create 'Show the command 'Delete' in context menu' checkbox
63 m_showDeleteCommand
= new QCheckBox(i18nc("@option:check", "Show 'Delete' command in context menu"), vBox
);
65 m_browseThroughArchives
= new QCheckBox(i18nc("option:check", "Browse through archives"), vBox
);
67 // Add a dummy widget with no restriction regarding
68 // a vertical resizing. This assures that the dialog layout
69 // is not stretched vertically.
72 topLayout
->addWidget(vBox
);
77 GeneralSettingsPage::~GeneralSettingsPage()
81 void GeneralSettingsPage::applySettings()
83 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
85 KSharedConfig::Ptr konqConfig
= KSharedConfig::openConfig("konquerorrc", KConfig::IncludeGlobals
);
86 KConfigGroup
trashConfig(konqConfig
, "Trash");
87 trashConfig
.writeEntry("ConfirmTrash", m_confirmMoveToTrash
->isChecked());
88 trashConfig
.writeEntry("ConfirmDelete", m_confirmDelete
->isChecked());
91 KConfigGroup
kdeConfig(KGlobal::config(), "KDE");
92 kdeConfig
.writeEntry("ShowDeleteCommand", m_showDeleteCommand
->isChecked());
95 settings
->setBrowseThroughArchives(m_browseThroughArchives
->isChecked());
98 void GeneralSettingsPage::restoreDefaults()
100 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
101 settings
->setDefaults();
103 // TODO: reset default settings for trash and show delete command...
108 void GeneralSettingsPage::loadSettings()
110 KSharedConfig::Ptr konqConfig
= KSharedConfig::openConfig("konquerorrc", KConfig::IncludeGlobals
);
111 const KConfigGroup
trashConfig(konqConfig
, "Trash");
112 m_confirmMoveToTrash
->setChecked(trashConfig
.readEntry("ConfirmTrash", false));
113 m_confirmDelete
->setChecked(trashConfig
.readEntry("ConfirmDelete", true));
115 const KConfigGroup
kdeConfig(KGlobal::config(), "KDE");
116 m_showDeleteCommand
->setChecked(kdeConfig
.readEntry("ShowDeleteCommand", false));
118 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
119 m_browseThroughArchives
->setChecked(settings
->browseThroughArchives());
122 #include "generalsettingspage.moc"