~ubuntu-branches/ubuntu/utopic/kdebase/utopic

« back to all changes in this revision

Viewing changes to apps/dolphin/src/settings/general/contextmenusettingspage.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-11-25 16:00:47 UTC
  • mfrom: (1.1.53 upstream)
  • Revision ID: james.westby@ubuntu.com-20101125160047-bsycodsp50o8su5s
Tags: 4:4.5.80-0ubuntu1
* New upstream beta release
* Drop kubuntu_06_simple_aboutpage.diff, didn't apply and no point
  keeping a distro patch to an app we don't ship by default
* Drop kubuntu_23_konqueror_spinner_in_toolbar.diff now upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
22
#include <settings/dolphinsettings.h>
 
23
#include <dolphin_generalsettings.h>
 
24
 
 
25
#include <kdialog.h>
 
26
#include <klocale.h>
 
27
#include <kvbox.h>
 
28
 
 
29
#include <QCheckBox>
 
30
#include <QVBoxLayout>
 
31
 
 
32
const bool SHOW_DELETE = false;
 
33
 
 
34
ContextMenuSettingsPage::ContextMenuSettingsPage(QWidget* parent) :
 
35
    SettingsPageBase(parent),
 
36
    m_showDeleteCommand(0),
 
37
    m_showCopyMoveMenu(0)
 
38
{
 
39
    QVBoxLayout* topLayout = new QVBoxLayout(this);
 
40
    KVBox* vBox = new KVBox(this);
 
41
    vBox->setSpacing(KDialog::spacingHint());
 
42
 
 
43
    m_showDeleteCommand = new QCheckBox(i18nc("@option:check", "Show 'Delete' command"), vBox);
 
44
 
 
45
    m_showCopyMoveMenu = new QCheckBox(i18nc("@option:check", "Show 'Copy To' and 'Move To' commands"), vBox);
 
46
 
 
47
    // Add a dummy widget with no restriction regarding
 
48
    // a vertical resizing. This assures that the dialog layout
 
49
    // is not stretched vertically.
 
50
    new QWidget(vBox);
 
51
 
 
52
    topLayout->addWidget(vBox);
 
53
 
 
54
    loadSettings();
 
55
 
 
56
    connect(m_showDeleteCommand, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
 
57
    connect(m_showCopyMoveMenu, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
 
58
}
 
59
 
 
60
ContextMenuSettingsPage::~ContextMenuSettingsPage()
 
61
{
 
62
}
 
63
 
 
64
void ContextMenuSettingsPage::applySettings()
 
65
{
 
66
    KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals);
 
67
    KConfigGroup configGroup(globalConfig, "KDE");
 
68
    configGroup.writeEntry("ShowDeleteCommand", m_showDeleteCommand->isChecked());
 
69
    configGroup.sync();
 
70
 
 
71
    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
 
72
    settings->setShowCopyMoveMenu(m_showCopyMoveMenu->isChecked());
 
73
    settings->writeConfig();
 
74
}
 
75
 
 
76
void ContextMenuSettingsPage::restoreDefaults()
 
77
{
 
78
    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
 
79
    settings->useDefaults(true);
 
80
    loadSettings();
 
81
    settings->useDefaults(false);
 
82
    m_showDeleteCommand->setChecked(SHOW_DELETE);
 
83
}
 
84
 
 
85
void ContextMenuSettingsPage::loadSettings()
 
86
{
 
87
    KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals);
 
88
    KConfigGroup configGroup(globalConfig, "KDE");
 
89
    m_showDeleteCommand->setChecked(configGroup.readEntry("ShowDeleteCommand", SHOW_DELETE));
 
90
 
 
91
    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
 
92
    m_showCopyMoveMenu->setChecked(settings->showCopyMoveMenu());
 
93
}
 
94
 
 
95
#include "contextmenusettingspage.moc"