]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/navigation/navigationsettingspage.cpp
Update e-mail address from peter.penz@gmx.at to peter.penz19@gmail.com
[dolphin.git] / src / settings / navigation / navigationsettingspage.cpp
1 /***************************************************************************
2 * Copyright (C) 2009 by Peter Penz <peter.penz19@gmail.com> *
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 "navigationsettingspage.h"
21
22 #include "settings/dolphinsettings.h"
23
24 #include "dolphin_generalsettings.h"
25
26 #include <KDialog>
27 #include <KGlobalSettings>
28 #include <KLocale>
29 #include <KVBox>
30
31 #include <QCheckBox>
32 #include <QGroupBox>
33 #include <QLabel>
34 #include <QRadioButton>
35 #include <QVBoxLayout>
36
37 NavigationSettingsPage::NavigationSettingsPage(QWidget* parent) :
38 SettingsPageBase(parent),
39 m_openArchivesAsFolder(0),
40 m_autoExpandFolders(0)
41 {
42 const int spacing = KDialog::spacingHint();
43
44 QVBoxLayout* topLayout = new QVBoxLayout(this);
45 KVBox* vBox = new KVBox(this);
46 vBox->setSpacing(spacing);
47
48 // create 'Mouse' group
49 QGroupBox* mouseBox = new QGroupBox(i18nc("@title:group", "Mouse"), vBox);
50 mouseBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
51 m_singleClick = new QRadioButton(i18nc("@option:check Mouse Settings",
52 "Single-click to open files and folders"), mouseBox);
53 m_doubleClick = new QRadioButton(i18nc("@option:check Mouse Settings",
54 "Double-click to open files and folders"), mouseBox);
55
56 QVBoxLayout* mouseBoxLayout = new QVBoxLayout(mouseBox);
57 mouseBoxLayout->addWidget(m_singleClick);
58 mouseBoxLayout->addWidget(m_doubleClick);
59
60 m_openArchivesAsFolder = new QCheckBox(i18nc("@option:check", "Open archives as folder"), vBox);
61
62 m_autoExpandFolders = new QCheckBox(i18nc("option:check", "Open folders during drag operations"), vBox);
63
64 // Add a dummy widget with no restriction regarding
65 // a vertical resizing. This assures that the dialog layout
66 // is not stretched vertically.
67 new QWidget(vBox);
68
69 topLayout->addWidget(vBox);
70
71 loadSettings();
72
73 connect(m_singleClick, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
74 connect(m_doubleClick, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
75 connect(m_openArchivesAsFolder, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
76 connect(m_autoExpandFolders, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
77 }
78
79 NavigationSettingsPage::~NavigationSettingsPage()
80 {
81 }
82
83 void NavigationSettingsPage::applySettings()
84 {
85 KConfig config("kcminputrc");
86 KConfigGroup group = config.group("KDE");
87 group.writeEntry("SingleClick", m_singleClick->isChecked(), KConfig::Persistent|KConfig::Global);
88 config.sync();
89 KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged, KGlobalSettings::SETTINGS_MOUSE);
90
91 GeneralSettings* settings = DolphinSettings::instance().generalSettings();
92 settings->setBrowseThroughArchives(m_openArchivesAsFolder->isChecked());
93 settings->setAutoExpandFolders(m_autoExpandFolders->isChecked());
94
95 settings->writeConfig();
96 }
97
98 void NavigationSettingsPage::restoreDefaults()
99 {
100 GeneralSettings* settings = DolphinSettings::instance().generalSettings();
101 settings->useDefaults(true);
102 loadSettings();
103 settings->useDefaults(false);
104
105 // The mouse settings stored in KGlobalSettings must be reset to
106 // the default values (= single click) manually.
107 m_singleClick->setChecked(true);
108 m_doubleClick->setChecked(false);
109 }
110
111 void NavigationSettingsPage::loadSettings()
112 {
113 const bool singleClick = KGlobalSettings::singleClick();
114 m_singleClick->setChecked(singleClick);
115 m_doubleClick->setChecked(!singleClick);
116 GeneralSettings* settings = DolphinSettings::instance().generalSettings();
117 m_openArchivesAsFolder->setChecked(settings->browseThroughArchives());
118 m_autoExpandFolders->setChecked(settings->autoExpandFolders());
119 }
120
121 #include "navigationsettingspage.moc"