From 5fab9a3a2cf048330f687dda48c76c95a3a67d98 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 9 Nov 2018 09:46:43 +0100 Subject: Add room joining --- include/ChatWindow.hpp | 25 ++++++++++++++++++------- include/InputDialog.hpp | 6 +++--- include/RoomNotificationsWindow.hpp | 36 ++++++++++++++++++++++++++++++++++++ include/RoomSettingsWindow.hpp | 30 ++++++++++++++++++++++++++++++ include/Topbar.hpp | 22 ++++++++++++++++++++++ 5 files changed, 109 insertions(+), 10 deletions(-) create mode 100644 include/RoomNotificationsWindow.hpp create mode 100644 include/RoomSettingsWindow.hpp create mode 100644 include/Topbar.hpp (limited to 'include') diff --git a/include/ChatWindow.hpp b/include/ChatWindow.hpp index d457b7d..48bbff5 100644 --- a/include/ChatWindow.hpp +++ b/include/ChatWindow.hpp @@ -1,6 +1,8 @@ #pragma once #include "ImageButton.hpp" +#include "RoomSettingsWindow.hpp" +#include "RoomNotificationsWindow.hpp" #include #include #include @@ -17,6 +19,7 @@ namespace dchat { class ChatMessage; class Window; + class Topbar; class ChatWindow : public Gtk::Grid { @@ -25,24 +28,31 @@ namespace dchat ~ChatWindow(); void addRoom(std::shared_ptr room); void addMessage(const RoomAddMessageRequest &request); - void addUser(std::shared_ptr room, std::shared_ptr user); + void addUser(const RoomAddUserRequest &request); void setUserNickname(const UserChangeNicknameRequest &request); void changeRoomName(const RoomChangeNameRequest &request); + void addInviteRequest(const InviteUserRequest &request); void scrollToBottom(); + + Topbar *topbar; + Gtk::Stack stack; + Gtk::Grid chatPage; + RoomSettingsWindow roomSettingsWindow; + RoomNotificationsWindow roomNotificationsWindow; + Window *window; private: - void setupTopBar(); + void setupTopbar(); void setupLeftPanel(Gtk::Paned *sidePanels); void setupMessageArea(Gtk::Grid *rightPanel); void setupChatInput(Gtk::Grid *rightPanel); void setCurrentRoom(std::shared_ptr room); private: - Gtk::Grid topbar; - Gtk::Entry topbarSearchBar; Gtk::Grid leftPanelChannels; Gtk::Stack leftPanelUsersStack; - ImageButton addRoomButton; - Gtk::Label currentChannelTitle; + ImageButton createRoomButton; + ImageButton joinRoomButton; + ImageButton userSettingsButton; Gtk::ScrolledWindow messageArea; Gtk::Stack messageAreaStack; Gtk::TextView chatInput; @@ -60,6 +70,7 @@ namespace dchat int roomCount; RoomData *currentRoomData; std::shared_ptr currentRoom; - Window *window; + bool chatInputShowPlaceholder; + bool chatInputChangeByPlaceholder; }; } \ No newline at end of file diff --git a/include/InputDialog.hpp b/include/InputDialog.hpp index 4b2b02a..ae06de2 100644 --- a/include/InputDialog.hpp +++ b/include/InputDialog.hpp @@ -2,15 +2,15 @@ #include #include +#include namespace dchat { class InputDialog : public Gtk::Dialog { public: - InputDialog(const char *title, const char *text, const char *acceptText = "Create", const char *cancelText = "Cancel"); - Glib::ustring getInput() const; + InputDialog(const char *title, const std::vector &texts, const char *acceptText = "Create", const char *cancelText = "Cancel"); - Gtk::Entry entry; + std::vector entries; }; } \ No newline at end of file diff --git a/include/RoomNotificationsWindow.hpp b/include/RoomNotificationsWindow.hpp new file mode 100644 index 0000000..e4e29f5 --- /dev/null +++ b/include/RoomNotificationsWindow.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include +#include +#include +#include +#include + +namespace dchat +{ + class ChatWindow; + + class RoomNotificationsWindow : public Gtk::Stack + { + public: + RoomNotificationsWindow(ChatWindow *chatWindow); + + void addInviteRequest(const InviteUserRequest &request); + private: + class RoomNotifications : public Gtk::ScrolledWindow + { + public: + Glib::RefPtr listStore; + Gtk::TreeModelColumn userPublicKeyColumn; + Gtk::TreeModelColumn messageColumn; + Gtk::TreeModel::ColumnRecord columns; + std::unordered_map inviteRequests; + }; + + RoomNotifications* createRoomNotifications(); + + std::unordered_map roomNotificationsMap; + + ChatWindow *chatWindow; + }; +} \ No newline at end of file diff --git a/include/RoomSettingsWindow.hpp b/include/RoomSettingsWindow.hpp new file mode 100644 index 0000000..9ffd808 --- /dev/null +++ b/include/RoomSettingsWindow.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include +#include +#include +#include + +namespace Gtk +{ + class Paned; +} + +namespace dchat +{ + class ChatWindow; + + class RoomSettingsWindow : public Gtk::Grid + { + public: + RoomSettingsWindow(ChatWindow *chatWindow); + void selectRoom(std::shared_ptr room); + + void setupLeftPanel(Gtk::Paned *sidePanels); + void setupRightPanel(Gtk::Paned *sidePanels); + private: + ChatWindow *chatWindow; + Gtk::Entry roomNameEntry; + Gtk::Label inviteKey; + }; +} \ No newline at end of file diff --git a/include/Topbar.hpp b/include/Topbar.hpp new file mode 100644 index 0000000..ebb7729 --- /dev/null +++ b/include/Topbar.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include "ImageButton.hpp" +#include +#include +#include + +namespace dchat +{ + class Topbar : public Gtk::Grid + { + public: + Topbar(); + void setTitle(const Glib::ustring &title); + + ImageButton roomSettingsButton; + ImageButton roomNotificationsButton; + private: + Gtk::SearchEntry topbarSearchBar; + Gtk::Label currentRoomTitle; + }; +} \ No newline at end of file -- cgit v1.2.3