Commit 3d457ba3 authored by Marco Martin's avatar Marco Martin
Browse files

derive the blacklist from desktop files

desktop files of installed "voice apps" which actually use mycroft-gui-app
in their exec like. extract from there the name of the skill and make a
list of skill not-to-be-used-in-process from there
parent 232a932a
......@@ -97,7 +97,8 @@ Window {
open: false
Keys.onEscapePressed: window.visible = false;
KeyNavigation.up: closeButton
activeSkills.blackList: ["youtube-skill.aiix", "skill-wikidata.aiix", "soundcloud-audio-player.aiix", "food-wizard.aiix", "unsplash-wallpaper-plasma-skill.aiix", "bitchute-skill.aiix"]
activeSkills.blackList: plasmoid.nativeInterface.applicationListModel.voiceAppSkills
activeSkills.onBlacklistedSkillActivated: {
plasmoid.nativeInterface.executeCommand("mycroft-gui-app --hideTextInput --skill=" + skillId);
}
......
......@@ -72,6 +72,7 @@ void ApplicationListModel::sycocaDbChanged(const QStringList &changes)
}
m_applicationList.clear();
m_voiceAppSkills.clear();
loadApplications();
}
......@@ -81,6 +82,11 @@ bool appNameLessThan(const ApplicationData &a1, const ApplicationData &a2)
return a1.name.toLower() < a2.name.toLower();
}
QStringList ApplicationListModel::voiceAppSkills() const
{
return m_voiceAppSkills;
}
void ApplicationListModel::loadApplications()
{
auto cfg = KSharedConfig::openConfig("applications-blacklistrc");
......@@ -136,6 +142,15 @@ void ApplicationListModel::loadApplications()
!blacklist.contains(service->desktopEntryName()) &&
service->showOnCurrentPlatform() &&
!service->property("Terminal", QVariant::Bool).toBool()) {
QRegularExpression voiceExpr(QStringLiteral("mycroft-gui-app .* --skill=(.*)\\.home"));
if (service->categories().contains(QStringLiteral("VoiceApp")) && voiceExpr.match(service->exec()).hasMatch()) {
QString exec = service->exec();
exec.replace (voiceExpr, QStringLiteral("\\1"));
if (!exec.isEmpty()) {
m_voiceAppSkills << exec;
}
}
bl << service->desktopEntryName();
......@@ -162,6 +177,8 @@ void ApplicationListModel::loadApplications()
}
}
emit voiceAppSkillsChanged();
blgroup.writeEntry("allapps", bl);
blgroup.writeEntry("blacklist", blacklist);
cfg->sync();
......
......@@ -43,6 +43,7 @@ class ApplicationListModel : public QAbstractListModel {
Q_PROPERTY(int count READ count NOTIFY countChanged)
Q_PROPERTY(QStringList appOrder READ appOrder WRITE setAppOrder NOTIFY appOrderChanged)
Q_PROPERTY(QStringList voiceAppSkills READ voiceAppSkills NOTIFY voiceAppSkillsChanged)
public:
ApplicationListModel(QObject *parent = nullptr);
......@@ -60,6 +61,8 @@ public:
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
QStringList voiceAppSkills() const;
enum Roles {
ApplicationNameRole = Qt::UserRole + 1,
ApplicationCommentRole,
......@@ -90,8 +93,10 @@ public Q_SLOTS:
Q_SIGNALS:
void countChanged();
void appOrderChanged();
void voiceAppSkillsChanged();
private:
QStringList m_voiceAppSkills;
QList<ApplicationData> m_applicationList;
QStringList m_appOrder;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment