Unity 8
xdgwatcher.h
1 /*
2  * Copyright (C) 2019 UBports Foundation
3  * Author(s): Marius Gripsgard <marius@ubports.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; version 3.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #include <QFileSystemWatcher>
19 #include <QHash>
20 #include <QFileInfo>
21 
22 class QFileInfo;
23 
24 class XdgWatcher: public QObject
25 {
26  Q_OBJECT
27 public:
28  XdgWatcher(QObject* parent = nullptr);
29 
30 Q_SIGNALS:
31  void appAdded(const QString &appId);
32  void appRemoved(const QString &appId);
33  void appInfoChanged(const QString &appId);
34 
35 private Q_SLOTS:
36  void onDirectoryChanged(const QString &path);
37  void onFileChanged(const QString &path);
38 
39 private:
40  const QString toStandardAppId(const QFileInfo fileInfo) const;
41  const QString getAppId(const QFileInfo file) const;
42  const QString stripAppIdVersion(const QString rawAppID) const;
43 
44  QFileSystemWatcher* m_watcher;
45  QHash<const QString, QString> m_registry;
46 };