1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Plugins: Allow to specify icon path relative to metadata directory

This commit is contained in:
David Rosca 2018-03-02 12:42:20 +01:00
parent 83f1e9c329
commit 71615c675f
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
3 changed files with 16 additions and 4 deletions

View File

@ -108,7 +108,12 @@ PluginSpec Plugins::createSpec(const DesktopFile &metaData)
if (QFileInfo::exists(iconName)) {
spec.icon = QIcon(iconName).pixmap(32);
} else {
spec.icon = QIcon::fromTheme(iconName).pixmap(32);
const QString relativeFile = QFileInfo(metaData.fileName()).dir().absoluteFilePath(iconName);
if (QFileInfo::exists(relativeFile)) {
spec.icon = QIcon(relativeFile).pixmap(32);
} else {
spec.icon = QIcon::fromTheme(iconName).pixmap(32);
}
}
}

View File

@ -23,13 +23,18 @@ DesktopFile::DesktopFile()
{
}
DesktopFile::DesktopFile(const QString &filePath)
DesktopFile::DesktopFile(const QString &fileName)
{
m_settings.reset(new QSettings(filePath, QSettings::IniFormat));
m_settings.reset(new QSettings(fileName, QSettings::IniFormat));
m_settings->setIniCodec("UTF-8");
m_settings->beginGroup(QSL("Desktop Entry"));
}
QString DesktopFile::fileName() const
{
return m_settings ? m_settings->fileName() : QString();
}
QString DesktopFile::name() const
{
return value(QSL("Name"), true).toString();

View File

@ -27,7 +27,9 @@ class FALKON_EXPORT DesktopFile
{
public:
explicit DesktopFile();
explicit DesktopFile(const QString &filePath);
explicit DesktopFile(const QString &fileName);
QString fileName() const;
QString name() const;
QString comment() const;