aboutsummaryrefslogtreecommitdiff
path: root/src/RoomSettingsWindow.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-11-09 09:46:43 +0100
committerdec05eba <dec05eba@protonmail.com>2018-11-09 09:46:47 +0100
commit5fab9a3a2cf048330f687dda48c76c95a3a67d98 (patch)
tree1be0385ef62f5fbf0794d98a697e0ff11fe7a510 /src/RoomSettingsWindow.cpp
parent118277121c8b1767a78f76d19c44aea496121b34 (diff)
Add room joining
Diffstat (limited to 'src/RoomSettingsWindow.cpp')
-rw-r--r--src/RoomSettingsWindow.cpp88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/RoomSettingsWindow.cpp b/src/RoomSettingsWindow.cpp
new file mode 100644
index 0000000..e20e36e
--- /dev/null
+++ b/src/RoomSettingsWindow.cpp
@@ -0,0 +1,88 @@
+#include "../include/RoomSettingsWindow.hpp"
+#include "../include/ChatWindow.hpp"
+#include <gtkmm/button.h>
+#include <gtkmm/togglebutton.h>
+#include <gtkmm/clipboard.h>
+#include <gtkmm/paned.h>
+#include <assert.h>
+
+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);
+ attach(*sidePanels, 0, 0, 1, 1);
+
+ setupLeftPanel(sidePanels);
+ setupRightPanel(sidePanels);
+
+ set_vexpand(true);
+ set_hexpand(true);
+ }
+
+ void RoomSettingsWindow::selectRoom(std::shared_ptr<Room> 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_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);
+ }
+} \ No newline at end of file