MCPcopy Create free account
hub / github.com/EasyIME/PIME / updateLanguageButtons

Method updateLanguageButtons

PIMETextService/PIMEClient.cpp:231–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229}
230
231void Client::updateLanguageButtons(Json::Value& msg) {
232 // language buttons
233 const auto& addButtonVal = msg["addButton"];
234 if (addButtonVal.isArray()) {
235 for (const auto& btn : addButtonVal) {
236 // FIXME: when to clear the id <=> button map??
237 auto langBtn = Ime::ComPtr<PIME::LangBarButton>::takeover(PIME::LangBarButton::fromJson(textService_, btn));
238 if (langBtn != nullptr) {
239 buttons_.emplace(langBtn->id(), langBtn); // insert into the map
240 textService_->addButton(langBtn);
241 }
242 }
243 }
244
245 const auto& removeButtonVal = msg["removeButton"];
246 if (removeButtonVal.isArray()) {
247 // FIXME: handle windows-mode-icon
248 for (const auto& btn : removeButtonVal) {
249 if (btn.isString()) {
250 string id = btn.asString();
251 auto map_it = buttons_.find(id);
252 if (map_it != buttons_.end()) {
253 textService_->removeButton(map_it->second);
254 buttons_.erase(map_it); // remove from the map
255 }
256 }
257 }
258 }
259 const auto& changeButtonVal = msg["changeButton"];
260 if (changeButtonVal.isArray()) {
261 // FIXME: handle windows-mode-icon
262 for (const auto& btn : changeButtonVal) {
263 if (btn.isObject()) {
264 string id = btn["id"].asString();
265 auto map_it = buttons_.find(id);
266 if (map_it != buttons_.end()) {
267 map_it->second->updateFromJson(btn);
268 }
269 }
270 }
271 }
272}
273
274void Client::updatePreservedKeys(Json::Value& msg) {
275 const auto& addPreservedKeyVal = msg["addPreservedKey"];

Callers

nothing calls this directly

Calls 5

addButtonMethod · 0.80
removeButtonMethod · 0.80
updateFromJsonMethod · 0.80
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected