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