diff --git a/CMakeLists.txt b/CMakeLists.txt index b680514..bc67c79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,7 +81,7 @@ add_executable(autocat_gnome main.cpp gtkpp/MessageDialog.cpp gtkpp/MessageDialog.h gtkpp/Leaflet.cpp - gtkpp/Leaflet.h) + gtkpp/Leaflet.h gtkpp/Dialog.cpp gtkpp/Dialog.h gui/AddNumberDialog.cpp gui/AddNumberDialog.h) target_link_libraries(autocat_gnome ${GTK_LIBRARIES} ${GLIB_LIBRARIES} @@ -91,7 +91,7 @@ target_link_libraries(autocat_gnome ${GTK_LIBRARIES} nlohmann_json::nlohmann_json ${FOLLY_DEP}) -set(XML gui/MainWindow.xml) +set(XML gui/MainWindow.xml gui/AddNumberDialog.xml) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules") include(GlibCompileResourcesSupport) diff --git a/gtkpp/Dialog.cpp b/gtkpp/Dialog.cpp new file mode 100644 index 0000000..3438d6e --- /dev/null +++ b/gtkpp/Dialog.cpp @@ -0,0 +1,5 @@ +// +// Created by selim on 17.05.2022. +// + +#include "Dialog.h" diff --git a/gtkpp/Dialog.h b/gtkpp/Dialog.h new file mode 100644 index 0000000..13a41fd --- /dev/null +++ b/gtkpp/Dialog.h @@ -0,0 +1,19 @@ +// +// Created by selim on 17.05.2022. +// + +#ifndef AUTOCAT_GNOME_DIALOG_H +#define AUTOCAT_GNOME_DIALOG_H + +#include "Window.h" + +namespace gtkpp { + + class Dialog: public Window { + public: + using Window::Window; + }; + +} + +#endif //AUTOCAT_GNOME_DIALOG_H diff --git a/gtkpp/Window.cpp b/gtkpp/Window.cpp index 0ea0761..120ec70 100644 --- a/gtkpp/Window.cpp +++ b/gtkpp/Window.cpp @@ -21,10 +21,10 @@ namespace gtkpp { _builder = nullptr; } - Window::Window(std::shared_ptr app, const char* resourceName) { + Window::Window(std::shared_ptr app, const char* resourceName, const char* id) { _app = app; _builder = gtk_builder_new_from_resource(resourceName); - _window = GTK_WINDOW(gtk_builder_get_object(_builder, "adw_main_window")); + _window = GTK_WINDOW(gtk_builder_get_object(_builder, id)); } void Window::show() { diff --git a/gtkpp/Window.h b/gtkpp/Window.h index ec16039..c08127d 100644 --- a/gtkpp/Window.h +++ b/gtkpp/Window.h @@ -22,7 +22,7 @@ namespace gtkpp { public: Window(std::shared_ptr app, bool isAppWindow); - Window(std::shared_ptr app, const char* resourceName); + Window(std::shared_ptr app, const char* resourceName, const char* id); void show(); void hide(); void setTitle(const std::string& title); diff --git a/gui/AddNumberDialog.cpp b/gui/AddNumberDialog.cpp new file mode 100644 index 0000000..9c0b5cb --- /dev/null +++ b/gui/AddNumberDialog.cpp @@ -0,0 +1,9 @@ +// +// Created by selim on 17.05.2022. +// + +#include "AddNumberDialog.h" + +AddNumberDialog::AddNumberDialog(): gtkpp::Window(nullptr, "/gui/AddNumberDialog.xml", "add_number_dialog") { + +} diff --git a/gui/AddNumberDialog.h b/gui/AddNumberDialog.h new file mode 100644 index 0000000..5b07748 --- /dev/null +++ b/gui/AddNumberDialog.h @@ -0,0 +1,16 @@ +// +// Created by selim on 17.05.2022. +// + +#ifndef AUTOCAT_GNOME_ADDNUMBERDIALOG_H +#define AUTOCAT_GNOME_ADDNUMBERDIALOG_H + +#include "../gtkpp/Window.h" + +class AddNumberDialog: public gtkpp::Window { +public: + AddNumberDialog(); +}; + + +#endif //AUTOCAT_GNOME_ADDNUMBERDIALOG_H diff --git a/gui/AddNumberDialog.xml b/gui/AddNumberDialog.xml new file mode 100644 index 0000000..dcd759d --- /dev/null +++ b/gui/AddNumberDialog.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + button_cancel + button_ok + + + \ No newline at end of file diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 3c79cf4..88532a1 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -3,15 +3,18 @@ // #include "MainWindow.h" +#include "AddNumberDialog.h" #include "../gtkpp/HeaderBar.h" #include MainWindow::MainWindow(std::shared_ptr app): - gtkpp::Window(std::move(app), "/gui/MainWindow.xml"), + gtkpp::Window(std::move(app), "/gui/MainWindow.xml", "adw_main_window"), _addNumberButton(_builder, "add_number_button") { _addNumberButton.onClick([this] { std::cout << "Add clicked" << std::endl; + auto dialog = std::make_unique(); + dialog->show(); }); }