]>
cloud.milkyroute.net Git - dolphin.git/blob - src/settings/navigation/navigationsettingspage.cpp
10e009faa12e343a80b25c14d0add014d57ebc42
1 /***************************************************************************
2 * Copyright (C) 2009 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 "navigationsettingspage.h"
22 #include "dolphin_generalsettings.h"
25 #include <KGlobalSettings>
26 #include <KLocalizedString>
32 #include <QRadioButton>
33 #include <QVBoxLayout>
35 NavigationSettingsPage::NavigationSettingsPage(QWidget
* parent
) :
36 SettingsPageBase(parent
),
37 m_openArchivesAsFolder(0),
38 m_autoExpandFolders(0)
40 const int spacing
= KDialog::spacingHint();
42 QVBoxLayout
* topLayout
= new QVBoxLayout(this);
43 KVBox
* vBox
= new KVBox(this);
44 vBox
->setSpacing(spacing
);
46 // create 'Mouse' group
47 QGroupBox
* mouseBox
= new QGroupBox(i18nc("@title:group", "Mouse"), vBox
);
48 mouseBox
->setSizePolicy(QSizePolicy::Preferred
, QSizePolicy::Maximum
);
49 m_singleClick
= new QRadioButton(i18nc("@option:check Mouse Settings",
50 "Single-click to open files and folders"), mouseBox
);
51 m_doubleClick
= new QRadioButton(i18nc("@option:check Mouse Settings",
52 "Double-click to open files and folders"), mouseBox
);
54 QVBoxLayout
* mouseBoxLayout
= new QVBoxLayout(mouseBox
);
55 mouseBoxLayout
->addWidget(m_singleClick
);
56 mouseBoxLayout
->addWidget(m_doubleClick
);
58 m_openArchivesAsFolder
= new QCheckBox(i18nc("@option:check", "Open archives as folder"), vBox
);
60 m_autoExpandFolders
= new QCheckBox(i18nc("option:check", "Open folders during drag operations"), vBox
);
62 // Add a dummy widget with no restriction regarding
63 // a vertical resizing. This assures that the dialog layout
64 // is not stretched vertically.
67 topLayout
->addWidget(vBox
);
71 connect(m_singleClick
, &QRadioButton::toggled
, this, &NavigationSettingsPage::changed
);
72 connect(m_doubleClick
, &QRadioButton::toggled
, this, &NavigationSettingsPage::changed
);
73 connect(m_openArchivesAsFolder
, &QCheckBox::toggled
, this, &NavigationSettingsPage::changed
);
74 connect(m_autoExpandFolders
, &QCheckBox::toggled
, this, &NavigationSettingsPage::changed
);
77 NavigationSettingsPage::~NavigationSettingsPage()
81 void NavigationSettingsPage::applySettings()
83 KConfig
config("kcminputrc");
84 KConfigGroup group
= config
.group("KDE");
85 group
.writeEntry("SingleClick", m_singleClick
->isChecked(), KConfig::Persistent
|KConfig::Global
);
87 KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged
, KGlobalSettings::SETTINGS_MOUSE
);
89 GeneralSettings
* settings
= GeneralSettings::self();
90 settings
->setBrowseThroughArchives(m_openArchivesAsFolder
->isChecked());
91 settings
->setAutoExpandFolders(m_autoExpandFolders
->isChecked());
93 settings
->writeConfig();
96 void NavigationSettingsPage::restoreDefaults()
98 GeneralSettings
* settings
= GeneralSettings::self();
99 settings
->useDefaults(true);
101 settings
->useDefaults(false);
103 // The mouse settings stored in KGlobalSettings must be reset to
104 // the default values (= single click) manually.
105 m_singleClick
->setChecked(true);
106 m_doubleClick
->setChecked(false);
109 void NavigationSettingsPage::loadSettings()
111 const bool singleClick
= KGlobalSettings::singleClick();
112 m_singleClick
->setChecked(singleClick
);
113 m_doubleClick
->setChecked(!singleClick
);
114 m_openArchivesAsFolder
->setChecked(GeneralSettings::browseThroughArchives());
115 m_autoExpandFolders
->setChecked(GeneralSettings::autoExpandFolders());