コミットを比較
2 コミット
5076f044a6
...
edb781580e
作成者 | SHA1 | 日付 | |
---|---|---|---|
edb781580e | |||
36b6390292 |
@ -75,12 +75,34 @@ EntryConfig EntryProvider::readFromDesktopFile(const QString &path)
|
||||
}
|
||||
}
|
||||
}
|
||||
if(key == "nodisplay")
|
||||
{
|
||||
result.hidden = args == "true";
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/* qsrun own's config file */
|
||||
EntryConfig EntryProvider::readFromFile(const QString &path)
|
||||
std::optional<EntryConfig> EntryProvider::readEntryFromPath(const QString &path)
|
||||
{
|
||||
QFileInfo info(path);
|
||||
if(info.isFile())
|
||||
{
|
||||
QString suffix = info.suffix();
|
||||
if(suffix == "desktop")
|
||||
{
|
||||
return readFromDesktopFile(path);
|
||||
}
|
||||
if(suffix == "qsrun")
|
||||
{
|
||||
return readqsrunFile(path);
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
/* qsrun's own format */
|
||||
EntryConfig EntryProvider::readqsrunFile(const QString &path)
|
||||
{
|
||||
EntryConfig result;
|
||||
EntryConfig inheritedConfig;
|
||||
@ -159,7 +181,11 @@ EntryConfig EntryProvider::readFromFile(const QString &path)
|
||||
}
|
||||
if(key == "inherit")
|
||||
{
|
||||
inheritedConfig = readFromDesktopFile(resolveEntryPath(splitted[1]));
|
||||
auto entry = readEntryFromPath(resolveEntryPath(splitted[1]));
|
||||
if(entry)
|
||||
{
|
||||
inheritedConfig = *entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.update(inheritedConfig);
|
||||
@ -197,17 +223,12 @@ QVector<EntryConfig> EntryProvider::readConfig(QStringList paths)
|
||||
while(it.hasNext())
|
||||
{
|
||||
QString path = it.next();
|
||||
QFileInfo info(path);
|
||||
if(info.isFile())
|
||||
std::optional<EntryConfig> entry = readEntryFromPath(path);
|
||||
if(entry)
|
||||
{
|
||||
QString suffix = info.suffix();
|
||||
if(suffix == "desktop")
|
||||
if(!entry->hidden)
|
||||
{
|
||||
result.append(readFromDesktopFile(path));
|
||||
}
|
||||
if(suffix == "qsrun")
|
||||
{
|
||||
result.append(readFromFile(path));
|
||||
result.append(*entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define ENTRYPROVIDER_H
|
||||
#include <QIcon>
|
||||
#include <QSettings>
|
||||
#include <optional>
|
||||
|
||||
class ConfigFormatException : public std::runtime_error
|
||||
{
|
||||
@ -17,6 +18,7 @@ class ConfigFormatException : public std::runtime_error
|
||||
class EntryConfig
|
||||
{
|
||||
public:
|
||||
bool hidden = false;
|
||||
QString key;
|
||||
QString name;
|
||||
QString command;
|
||||
@ -34,8 +36,9 @@ class EntryProvider
|
||||
QStringList _desktopIgnoreArgs;
|
||||
QStringList userEntriesDirsPaths;
|
||||
QStringList systemEntriesDirsPaths;
|
||||
EntryConfig readFromFile(const QString &path);
|
||||
EntryConfig readqsrunFile(const QString &path);
|
||||
EntryConfig readFromDesktopFile(const QString &path);
|
||||
std::optional<EntryConfig> readEntryFromPath(const QString &path);
|
||||
QVector<EntryConfig> readConfig(QStringList paths);
|
||||
QString resolveEntryPath(QString path);
|
||||
|
||||
|
読み込み中…
x
新しいイシューから参照
ユーザーをブロックする