#include "../include/RoomSettingsWindow.hpp" #include "../include/ChatWindow.hpp" #include #include #include #include #include namespace dchat { RoomSettingsWindow::RoomSettingsWindow(ChatWindow *_chatWindow) : chatWindow(_chatWindow) { assert(chatWindow); Gtk::Paned *sidePanels = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_HORIZONTAL)); sidePanels->get_style_context()->add_class("side-panels"); sidePanels->set_vexpand(true); sidePanels->set_hexpand(true); sidePanels->set_wide_handle(true); attach(*sidePanels, 0, 0, 1, 1); setupLeftPanel(sidePanels); setupRightPanel(sidePanels); set_vexpand(true); set_hexpand(true); } void RoomSettingsWindow::selectRoom(std::shared_ptr room) { roomNameEntry.set_text(room->name); inviteKey.set_text(room->inviteKey); } void RoomSettingsWindow::setupLeftPanel(Gtk::Paned *sidePanels) { Gtk::Grid *leftPanel = Gtk::manage(new Gtk::Grid()); leftPanel->set_vexpand(true); //leftPanel->set_valign(Gtk::ALIGN_START); //leftPanel->set_halign(Gtk::ALIGN_START); leftPanel->set_size_request(200); leftPanel->get_style_context()->add_class("left-panel"); sidePanels->add1(*leftPanel); Gtk::Label *settingsLabel = Gtk::manage(new Gtk::Label("Settings")); leftPanel->attach(*settingsLabel, 0, 0, 1, 1); Gtk::ToggleButton *generalButton = Gtk::manage(new Gtk::ToggleButton("General")); leftPanel->attach_next_to(*generalButton, *settingsLabel, Gtk::POS_BOTTOM, 1, 1); Gtk::ToggleButton *returnToChatButton = Gtk::manage(new Gtk::ToggleButton("Return to chat")); returnToChatButton->signal_clicked().connect([this] { chatWindow->chatPage.show_all(); chatWindow->stack.set_visible_child("chat"); }); leftPanel->attach_next_to(*returnToChatButton, *generalButton, Gtk::POS_BOTTOM, 1, 1); } void RoomSettingsWindow::setupRightPanel(Gtk::Paned *sidePanels) { Gtk::Grid *rightPanel = Gtk::manage(new Gtk::Grid()); rightPanel->set_margin_top(10); rightPanel->set_margin_left(10); rightPanel->set_vexpand(true); rightPanel->set_valign(Gtk::ALIGN_START); rightPanel->set_halign(Gtk::ALIGN_START); sidePanels->add2(*rightPanel); Gtk::Label *roomNameLabel = Gtk::manage(new Gtk::Label("Room name")); rightPanel->attach(*roomNameLabel, 0, 0, 1, 1); roomNameEntry.set_editable(false); rightPanel->attach_next_to(roomNameEntry, *roomNameLabel, Gtk::POS_BOTTOM, 1, 1); Gtk::Label *inviteKeyLabel = Gtk::manage(new Gtk::Label("Invite key")); rightPanel->attach_next_to(*inviteKeyLabel, roomNameEntry, Gtk::POS_BOTTOM, 1, 1); inviteKey.set_selectable(true); inviteKey.set_line_wrap(true); inviteKey.set_line_wrap_mode(Pango::WRAP_WORD_CHAR); rightPanel->attach_next_to(inviteKey, *inviteKeyLabel, Gtk::POS_BOTTOM, 1, 1); Gtk::Button *copyInviteKeyButton = Gtk::manage(new Gtk::Button("_Copy", true)); copyInviteKeyButton->signal_clicked().connect([this] { Gtk::Clipboard::get()->set_text(inviteKey.get_text()); }); rightPanel->attach_next_to(*copyInviteKeyButton, inviteKey, Gtk::POS_RIGHT, 1, 1); } }