Skip to content

Commit

Permalink
Use keyman icon for input method. (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed Nov 19, 2022
1 parent 432e51d commit 7bea13f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,22 @@ std::vector<InputMethodEntry> KeymanEngine::listInputMethods() {
}
std::vector<InputMethodEntry> result;
for (auto &[id, keyboard] : keyboards) {
std::string icon = "km-config";
// Check if icon file exists, otherwise fallback to keyman's icon.
for (auto *suffix : {".bmp.png", ".icon.png"}) {
auto path = stringutils::joinPath(keyboard->baseDir,
stringutils::concat(id, suffix));
if (fs::isreg(path)) {
icon = std::move(path);
break;
}
}

result.emplace_back(stringutils::concat("keyman:", id),
stringutils::concat(keyboard->name, " (Keyman)"),
keyboard->language, "keyman");
result.back()
.setIcon("km-config")
.setConfigurable(true)
.setUserData(std::move(keyboard));
result.back().setIcon(icon).setConfigurable(true).setUserData(
std::move(keyboard));
}
return result;
}
Expand Down

0 comments on commit 7bea13f

Please sign in to comment.