Adding dialog
This commit is contained in:
parent
4590aeaee8
commit
786f423394
@ -81,7 +81,7 @@ add_executable(autocat_gnome main.cpp
|
|||||||
gtkpp/MessageDialog.cpp
|
gtkpp/MessageDialog.cpp
|
||||||
gtkpp/MessageDialog.h
|
gtkpp/MessageDialog.h
|
||||||
gtkpp/Leaflet.cpp
|
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}
|
target_link_libraries(autocat_gnome ${GTK_LIBRARIES}
|
||||||
${GLIB_LIBRARIES}
|
${GLIB_LIBRARIES}
|
||||||
@ -91,7 +91,7 @@ target_link_libraries(autocat_gnome ${GTK_LIBRARIES}
|
|||||||
nlohmann_json::nlohmann_json
|
nlohmann_json::nlohmann_json
|
||||||
${FOLLY_DEP})
|
${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")
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/Modules")
|
||||||
include(GlibCompileResourcesSupport)
|
include(GlibCompileResourcesSupport)
|
||||||
|
|||||||
5
gtkpp/Dialog.cpp
Normal file
5
gtkpp/Dialog.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
//
|
||||||
|
// Created by selim on 17.05.2022.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "Dialog.h"
|
||||||
19
gtkpp/Dialog.h
Normal file
19
gtkpp/Dialog.h
Normal file
@ -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
|
||||||
@ -21,10 +21,10 @@ namespace gtkpp {
|
|||||||
_builder = nullptr;
|
_builder = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::Window(std::shared_ptr<Application> app, const char* resourceName) {
|
Window::Window(std::shared_ptr<Application> app, const char* resourceName, const char* id) {
|
||||||
_app = app;
|
_app = app;
|
||||||
_builder = gtk_builder_new_from_resource(resourceName);
|
_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() {
|
void Window::show() {
|
||||||
|
|||||||
@ -22,7 +22,7 @@ namespace gtkpp {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Window(std::shared_ptr<Application> app, bool isAppWindow);
|
Window(std::shared_ptr<Application> app, bool isAppWindow);
|
||||||
Window(std::shared_ptr<Application> app, const char* resourceName);
|
Window(std::shared_ptr<Application> app, const char* resourceName, const char* id);
|
||||||
void show();
|
void show();
|
||||||
void hide();
|
void hide();
|
||||||
void setTitle(const std::string& title);
|
void setTitle(const std::string& title);
|
||||||
|
|||||||
9
gui/AddNumberDialog.cpp
Normal file
9
gui/AddNumberDialog.cpp
Normal file
@ -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") {
|
||||||
|
|
||||||
|
}
|
||||||
16
gui/AddNumberDialog.h
Normal file
16
gui/AddNumberDialog.h
Normal file
@ -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
|
||||||
19
gui/AddNumberDialog.xml
Normal file
19
gui/AddNumberDialog.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<object class="GtkDialog" id="add_number_dialog">
|
||||||
|
<child type="action">
|
||||||
|
<object class="GtkButton" id="button_cancel"/>
|
||||||
|
</child>
|
||||||
|
<child type="action">
|
||||||
|
<object class="GtkButton" id="button_ok">
|
||||||
|
<!--
|
||||||
|
<property name="can-default">True</property>
|
||||||
|
-->
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<action-widgets>
|
||||||
|
<action-widget response="cancel">button_cancel</action-widget>
|
||||||
|
<action-widget response="ok" default="true">button_ok</action-widget>
|
||||||
|
</action-widgets>
|
||||||
|
</object>
|
||||||
|
</interface>
|
||||||
@ -3,15 +3,18 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
#include "AddNumberDialog.h"
|
||||||
#include "../gtkpp/HeaderBar.h"
|
#include "../gtkpp/HeaderBar.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
MainWindow::MainWindow(std::shared_ptr<gtkpp::Application> app):
|
MainWindow::MainWindow(std::shared_ptr<gtkpp::Application> 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(_builder, "add_number_button") {
|
||||||
|
|
||||||
_addNumberButton.onClick([this] {
|
_addNumberButton.onClick([this] {
|
||||||
std::cout << "Add clicked" << std::endl;
|
std::cout << "Add clicked" << std::endl;
|
||||||
|
auto dialog = std::make_unique<AddNumberDialog>();
|
||||||
|
dialog->show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user