mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 17:17:42 +00:00
IRCClient: Start using GStackWidget for the subwindows.
This commit is contained in:
parent
497300c492
commit
1089cd1378
5 changed files with 22 additions and 20 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "IRCAppWindow.h"
|
||||
#include "IRCClientWindow.h"
|
||||
#include "IRCClientWindowListModel.h"
|
||||
#include <LibGUI/GStackWidget.h>
|
||||
#include <LibGUI/GTableView.h>
|
||||
#include <LibGUI/GBoxLayout.h>
|
||||
|
||||
|
@ -28,14 +29,6 @@ void IRCAppWindow::setup_client()
|
|||
ensure_window(IRCClientWindow::Channel, channel_name);
|
||||
};
|
||||
|
||||
m_client.on_query_message = [this] (const String& name) {
|
||||
// FIXME: Update query view.
|
||||
};
|
||||
|
||||
m_client.on_channel_message = [this] (const String& channel_name) {
|
||||
// FIXME: Update channel view.
|
||||
};
|
||||
|
||||
m_client.connect();
|
||||
}
|
||||
|
||||
|
@ -46,22 +39,23 @@ void IRCAppWindow::setup_widgets()
|
|||
set_main_widget(widget);
|
||||
widget->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
|
||||
auto* subwindow_list = new GTableView(widget);
|
||||
subwindow_list->set_headers_visible(false);
|
||||
subwindow_list->set_model(OwnPtr<IRCClientWindowListModel>(m_client.client_window_list_model()));
|
||||
subwindow_list->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
subwindow_list->set_preferred_size({ 120, 0 });
|
||||
auto* window_list = new GTableView(widget);
|
||||
window_list->set_headers_visible(false);
|
||||
window_list->set_model(OwnPtr<IRCClientWindowListModel>(m_client.client_window_list_model()));
|
||||
window_list->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
window_list->set_preferred_size({ 120, 0 });
|
||||
m_client.client_window_list_model()->on_activation = [this] (IRCClientWindow& window) {
|
||||
m_container->set_active_widget(&window);
|
||||
};
|
||||
|
||||
m_subwindow_container = new GWidget(widget);
|
||||
m_subwindow_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
m_subwindow_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fill);
|
||||
m_container = new GStackWidget(widget);
|
||||
|
||||
create_subwindow(IRCClientWindow::Server, "Server");
|
||||
}
|
||||
|
||||
IRCClientWindow& IRCAppWindow::create_subwindow(IRCClientWindow::Type type, const String& name)
|
||||
{
|
||||
return *new IRCClientWindow(m_client, type, name, m_subwindow_container);
|
||||
return *new IRCClientWindow(m_client, type, name, m_container);
|
||||
}
|
||||
|
||||
IRCClientWindow& IRCAppWindow::ensure_window(IRCClientWindow::Type type, const String& name)
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include "IRCClient.h"
|
||||
#include "IRCClientWindow.h"
|
||||
|
||||
class GStackWidget;
|
||||
|
||||
class IRCAppWindow : public GWindow {
|
||||
public:
|
||||
IRCAppWindow();
|
||||
|
@ -19,5 +21,5 @@ private:
|
|||
|
||||
IRCClient m_client;
|
||||
|
||||
GWidget* m_subwindow_container { nullptr };
|
||||
GStackWidget* m_container { nullptr };
|
||||
};
|
||||
|
|
|
@ -199,7 +199,7 @@ void IRCClient::join_channel(const String& channel_name)
|
|||
send(String::format("JOIN %s\r\n", channel_name.characters()));
|
||||
}
|
||||
|
||||
void IRCClient::handle(const Message& msg, const String& verbatim)
|
||||
void IRCClient::handle(const Message& msg, const String&)
|
||||
{
|
||||
printf("IRCClient::execute: prefix='%s', command='%s', arguments=%d\n",
|
||||
msg.prefix.characters(),
|
||||
|
|
|
@ -52,6 +52,8 @@ void IRCClientWindowListModel::update()
|
|||
did_update();
|
||||
}
|
||||
|
||||
void IRCClientWindowListModel::activate(const GModelIndex&)
|
||||
void IRCClientWindowListModel::activate(const GModelIndex& index)
|
||||
{
|
||||
if (on_activation)
|
||||
on_activation(m_client.window_at(index.row()));
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibGUI/GTableModel.h>
|
||||
#include <AK/Function.h>
|
||||
|
||||
class IRCClient;
|
||||
class IRCClientWindow;
|
||||
|
||||
class IRCClientWindowListModel final : public GTableModel {
|
||||
public:
|
||||
|
@ -21,6 +23,8 @@ public:
|
|||
virtual void update() override;
|
||||
virtual void activate(const GModelIndex&) override;
|
||||
|
||||
Function<void(IRCClientWindow&)> on_activation;
|
||||
|
||||
private:
|
||||
IRCClient& m_client;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue