]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/navigation/navigationsettingspage.cpp
Merge branch 'release/20.08'
[dolphin.git] / src / settings / navigation / navigationsettingspage.cpp
1 /*
2 * SPDX-FileCopyrightText: 2009 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #include "navigationsettingspage.h"
8
9 #include "dolphin_generalsettings.h"
10
11 #include <KLocalizedString>
12
13 #include <QCheckBox>
14 #include <QVBoxLayout>
15
16 NavigationSettingsPage::NavigationSettingsPage(QWidget* parent) :
17 SettingsPageBase(parent),
18 m_openArchivesAsFolder(nullptr),
19 m_autoExpandFolders(nullptr)
20 {
21 QVBoxLayout* topLayout = new QVBoxLayout(this);
22 QWidget* vBox = new QWidget(this);
23 QVBoxLayout *vBoxLayout = new QVBoxLayout(vBox);
24 vBoxLayout->setContentsMargins(0, 0, 0, 0);
25 vBoxLayout->setAlignment(Qt::AlignTop);
26
27 m_openArchivesAsFolder = new QCheckBox(i18nc("@option:check", "Open archives as folder"), vBox);
28 vBoxLayout->addWidget(m_openArchivesAsFolder);
29
30 m_autoExpandFolders = new QCheckBox(i18nc("option:check", "Open folders during drag operations"), vBox);
31 vBoxLayout->addWidget(m_autoExpandFolders);
32
33 topLayout->addWidget(vBox);
34
35 loadSettings();
36
37 connect(m_openArchivesAsFolder, &QCheckBox::toggled, this, &NavigationSettingsPage::changed);
38 connect(m_autoExpandFolders, &QCheckBox::toggled, this, &NavigationSettingsPage::changed);
39 }
40
41 NavigationSettingsPage::~NavigationSettingsPage()
42 {
43 }
44
45 void NavigationSettingsPage::applySettings()
46 {
47 GeneralSettings* settings = GeneralSettings::self();
48 settings->setBrowseThroughArchives(m_openArchivesAsFolder->isChecked());
49 settings->setAutoExpandFolders(m_autoExpandFolders->isChecked());
50
51 settings->save();
52 }
53
54 void NavigationSettingsPage::restoreDefaults()
55 {
56 GeneralSettings* settings = GeneralSettings::self();
57 settings->useDefaults(true);
58 loadSettings();
59 settings->useDefaults(false);
60 }
61
62 void NavigationSettingsPage::loadSettings()
63 {
64 m_openArchivesAsFolder->setChecked(GeneralSettings::browseThroughArchives());
65 m_autoExpandFolders->setChecked(GeneralSettings::autoExpandFolders());
66 }
67