1
0

Fixed everything

It works perfectly now!
This commit is contained in:
Patrick Gaskin
2020-04-22 02:45:04 -04:00
parent be1a40d524
commit 846c16174d

View File

@@ -60,27 +60,20 @@ extern "C" int nmi_menu_hook(void *libnickel, nmi_menu_entry_t *entries, size_t
extern "C" MenuTextItem* _nmi_menu_hook(void* _this, QMenu* menu, QString const& label, bool checkable, bool checked, QString const& thingy) {
NMI_LOG("AbstractNickelMenuController::createMenuTextItem(%p, `%s`, %d, %d, `%s`)", menu, qPrintable(label), checkable, checked, qPrintable(thingy));
// TODO: test on other locales
// TODO: handle other locales (either parse the translations file, call tr, or something else)
bool ismm, isrm;
if ((ismm = label == "Help" && !checkable))
if ((ismm = !label.compare("Help") && !checkable))
NMI_LOG("Intercepting main menu (label=Help, checkable=false)...");
if ((isrm = label == "Dictionary" && !checkable))
if ((isrm = !label.compare("Dictionary") && !checkable))
NMI_LOG("Intercepting reader menu (label=Dictionary, checkable=false)...");
bool add[_entries_n];
for (size_t i = 0; i < _entries_n; i++) {
nmi_menu_entry_t *ent = &_entries[i];
switch (_entries[i].loc) {
case NMI_MENU_LOCATION_MAIN_MENU:
add[i] = ismm;
case NMI_MENU_LOCATION_READER_MENU:
add[i] = isrm;
}
}
if (ent->loc == NMI_MENU_LOCATION_MAIN_MENU && !ismm)
continue;
if (ent->loc == NMI_MENU_LOCATION_READER_MENU && !isrm)
continue;
for (size_t i = 0; i < _entries_n; i++) {
nmi_menu_entry_t *ent = &_entries[i];
if (add[i]) {
NMI_LOG("Adding item '%s'...", ent->lbl);
QString lbl(ent->lbl);
@@ -102,7 +95,6 @@ extern "C" MenuTextItem* _nmi_menu_hook(void* _this, QMenu* menu, QString const&
NMI_LOG("Success!", err);
}));
}
}
return AbstractNickelMenuController_createMenuTextItem_orig(_this, menu, label, checkable, checked, thingy);
}