Compare commits
2 Commits
5076f044a6
...
edb781580e
Author | SHA1 | Date | |
---|---|---|---|
edb781580e | |||
36b6390292 |
@ -75,12 +75,34 @@ EntryConfig EntryProvider::readFromDesktopFile(const QString &path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(key == "nodisplay")
|
||||||
|
{
|
||||||
|
result.hidden = args == "true";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* qsrun own's config file */
|
std::optional<EntryConfig> EntryProvider::readEntryFromPath(const QString &path)
|
||||||
EntryConfig EntryProvider::readFromFile(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 result;
|
||||||
EntryConfig inheritedConfig;
|
EntryConfig inheritedConfig;
|
||||||
@ -159,7 +181,11 @@ EntryConfig EntryProvider::readFromFile(const QString &path)
|
|||||||
}
|
}
|
||||||
if(key == "inherit")
|
if(key == "inherit")
|
||||||
{
|
{
|
||||||
inheritedConfig = readFromDesktopFile(resolveEntryPath(splitted[1]));
|
auto entry = readEntryFromPath(resolveEntryPath(splitted[1]));
|
||||||
|
if(entry)
|
||||||
|
{
|
||||||
|
inheritedConfig = *entry;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result.update(inheritedConfig);
|
return result.update(inheritedConfig);
|
||||||
@ -197,17 +223,12 @@ QVector<EntryConfig> EntryProvider::readConfig(QStringList paths)
|
|||||||
while(it.hasNext())
|
while(it.hasNext())
|
||||||
{
|
{
|
||||||
QString path = it.next();
|
QString path = it.next();
|
||||||
QFileInfo info(path);
|
std::optional<EntryConfig> entry = readEntryFromPath(path);
|
||||||
if(info.isFile())
|
if(entry)
|
||||||
{
|
{
|
||||||
QString suffix = info.suffix();
|
if(!entry->hidden)
|
||||||
if(suffix == "desktop")
|
|
||||||
{
|
{
|
||||||
result.append(readFromDesktopFile(path));
|
result.append(*entry);
|
||||||
}
|
|
||||||
if(suffix == "qsrun")
|
|
||||||
{
|
|
||||||
result.append(readFromFile(path));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define ENTRYPROVIDER_H
|
#define ENTRYPROVIDER_H
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
class ConfigFormatException : public std::runtime_error
|
class ConfigFormatException : public std::runtime_error
|
||||||
{
|
{
|
||||||
@ -17,6 +18,7 @@ class ConfigFormatException : public std::runtime_error
|
|||||||
class EntryConfig
|
class EntryConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
bool hidden = false;
|
||||||
QString key;
|
QString key;
|
||||||
QString name;
|
QString name;
|
||||||
QString command;
|
QString command;
|
||||||
@ -34,8 +36,9 @@ class EntryProvider
|
|||||||
QStringList _desktopIgnoreArgs;
|
QStringList _desktopIgnoreArgs;
|
||||||
QStringList userEntriesDirsPaths;
|
QStringList userEntriesDirsPaths;
|
||||||
QStringList systemEntriesDirsPaths;
|
QStringList systemEntriesDirsPaths;
|
||||||
EntryConfig readFromFile(const QString &path);
|
EntryConfig readqsrunFile(const QString &path);
|
||||||
EntryConfig readFromDesktopFile(const QString &path);
|
EntryConfig readFromDesktopFile(const QString &path);
|
||||||
|
std::optional<EntryConfig> readEntryFromPath(const QString &path);
|
||||||
QVector<EntryConfig> readConfig(QStringList paths);
|
QVector<EntryConfig> readConfig(QStringList paths);
|
||||||
QString resolveEntryPath(QString path);
|
QString resolveEntryPath(QString path);
|
||||||
|
|
||||||
|
@ -23,5 +23,5 @@ SOURCES += calculationengine.cpp \
|
|||||||
QT += widgets sql network
|
QT += widgets sql network
|
||||||
QT_CONFIG -= no-pkg-config
|
QT_CONFIG -= no-pkg-config
|
||||||
LIBS += -lcln
|
LIBS += -lcln
|
||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig c++17
|
||||||
PKGCONFIG += libqalculate
|
PKGCONFIG += libqalculate
|
||||||
|
Loading…
x
Reference in New Issue
Block a user