]> cloud.milkyroute.net Git - dolphin.git/blob - src/settings/viewmodes/generalviewsettingspage.cpp
Revert "Remove unused m_showToolTips variable"
[dolphin.git] / src / settings / viewmodes / generalviewsettingspage.cpp
1 /*
2 * SPDX-FileCopyrightText: 2006 Peter Penz (peter.penz@gmx.at) and Patrice Tremblay
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #include "generalviewsettingspage.h"
8 #include "dolphin_generalsettings.h"
9 #include "dolphinmainwindow.h"
10 #include "views/viewproperties.h"
11
12 #include <KLocalizedString>
13
14 #include <QButtonGroup>
15 #include <QCheckBox>
16 #include <QFormLayout>
17 #include <QVBoxLayout>
18
19 GeneralViewSettingsPage::GeneralViewSettingsPage(const QUrl &url, QWidget *parent)
20 : SettingsPageBase(parent)
21 , m_url(url)
22 , m_localViewProps(nullptr)
23 , m_globalViewProps(nullptr)
24 , m_showToolTips(nullptr)
25 , m_showSelectionToggle(nullptr)
26 , m_renameInline(nullptr)
27 {
28 QFormLayout *topLayout = new QFormLayout(this);
29
30 // Display style
31 m_globalViewProps = new QRadioButton(i18nc("@option:radio", "Use common display style for all folders"));
32 m_localViewProps = new QRadioButton(i18nc("@option:radio", "Remember display style for each folder"));
33 m_localViewProps->setToolTip(i18nc("@info", "Dolphin will create a hidden .directory file in each folder you change view properties for."));
34
35 QButtonGroup *viewGroup = new QButtonGroup(this);
36 viewGroup->addButton(m_globalViewProps);
37 viewGroup->addButton(m_localViewProps);
38 topLayout->addRow(i18nc("@title:group", "Display style: "), m_globalViewProps);
39 topLayout->addRow(QString(), m_localViewProps);
40
41 topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed));
42
43 // Browsing
44 m_openArchivesAsFolder = new QCheckBox(i18nc("@option:check", "Open archives as folder"));
45 m_autoExpandFolders = new QCheckBox(i18nc("option:check", "Open folders during drag operations"));
46 topLayout->addRow(i18nc("@title:group", "Browsing: "), m_openArchivesAsFolder);
47 topLayout->addRow(QString(), m_autoExpandFolders);
48
49 topLayout->addItem(new QSpacerItem(0, Dolphin::VERTICAL_SPACER_HEIGHT, QSizePolicy::Fixed, QSizePolicy::Fixed));
50
51 #if HAVE_BALOO
52 // 'Show tooltips'
53 m_showToolTips = new QCheckBox(i18nc("@option:check", "Show tooltips"));
54 topLayout->addRow(i18nc("@title:group", "Miscellaneous: "), m_showToolTips);
55 #endif
56
57 // 'Show selection marker'
58 m_showSelectionToggle = new QCheckBox(i18nc("@option:check", "Show selection marker"));
59 #if HAVE_BALOO
60 topLayout->addRow(QString(), m_showSelectionToggle);
61 #else
62 topLayout->addRow(i18nc("@title:group", "Miscellaneous: "), m_showSelectionToggle);
63 #endif
64
65 // 'Inline renaming of items'
66 m_renameInline = new QCheckBox(i18nc("option:check", "Rename inline"));
67 topLayout->addRow(QString(), m_renameInline);
68
69 loadSettings();
70
71 connect(m_localViewProps, &QRadioButton::toggled, this, &GeneralViewSettingsPage::changed);
72 connect(m_globalViewProps, &QRadioButton::toggled, this, &GeneralViewSettingsPage::changed);
73
74 connect(m_openArchivesAsFolder, &QCheckBox::toggled, this, &GeneralViewSettingsPage::changed);
75 connect(m_autoExpandFolders, &QCheckBox::toggled, this, &GeneralViewSettingsPage::changed);
76 #if HAVE_BALOO
77 connect(m_showToolTips, &QCheckBox::toggled, this, &GeneralViewSettingsPage::changed);
78 #endif
79 connect(m_showSelectionToggle, &QCheckBox::toggled, this, &GeneralViewSettingsPage::changed);
80 connect(m_renameInline, &QCheckBox::toggled, this, &GeneralViewSettingsPage::changed);
81 }
82
83 GeneralViewSettingsPage::~GeneralViewSettingsPage()
84 {
85 }
86
87 void GeneralViewSettingsPage::applySettings()
88 {
89 GeneralSettings *settings = GeneralSettings::self();
90 ViewProperties props(m_url); // read current view properties
91 const bool useGlobalViewProps = m_globalViewProps->isChecked();
92 settings->setGlobalViewProps(useGlobalViewProps);
93 #if HAVE_BALOO
94 settings->setShowToolTips(m_showToolTips->isChecked());
95 #endif
96 settings->setShowSelectionToggle(m_showSelectionToggle->isChecked());
97 settings->setRenameInline(m_renameInline->isChecked());
98 settings->setAutoExpandFolders(m_autoExpandFolders->isChecked());
99 settings->save();
100 if (useGlobalViewProps) {
101 // Remember the global view properties by applying the current view properties.
102 // It is important that GeneralSettings::globalViewProps() is set before
103 // the class ViewProperties is used, as ViewProperties uses this setting
104 // to find the destination folder for storing the view properties.
105 ViewProperties globalProps(m_url);
106 globalProps.setDirProperties(props);
107 }
108 }
109
110 void GeneralViewSettingsPage::restoreDefaults()
111 {
112 GeneralSettings *settings = GeneralSettings::self();
113 settings->useDefaults(true);
114 loadSettings();
115 settings->useDefaults(false);
116 }
117
118 void GeneralViewSettingsPage::loadSettings()
119 {
120 const bool useGlobalViewProps = GeneralSettings::globalViewProps();
121 m_openArchivesAsFolder->setChecked(GeneralSettings::browseThroughArchives());
122 m_autoExpandFolders->setChecked(GeneralSettings::autoExpandFolders());
123 #if HAVE_BALOO
124 m_showToolTips->setChecked(GeneralSettings::showToolTips());
125 #endif
126 m_showSelectionToggle->setChecked(GeneralSettings::showSelectionToggle());
127 m_renameInline->setChecked(GeneralSettings::renameInline());
128
129 m_localViewProps->setChecked(!useGlobalViewProps);
130 m_globalViewProps->setChecked(useGlobalViewProps);
131 }
132
133 #include "moc_generalviewsettingspage.cpp"