forked from OpenGamers/abaddon
add confirmation dialog to leave guild
This commit is contained in:
@@ -138,6 +138,8 @@ add_executable(abaddon
|
|||||||
components/chatwindow.cpp
|
components/chatwindow.cpp
|
||||||
components/memberlist.hpp
|
components/memberlist.hpp
|
||||||
components/memberlist.cpp
|
components/memberlist.cpp
|
||||||
|
dialogs/confirm.hpp
|
||||||
|
dialogs/confirm.cpp
|
||||||
dialogs/editmessage.hpp
|
dialogs/editmessage.hpp
|
||||||
dialogs/editmessage.cpp
|
dialogs/editmessage.cpp
|
||||||
dialogs/joinguild.hpp
|
dialogs/joinguild.hpp
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "dialogs/token.hpp"
|
#include "dialogs/token.hpp"
|
||||||
#include "dialogs/editmessage.hpp"
|
#include "dialogs/editmessage.hpp"
|
||||||
#include "dialogs/joinguild.hpp"
|
#include "dialogs/joinguild.hpp"
|
||||||
|
#include "dialogs/confirm.hpp"
|
||||||
#include "abaddon.hpp"
|
#include "abaddon.hpp"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -314,7 +315,10 @@ void Abaddon::ActionInsertMention(Snowflake id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Abaddon::ActionLeaveGuild(Snowflake id) {
|
void Abaddon::ActionLeaveGuild(Snowflake id) {
|
||||||
m_discord.LeaveGuild(id);
|
ConfirmDialog dlg(*m_main_window);
|
||||||
|
auto response = dlg.run();
|
||||||
|
if (response == Gtk::RESPONSE_OK)
|
||||||
|
m_discord.LeaveGuild(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Abaddon::ActionReloadCSS() {
|
void Abaddon::ActionReloadCSS() {
|
||||||
|
|||||||
30
dialogs/confirm.cpp
Normal file
30
dialogs/confirm.cpp
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#include "confirm.hpp"
|
||||||
|
|
||||||
|
ConfirmDialog::ConfirmDialog(Gtk::Window &parent)
|
||||||
|
: Gtk::Dialog("Confirm", parent, true)
|
||||||
|
, m_layout(Gtk::ORIENTATION_VERTICAL)
|
||||||
|
, m_bbox(Gtk::ORIENTATION_HORIZONTAL)
|
||||||
|
, m_ok("OK")
|
||||||
|
, m_cancel("Cancel") {
|
||||||
|
set_default_size(300, 50);
|
||||||
|
|
||||||
|
m_label.set_text("Are you sure?");
|
||||||
|
|
||||||
|
m_ok.signal_clicked().connect([&]() {
|
||||||
|
response(Gtk::RESPONSE_OK);
|
||||||
|
});
|
||||||
|
|
||||||
|
m_cancel.signal_clicked().connect([&]() {
|
||||||
|
response(Gtk::RESPONSE_CANCEL);
|
||||||
|
});
|
||||||
|
|
||||||
|
m_bbox.pack_start(m_ok, Gtk::PACK_SHRINK);
|
||||||
|
m_bbox.pack_start(m_cancel, Gtk::PACK_SHRINK);
|
||||||
|
m_bbox.set_layout(Gtk::BUTTONBOX_END);
|
||||||
|
|
||||||
|
m_layout.add(m_label);
|
||||||
|
m_layout.add(m_bbox);
|
||||||
|
get_content_area()->add(m_layout);
|
||||||
|
|
||||||
|
show_all_children();
|
||||||
|
}
|
||||||
14
dialogs/confirm.hpp
Normal file
14
dialogs/confirm.hpp
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <gtkmm.h>
|
||||||
|
|
||||||
|
class ConfirmDialog : public Gtk::Dialog {
|
||||||
|
public:
|
||||||
|
ConfirmDialog(Gtk::Window &parent);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Gtk::Label m_label;
|
||||||
|
Gtk::Box m_layout;
|
||||||
|
Gtk::Button m_ok;
|
||||||
|
Gtk::Button m_cancel;
|
||||||
|
Gtk::ButtonBox m_bbox;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user