2020-01-18 11:38:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2019-03-15 14:14:23 +03:00
|
|
|
#pragma once
|
|
|
|
|
2020-02-06 22:33:02 +03:00
|
|
|
#include <LibGUI/Widget.h>
|
2020-03-07 12:32:51 +03:00
|
|
|
#include <LibWeb/Forward.h>
|
2019-03-15 14:14:23 +03:00
|
|
|
|
2019-03-16 03:45:49 +03:00
|
|
|
class IRCChannel;
|
2019-03-15 15:07:04 +03:00
|
|
|
class IRCClient;
|
2019-03-16 03:45:49 +03:00
|
|
|
class IRCQuery;
|
2019-03-15 15:07:04 +03:00
|
|
|
class IRCLogBuffer;
|
|
|
|
|
2020-02-02 17:07:41 +03:00
|
|
|
class IRCWindow : public GUI::Widget {
|
2019-07-25 20:49:28 +03:00
|
|
|
C_OBJECT(IRCWindow)
|
2019-03-15 14:14:23 +03:00
|
|
|
public:
|
2019-06-07 18:13:23 +03:00
|
|
|
enum Type {
|
2019-03-15 15:07:04 +03:00
|
|
|
Server,
|
|
|
|
Channel,
|
|
|
|
Query,
|
|
|
|
};
|
|
|
|
|
2019-03-16 03:15:19 +03:00
|
|
|
virtual ~IRCWindow() override;
|
2019-03-15 14:14:23 +03:00
|
|
|
|
|
|
|
String name() const { return m_name; }
|
|
|
|
void set_name(const String& name) { m_name = name; }
|
|
|
|
|
2019-03-15 15:07:04 +03:00
|
|
|
Type type() const { return m_type; }
|
|
|
|
|
|
|
|
void set_log_buffer(const IRCLogBuffer&);
|
|
|
|
|
2019-03-16 04:14:53 +03:00
|
|
|
bool is_active() const;
|
|
|
|
|
|
|
|
int unread_count() const;
|
|
|
|
void clear_unread_count();
|
|
|
|
|
2020-03-26 22:11:23 +03:00
|
|
|
void did_add_message(const String& name = {}, const String& message = {});
|
2019-03-16 04:14:53 +03:00
|
|
|
|
2019-03-16 03:45:49 +03:00
|
|
|
IRCChannel& channel() { return *(IRCChannel*)m_owner; }
|
|
|
|
const IRCChannel& channel() const { return *(const IRCChannel*)m_owner; }
|
|
|
|
|
|
|
|
IRCQuery& query() { return *(IRCQuery*)m_owner; }
|
|
|
|
const IRCQuery& query() const { return *(const IRCQuery*)m_owner; }
|
|
|
|
|
2019-03-15 14:14:23 +03:00
|
|
|
private:
|
2020-02-23 14:07:13 +03:00
|
|
|
IRCWindow(IRCClient&, void* owner, Type, const String& name);
|
|
|
|
|
2020-03-26 22:18:22 +03:00
|
|
|
void post_notification_if_needed(const String& name, const String& message);
|
|
|
|
|
2020-09-10 19:42:26 +03:00
|
|
|
NonnullRefPtr<IRCClient> m_client;
|
2019-03-16 03:45:49 +03:00
|
|
|
void* m_owner { nullptr };
|
2019-03-15 15:07:04 +03:00
|
|
|
Type m_type;
|
2019-03-15 14:14:23 +03:00
|
|
|
String m_name;
|
2020-08-17 16:58:29 +03:00
|
|
|
RefPtr<Web::InProcessWebView> m_page_view;
|
2020-05-27 21:25:13 +03:00
|
|
|
RefPtr<GUI::TextBox> m_text_box;
|
2019-06-21 19:37:47 +03:00
|
|
|
RefPtr<IRCLogBuffer> m_log_buffer;
|
2020-04-07 20:14:28 +03:00
|
|
|
RefPtr<GUI::Menu> m_context_menu;
|
2019-03-16 04:14:53 +03:00
|
|
|
int m_unread_count { 0 };
|
2019-03-15 14:14:23 +03:00
|
|
|
};
|