diff options
Diffstat (limited to 'src/userfeedback')
| -rw-r--r-- | src/userfeedback/dolphinfeedbackprovider.cpp | 41 | ||||
| -rw-r--r-- | src/userfeedback/dolphinfeedbackprovider.h | 28 | ||||
| -rw-r--r-- | src/userfeedback/placesdatasource.cpp | 76 | ||||
| -rw-r--r-- | src/userfeedback/placesdatasource.h | 25 | ||||
| -rw-r--r-- | src/userfeedback/settingsdatasource.cpp | 55 | ||||
| -rw-r--r-- | src/userfeedback/settingsdatasource.h | 27 |
6 files changed, 252 insertions, 0 deletions
diff --git a/src/userfeedback/dolphinfeedbackprovider.cpp b/src/userfeedback/dolphinfeedbackprovider.cpp new file mode 100644 index 000000000..c2feba23d --- /dev/null +++ b/src/userfeedback/dolphinfeedbackprovider.cpp @@ -0,0 +1,41 @@ +/* + * SPDX-FileCopyrightText: 2020 Elvis Angelaccio <[email protected] + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "dolphinfeedbackprovider.h" +#include "placesdatasource.h" +#include "settingsdatasource.h" + +#include <KUserFeedback/ApplicationVersionSource> +#include <KUserFeedback/LocaleInfoSource> +#include <KUserFeedback/PlatformInfoSource> +#include <KUserFeedback/QtVersionSource> +#include <KUserFeedback/ScreenInfoSource> +#include <KUserFeedback/StartCountSource> +#include <KUserFeedback/UsageTimeSource> + +DolphinFeedbackProvider *DolphinFeedbackProvider::instance() +{ + static DolphinFeedbackProvider s_self; + return &s_self; +} + +DolphinFeedbackProvider::DolphinFeedbackProvider() + : KUserFeedback::Provider() +{ + setProductIdentifier(QStringLiteral("org.kde.dolphin")); + setFeedbackServer(QUrl(QStringLiteral("https://telemetry.kde.org"))); + setSubmissionInterval(7); + + addDataSource(new KUserFeedback::ApplicationVersionSource); + addDataSource(new KUserFeedback::LocaleInfoSource); + addDataSource(new KUserFeedback::PlatformInfoSource); + addDataSource(new KUserFeedback::QtVersionSource); + addDataSource(new KUserFeedback::ScreenInfoSource); + addDataSource(new KUserFeedback::StartCountSource); + addDataSource(new KUserFeedback::UsageTimeSource); + addDataSource(new PlacesDataSource); + addDataSource(new SettingsDataSource); +} diff --git a/src/userfeedback/dolphinfeedbackprovider.h b/src/userfeedback/dolphinfeedbackprovider.h new file mode 100644 index 000000000..f6575d49f --- /dev/null +++ b/src/userfeedback/dolphinfeedbackprovider.h @@ -0,0 +1,28 @@ +/* + * SPDX-FileCopyrightText: 2020 Elvis Angelaccio <[email protected] + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef DOLPHINFEEDBACKPROVIDER_H +#define DOLPHINFEEDBACKPROVIDER_H + +#include <KUserFeedback/Provider> + +class DolphinFeedbackProvider : public KUserFeedback::Provider +{ + Q_OBJECT + +public: + static DolphinFeedbackProvider *instance(); + + DolphinFeedbackProvider(const DolphinFeedbackProvider&) = delete; + DolphinFeedbackProvider(DolphinFeedbackProvider&&) = delete; + DolphinFeedbackProvider& operator=(const DolphinFeedbackProvider&) = delete; + DolphinFeedbackProvider& operator=(DolphinFeedbackProvider&&) = delete; + +private: + DolphinFeedbackProvider(); +}; + +#endif // DOLPHINFEEDBACKPROVIDER_H diff --git a/src/userfeedback/placesdatasource.cpp b/src/userfeedback/placesdatasource.cpp new file mode 100644 index 000000000..6db89636d --- /dev/null +++ b/src/userfeedback/placesdatasource.cpp @@ -0,0 +1,76 @@ +/* + * SPDX-FileCopyrightText: 2020 Elvis Angelaccio <[email protected] + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "placesdatasource.h" + +#include <KLocalizedString> +#include <KMountPoint> +#include <KUserFeedback/Provider> +#include <Solid/Device> +#include <Solid/NetworkShare> +#include <Solid/StorageAccess> + +#include <QVariant> + +PlacesDataSource::PlacesDataSource() + : KUserFeedback::AbstractDataSource(QStringLiteral("places"), KUserFeedback::Provider::DetailedSystemInformation) +{} + +QString PlacesDataSource::name() const +{ + return i18nc("name of kuserfeedback data source provided by dolphin", "Places"); +} + +QString PlacesDataSource::description() const +{ + // TODO: add count of remote places grouped by protocol type. + return i18nc("description of kuserfeedback data source provided by dolphin", "Count of available Network Shares"); +} + +QVariant PlacesDataSource::data() +{ + QVariantMap map; + + bool hasSSHFS = false; + bool hasSambaShare = false; + bool hasNfsShare = false; + + const auto devices = Solid::Device::listFromType(Solid::DeviceInterface::NetworkShare); + for (const auto &device : devices) { + if (!hasSSHFS && device.vendor() == QLatin1String("fuse.sshfs")) { + // Ignore kdeconnect SSHFS mounts, we already know that people have those. + auto storageAccess = device.as<Solid::StorageAccess>(); + if (storageAccess) { + auto mountPoint = KMountPoint::currentMountPoints().findByPath(storageAccess->filePath()); + if (!mountPoint->mountedFrom().startsWith(QLatin1String("kdeconnect@"))) { + hasSSHFS = true; + continue; + } + } + } + + if (!device.is<Solid::NetworkShare>()) { + continue; + } + + switch (device.as<Solid::NetworkShare>()->type()) { + case Solid::NetworkShare::Cifs: + hasSambaShare = true; + continue; + case Solid::NetworkShare::Nfs: + hasNfsShare = true; + continue; + default: + continue; + } + } + + map.insert(QStringLiteral("hasSSHFSMount"), hasSSHFS); + map.insert(QStringLiteral("hasSambaShare"), hasSambaShare); + map.insert(QStringLiteral("hasNfsShare"), hasNfsShare); + + return map; +} diff --git a/src/userfeedback/placesdatasource.h b/src/userfeedback/placesdatasource.h new file mode 100644 index 000000000..f25f1067c --- /dev/null +++ b/src/userfeedback/placesdatasource.h @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: 2020 Elvis Angelaccio <[email protected] + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef PLACESDATASOURCE_H +#define PLACESDATASOURCE_H + +#include <KUserFeedback/AbstractDataSource> + +class DolphinMainWindow; + +class PlacesDataSource : public KUserFeedback::AbstractDataSource +{ +public: + PlacesDataSource(); + + QString name() const override; + QString description() const override; + QVariant data() override; + +}; + +#endif // PLACESDATASOURCE_H diff --git a/src/userfeedback/settingsdatasource.cpp b/src/userfeedback/settingsdatasource.cpp new file mode 100644 index 000000000..03a25ff75 --- /dev/null +++ b/src/userfeedback/settingsdatasource.cpp @@ -0,0 +1,55 @@ +/* + * SPDX-FileCopyrightText: 2020 Elvis Angelaccio <[email protected] + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "settingsdatasource.h" +#include "dolphinmainwindow.h" +#include "dolphin_generalsettings.h" + +#include <KLocalizedString> +#include <KUserFeedback/Provider> + +#include <QApplication> +#include <QVariant> + +SettingsDataSource::SettingsDataSource() + : KUserFeedback::AbstractDataSource(QStringLiteral("settings"), KUserFeedback::Provider::DetailedSystemInformation) +{} + +QString SettingsDataSource::name() const +{ + return i18nc("name of kuserfeedback data source provided by dolphin", "Settings"); +} + +QString SettingsDataSource::description() const +{ + return i18nc("description of kuserfeedback data source provided by dolphin", "A subset of Dolphin settings."); +} + +QVariant SettingsDataSource::data() +{ + if (!m_mainWindow) { + // This assumes there is only one DolphinMainWindow per process. + const auto topLevelWidgets = QApplication::topLevelWidgets(); + for (const auto widget : topLevelWidgets) { + if (qobject_cast<DolphinMainWindow *>(widget)) { + m_mainWindow = static_cast<DolphinMainWindow *>(widget); + break; + } + } + } + + QVariantMap map; + + if (m_mainWindow) { + map.insert(QStringLiteral("informationPanelEnabled"), m_mainWindow->isInformationPanelEnabled()); + map.insert(QStringLiteral("foldersPanelEnabled"), m_mainWindow->isFoldersPanelEnabled()); + } + + map.insert(QStringLiteral("tooltipsEnabled"), GeneralSettings::showToolTips()); + map.insert(QStringLiteral("browseArchivesEnable"), GeneralSettings::browseThroughArchives()); + + return map; +} diff --git a/src/userfeedback/settingsdatasource.h b/src/userfeedback/settingsdatasource.h new file mode 100644 index 000000000..9804c78a7 --- /dev/null +++ b/src/userfeedback/settingsdatasource.h @@ -0,0 +1,27 @@ +/* + * SPDX-FileCopyrightText: 2020 Elvis Angelaccio <[email protected] + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef SETTINGSDATASOURCE_H +#define SETTINGSDATASOURCE_H + +#include <KUserFeedback/AbstractDataSource> + +class DolphinMainWindow; + +class SettingsDataSource : public KUserFeedback::AbstractDataSource +{ +public: + SettingsDataSource(); + + QString name() const override; + QString description() const override; + QVariant data() override; + +private: + DolphinMainWindow *m_mainWindow = nullptr; +}; + +#endif // SETTINGSDATASOURCE_H |
