Added klocalizedtranslator.

This commit is contained in:
Ayush Singh 2021-12-27 19:58:13 +05:30
parent cba1951df6
commit a5ca07bad8
2 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,28 @@
use cpp::{cpp, cpp_class};
#[cfg(feature = "qmetaobject")]
use qmetaobject::{QObject, QObjectPinned};
cpp! {{
#include <KLocalizedTranslator>
struct KLocalizedTranslatorHolder {
std::unique_ptr<KLocalizedTranslator> translator;
KLocalizedTranslatorHolder(QObject *parent) : translator(new KLocalizedTranslator(parent)) {}
};
}}
cpp_class!(
pub unsafe struct KLocalizedTranslator as "KLocalizedTranslatorHolder"
);
impl KLocalizedTranslator {
#[cfg(feature = "qmetaobject")]
pub fn new<T: QObject + Sized>(obj: QObjectPinned<T>) -> KLocalizedTranslator {
let obj_ptr = obj.get_or_create_cpp_object();
cpp!(unsafe [obj_ptr as "QObject *"] -> KLocalizedTranslator as "KLocalizedTranslatorHolder" {
return KLocalizedTranslatorHolder(obj_ptr);
})
}
}

View file

@ -47,6 +47,7 @@
pub mod klocalizedcontext; pub mod klocalizedcontext;
pub mod klocalizedstring; pub mod klocalizedstring;
pub mod klocalizedtranslator;
// pub mod kcountry; // pub mod kcountry;
pub mod prelude { pub mod prelude {