1 /***************************************************************************
2 * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
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 "navigationsettingspage.h"
22 #include "settings/dolphinsettings.h"
24 #include "dolphin_generalsettings.h"
27 #include <kglobalsettings.h>
34 #include <QRadioButton>
35 #include <QVBoxLayout>
37 NavigationSettingsPage::NavigationSettingsPage(QWidget
* parent
) :
38 SettingsPageBase(parent
),
39 m_browseThroughArchives(0),
40 m_autoExpandFolders(0)
42 const int spacing
= KDialog::spacingHint();
44 QVBoxLayout
* topLayout
= new QVBoxLayout(this);
45 KVBox
* vBox
= new KVBox(this);
46 vBox
->setSpacing(spacing
);
48 // create 'Mouse' group
49 QGroupBox
* mouseBox
= new QGroupBox(i18nc("@title:group", "Mouse"), vBox
);
50 m_singleClick
= new QRadioButton(i18nc("@option:check Mouse Settings",
51 "Single-click to open files and folders"), mouseBox
);
52 connect(m_singleClick
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
53 m_doubleClick
= new QRadioButton(i18nc("@option:check Mouse Settings",
54 "Double-click to open files and folders"), mouseBox
);
55 connect(m_doubleClick
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
57 QVBoxLayout
* mouseBoxLayout
= new QVBoxLayout(mouseBox
);
58 mouseBoxLayout
->addWidget(m_singleClick
);
59 mouseBoxLayout
->addWidget(m_doubleClick
);
61 m_browseThroughArchives
= new QCheckBox(i18nc("@option:check", "Browse through archives"), vBox
);
62 connect(m_browseThroughArchives
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
64 m_autoExpandFolders
= new QCheckBox(i18nc("option:check", "Open folders during drag operations"), vBox
);
65 connect(m_autoExpandFolders
, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
67 // Add a dummy widget with no restriction regarding
68 // a vertical resizing. This assures that the dialog layout
69 // is not stretched vertically.
72 topLayout
->addWidget(vBox
);
77 NavigationSettingsPage::~NavigationSettingsPage()
81 void NavigationSettingsPage::applySettings()
83 KConfig
config("kcminputrc");
84 KConfigGroup group
= config
.group("Mouse");
85 group
.writeEntry("SingleClick", m_singleClick
->isChecked(), KConfig::Persistent
|KConfig::Global
);
87 KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged
, KGlobalSettings::SETTINGS_MOUSE
);
89 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
90 settings
->setBrowseThroughArchives(m_browseThroughArchives
->isChecked());
91 settings
->setAutoExpandFolders(m_autoExpandFolders
->isChecked());
94 void NavigationSettingsPage::restoreDefaults()
96 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
97 settings
->setDefaults();
101 void NavigationSettingsPage::loadSettings()
103 const bool singleClick
= KGlobalSettings::singleClick();
104 m_singleClick
->setChecked(singleClick
);
105 m_doubleClick
->setChecked(!singleClick
);
107 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
108 m_browseThroughArchives
->setChecked(settings
->browseThroughArchives());
109 m_autoExpandFolders
->setChecked(settings
->autoExpandFolders());
112 #include "navigationsettingspage.moc"