Added Methods for klocalizedtranslator.

This commit is contained in:
Ayush Singh 2022-01-01 20:35:14 +05:30
parent 47c519e109
commit 3ed2893739

View file

@ -1,4 +1,5 @@
use cpp::{cpp, cpp_class}; use cpp::{cpp, cpp_class};
use qttypes::QString;
#[cfg(feature = "qmetaobject")] #[cfg(feature = "qmetaobject")]
use qmetaobject::{QObject, QObjectPinned}; use qmetaobject::{QObject, QObjectPinned};
@ -27,4 +28,25 @@ impl KLocalizedTranslator {
return KLocalizedTranslatorHolder(obj_ptr); return KLocalizedTranslatorHolder(obj_ptr);
}) })
} }
/// Adds a context for which this Translator should be active.
pub fn add_context_to_monitor(&mut self, context: QString) {
cpp!(unsafe [self as "KLocalizedTranslatorHolder *", context as "QString"] {
self->translator->addContextToMonitor(context);
});
}
/// Stop translating for the given context.
pub fn remove_context_to_moitor(&mut self, context: QString) {
cpp!(unsafe [self as "KLocalizedTranslatorHolder *", context as "QString"] {
self->translator->removeContextToMonitor(context);
});
}
/// Sets the translationDomain to be used.
pub fn set_translation_domain(&mut self, translation_domain: QString) {
cpp!(unsafe [self as "KLocalizedTranslatorHolder *", translation_domain as "QString"] {
self->translator->setTranslationDomain(translation_domain);
});
}
} }