1 /***************************************************************************
2 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
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. *
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. *
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 ***************************************************************************/
20 #include "confirmationssettingspage.h"
22 #include <dolphin_generalsettings.h>
29 #include <QVBoxLayout>
32 const bool ConfirmTrash
= false;
33 const bool ConfirmDelete
= true;
36 ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget
* parent
) :
37 SettingsPageBase(parent
),
38 m_confirmMoveToTrash(0),
40 m_confirmClosingMultipleTabs(0)
42 QVBoxLayout
* topLayout
= new QVBoxLayout(this);
44 QLabel
* confirmLabelKde
= new QLabel(i18nc("@title:group", "Ask for confirmation in all KDE applications when:"), this);
45 confirmLabelKde
->setWordWrap(true);
47 m_confirmMoveToTrash
= new QCheckBox(i18nc("@option:check Ask for confirmation when",
48 "Moving files or folders to trash"), this);
49 m_confirmDelete
= new QCheckBox(i18nc("@option:check Ask for confirmation when",
50 "Deleting files or folders"), this);
52 QLabel
* confirmLabelDolphin
= new QLabel(i18nc("@title:group", "Ask for confirmation when:"), this);
53 confirmLabelDolphin
->setWordWrap(true);
55 m_confirmClosingMultipleTabs
= new QCheckBox(i18nc("@option:check Ask for confirmation when",
56 "Closing Dolphin windows with multiple tabs"), this);
58 topLayout
->addSpacing(KDialog::spacingHint());
59 topLayout
->addWidget(confirmLabelKde
);
60 topLayout
->addSpacing(KDialog::spacingHint());
61 topLayout
->addWidget(m_confirmMoveToTrash
);
62 topLayout
->addWidget(m_confirmDelete
);
63 topLayout
->addSpacing(KDialog::spacingHint());
64 topLayout
->addWidget(confirmLabelDolphin
);
65 topLayout
->addSpacing(KDialog::spacingHint());
66 topLayout
->addWidget(m_confirmClosingMultipleTabs
);
67 topLayout
->addStretch();
71 connect(m_confirmMoveToTrash
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
72 connect(m_confirmDelete
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
73 connect(m_confirmClosingMultipleTabs
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
76 ConfirmationsSettingsPage::~ConfirmationsSettingsPage()
80 void ConfirmationsSettingsPage::applySettings()
82 KSharedConfig::Ptr kioConfig
= KSharedConfig::openConfig("kiorc", KConfig::NoGlobals
);
83 KConfigGroup
confirmationGroup(kioConfig
, "Confirmations");
84 confirmationGroup
.writeEntry("ConfirmTrash", m_confirmMoveToTrash
->isChecked());
85 confirmationGroup
.writeEntry("ConfirmDelete", m_confirmDelete
->isChecked());
86 confirmationGroup
.sync();
88 GeneralSettings
* settings
= GeneralSettings::self();
89 settings
->setConfirmClosingMultipleTabs(m_confirmClosingMultipleTabs
->isChecked());
90 settings
->writeConfig();
93 void ConfirmationsSettingsPage::restoreDefaults()
95 GeneralSettings
* settings
= GeneralSettings::self();
96 settings
->useDefaults(true);
98 settings
->useDefaults(false);
100 m_confirmMoveToTrash
->setChecked(ConfirmTrash
);
101 m_confirmDelete
->setChecked(ConfirmDelete
);
104 void ConfirmationsSettingsPage::loadSettings()
106 KSharedConfig::Ptr kioConfig
= KSharedConfig::openConfig("kiorc", KConfig::IncludeGlobals
);
107 const KConfigGroup
confirmationGroup(kioConfig
, "Confirmations");
108 m_confirmMoveToTrash
->setChecked(confirmationGroup
.readEntry("ConfirmTrash", ConfirmTrash
));
109 m_confirmDelete
->setChecked(confirmationGroup
.readEntry("ConfirmDelete", ConfirmDelete
));
111 m_confirmClosingMultipleTabs
->setChecked(GeneralSettings::confirmClosingMultipleTabs());
114 #include "confirmationssettingspage.moc"