/* * Copyright (C) 2021 CutefishOS Team. * * Author: Reion Wong * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef MIMEAPPMANAGER_H #define MIMEAPPMANAGER_H #include #include #include #include #include #include "xdgdesktopfile.h" class QMimeType; class MimeAppManager : public QObject { Q_OBJECT public: static MimeAppManager *self(); explicit MimeAppManager(QObject *parent = nullptr); QStringList desktopPaths(); QString mimeAppsListFilePath(); void initApplications(); QString getDefaultAppByFilePath(const QString &filePath); QString getDefaultAppByMimeType(const QMimeType &mimeType); QString getDefaultAppDesktopByMimeType(const QString &mimeType); Q_INVOKABLE bool setDefaultAppForType(const QString &mimeType, const QString &app); Q_INVOKABLE bool setDefaultAppForFile(const QString &filePath, const QString &desktop); QStringList getRecommendedAppsByFilePath(const QString &filePath); QStringList getRecommendedAppsByMimeType(const QMimeType &mimeType); Q_INVOKABLE QVariantList recommendedApps(const QUrl &url); Q_INVOKABLE void launchTerminal(const QString &path); private slots: void onFileChanged(const QString &path); private: QStringList m_desktopFiles; QMap m_mimeApps; QMap m_videoMimeApps; QMap m_imageMimeApps; QMap m_textMimeApps; QMap m_audioMimeApps; QMap m_desktopObjects; QList m_terminalApps; QFileSystemWatcher *m_fileSystemWatcher; QTimer *m_updateTimer; }; #endif // MIMEAPPMANAGER_H