Comparar commits

..

No hay commits en común. "edb781580e9f6db5a78528ca218628403f15e40d" y "5076f044a647fb518a188361ed2b44b353292b54" tienen historias totalmente diferentes.

Se han modificado 3 ficheros con 14 adiciones y 38 borrados

Ver fichero

@ -75,34 +75,12 @@ EntryConfig EntryProvider::readFromDesktopFile(const QString &path)
} }
} }
} }
if(key == "nodisplay")
{
result.hidden = args == "true";
}
} }
return result; return result;
} }
std::optional<EntryConfig> EntryProvider::readEntryFromPath(const QString &path) /* qsrun own's config file */
{ 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;
@ -181,11 +159,7 @@ EntryConfig EntryProvider::readqsrunFile(const QString &path)
} }
if(key == "inherit") if(key == "inherit")
{ {
auto entry = readEntryFromPath(resolveEntryPath(splitted[1])); inheritedConfig = readFromDesktopFile(resolveEntryPath(splitted[1]));
if(entry)
{
inheritedConfig = *entry;
}
} }
} }
return result.update(inheritedConfig); return result.update(inheritedConfig);
@ -223,12 +197,17 @@ QVector<EntryConfig> EntryProvider::readConfig(QStringList paths)
while(it.hasNext()) while(it.hasNext())
{ {
QString path = it.next(); QString path = it.next();
std::optional<EntryConfig> entry = readEntryFromPath(path); QFileInfo info(path);
if(entry) if(info.isFile())
{ {
if(!entry->hidden) QString suffix = info.suffix();
if(suffix == "desktop")
{ {
result.append(*entry); result.append(readFromDesktopFile(path));
}
if(suffix == "qsrun")
{
result.append(readFromFile(path));
} }
} }
} }

Ver fichero

@ -2,7 +2,6 @@
#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
{ {
@ -18,7 +17,6 @@ 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;
@ -36,9 +34,8 @@ class EntryProvider
QStringList _desktopIgnoreArgs; QStringList _desktopIgnoreArgs;
QStringList userEntriesDirsPaths; QStringList userEntriesDirsPaths;
QStringList systemEntriesDirsPaths; QStringList systemEntriesDirsPaths;
EntryConfig readqsrunFile(const QString &path); EntryConfig readFromFile(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);

Ver fichero

@ -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 c++17 CONFIG += link_pkgconfig
PKGCONFIG += libqalculate PKGCONFIG += libqalculate