From d15b2c77bdff642ea40054cf09200b00e885b3e6 Mon Sep 17 00:00:00 2001 From: Reim-developer Date: Fri, 15 Aug 2025 13:52:34 +0700 Subject: [PATCH 1/7] Added format options to `clang-format` config file --- .clang-format | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.clang-format b/.clang-format index 84a95bb..d2540f7 100644 --- a/.clang-format +++ b/.clang-format @@ -1,4 +1,9 @@ +--- Language: Cpp BasedOnStyle: Google IndentWidth: 4 -ColumnLimit: 80 \ No newline at end of file +ColumnLimit: 80 +UseTab: Always +TabWidth: 4 +IndentPPDirectives: BeforeHash +PPIndentWidth: 4 \ No newline at end of file From 39d36f2d6f7edd2726b609f9b60fe7218a4e3cde Mon Sep 17 00:00:00 2001 From: Reim-developer Date: Fri, 15 Aug 2025 13:52:52 +0700 Subject: [PATCH 2/7] Added `files.associations` to VS Code setting --- .vscode/settings.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 49d6baf..8f54bbb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,9 @@ "rust-analyzer.linkedProjects": [ "src/back_end/Cargo.toml" ], - "rust-analyzer.check.command": "clippy" + "rust-analyzer.check.command": "clippy", + "files.associations": { + ".clang-format": "yaml", + ".clang-tidy": "yaml" + } } \ No newline at end of file From dcb2b438af273741071465d5c73ec1c08cf1fcfd Mon Sep 17 00:00:00 2001 From: Reim-developer Date: Fri, 15 Aug 2025 13:53:29 +0700 Subject: [PATCH 3/7] Implement `RawAppConfig` struct to `config raw` header --- src/ffi/raw/config.hxx | 47 +++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/src/ffi/raw/config.hxx b/src/ffi/raw/config.hxx index 380256c..ff3d2a9 100644 --- a/src/ffi/raw/config.hxx +++ b/src/ffi/raw/config.hxx @@ -7,17 +7,48 @@ extern "C" { #include +/* From module `utils::fs_utils` in Rust backend */ enum WriteConfigStatus : uint8_t { - OK, - TOML_TO_STRING_FAILED, - CREATE_DIR_FAILED, - CREATE_FILE_FAILED, - WRITE_FILE_FAILED, - GET_DATA_LOCAL_FAILED, + OK, + TOML_TO_STRING_FAILED, + CREATE_DIR_FAILED, + CREATE_FILE_FAILED, + WRITE_FILE_FAILED, + GET_DATA_LOCAL_FAILED, }; -char* raw_config_dir(); -WriteConfigStatus raw_write_default_config(); +char *raw_config_dir(); +auto raw_write_default_config() -> WriteConfigStatus; +/* End module */ + +/* From module `raw_config` in Rust backend */ +enum RawReadAppConfigStatus : uint8_t { + READ_OK, + READ_FILE_FAILED, + UTF_8_ERROR, + PARSE_TOML_FAILED, + CONVERT_TO_MUT_FAILED, +}; + +typedef struct { + bool hide_when_closed; + bool notification; +} RawAppSettings; + +typedef struct { + char *background_color; + char *foreground_color; +} RawAppGuiSettings; + +typedef struct { + RawAppSettings raw_app_settings; + RawAppGuiSettings raw_app_gui_settings; +} RawAppConfig; + +RawReadAppConfigStatus raw_exists_config(const char *path, + RawAppConfig *config_out); +void raw_free_cstr_app_config(RawAppConfig *config); +/* End module */ #ifdef __cplusplus } From c068c60686b2a1fde362312783c7d6077517c0e4 Mon Sep 17 00:00:00 2001 From: Reim-developer Date: Fri, 15 Aug 2025 13:54:14 +0700 Subject: [PATCH 4/7] Added function wrap to `RawAppConfig` --- src/ffi/namespace/include/config.hxx | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/ffi/namespace/include/config.hxx b/src/ffi/namespace/include/config.hxx index 59d28b6..db2c118 100644 --- a/src/ffi/namespace/include/config.hxx +++ b/src/ffi/namespace/include/config.hxx @@ -4,16 +4,29 @@ namespace Lazyboard::ffi { -inline char* config_dir() { - char* result = raw_config_dir(); +inline char *config_dir() { + char *result = raw_config_dir(); - return result; + return result; } + inline WriteConfigStatus write_default_config() { - auto result = raw_write_default_config(); + auto result = raw_write_default_config(); + + return result; +} + +inline RawReadAppConfigStatus exists_config(const char *path, + RawAppConfig *config_out) { + auto result = raw_exists_config(path, config_out); - return result; + return result; } + +inline void free_cstr_app_config(RawAppConfig *config_out) { + raw_free_cstr_app_config(config_out); +} + } // namespace Lazyboard::ffi -#endif // CONFIG_HXX \ No newline at end of file +#endif // CONFIG_HXX \ No newline at end of file From 05a6bc16fb17e1267c6a9e6c6f44f7cc4a4f7c21 Mon Sep 17 00:00:00 2001 From: Reim-developer Date: Fri, 15 Aug 2025 13:54:40 +0700 Subject: [PATCH 5/7] Implement preload, & set window color via TOML configuration --- src/front_end/include/main_window_preload.hxx | 24 +- src/front_end/main_window_preload.cxx | 214 +++++++++++++----- 2 files changed, 179 insertions(+), 59 deletions(-) diff --git a/src/front_end/include/main_window_preload.hxx b/src/front_end/include/main_window_preload.hxx index 016610e..d993a92 100644 --- a/src/front_end/include/main_window_preload.hxx +++ b/src/front_end/include/main_window_preload.hxx @@ -3,16 +3,34 @@ #include +#include +#include + #include "../../ffi/raw/config.hxx" +using std::string; +using std::unique_ptr; + namespace Lazyboard::front_end { class MainWindowPreload { private: - void on_error(WriteConfigStatus status, QMainWindow* main_window); + unique_ptr raw_app_config; + + private: + void on_gen_default_cfg_error(WriteConfigStatus status, + QMainWindow *main_window); + + void on_read_exists_cfg_error(RawReadAppConfigStatus status, + QMainWindow *main_window); + + string application_config(); + void set_application_theme(QMainWindow *main_window, + RawAppConfig *app_config); public: - void create_default_config(QMainWindow* main_window); + void create_default_config(QMainWindow *main_window); + void read_if_exists_config(QMainWindow *main_window); }; } // namespace Lazyboard::front_end -#endif // PRELOAD_HXX \ No newline at end of file +#endif // PRELOAD_HXX \ No newline at end of file diff --git a/src/front_end/main_window_preload.cxx b/src/front_end/main_window_preload.cxx index a0e08ed..7dd7936 100644 --- a/src/front_end/main_window_preload.cxx +++ b/src/front_end/main_window_preload.cxx @@ -1,8 +1,12 @@ #include "include/main_window_preload.hxx" +#include #include #include +#include +#include +#include #include #include @@ -10,78 +14,176 @@ #include "../ffi/namespace/include/utils.hxx" #if defined(LAZY_DEBUG) -#include -#include + #include +using std::cout; #endif using Lazyboard::front_end::MainWindowPreload; using Self = MainWindowPreload; +using std::make_unique; using std::string; using std::stringstream; using namespace Lazyboard::ffi; -void Self::on_error(WriteConfigStatus status, QMainWindow* main_window) { - switch (status) { - case WriteConfigStatus::OK: - break; - - case WriteConfigStatus::CREATE_DIR_FAILED: - QMessageBox::critical(main_window, "Error", - "Could not create config directory"); - break; - - case WriteConfigStatus::GET_DATA_LOCAL_FAILED: - QMessageBox::critical(main_window, "Error", - "Could not get application local data"); - break; - - case WriteConfigStatus::CREATE_FILE_FAILED: - QMessageBox::critical(main_window, "Error", - "Could not create configuration file"); - break; - - case WriteConfigStatus::WRITE_FILE_FAILED: - QMessageBox::critical(main_window, "Error", - "Could not write configuration"); - break; - - case WriteConfigStatus::TOML_TO_STRING_FAILED: - QMessageBox::critical(main_window, "Error", - "Could not convert TOML data to string"); - break; - } +void Self::on_gen_default_cfg_error(WriteConfigStatus status, + QMainWindow *main_window) { + switch (status) { + case WriteConfigStatus::OK: + break; + + case WriteConfigStatus::CREATE_DIR_FAILED: + QMessageBox::critical(main_window, "Error", + "Could not create config directory"); + + break; + + case WriteConfigStatus::GET_DATA_LOCAL_FAILED: + QMessageBox::critical(main_window, "Error", + "Could not get application local data"); + break; + + case WriteConfigStatus::CREATE_FILE_FAILED: + QMessageBox::critical(main_window, "Error", + "Could not create configuration file"); + break; + + case WriteConfigStatus::WRITE_FILE_FAILED: + QMessageBox::critical(main_window, "Error", + "Could not write configuration"); + break; + + case WriteConfigStatus::TOML_TO_STRING_FAILED: + QMessageBox::critical(main_window, "Error", + "Could not convert TOML data to string"); + break; + } } -void Self::create_default_config(QMainWindow* main_window) { - auto config_dir_raw = ffi::config_dir(); +void Self::on_read_exists_cfg_error(RawReadAppConfigStatus status, + QMainWindow *main_window) { + using Status = RawReadAppConfigStatus; + + switch (status) { + case Status::READ_OK: + break; + + case Status::CONVERT_TO_MUT_FAILED: + QMessageBox::critical(main_window, "Error", + "Could not convert to *mut c_char"); + break; + + case Status::PARSE_TOML_FAILED: + QMessageBox::critical(main_window, "Error", + "Parse TOML configuration failed"); + break; + + case Status::READ_FILE_FAILED: + QMessageBox::critical(main_window, "Error", + "Could not read configuration file"); + break; + + case Status::UTF_8_ERROR: + QMessageBox::critical(main_window, "Error", + "UTF-8 error in configuration file"); + break; + } +} + +string Self::application_config() { + auto config_dir_raw = ffi::config_dir(); + + stringstream string_stream; + string_stream << config_dir_raw << "/Lazyboard" + << "/settings.toml"; + string config_path = string_stream.str(); + + ffi::free_c_str(config_dir_raw); + return config_path; +} + +void Self::create_default_config(QMainWindow *main_window) { + auto config_path = this->application_config(); + auto is_config_exists = ffi::is_exists_path(config_path.data()); + + if (!is_config_exists) { + auto status = ffi::write_default_config(); + on_gen_default_cfg_error(status, main_window); + + // clang-format off + #if defined(LAZY_DEBUG) + cout << "[DEBUG] " << "Config path not found, generate at: " << config_path + << "\n"; + #endif + + return; + } + + #if defined(LAZY_DEBUG) + cout << "[DEBUG] " <<"Found config path at:" << config_path << "\n"; + #endif // clang-format on +} - stringstream string_stream; - string_stream << config_dir_raw << "/Lazyboard" - << "/settings.toml"; - string config_path = string_stream.str(); +void Self::set_application_theme(QMainWindow *main_window, + RawAppConfig *app_config) { + auto bg_color = string(app_config->raw_app_gui_settings.background_color); + auto fg_color = string(app_config->raw_app_gui_settings.foreground_color); - auto is_config_exists = ffi::is_exists_path(config_path.data()); - ffi::free_c_str(config_dir_raw); + auto bg_hex = QColor(QString::fromStdString(bg_color)); + auto fg_hex = QColor(QString::fromStdString(fg_color)); + free_cstr_app_config(raw_app_config.get()); + + if (!bg_hex.isValid() || !fg_hex.isValid()) { + stringstream string_stream; + + string_stream << "Invalid HEX color, please check your configuration\n" + << "Your 'background_color' setting: " << bg_color << "\n" + << "Your 'foregounrd_color: setting: " << fg_color + << "\n"; + auto error_message = string_stream.str(); + + QMessageBox::critical(main_window, "Error", error_message.c_str()); + // clang-format off + #if defined (LAZY_DEBUG) + stringstream string_stream_debug; + string_stream_debug + << "[DEBUG] Found error when load TOML configuration:\n" + << "[DEBUG] Error Type: 'Invalid HEX Color'\n" + << "[DEBUG] 'bg_color' setting: " << bg_color << "\n" + << "[DEBUG] 'fg_color' setting: " << fg_color << "\n"; + + cout << string_stream_debug.str().c_str(); + + #endif // clang-format on + + return; + } + + QPalette palette; + + palette.setColor(QPalette::Window, bg_hex); + palette.setColor(QPalette::Base, bg_hex); + palette.setColor(QPalette::WindowText, fg_hex); + + main_window->setPalette(palette); + main_window->setAutoFillBackground(true); +} - if (!is_config_exists) { - // clang-format off - #if defined (LAZY_DEBUG) - auto q_string_value = QString::fromStdString(config_path); +void Self::read_if_exists_config(QMainWindow *main_window) { + raw_app_config = make_unique(); + auto config_path = this->application_config(); - qDebug() << "Config path not found, generate at: " << q_string_value << "\n"; - #endif - // clang-format on + auto status = exists_config(config_path.data(), raw_app_config.get()); + this->on_read_exists_cfg_error(status, main_window); - auto status = ffi::write_default_config(); - on_error(status, main_window); - } + // clang-format off + #if defined(LAZY_DEBUG) + cout << "[DEBUG] " << "Found config setting 'background_color': " + << raw_app_config->raw_app_gui_settings.background_color << "\n"; - // clang-format off - #if defined (LAZY_DEBUG) - auto q_string_value = QString::fromStdString(config_path); + cout << "[DEBUG] " << "Found config setting 'foreground_color': " + << raw_app_config->raw_app_gui_settings.foreground_color << "\n"; + #endif // clang-format on - qDebug() << "Found config path at: " << q_string_value << "\n"; - #endif - // clang-format on + this->set_application_theme(main_window, raw_app_config.get()); } \ No newline at end of file From 607ab85025ca5aafbcce520c38975a1e9fd83a79 Mon Sep 17 00:00:00 2001 From: Reim-developer Date: Fri, 15 Aug 2025 13:54:58 +0700 Subject: [PATCH 6/7] Call implement from `WindowPreload` --- src/front_end/main_window.cxx | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/front_end/main_window.cxx b/src/front_end/main_window.cxx index 6d3f2f0..b7caf10 100644 --- a/src/front_end/main_window.cxx +++ b/src/front_end/main_window.cxx @@ -17,33 +17,33 @@ using std::make_unique; using Self = MainWindow; Self::MainWindow() { - main_window = make_unique(); - main_window_preload = make_unique(); - auto central_w = make_unique(); - auto layout_w = make_unique(central_w.get()); + main_window = make_unique(); + main_window_preload = make_unique(); + auto central_w = make_unique(); + auto layout_w = make_unique(central_w.get()); - main_window->setCentralWidget(central_w.get()); + main_window->setCentralWidget(central_w.get()); - central_widget = central_w.release(); - grid_layout = layout_w.release(); + central_widget = central_w.release(); + grid_layout = layout_w.release(); } -Self* Self::init_main_window() { - main_window->setMinimumSize(MIN_WIDTH, MIN_HEIGHT); - main_window->setWindowTitle("Lazyboard"); - main_window_preload->create_default_config(main_window.get()); - this->front_end_show(); - main_window->show(); +Self *Self::init_main_window() { + main_window->setMinimumSize(MIN_WIDTH, MIN_HEIGHT); + main_window->setWindowTitle("Lazyboard"); + main_window_preload->create_default_config(main_window.get()); + main_window_preload->read_if_exists_config(main_window.get()); + this->front_end_show(); + main_window->show(); - return this; + return this; } - void Self::front_end_show() { - table_widget = make_unique(); - setting_widget = make_unique(); - about_widget = make_unique(); + table_widget = make_unique(); + setting_widget = make_unique(); + about_widget = make_unique(); - table_widget->setup_widget(this->grid_layout); - setting_widget->setup_widget(this->grid_layout); - about_widget->setup_widget(this->grid_layout); + table_widget->setup_widget(this->grid_layout); + setting_widget->setup_widget(this->grid_layout); + about_widget->setup_widget(this->grid_layout); } \ No newline at end of file From ac1d9e5b5a054143e43df22cfd2abdd542b90778 Mon Sep 17 00:00:00 2001 From: Reim-developer Date: Fri, 15 Aug 2025 13:55:04 +0700 Subject: [PATCH 7/7] Re-format project --- src/ffi/namespace/include/utils.hxx | 22 +++--- src/ffi/raw/utils.hxx | 24 +++--- src/front_end/about_widget.cxx | 22 +++--- src/front_end/about_window.cxx | 96 ++++++++++++------------ src/front_end/include/about_widget.hxx | 12 +-- src/front_end/include/about_window.hxx | 36 ++++----- src/front_end/include/main_window.hxx | 32 ++++---- src/front_end/include/setting_widget.hxx | 6 +- src/front_end/include/table_widget.hxx | 12 +-- src/front_end/setting_widget.cxx | 6 +- src/front_end/table_widget.cxx | 18 ++--- src/main.cxx | 12 +-- tests-ffi/config.cxx | 44 +++++------ tests-ffi/fs.cxx | 12 +-- tests-ffi/toml_config.cxx | 74 +++++++++--------- 15 files changed, 214 insertions(+), 214 deletions(-) diff --git a/src/ffi/namespace/include/utils.hxx b/src/ffi/namespace/include/utils.hxx index 9f3784b..481e354 100644 --- a/src/ffi/namespace/include/utils.hxx +++ b/src/ffi/namespace/include/utils.hxx @@ -3,25 +3,25 @@ #include "../../raw/utils.hxx" namespace Lazyboard::ffi { -inline OpenBrowserStatus open_browser(const char* url) { - auto result = raw_open_browser(url); +inline OpenBrowserStatus open_browser(const char *url) { + auto result = raw_open_browser(url); - return result; + return result; } -inline CreateFileSystemStatus new_folder(const char* path) { - auto result = raw_new_folder(path); +inline CreateFileSystemStatus new_folder(const char *path) { + auto result = raw_new_folder(path); - return result; + return result; } -inline bool is_exists_path(char* path) { - auto result = raw_is_path_exists(path); +inline bool is_exists_path(char *path) { + auto result = raw_is_path_exists(path); - return result; + return result; } -inline void free_c_str(char* c_str) { raw_free_c_str(c_str); } +inline void free_c_str(char *c_str) { raw_free_c_str(c_str); } } // namespace Lazyboard::ffi -#endif // UTILS_HXX \ No newline at end of file +#endif // UTILS_HXX \ No newline at end of file diff --git a/src/ffi/raw/utils.hxx b/src/ffi/raw/utils.hxx index d5cb2b0..0a1003d 100644 --- a/src/ffi/raw/utils.hxx +++ b/src/ffi/raw/utils.hxx @@ -9,24 +9,24 @@ extern "C" { using std::uint8_t; enum class OpenBrowserStatus : uint8_t { - OK, - WRAP_RAW_C_FAILED, - URL_IS_EMPTY, - OPEN_BROWSER_FAILED, + OK, + WRAP_RAW_C_FAILED, + URL_IS_EMPTY, + OPEN_BROWSER_FAILED, }; enum class CreateFileSystemStatus : uint8_t { - OK, - WRAP_RAW_C_FAILED, - FAILED, + OK, + WRAP_RAW_C_FAILED, + FAILED, }; -OpenBrowserStatus raw_open_browser(const char* url); -CreateFileSystemStatus raw_new_folder(const char* path); -bool raw_is_path_exists(const char* path); -void raw_free_c_str(char* c_str); +OpenBrowserStatus raw_open_browser(const char *url); +CreateFileSystemStatus raw_new_folder(const char *path); +bool raw_is_path_exists(const char *path); +void raw_free_c_str(char *c_str); #ifdef __cplusplus } #endif -#endif // UTILS_RAW_HXX \ No newline at end of file +#endif // UTILS_RAW_HXX \ No newline at end of file diff --git a/src/front_end/about_widget.cxx b/src/front_end/about_widget.cxx index 08d82bf..c78ddd4 100644 --- a/src/front_end/about_widget.cxx +++ b/src/front_end/about_widget.cxx @@ -17,19 +17,19 @@ using Self = AboutWidget; AboutWidget::AboutWidget() { show_about = make_unique(); } void Self::setup_event() { - const auto function = [this]() { - if (!about_window) { - about_window = make_unique(); - } + const auto function = [this]() { + if (!about_window) { + about_window = make_unique(); + } - about_window->show_window(); - }; + about_window->show_window(); + }; - QObject::connect(show_about.get(), &QPushButton::clicked, function); + QObject::connect(show_about.get(), &QPushButton::clicked, function); } -void Self::setup_widget(QGridLayout* grid_layout) { - show_about->setText("About"); - this->setup_event(); - grid_layout->addWidget(show_about.get(), 1, 1); +void Self::setup_widget(QGridLayout *grid_layout) { + show_about->setText("About"); + this->setup_event(); + grid_layout->addWidget(show_about.get(), 1, 1); } \ No newline at end of file diff --git a/src/front_end/about_window.cxx b/src/front_end/about_window.cxx index 50cf5d8..3778e69 100644 --- a/src/front_end/about_window.cxx +++ b/src/front_end/about_window.cxx @@ -16,72 +16,72 @@ using std::make_unique; using Self = AboutWindow; AboutWindow::AboutWindow() { - about_window = make_unique(); - grid_layout = make_unique(); - github_button = make_unique(); - github_issue_button = make_unique(); - github_pull_button = make_unique(); + about_window = make_unique(); + grid_layout = make_unique(); + github_button = make_unique(); + github_issue_button = make_unique(); + github_pull_button = make_unique(); } void Self::is_open_browser_ok(OpenBrowserStatus status) { - switch (status) { - case OpenBrowserStatus::OK: - break; - - case OpenBrowserStatus::OPEN_BROWSER_FAILED: - QMessageBox::critical(about_window.get(), "Error", - "Could not open your browser"); - break; - - case OpenBrowserStatus::WRAP_RAW_C_FAILED: - QMessageBox::critical(about_window.get(), "Error", - "Could not wrap C raw to safety string"); - - break; - case OpenBrowserStatus::URL_IS_EMPTY: - QMessageBox::critical(about_window.get(), "Error", "Url is empty"); - break; - } + switch (status) { + case OpenBrowserStatus::OK: + break; + + case OpenBrowserStatus::OPEN_BROWSER_FAILED: + QMessageBox::critical(about_window.get(), "Error", + "Could not open your browser"); + break; + + case OpenBrowserStatus::WRAP_RAW_C_FAILED: + QMessageBox::critical(about_window.get(), "Error", + "Could not wrap C raw to safety string"); + + break; + case OpenBrowserStatus::URL_IS_EMPTY: + QMessageBox::critical(about_window.get(), "Error", "Url is empty"); + break; + } } -void Self::open_browser_when_clicked(QPushButton* button, const char* url) { - const auto open_browser = [this, url] { - auto status = Lazyboard::ffi::open_browser(url); - is_open_browser_ok(status); - }; +void Self::open_browser_when_clicked(QPushButton *button, const char *url) { + const auto open_browser = [this, url] { + auto status = Lazyboard::ffi::open_browser(url); + is_open_browser_ok(status); + }; - QObject::connect(button, &QPushButton::clicked, open_browser); + QObject::connect(button, &QPushButton::clicked, open_browser); } void Self::setup_buttons() { - github_button->setText("GitHub | Source Code"); - github_button->setToolTip("Get Lazyboard source code"); + github_button->setText("GitHub | Source Code"); + github_button->setToolTip("Get Lazyboard source code"); - github_issue_button->setText("Issue | Bug Report"); - github_issue_button->setToolTip("Report issue/bug"); + github_issue_button->setText("Issue | Bug Report"); + github_issue_button->setToolTip("Report issue/bug"); - github_pull_button->setText("Pull Request | Contribute"); - github_pull_button->setToolTip("Contribute"); + github_pull_button->setText("Pull Request | Contribute"); + github_pull_button->setToolTip("Contribute"); - this->open_browser_when_clicked(github_button.get(), GITHUB_URL); - this->open_browser_when_clicked(github_issue_button.get(), - GITHUB_ISSUE_URL); - this->open_browser_when_clicked(github_pull_button.get(), GITHUB_PULL_URL); + this->open_browser_when_clicked(github_button.get(), GITHUB_URL); + this->open_browser_when_clicked(github_issue_button.get(), + GITHUB_ISSUE_URL); + this->open_browser_when_clicked(github_pull_button.get(), GITHUB_PULL_URL); - grid_layout->addWidget(github_button.get(), 0, 0); - grid_layout->addWidget(github_issue_button.get(), 0, 1); - grid_layout->addWidget(github_pull_button.get(), 1, 0); + grid_layout->addWidget(github_button.get(), 0, 0); + grid_layout->addWidget(github_issue_button.get(), 0, 1); + grid_layout->addWidget(github_pull_button.get(), 1, 0); } void Self::setup_front_end() { - about_window->setLayout(this->grid_layout.get()); - this->setup_buttons(); + about_window->setLayout(this->grid_layout.get()); + this->setup_buttons(); } void Self::show_window() { - about_window->setMinimumSize(MIN_WIDTH, MIN_HEIGHT); - about_window->setWindowTitle("Lazyboard About"); + about_window->setMinimumSize(MIN_WIDTH, MIN_HEIGHT); + about_window->setWindowTitle("Lazyboard About"); - this->setup_front_end(); - about_window->exec(); + this->setup_front_end(); + about_window->exec(); } \ No newline at end of file diff --git a/src/front_end/include/about_widget.hxx b/src/front_end/include/about_widget.hxx index ff51ab0..6dd91ee 100644 --- a/src/front_end/include/about_widget.hxx +++ b/src/front_end/include/about_widget.hxx @@ -13,19 +13,19 @@ using std::unique_ptr; namespace Lazyboard::front_end { class AboutWidget { public: - AboutWidget(); + AboutWidget(); private: - unique_ptr show_about; - unique_ptr about_window; + unique_ptr show_about; + unique_ptr about_window; private: - void setup_event(); + void setup_event(); public: - void setup_widget(QGridLayout* layout); + void setup_widget(QGridLayout *layout); }; } // namespace Lazyboard::front_end -#endif // ABOUT_WIDGET_HXX \ No newline at end of file +#endif // ABOUT_WIDGET_HXX \ No newline at end of file diff --git a/src/front_end/include/about_window.hxx b/src/front_end/include/about_window.hxx index 8da053a..13792c0 100644 --- a/src/front_end/include/about_window.hxx +++ b/src/front_end/include/about_window.hxx @@ -13,32 +13,32 @@ using std::unique_ptr; namespace Lazyboard::front_end { class AboutWindow { private: - unique_ptr about_window; - unique_ptr grid_layout; - unique_ptr github_button; - unique_ptr github_issue_button; - unique_ptr github_pull_button; + unique_ptr about_window; + unique_ptr grid_layout; + unique_ptr github_button; + unique_ptr github_issue_button; + unique_ptr github_pull_button; private: - static constexpr int MIN_WIDTH = 600; - static constexpr int MIN_HEIGHT = 600; - const char* GITHUB_URL = "https://github.com/reim-developer/zClipboard"; - const char* GITHUB_ISSUE_URL = - "https://github.com/reim-developer/zClipboard/issues"; - const char* GITHUB_PULL_URL = - "https://github.com/reim-developer/zClipboard/pulls"; + static constexpr int MIN_WIDTH = 600; + static constexpr int MIN_HEIGHT = 600; + const char *GITHUB_URL = "https://github.com/reim-developer/zClipboard"; + const char *GITHUB_ISSUE_URL = + "https://github.com/reim-developer/zClipboard/issues"; + const char *GITHUB_PULL_URL = + "https://github.com/reim-developer/zClipboard/pulls"; private: - void is_open_browser_ok(OpenBrowserStatus status); - void open_browser_when_clicked(QPushButton* button, const char* url); + void is_open_browser_ok(OpenBrowserStatus status); + void open_browser_when_clicked(QPushButton *button, const char *url); private: - void setup_front_end(); - void setup_buttons(); + void setup_front_end(); + void setup_buttons(); public: - AboutWindow(); - void show_window(); + AboutWindow(); + void show_window(); }; } // namespace Lazyboard::front_end diff --git a/src/front_end/include/main_window.hxx b/src/front_end/include/main_window.hxx index 5fda68c..395b2d5 100644 --- a/src/front_end/include/main_window.hxx +++ b/src/front_end/include/main_window.hxx @@ -19,32 +19,32 @@ using std::unique_ptr; namespace Lazyboard::front_end { class MainWindow { private: - using Self = MainWindow; - using Window = QMainWindow; - using Layout = QGridLayout; + using Self = MainWindow; + using Window = QMainWindow; + using Layout = QGridLayout; private: - static constexpr int MIN_WIDTH = 600; - static constexpr int MIN_HEIGHT = 400; + static constexpr int MIN_WIDTH = 600; + static constexpr int MIN_HEIGHT = 400; public: - MainWindow(); + MainWindow(); private: - Layout* grid_layout; - QWidget* central_widget; + Layout *grid_layout; + QWidget *central_widget; private: - unique_ptr main_window; - unique_ptr table_widget; - unique_ptr setting_widget; - unique_ptr about_widget; - unique_ptr main_window_preload; + unique_ptr main_window; + unique_ptr table_widget; + unique_ptr setting_widget; + unique_ptr about_widget; + unique_ptr main_window_preload; public: - Self* init_main_window(); - void front_end_show(); + Self *init_main_window(); + void front_end_show(); }; } // namespace Lazyboard::front_end -#endif // MAIN_WINDOWS_HXX \ No newline at end of file +#endif // MAIN_WINDOWS_HXX \ No newline at end of file diff --git a/src/front_end/include/setting_widget.hxx b/src/front_end/include/setting_widget.hxx index 84351ff..ea903bd 100644 --- a/src/front_end/include/setting_widget.hxx +++ b/src/front_end/include/setting_widget.hxx @@ -11,11 +11,11 @@ using std::unique_ptr; namespace Lazyboard::front_end { class SettingWidget { private: - unique_ptr open_setting; + unique_ptr open_setting; public: - SettingWidget(); - void setup_widget(QGridLayout* grid_layout); + SettingWidget(); + void setup_widget(QGridLayout *grid_layout); }; } // namespace Lazyboard::front_end diff --git a/src/front_end/include/table_widget.hxx b/src/front_end/include/table_widget.hxx index 90243de..76447d6 100644 --- a/src/front_end/include/table_widget.hxx +++ b/src/front_end/include/table_widget.hxx @@ -12,18 +12,18 @@ using std::unique_ptr; namespace Lazyboard::front_end { class TableWidget { public: - TableWidget() noexcept; + TableWidget() noexcept; private: - QStringList header_labels; - static constexpr int DEFAULT_MAX_ROW = 10; + QStringList header_labels; + static constexpr int DEFAULT_MAX_ROW = 10; private: - unique_ptr table_widget; + unique_ptr table_widget; public: - void setup_widget(QGridLayout* grid_layout); + void setup_widget(QGridLayout *grid_layout); }; } // namespace Lazyboard::front_end -#endif // TABLE_WIDGET_HXX \ No newline at end of file +#endif // TABLE_WIDGET_HXX \ No newline at end of file diff --git a/src/front_end/setting_widget.cxx b/src/front_end/setting_widget.cxx index 9b5b03a..4909bb4 100644 --- a/src/front_end/setting_widget.cxx +++ b/src/front_end/setting_widget.cxx @@ -11,8 +11,8 @@ using Self = SettingWidget; SettingWidget::SettingWidget() { open_setting = make_unique(); } -void Self::setup_widget(QGridLayout* grid_layout) { - open_setting->setText("Settings"); +void Self::setup_widget(QGridLayout *grid_layout) { + open_setting->setText("Settings"); - grid_layout->addWidget(open_setting.get(), 0, 1); + grid_layout->addWidget(open_setting.get(), 0, 1); } \ No newline at end of file diff --git a/src/front_end/table_widget.cxx b/src/front_end/table_widget.cxx index d7faa82..8efa302 100644 --- a/src/front_end/table_widget.cxx +++ b/src/front_end/table_widget.cxx @@ -11,16 +11,16 @@ using std::make_unique; using Self = TableWidget; Self::TableWidget() noexcept { - table_widget = make_unique(); - header_labels = {"Time", "Content", "Type", "Pinned"}; + table_widget = make_unique(); + header_labels = {"Time", "Content", "Type", "Pinned"}; } -void Self::setup_widget(QGridLayout* grid_layout) { - table_widget->setRowCount(DEFAULT_MAX_ROW); - table_widget->setColumnCount(4); - table_widget->setHorizontalHeaderLabels(header_labels); - table_widget->horizontalHeader()->setSectionResizeMode( - QHeaderView::Stretch); +void Self::setup_widget(QGridLayout *grid_layout) { + table_widget->setRowCount(DEFAULT_MAX_ROW); + table_widget->setColumnCount(4); + table_widget->setHorizontalHeaderLabels(header_labels); + table_widget->horizontalHeader()->setSectionResizeMode( + QHeaderView::Stretch); - grid_layout->addWidget(table_widget.get(), 0, 0); + grid_layout->addWidget(table_widget.get(), 0, 0); } \ No newline at end of file diff --git a/src/main.cxx b/src/main.cxx index 472b3dc..7209e96 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -7,12 +7,12 @@ using Lazyboard::front_end::MainWindow; using std::make_unique; using std::unique_ptr; -int main(int argc, char* argv[]) { - unique_ptr application = - make_unique(argc, argv); - unique_ptr main_window = make_unique(); +int main(int argc, char *argv[]) { + unique_ptr application = + make_unique(argc, argv); + unique_ptr main_window = make_unique(); - main_window->init_main_window(); + main_window->init_main_window(); - return application->exec(); + return application->exec(); } \ No newline at end of file diff --git a/tests-ffi/config.cxx b/tests-ffi/config.cxx index 56c91fc..328fb07 100644 --- a/tests-ffi/config.cxx +++ b/tests-ffi/config.cxx @@ -9,36 +9,36 @@ using std::string; using std::uint8_t; enum WriteConfigStatus : uint8_t { - OK, - TOML_TO_STRING_FAILED, - CREATE_DIR_FAILED, - CREATE_FILE_FAILED, - WRITE_FILE_FAILED, - GET_DATA_LOCAL_FAILED, + OK, + TOML_TO_STRING_FAILED, + CREATE_DIR_FAILED, + CREATE_FILE_FAILED, + WRITE_FILE_FAILED, + GET_DATA_LOCAL_FAILED, }; -extern "C" char* raw_config_dir(); -extern "C" void raw_free_c_str(char* str); +extern "C" char *raw_config_dir(); +extern "C" void raw_free_c_str(char *str); extern "C" WriteConfigStatus raw_write_default_config(); void gen_config_test() { - auto status = raw_write_default_config(); - - assert(status != WriteConfigStatus::WRITE_FILE_FAILED); - assert(status != WriteConfigStatus::CREATE_FILE_FAILED); - assert(status != WriteConfigStatus::CREATE_DIR_FAILED); - assert(status != WriteConfigStatus::GET_DATA_LOCAL_FAILED); - assert(status != WriteConfigStatus::TOML_TO_STRING_FAILED); - assert(status == WriteConfigStatus::OK); + auto status = raw_write_default_config(); + + assert(status != WriteConfigStatus::WRITE_FILE_FAILED); + assert(status != WriteConfigStatus::CREATE_FILE_FAILED); + assert(status != WriteConfigStatus::CREATE_DIR_FAILED); + assert(status != WriteConfigStatus::GET_DATA_LOCAL_FAILED); + assert(status != WriteConfigStatus::TOML_TO_STRING_FAILED); + assert(status == WriteConfigStatus::OK); } int main() { - auto raw_result = raw_config_dir(); - auto result = string(raw_result); - raw_free_c_str(raw_result); + auto raw_result = raw_config_dir(); + auto result = string(raw_result); + raw_free_c_str(raw_result); - gen_config_test(); - assert(!result.empty()); + gen_config_test(); + assert(!result.empty()); - return 0; + return 0; } \ No newline at end of file diff --git a/tests-ffi/fs.cxx b/tests-ffi/fs.cxx index f28ac05..cccc9c0 100644 --- a/tests-ffi/fs.cxx +++ b/tests-ffi/fs.cxx @@ -1,13 +1,13 @@ #include -extern "C" bool raw_is_path_exists(const char* path); +extern "C" bool raw_is_path_exists(const char *path); int main() { - const char* valid_path = "../tests-ffi"; - const char* wrong_path = "../abcxyzw1133"; + const char *valid_path = "../tests-ffi"; + const char *wrong_path = "../abcxyzw1133"; - assert(raw_is_path_exists(valid_path)); - assert(!raw_is_path_exists(wrong_path)); + assert(raw_is_path_exists(valid_path)); + assert(!raw_is_path_exists(wrong_path)); - return 0; + return 0; } \ No newline at end of file diff --git a/tests-ffi/toml_config.cxx b/tests-ffi/toml_config.cxx index 503e8c9..5c7f73c 100644 --- a/tests-ffi/toml_config.cxx +++ b/tests-ffi/toml_config.cxx @@ -9,62 +9,62 @@ using std::uint8_t; using std::unique_ptr; extern "C" enum RawReadAppConfigStatus : uint8_t { - OK, - READ_FILE_FAILED, - UTF_8_ERROR, - PARSE_TOML_FAILED, - CONVERT_TO_MUT_FAILED + OK, + READ_FILE_FAILED, + UTF_8_ERROR, + PARSE_TOML_FAILED, + CONVERT_TO_MUT_FAILED }; extern "C" typedef struct { - bool hide_when_closed; - bool notification; + bool hide_when_closed; + bool notification; } RawAppSettings; extern "C" typedef struct { - char* background_color; - char* foreground_color; + char *background_color; + char *foreground_color; } RawAppGuiSettings; extern "C" typedef struct { - RawAppSettings raw_app_settings; - RawAppGuiSettings raw_app_gui_settings; + RawAppSettings raw_app_settings; + RawAppGuiSettings raw_app_gui_settings; } RawAppConfig; -extern "C" RawReadAppConfigStatus raw_exists_config(const char* file_path, - RawAppConfig* config_out); +extern "C" RawReadAppConfigStatus raw_exists_config(const char *file_path, + RawAppConfig *config_out); -extern "C" void raw_free_cstr_app_config(RawAppConfig* config); +extern "C" void raw_free_cstr_app_config(RawAppConfig *config); int main() { - using Status = RawReadAppConfigStatus; + using Status = RawReadAppConfigStatus; - const char* path = "demo.toml"; - unique_ptr raw = make_unique(); + const char *path = "demo.toml"; + unique_ptr raw = make_unique(); - auto result = raw_exists_config(path, raw.get()); - auto bg_color = string(raw->raw_app_gui_settings.background_color); - auto fg_color = string(raw->raw_app_gui_settings.foreground_color); + auto result = raw_exists_config(path, raw.get()); + auto bg_color = string(raw->raw_app_gui_settings.background_color); + auto fg_color = string(raw->raw_app_gui_settings.foreground_color); - raw_free_cstr_app_config(raw.get()); + raw_free_cstr_app_config(raw.get()); - assert(result != Status::UTF_8_ERROR); - assert(result != Status::PARSE_TOML_FAILED); - assert(result != Status::READ_FILE_FAILED); - assert(result != Status::CONVERT_TO_MUT_FAILED); - assert(result == Status::OK); + assert(result != Status::UTF_8_ERROR); + assert(result != Status::PARSE_TOML_FAILED); + assert(result != Status::READ_FILE_FAILED); + assert(result != Status::CONVERT_TO_MUT_FAILED); + assert(result == Status::OK); - assert(raw->raw_app_settings.hide_when_closed != true); - assert(raw->raw_app_settings.hide_when_closed == false); - assert(raw->raw_app_settings.notification != false); - assert(raw->raw_app_settings.notification == true); + assert(raw->raw_app_settings.hide_when_closed != true); + assert(raw->raw_app_settings.hide_when_closed == false); + assert(raw->raw_app_settings.notification != false); + assert(raw->raw_app_settings.notification == true); - assert(!bg_color.empty()); - assert(!fg_color.empty()); - assert(bg_color != "717841xx18"); - assert(fg_color != "81388181"); - assert(bg_color == "#2f3136"); - assert(fg_color == "#ffffff"); + assert(!bg_color.empty()); + assert(!fg_color.empty()); + assert(bg_color != "717841xx18"); + assert(fg_color != "81388181"); + assert(bg_color == "#2f3136"); + assert(fg_color == "#ffffff"); - return 0; + return 0; } \ No newline at end of file