Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Commit 426d399

Browse files
[applications] Send telemetry about available terminals
1 parent a0e14ea commit 426d399

File tree

5 files changed

+30
-5
lines changed

5 files changed

+30
-5
lines changed

applications/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.16)
22
find_package(Albert REQUIRED)
33

4-
project(applications VERSION 13.7)
4+
project(applications VERSION 13.8)
55

66
file(GLOB_RECURSE I18N_SOURCES src/*)
77

applications/src/xdg/application.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ Application::Application(const QString &id, const QString &path, ParseOptions po
2020
// Post a warning on unsupported terminals
2121
try {
2222
if (ranges::any_of(p.getString(root_section, QStringLiteral("Categories")).split(';', Qt::SkipEmptyParts),
23-
[&](const auto &cat){ return cat == QStringLiteral("TerminalEmulator"); })
24-
&& !Plugin::exec_args.contains(id))
25-
WARN << QString("Terminal '%1' not supported. Please post an issue.").arg(id);
23+
[&](const auto &cat){ return cat == QStringLiteral("TerminalEmulator"); }))
24+
{
25+
is_terminal_ = true;
26+
if (!Plugin::exec_args.contains(id))
27+
WARN << QString("Terminal '%1' not supported. Please post an issue.").arg(id);
28+
}
2629
} catch (const out_of_range &) { }
2730

2831
// Type - string, REQUIRED to be Application
@@ -210,6 +213,8 @@ const QStringList &Application::exec() const
210213
return exec_;
211214
}
212215

216+
bool Application::isTerminal() const { return is_terminal_; }
217+
213218
void Application::launchExec(const QStringList &exec, QUrl url, const QString &working_dir) const
214219
{
215220
auto commandline = fieldCodesExpanded(exec, url);

applications/src/xdg/application.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class Application : public ApplicationBase
2929

3030
const QStringList &exec() const;
3131

32+
bool isTerminal() const;
33+
3234
protected:
3335

3436
void launchExec(const QStringList &exec, QUrl url, const QString &working_dir) const;
@@ -51,5 +53,6 @@ class Application : public ApplicationBase
5153
QString working_dir_;
5254
std::vector<DesktopAction> desktop_actions_;
5355
bool term_ = false;
56+
bool is_terminal_ = false;
5457

5558
};

applications/src/xdg/plugin.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,15 @@ void Plugin::runTerminal(QStringList commandline, const QString working_dir) con
209209
{
210210
terminal->launch(commandline, working_dir);
211211
}
212+
213+
QJsonObject Plugin::telemetryData() const
214+
{
215+
QJsonObject t;
216+
for (const auto &iapp : applications)
217+
if (const auto &app = static_pointer_cast<::Application>(iapp); app->isTerminal())
218+
t.insert(app->id(), app->exec().join(" "));
219+
220+
QJsonObject o;
221+
o.insert("terminals", t);
222+
return o;
223+
}

applications/src/xdg/plugin.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
#pragma once
44
#include "pluginbase.h"
55
#include <QStringList>
6+
#include <albert/telemetryprovider.h>
67

7-
class Plugin : public PluginBase
8+
class Plugin : public PluginBase,
9+
public albert::TelemetryProvider
810
{
911
ALBERT_PLUGIN
1012

@@ -16,6 +18,9 @@ class Plugin : public PluginBase
1618
// albert::ExtensionPlugin
1719
QWidget *buildConfigWidget() override;
1820

21+
// albert::TelemetryProvider
22+
QJsonObject telemetryData() const override;
23+
1924
using PluginBase::runTerminal;
2025

2126
void runTerminal(QStringList commandline, const QString working_dir = {}) const;

0 commit comments

Comments
 (0)