diff --git a/.gitignore b/.gitignore index 1a33836..cbc88d9 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ zClipboard-1.0.1 # AUR repo aur __pycache__ -*.json \ No newline at end of file +*.json +target \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 49c08bc..f6c1484 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,10 +36,36 @@ target_link_libraries( PRIVATE Qt6::Gui PRIVATE Qt6::Network ) + +# We don't suggest enable this in production. if(Z_DEBUG) add_compile_definitions(${PROJECT_NAME} PRIVATE Z_DEBUG) endif() +# Enable all features, except to 'Z_DEBUG' flag. +if(Z_ENABLE_ALL_FEATURES) + add_compile_definitions(${PROJECT_NAME} PRIVATE Z_ENABLE_ALL_FEATURES) +endif() + +# Static linking mode. Beta. +if(Z_STATIC_LINKING) + add_compile_definitions(${PROJECT_NAME} PRIVATE Z_STATIC_LINKING) +endif() + +# Use it if you want use native notification +# in Linux. (Suggested.) +if(Z_USE_LIB_NOTIFY) + if(NOT LINUX) + message(FATAL_ERROR "Could not use 'LibNotify' in operating system outside of Linux") + endif() + + if(Z_STATIC_LINKING) + message(FATAL_ERROR "Could not use 'LibNotify' if you want use static linking mode") + endif() + + add_compile_definitions(${PROJECT_NAME} PRIVATE Z_USE_LIB_NOTIFY) +endif() + if(NOT WIN32) target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::SODIUM) endif() diff --git a/Source/GUI/Windows/Translator/Include/SettingWindow_Translator.hpp b/Source/GUI/Windows/Translator/Include/SettingWindow_Translator.hpp new file mode 100644 index 0000000..84aa511 --- /dev/null +++ b/Source/GUI/Windows/Translator/Include/SettingWindow_Translator.hpp @@ -0,0 +1,33 @@ +#ifndef SETTING_WINDOW_TRANSLATOR_HPP +#define SETTING_WINDOW_TRANSLATOR_HPP +#include "../../../../Utils/Include/Namespace_Macro.hpp" +#include "../../../../Lib_Memory/Include/Memory.hpp" +#include "../../../../GUI/Toolkit/Include/SettingWindow_Components.hpp" +#include +#include + +using ZClipboard::Lib_Memory::PtrUnique; +using ZClipboard::GUI::Toolkit::SettingWindowComponentsManager; + +GUI_WINDOW_TRANSLATOR_NAMESPACE + + class SettingWindowTranslator { + private: + using Settings = QSettings; + using Components = SettingWindowComponentsManager; + using Window = QDialog; + + private: + PtrUnique settings; + + private: + void VietNameseTranslator(Window *window, Components *components); + void EnglishTranslator(Window *window, Components *components); + + public: + void LoadTranslator(Window *window, Components *components); + }; + +END_NAMESPACE + +#endif // SETTING_WINDOW_TRANSLATOR_HPP \ No newline at end of file diff --git a/Source/GUI/Windows/Translator/SettingWindow_Translator.cc b/Source/GUI/Windows/Translator/SettingWindow_Translator.cc new file mode 100644 index 0000000..7dc075c --- /dev/null +++ b/Source/GUI/Windows/Translator/SettingWindow_Translator.cc @@ -0,0 +1,33 @@ +#include "Include/SettingWindow_Translator.hpp" +#include "../../../Language/Include/Language.hpp" + +using ZClipboard::GUI::Windows::Translator::SettingWindowTranslator; +using ZClipboard::Lib_Memory::MakePtr; + +using Self = SettingWindowTranslator; + +#if defined (Z_DEBUG) + +#endif + +void Self::VietNameseTranslator(Window *window, Components *components) { + constexpr auto TITLE = SETTING_DIALOG_VI; + + + window->setWindowTitle(TITLE); +} + +void Self::EnglishTranslator(Window *window, Components *components) { + const auto TITLE = SETTING_DIALOG_EN; + + window->setWindowTitle(TITLE); +} + +void Self::LoadTranslator(Window *window, Components *components) { + if(!settings) { + settings = MakePtr(); + + + } + +} \ No newline at end of file diff --git a/rustlib_test/Cargo.lock b/rustlib_test/Cargo.lock new file mode 100644 index 0000000..da7739d --- /dev/null +++ b/rustlib_test/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "rustlib_test" +version = "0.1.0" diff --git a/rustlib_test/Cargo.toml b/rustlib_test/Cargo.toml new file mode 100644 index 0000000..8ef22bf --- /dev/null +++ b/rustlib_test/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "rustlib_test" +version = "0.1.0" +edition = "2024" + +[lib] +crate-type = ["staticlib"] + +[profile.dev] +panic = "abort" \ No newline at end of file diff --git a/rustlib_test/main.cxx b/rustlib_test/main.cxx new file mode 100644 index 0000000..f5f3247 --- /dev/null +++ b/rustlib_test/main.cxx @@ -0,0 +1,22 @@ +#include +#include + +using std::cout; +using std::endl; +using std::string; + +extern "C" { + void greet(); + char *get_reim_name(); + void free_name(char *name); +} + +int main() { + greet(); + + auto raw_name = get_reim_name(); + auto name_string = string(raw_name); + free_name(raw_name); + + cout << name_string << endl; +} \ No newline at end of file diff --git a/rustlib_test/src/lib.rs b/rustlib_test/src/lib.rs new file mode 100644 index 0000000..c57f671 --- /dev/null +++ b/rustlib_test/src/lib.rs @@ -0,0 +1,26 @@ +#![deny(clippy::all, clippy::pedantic, clippy::nursery, clippy::perf)] + +use std::{ffi::CString, os::raw::c_char}; +use std::ptr::null_mut; + +#[unsafe(no_mangle)] +pub unsafe extern "C" fn greet() { + println!("Hello World"); +} + +#[unsafe(no_mangle)] +pub extern "C" fn get_reim_name() -> *mut c_char { + CString + ::new("REIM DEVELOPER") + .map(|name| name.into_raw()) + .unwrap_or(null_mut()) +} + +#[unsafe(no_mangle)] +pub unsafe extern "C" fn free_name(c_string: *mut c_char) { + if !c_string.is_null() { + unsafe { + let _ = CString::from_raw(c_string); + } + } +} \ No newline at end of file diff --git a/rustlib_test/test.sh b/rustlib_test/test.sh new file mode 100755 index 0000000..a650cb3 --- /dev/null +++ b/rustlib_test/test.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +function test_lib() { + if [ ! -d "build" ]; then + mkdir -p "build" + fi + + cargo build + + local rust_lib="target/debug/librustlib_test.a" + clang++ "main.cxx" "$rust_lib" -o "build/main" + + "./build/main" +} + +test_lib \ No newline at end of file