]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/navigation/navigationsettingspage.cpp
e37a35d8eb9e6141319243338882e254c4f5518f
[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 "dolphin_generalsettings.h"
23
24 #include <KLocalizedString>
25
26 #include <QCheckBox>
27 #include <QVBoxLayout>
28
29 NavigationSettingsPage::NavigationSettingsPage(QWidget* parent) :
30 SettingsPageBase(parent),
31 m_openArchivesAsFolder(0),
32 m_autoExpandFolders(0)
33 {
34 QVBoxLayout* topLayout = new QVBoxLayout(this);
35 QWidget* vBox = new QWidget(this);
36 QVBoxLayout *vBoxLayout = new QVBoxLayout(vBox);
37 vBoxLayout->setMargin(0);
38 vBoxLayout->setAlignment(Qt::AlignTop);
39
40 m_openArchivesAsFolder = new QCheckBox(i18nc("@option:check", "Open archives as folder"), vBox);
41 vBoxLayout->addWidget(m_openArchivesAsFolder);
42
43 m_autoExpandFolders = new QCheckBox(i18nc("option:check", "Open folders during drag operations"), vBox);
44 vBoxLayout->addWidget(m_autoExpandFolders);
45
46 topLayout->addWidget(vBox);
47
48 loadSettings();
49
50 connect(m_openArchivesAsFolder, &QCheckBox::toggled, this, &NavigationSettingsPage::changed);
51 connect(m_autoExpandFolders, &QCheckBox::toggled, this, &NavigationSettingsPage::changed);
52 }
53
54 NavigationSettingsPage::~NavigationSettingsPage()
55 {
56 }
57
58 void NavigationSettingsPage::applySettings()
59 {
60 GeneralSettings* settings = GeneralSettings::self();
61 settings->setBrowseThroughArchives(m_openArchivesAsFolder->isChecked());
62 settings->setAutoExpandFolders(m_autoExpandFolders->isChecked());
63
64 settings->save();
65 }
66
67 void NavigationSettingsPage::restoreDefaults()
68 {
69 GeneralSettings* settings = GeneralSettings::self();
70 settings->useDefaults(true);
71 loadSettings();
72 settings->useDefaults(false);
73 }
74
75 void NavigationSettingsPage::loadSettings()
76 {
77 m_openArchivesAsFolder->setChecked(GeneralSettings::browseThroughArchives());
78 m_autoExpandFolders->setChecked(GeneralSettings::autoExpandFolders());
79 }
80