]> cloud.milkyroute.net Git - dolphin.git/blob - src/generalsettingspage.cpp
SVN_SILENT made messages (.desktop file)
[dolphin.git] / src / generalsettingspage.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) and *
3 * and Patrice Tremblay *
4 * *
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. *
9 * *
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. *
14 * *
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 ***************************************************************************/
20
21 #include "generalsettingspage.h"
22
23 #include "dolphinsettings.h"
24
25 #include "dolphin_generalsettings.h"
26
27 #include <kdialog.h>
28 #include <klocale.h>
29 #include <kvbox.h>
30
31 #include <QCheckBox>
32 #include <QGroupBox>
33 #include <QLabel>
34 #include <QVBoxLayout>
35
36 GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin, QWidget* parent) :
37 SettingsPageBase(parent),
38 m_showDeleteCommand(0),
39 m_confirmMoveToTrash(0),
40 m_confirmDelete(0),
41 m_browseThroughArchives(0)
42 {
43 const int spacing = KDialog::spacingHint();
44
45 QVBoxLayout* topLayout = new QVBoxLayout(this);
46 KVBox* vBox = new KVBox(this);
47 vBox->setSpacing(spacing);
48
49 // create 'Ask Confirmation For' group
50 QGroupBox* confirmBox = new QGroupBox(i18nc("@title:group", "Ask For Confirmation When"), vBox);
51 m_confirmMoveToTrash = new QCheckBox(i18nc("@option:check Ask for Confirmation When",
52 "Moving files or folders to trash"), confirmBox);
53 m_confirmDelete = new QCheckBox(i18nc("@option:check Ask for Confirmation When",
54 "Deleting files or folders"), confirmBox);
55
56 QVBoxLayout* confirmBoxLayout = new QVBoxLayout(confirmBox);
57 confirmBoxLayout->addWidget(m_confirmMoveToTrash);
58 confirmBoxLayout->addWidget(m_confirmDelete);
59
60 // create 'Show the command 'Delete' in context menu' checkbox
61 m_showDeleteCommand = new QCheckBox(i18nc("@option:check", "Show 'Delete' command in context menu"), vBox);
62
63 m_browseThroughArchives = new QCheckBox(i18nc("option:check", "Browse through archives"), vBox);
64
65 // Add a dummy widget with no restriction regarding
66 // a vertical resizing. This assures that the dialog layout
67 // is not stretched vertically.
68 new QWidget(vBox);
69
70 topLayout->addWidget(vBox);
71
72 loadSettings();
73 }
74
75 GeneralSettingsPage::~GeneralSettingsPage()
76 {
77 }
78
79 void GeneralSettingsPage::applySettings()
80 {
81 GeneralSettings* settings = DolphinSettings::instance().generalSettings();
82
83 KSharedConfig::Ptr konqConfig = KSharedConfig::openConfig("konquerorrc", KConfig::IncludeGlobals);
84 KConfigGroup trashConfig(konqConfig, "Trash");
85 trashConfig.writeEntry("ConfirmTrash", m_confirmMoveToTrash->isChecked());
86 trashConfig.writeEntry("ConfirmDelete", m_confirmDelete->isChecked());
87 trashConfig.sync();
88
89 KConfigGroup kdeConfig(KGlobal::config(), "KDE");
90 kdeConfig.writeEntry("ShowDeleteCommand", m_showDeleteCommand->isChecked());
91 kdeConfig.sync();
92
93 settings->setBrowseThroughArchives(m_browseThroughArchives->isChecked());
94 }
95
96 void GeneralSettingsPage::restoreDefaults()
97 {
98 GeneralSettings* settings = DolphinSettings::instance().generalSettings();
99 settings->setDefaults();
100
101 // TODO: reset default settings for trash and show delete command...
102
103 loadSettings();
104 }
105
106 void GeneralSettingsPage::loadSettings()
107 {
108 KSharedConfig::Ptr konqConfig = KSharedConfig::openConfig("konquerorrc", KConfig::IncludeGlobals);
109 const KConfigGroup trashConfig(konqConfig, "Trash");
110 m_confirmMoveToTrash->setChecked(trashConfig.readEntry("ConfirmTrash", false));
111 m_confirmDelete->setChecked(trashConfig.readEntry("ConfirmDelete", true));
112
113 const KConfigGroup kdeConfig(KGlobal::config(), "KDE");
114 m_showDeleteCommand->setChecked(kdeConfig.readEntry("ShowDeleteCommand", false));
115
116 GeneralSettings* settings = DolphinSettings::instance().generalSettings();
117 m_browseThroughArchives->setChecked(settings->browseThroughArchives());
118 }
119
120 #include "generalsettingspage.moc"