Commit 3cc4aa0c authored by Laurent Montel's avatar Laurent Montel 😁

Add support to load icon

parent aec8b2cf
......@@ -38,6 +38,7 @@ void ViewerPluginExternalScriptInfoTest::shouldHaveDefaultValue()
QVERIFY(info.commandLine().isEmpty());
QVERIFY(info.executable().isEmpty());
QVERIFY(info.description().isEmpty());
QVERIFY(info.icon().isEmpty());
QVERIFY(!info.isValid());
}
......
......@@ -62,6 +62,16 @@ void ViewerPluginExternalScriptInfo::setDescription(const QString &description)
mDescription = description;
}
QString ViewerPluginExternalScriptInfo::icon() const
{
return mIcon;
}
void ViewerPluginExternalScriptInfo::setIcon(const QString &icon)
{
mIcon = icon;
}
bool ViewerPluginExternalScriptInfo::isValid() const
{
return !mName.trimmed().isEmpty() &&
......
......@@ -36,12 +36,16 @@ public:
QString description() const;
void setDescription(const QString &description);
QString icon() const;
void setIcon(const QString &icon);
bool isValid() const;
private:
QString mCommandLine;
QString mName;
QString mExecutable;
QString mDescription;
QString mIcon;
};
Q_DECLARE_TYPEINFO(ViewerPluginExternalScriptInfo, Q_MOVABLE_TYPE);
Q_DECLARE_METATYPE(ViewerPluginExternalScriptInfo)
......
......@@ -106,6 +106,10 @@ void ViewerPluginExternalscriptInterface::createAction(KActionCollection *ac)
if (!description.isEmpty()) {
addHelpTextAction(act, description);
}
const QString &icon = info.icon();
if (!icon.isEmpty()) {
act->setIcon(QIcon::fromTheme(icon));
}
ac->addAction(QStringLiteral("externalscript_%1").arg(info.name()), act);
QStringList actionInfo;
actionInfo.append(info.commandLine());
......
......@@ -57,6 +57,7 @@ void ViewerPluginExternalScriptsLoadJob::start()
info.setExecutable(group.readEntry("Executable", QString()));
info.setCommandLine(group.readEntry("CommandLine", QString()));
info.setDescription(group.readEntry("Description", QString()));
info.setIcon(group.readEntry("Icon", QString()));
if (info.isValid() && !scriptNames.contains(name)) {
mScriptInfos.append(info);
scriptNames.append(name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment