]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/contextmenusettingspage.cpp
SVN_SILENT: Minor coding style and format cleanups. No change of behavior has been...
[dolphin.git] / src / settings / contextmenusettingspage.cpp
1 /***************************************************************************
2 * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #include "contextmenusettingspage.h"
21 #include "dolphinsettings.h"
22 #include "dolphin_generalsettings.h"
23
24 #include <kdialog.h>
25 #include <klocale.h>
26 #include <kvbox.h>
27
28 #include <QCheckBox>
29 #include <QVBoxLayout>
30
31 const bool SHOW_DELETE = false;
32
33 ContextMenuSettingsPage::ContextMenuSettingsPage(QWidget* parent) :
34 SettingsPageBase(parent),
35 m_showDeleteCommand(0),
36 m_showCopyMoveMenu(0)
37 {
38 QVBoxLayout* topLayout = new QVBoxLayout(this);
39 KVBox* vBox = new KVBox(this);
40 vBox->setSpacing(KDialog::spacingHint());
41
42 m_showDeleteCommand = new QCheckBox(i18nc("@option:check", "Show 'Delete' command"), vBox);
43 connect(m_showDeleteCommand, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
44
45 m_showCopyMoveMenu = new QCheckBox(i18nc("@option:check", "Show 'Copy To' and 'Move To' commands"), vBox);
46 connect(m_showCopyMoveMenu, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
47
48 // Add a dummy widget with no restriction regarding
49 // a vertical resizing. This assures that the dialog layout
50 // is not stretched vertically.
51 new QWidget(vBox);
52
53 topLayout->addWidget(vBox);
54
55 loadSettings();
56 }
57
58 ContextMenuSettingsPage::~ContextMenuSettingsPage()
59 {
60 }
61
62 void ContextMenuSettingsPage::applySettings()
63 {
64 KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals);
65 KConfigGroup configGroup(globalConfig, "KDE");
66 configGroup.writeEntry("ShowDeleteCommand", m_showDeleteCommand->isChecked());
67 configGroup.sync();
68
69 GeneralSettings* settings = DolphinSettings::instance().generalSettings();
70 settings->setShowCopyMoveMenu(m_showCopyMoveMenu->isChecked());
71 settings->writeConfig();
72 }
73
74 void ContextMenuSettingsPage::restoreDefaults()
75 {
76 GeneralSettings* settings = DolphinSettings::instance().generalSettings();
77 settings->useDefaults(true);
78 loadSettings();
79 settings->useDefaults(false);
80 m_showDeleteCommand->setChecked(SHOW_DELETE);
81 }
82
83 void ContextMenuSettingsPage::loadSettings()
84 {
85 KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals);
86 KConfigGroup configGroup(globalConfig, "KDE");
87 m_showDeleteCommand->setChecked(configGroup.readEntry("ShowDeleteCommand", SHOW_DELETE));
88
89 GeneralSettings* settings = DolphinSettings::instance().generalSettings();
90 m_showCopyMoveMenu->setChecked(settings->showCopyMoveMenu());
91 }
92
93 #include "contextmenusettingspage.moc"