Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/lib/fcitx/inputmethodmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class InputMethodManagerPrivate : QPtrHolder<InputMethodManager> {
Instance *instance_ = nullptr;
std::unique_ptr<HandlerTableEntry<EventHandler>> eventWatcher_;
int64_t timestamp_ = 0;
std::vector<std::string> missingInputMethods_;
};

bool checkEntry(const InputMethodEntry &entry,
Expand Down Expand Up @@ -111,6 +112,7 @@ void InputMethodManagerPrivate::loadConfig(
FCITX_WARN() << "Group Item " << item.name.value()
<< " in group " << groupConfig.name.value()
<< " is not valid. Removed.";
missingInputMethods_.push_back(item.name.value());
continue;
}
group.inputMethodList().emplace_back(
Expand Down Expand Up @@ -236,6 +238,7 @@ void InputMethodManager::load(const std::function<void(InputMethodManager &)>
d->loadStaticEntries(addonNames);
d->loadDynamicEntries(addonNames);

d->missingInputMethods_.clear();
d->loadConfig(buildDefaultGroupCallback);
// groupOrder guarantee to be non-empty at this point.
emit<InputMethodManager::CurrentGroupChanged>(d->groupOrder_.front());
Expand Down Expand Up @@ -455,6 +458,13 @@ InputMethodManager::entry(const std::string &name) const {
FCITX_D();
return findValue(d->entries_, name);
}

const std::vector<std::string> &
InputMethodManager::missingInputMethods() const {
FCITX_D();
return d->missingInputMethods_;
}

bool InputMethodManager::foreachEntries(
const std::function<bool(const InputMethodEntry &entry)> &callback) {
FCITX_D();
Expand Down
7 changes: 7 additions & 0 deletions src/lib/fcitx/inputmethodmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ class FCITXCORE_EXPORT InputMethodManager : public ConnectableObject {
/// Return a given input method entry by name.
const InputMethodEntry *entry(const std::string &name) const;

/**
* Return the names of input methods that are configured but not available.
*
* @since 5.1.13
*/
const std::vector<std::string> &missingInputMethods() const;

/**
* Enumerate all the input method entries.
*
Expand Down
13 changes: 13 additions & 0 deletions src/lib/fcitx/instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,19 @@ void Instance::initialize() {
return false;
});
d->notifications_ = d->addonManager_.addon("notifications", true);
if (d->notifications_ && !d->imManager_.missingInputMethods().empty()) {
std::string body;
for (const auto &im : d->imManager_.missingInputMethods()) {
if (!body.empty()) {
body += ", ";
}
body += im;
}
d->notifications_->call<INotifications::sendNotification>(
"fcitx", 0, "fcitx", _("Missing input methods"),
_("The following input methods are not available: {0}"),
std::vector<std::string>{body}, 0, nullptr, nullptr);
}
}

int Instance::exec() {
Expand Down
Loading