Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ zClipboard-1.0.1
# AUR repo
aur
__pycache__
*.json
*.json
target
26 changes: 26 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
33 changes: 33 additions & 0 deletions Source/GUI/Windows/Translator/Include/SettingWindow_Translator.hpp
Original file line number Diff line number Diff line change
@@ -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 <QSettings>
#include <QDialog>

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> 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
33 changes: 33 additions & 0 deletions Source/GUI/Windows/Translator/SettingWindow_Translator.cc
Original file line number Diff line number Diff line change
@@ -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<Settings>();


}

}
7 changes: 7 additions & 0 deletions rustlib_test/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions rustlib_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "rustlib_test"
version = "0.1.0"
edition = "2024"

[lib]
crate-type = ["staticlib"]

[profile.dev]
panic = "abort"
22 changes: 22 additions & 0 deletions rustlib_test/main.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include <iostream>
#include <string>

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;
}
26 changes: 26 additions & 0 deletions rustlib_test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
16 changes: 16 additions & 0 deletions rustlib_test/test.sh
Original file line number Diff line number Diff line change
@@ -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
Loading