]> cloud.milkyroute.net Git - dolphin.git/blob - src/userfeedback/settingsdatasource.cpp
Port to KF6 rename of KUserFeedback
[dolphin.git] / src / userfeedback / settingsdatasource.cpp
1 /*
2 * SPDX-FileCopyrightText: 2020 Elvis Angelaccio <elvis.angelaccio@kde.org
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #include "settingsdatasource.h"
8 #include "dolphin_generalsettings.h"
9 #include "dolphinmainwindow.h"
10
11 #include <KLocalizedString>
12 #include <KUserFeedback/Provider>
13
14 #include <QApplication>
15 #include <QVariant>
16
17 SettingsDataSource::SettingsDataSource()
18 : KUserFeedback::AbstractDataSource(QStringLiteral("settings"), KUserFeedback::Provider::DetailedSystemInformation)
19 {
20 }
21
22 QString SettingsDataSource::name() const
23 {
24 return i18nc("name of kuserfeedback data source provided by dolphin", "Settings");
25 }
26
27 QString SettingsDataSource::description() const
28 {
29 return i18nc("description of kuserfeedback data source provided by dolphin", "A subset of Dolphin settings.");
30 }
31
32 QVariant SettingsDataSource::data()
33 {
34 if (!m_mainWindow) {
35 // This assumes there is only one DolphinMainWindow per process.
36 const auto topLevelWidgets = QApplication::topLevelWidgets();
37 for (const auto widget : topLevelWidgets) {
38 if (qobject_cast<DolphinMainWindow *>(widget)) {
39 m_mainWindow = static_cast<DolphinMainWindow *>(widget);
40 break;
41 }
42 }
43 }
44
45 QVariantMap map;
46
47 if (m_mainWindow) {
48 map.insert(QStringLiteral("informationPanelEnabled"), m_mainWindow->isInformationPanelEnabled());
49 map.insert(QStringLiteral("foldersPanelEnabled"), m_mainWindow->isFoldersPanelEnabled());
50 }
51
52 map.insert(QStringLiteral("tooltipsEnabled"), GeneralSettings::showToolTips());
53 map.insert(QStringLiteral("browseArchivesEnable"), GeneralSettings::browseThroughArchives());
54
55 return map;
56 }