use cxx::let_cxx_string;
use crate::ffi;
pub struct Application {
ptr: *mut ffi::QApplication,
}
impl Application {
pub fn new() -> Self {
let ptr = unsafe { ffi::QApplication_new() };
debug_assert!(!ptr.is_null(), "QApplication_new returned null");
Self { ptr }
}
pub fn set_icon(&self, icon_path: &str) {
debug_assert!(!self.ptr.is_null(), "Application::set_icon on null pointer");
let_cxx_string!(c_path = icon_path);
unsafe {
ffi::QApplication_setWindowIcon(self.ptr, &c_path);
}
}
pub fn set_desktop_file_name(&self, name: &str) {
debug_assert!(!self.ptr.is_null(), "Application::set_desktop_file_name on null pointer");
let_cxx_string!(c_name = name);
unsafe {
ffi::QApplication_setDesktopFileName(self.ptr, &c_name);
}
}
pub fn exec(&self) -> i32 {
debug_assert!(!self.ptr.is_null(), "Application::exec on null pointer");
unsafe { ffi::QApplication_exec(self.ptr) }
}
}
impl Default for Application {
fn default() -> Self {
Self::new()
}
}