diff --git a/Cargo.toml b/Cargo.toml index c7f5c61..593f9ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "ki18n" description = "A crate to use KF5I18n from rust." author = ["Ayush Singh "] -version = "2.0.0" +version = "2.0.1" edition = "2021" links = "KF5I18n" license = "MIT" diff --git a/src/klocalizedcontext.rs b/src/klocalizedcontext.rs index 3aaa8f0..6e0865b 100644 --- a/src/klocalizedcontext.rs +++ b/src/klocalizedcontext.rs @@ -46,7 +46,7 @@ impl KLocalizedContext { /// Returns a pointer to the C++ object. The pointer is of the type `KLocalizedContext *` in C++. pub fn cpp_ptr(&self) -> *mut c_void { - cpp!(unsafe [self as "KLocalizedContextHolder *"] -> *mut c_void as "KLocalizedContext *" { + cpp!(unsafe [self as "const KLocalizedContextHolder *"] -> *mut c_void as "KLocalizedContext *" { return self->klocalized.get(); }) } @@ -75,7 +75,7 @@ context.set_translation_domain("Test Domain".into()); /// Returns the current Translation Domain. pub fn translation_domain(&self) -> QString { - cpp!(unsafe [self as "KLocalizedContextHolder *"] -> QString as "QString" { + cpp!(unsafe [self as "const KLocalizedContextHolder *"] -> QString as "QString" { return self->klocalized->translationDomain(); }) } diff --git a/src/klocalizedstring.rs b/src/klocalizedstring.rs index 5a887a9..6657bd7 100644 --- a/src/klocalizedstring.rs +++ b/src/klocalizedstring.rs @@ -50,7 +50,7 @@ impl KLocalizedString { /// Set the languages for which translations will be made. /// This overrides the languages provided by the locale. Languages should be ordered with decreasing priority. /// TODO: Add Test - pub fn set_languages(languages: &QStringList) { + pub fn set_languages(languages: QStringList) { cpp!(unsafe [languages as "QStringList"] { KLocalizedString::setLanguages(languages); }); @@ -98,7 +98,7 @@ impl KLocalizedString { /// Finalize the translation. /// Creates translated QString, with placeholders substituted by arguments given by KLocalizedString::subs methods. pub fn to_qstring(&self) -> QString { - cpp!(unsafe [self as "KLocalizedString *"] -> QString as "QString" { + cpp!(unsafe [self as "const KLocalizedString *"] -> QString as "QString" { return self->toString(); }) } @@ -107,15 +107,15 @@ impl KLocalizedString { /// TODO: Add Test pub fn with_domain(&self, domain: &CStr) -> KLocalizedString { let domain_ptr = domain.as_ptr(); - cpp!(unsafe [self as "KLocalizedString *", domain_ptr as "char*"] -> KLocalizedString as "KLocalizedString" { + cpp!(unsafe [self as "const KLocalizedString *", domain_ptr as "char*"] -> KLocalizedString as "KLocalizedString" { return self->withDomain(domain_ptr); }) } /// Indicate to look for translation only in given languages. /// TODO: Add Test - pub fn with_languages(&self, languages: &QStringList) -> KLocalizedString { - cpp!(unsafe [self as "KLocalizedString *", languages as "QStringList"] -> KLocalizedString as "KLocalizedString" { + pub fn with_languages(&self, languages: QStringList) -> KLocalizedString { + cpp!(unsafe [self as "const KLocalizedString *", languages as "QStringList"] -> KLocalizedString as "KLocalizedString" { return self->withLanguages(languages); }) } diff --git a/src/lib.rs b/src/lib.rs index 4250ceb..da80fa8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,5 +74,6 @@ pub mod klocalizedtranslator; // pub mod kcountry; pub mod prelude { + pub use crate::klocalizedcontext::KLocalizedContext; pub use crate::klocalizedstring::KLocalizedString; }