2020-09-06 19:40:46 +02:00
|
|
|
#ifndef ENTRYPROVIDER_H
|
|
|
|
#define ENTRYPROVIDER_H
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QSettings>
|
2020-09-06 22:23:36 +02:00
|
|
|
#include <optional>
|
2020-09-06 19:40:46 +02:00
|
|
|
|
|
|
|
class ConfigFormatException : public std::runtime_error
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ConfigFormatException() : std::runtime_error("Error in configuration file, misformated line?")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
ConfigFormatException(const std::string &str) : std::runtime_error(str)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class EntryConfig
|
|
|
|
{
|
|
|
|
public:
|
2020-09-13 15:13:28 +02:00
|
|
|
bool userEntry = false;
|
2020-09-06 22:08:54 +02:00
|
|
|
bool hidden = false;
|
2020-09-13 15:13:28 +02:00
|
|
|
QString entryPath;
|
2020-09-06 19:40:46 +02:00
|
|
|
QString key;
|
|
|
|
QString name;
|
|
|
|
QString command;
|
|
|
|
QStringList arguments;
|
|
|
|
QIcon icon;
|
|
|
|
int row = 0;
|
|
|
|
int col = 0;
|
2020-09-06 21:37:15 +02:00
|
|
|
|
|
|
|
EntryConfig &update(const EntryConfig &o);
|
2020-09-06 19:40:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class EntryProvider
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
QStringList _desktopIgnoreArgs;
|
|
|
|
QStringList userEntriesDirsPaths;
|
|
|
|
QStringList systemEntriesDirsPaths;
|
2020-09-06 22:23:36 +02:00
|
|
|
EntryConfig readqsrunFile(const QString &path);
|
2020-09-06 19:40:46 +02:00
|
|
|
EntryConfig readFromDesktopFile(const QString &path);
|
2020-09-06 22:23:36 +02:00
|
|
|
std::optional<EntryConfig> readEntryFromPath(const QString &path);
|
2020-09-13 15:13:28 +02:00
|
|
|
QVector<EntryConfig> readConfig(QStringList paths, bool userentrymode=false);
|
2020-09-06 19:40:46 +02:00
|
|
|
QString resolveEntryPath(QString path);
|
|
|
|
|
|
|
|
public:
|
|
|
|
EntryProvider(QStringList userEntriesDirsPaths, QStringList systemEntriesDirsPaths);
|
|
|
|
QVector<EntryConfig> getUserEntries();
|
|
|
|
QVector<EntryConfig> getSystemEntries();
|
2020-09-13 15:13:28 +02:00
|
|
|
void saveUserEntry(const EntryConfig &config);
|
2020-09-06 19:40:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ENTRYPROVIDER_H
|