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
7 changes: 6 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---
Language: Cpp
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 80
ColumnLimit: 80
UseTab: Always
TabWidth: 4
IndentPPDirectives: BeforeHash
PPIndentWidth: 4
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
25 changes: 19 additions & 6 deletions src/ffi/namespace/include/config.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
#endif // CONFIG_HXX
22 changes: 11 additions & 11 deletions src/ffi/namespace/include/utils.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
#endif // UTILS_HXX
47 changes: 39 additions & 8 deletions src/ffi/raw/config.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,48 @@ extern "C" {

#include <cstdint>

/* 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
}
Expand Down
24 changes: 12 additions & 12 deletions src/ffi/raw/utils.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
#endif // UTILS_RAW_HXX
22 changes: 11 additions & 11 deletions src/front_end/about_widget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ using Self = AboutWidget;
AboutWidget::AboutWidget() { show_about = make_unique<QPushButton>(); }

void Self::setup_event() {
const auto function = [this]() {
if (!about_window) {
about_window = make_unique<AboutWindow>();
}
const auto function = [this]() {
if (!about_window) {
about_window = make_unique<AboutWindow>();
}

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);
}
96 changes: 48 additions & 48 deletions src/front_end/about_window.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,72 +16,72 @@ using std::make_unique;
using Self = AboutWindow;

AboutWindow::AboutWindow() {
about_window = make_unique<QDialog>();
grid_layout = make_unique<QGridLayout>();
github_button = make_unique<QPushButton>();
github_issue_button = make_unique<QPushButton>();
github_pull_button = make_unique<QPushButton>();
about_window = make_unique<QDialog>();
grid_layout = make_unique<QGridLayout>();
github_button = make_unique<QPushButton>();
github_issue_button = make_unique<QPushButton>();
github_pull_button = make_unique<QPushButton>();
}

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();
}
12 changes: 6 additions & 6 deletions src/front_end/include/about_widget.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ using std::unique_ptr;
namespace Lazyboard::front_end {
class AboutWidget {
public:
AboutWidget();
AboutWidget();

private:
unique_ptr<QPushButton> show_about;
unique_ptr<AboutWindow> about_window;
unique_ptr<QPushButton> show_about;
unique_ptr<AboutWindow> 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
#endif // ABOUT_WIDGET_HXX
Loading