Commit a963b5ee authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

[konsolesessions] Also use icon set for profile

parent 2f3bcfa8
......@@ -94,16 +94,15 @@ void KonsoleSessions::loadSessions()
QFileInfo info(profilePath);
const QString profileName = info.baseName();
QString niceName=profileName;
KConfig _config(profilePath, KConfig::SimpleConfig);
if (_config.hasGroup("General"))
{
KonsoleProfileData profileData;
KConfigGroup cfg(&_config, "General");
if (cfg.hasKey("Name")) {
niceName = cfg.readEntry("Name");
}
profileData.displayName = cfg.readEntry("Name", profileName);
profileData.iconName = cfg.readEntry("Icon", QStringLiteral("utilities-terminal"));
m_sessions.insert(profileName, niceName);
m_sessions.insert(profileName, profileData);
}
}
}
......@@ -120,22 +119,24 @@ void KonsoleSessions::match(Plasma::RunnerContext &context)
}
if (term.compare(QLatin1String( "konsole" ), Qt::CaseInsensitive) == 0) {
QHashIterator<QString, QString> i(m_sessions);
QHashIterator<QString, KonsoleProfileData> i(m_sessions);
while (i.hasNext()) {
i.next();
const auto& profileData = i.value();
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::PossibleMatch);
match.setRelevance(1.0);
match.setIconName(QStringLiteral("utilities-terminal"));
match.setIconName(profileData.iconName);
match.setData(i.key());
match.setText(QLatin1String( "Konsole: " ) + i.value());
match.setText(QLatin1String("Konsole: ") + profileData.displayName);
context.addMatch(match);
}
} else {
if (term.startsWith(QLatin1String("konsole "), Qt::CaseInsensitive)) {
term.remove(0, 8);
}
QHashIterator<QString, QString> i(m_sessions);
QHashIterator<QString, KonsoleProfileData> i(m_sessions);
while (i.hasNext()) {
if (!context.isValid()) {
return;
......@@ -143,14 +144,15 @@ void KonsoleSessions::match(Plasma::RunnerContext &context)
i.next();
if (i.value().contains(term, Qt::CaseInsensitive)) {
const auto& profileData = i.value();
if (profileData.displayName.contains(term, Qt::CaseInsensitive)) {
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::PossibleMatch);
match.setIconName(QStringLiteral("utilities-terminal"));
match.setIconName(profileData.iconName);
match.setData(i.key());
match.setText(QLatin1String( "Konsole: " ) + i.value());
match.setText(QLatin1String("Konsole: ") + profileData.displayName);
if (i.value().compare(term, Qt::CaseInsensitive) == 0) {
if (profileData.displayName.compare(term, Qt::CaseInsensitive) == 0) {
match.setRelevance(1.0);
} else {
match.setRelevance(0.6);
......
......@@ -24,6 +24,14 @@
class KDirWatch;
struct KonsoleProfileData
{
QString displayName;
QString iconName;
};
Q_DECLARE_TYPEINFO(KonsoleProfileData, Q_MOVABLE_TYPE);
class KonsoleSessions : public Plasma::AbstractRunner {
Q_OBJECT
......@@ -43,7 +51,7 @@ private Q_SLOTS:
private:
KDirWatch* m_sessionWatch = nullptr;
QHash<QString, QString> m_sessions;
QHash<QString, KonsoleProfileData> m_sessions;
};
#endif
Supports Markdown
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