Skip to content

Commit 7bea13f

Browse files
committed
Use keyman icon for input method. (#1)
1 parent 432e51d commit 7bea13f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/engine.cpp

+13-4
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,22 @@ std::vector<InputMethodEntry> KeymanEngine::listInputMethods() {
276276
}
277277
std::vector<InputMethodEntry> result;
278278
for (auto &[id, keyboard] : keyboards) {
279+
std::string icon = "km-config";
280+
// Check if icon file exists, otherwise fallback to keyman's icon.
281+
for (auto *suffix : {".bmp.png", ".icon.png"}) {
282+
auto path = stringutils::joinPath(keyboard->baseDir,
283+
stringutils::concat(id, suffix));
284+
if (fs::isreg(path)) {
285+
icon = std::move(path);
286+
break;
287+
}
288+
}
289+
279290
result.emplace_back(stringutils::concat("keyman:", id),
280291
stringutils::concat(keyboard->name, " (Keyman)"),
281292
keyboard->language, "keyman");
282-
result.back()
283-
.setIcon("km-config")
284-
.setConfigurable(true)
285-
.setUserData(std::move(keyboard));
293+
result.back().setIcon(icon).setConfigurable(true).setUserData(
294+
std::move(keyboard));
286295
}
287296
return result;
288297
}

0 commit comments

Comments
 (0)