summaryrefslogtreecommitdiff
path: root/Applications
diff options
context:
space:
mode:
authorChristopher Dumas <christopherdumas@gmail.com>2019-05-25 16:43:15 -0700
committerAndreas Kling <awesomekling@gmail.com>2019-05-27 21:40:53 +0200
commite3f81bce498523cc722524fc795f33e7d5c23c3e (patch)
tree135f279eb7919a61418a7dd261df2f144d317208 /Applications
parent63486b8438a9d1ec001adc1476a75b276ee308b3 (diff)
downloadserenity-e3f81bce498523cc722524fc795f33e7d5c23c3e.zip
IRC client setttings, Terminal settings, more WM settings
Diffstat (limited to 'Applications')
-rw-r--r--Applications/IRCClient/IRCAppWindow.cpp14
-rw-r--r--Applications/IRCClient/IRCClient.cpp14
-rw-r--r--Applications/IRCClient/IRCClient.h4
-rw-r--r--Applications/Terminal/Terminal.cpp18
-rw-r--r--Applications/Terminal/Terminal.h7
-rw-r--r--Applications/Terminal/main.cpp10
6 files changed, 53 insertions, 14 deletions
diff --git a/Applications/IRCClient/IRCAppWindow.cpp b/Applications/IRCClient/IRCAppWindow.cpp
index c49125ef20..c6ebb54226 100644
--- a/Applications/IRCClient/IRCAppWindow.cpp
+++ b/Applications/IRCClient/IRCAppWindow.cpp
@@ -52,12 +52,14 @@ void IRCAppWindow::setup_client()
m_client.join_channel("#test");
};
- GInputBox input_box("Enter server:", "Connect to server", this);
- auto result = input_box.exec();
- if (result == GInputBox::ExecCancel)
- ::exit(0);
-
- m_client.set_server(input_box.text_value(), 6667);
+ if (m_client.hostname() == "none") {
+ GInputBox input_box("Enter server:", "Connect to server", this);
+ auto result = input_box.exec();
+ if (result == GInputBox::ExecCancel)
+ ::exit(0);
+
+ m_client.set_server(input_box.text_value(), 6667);
+ }
update_title();
bool success = m_client.connect();
ASSERT(success);
diff --git a/Applications/IRCClient/IRCClient.cpp b/Applications/IRCClient/IRCClient.cpp
index fe36914278..76a3f16535 100644
--- a/Applications/IRCClient/IRCClient.cpp
+++ b/Applications/IRCClient/IRCClient.cpp
@@ -31,8 +31,12 @@ IRCClient::IRCClient()
: m_nickname("seren1ty")
, m_client_window_list_model(IRCWindowListModel::create(*this))
, m_log(IRCLogBuffer::create())
+ , m_config(CConfigFile::get_for_app("IRCClient"))
{
m_socket = new CTCPSocket(this);
+ m_nickname = m_config->read_entry("User", "Nickname", "seren1ty");
+ m_hostname = m_config->read_entry("Connection", "Server", "chat.freenode.net");
+ m_port = m_config->read_num_entry("Connection", "Port", 6667);
}
IRCClient::~IRCClient()
@@ -53,8 +57,16 @@ void IRCClient::on_socket_connected()
send_user();
send_nick();
- if (on_connect)
+ if (on_connect) {
+ auto channel_str = m_config->read_entry("Connection", "AutoJoinChannels", "#test");
+ dbgprintf("IRCClient: Channels to autojoin: %s\n", channel_str.characters());
+ auto channels = channel_str.split(',');
+ for (auto channel : channels) {
+ join_channel(channel);
+ dbgprintf("IRCClient: Auto joining channel: %s\n", channel.characters());
+ }
on_connect();
+ }
}
bool IRCClient::connect()
diff --git a/Applications/IRCClient/IRCClient.h b/Applications/IRCClient/IRCClient.h
index 4502cb0b5f..98fb7664ff 100644
--- a/Applications/IRCClient/IRCClient.h
+++ b/Applications/IRCClient/IRCClient.h
@@ -5,6 +5,7 @@
#include <AK/CircularQueue.h>
#include <AK/Function.h>
#include <LibCore/CTCPSocket.h>
+#include <LibCore/CConfigFile.h>
#include "IRCLogBuffer.h"
#include "IRCWindow.h"
@@ -111,7 +112,7 @@ private:
void on_socket_connected();
- String m_hostname;
+ String m_hostname { "none" };
int m_port { 6667 };
CTCPSocket* m_socket { nullptr };
@@ -127,4 +128,5 @@ private:
Retained<IRCWindowListModel> m_client_window_list_model;
Retained<IRCLogBuffer> m_log;
+ Retained<CConfigFile> m_config;
};
diff --git a/Applications/Terminal/Terminal.cpp b/Applications/Terminal/Terminal.cpp
index 4f1f23905f..2b987e8b21 100644
--- a/Applications/Terminal/Terminal.cpp
+++ b/Applications/Terminal/Terminal.cpp
@@ -17,21 +17,30 @@
//#define TERMINAL_DEBUG
-Terminal::Terminal(int ptm_fd)
+Terminal::Terminal(int ptm_fd, RetainPtr<CConfigFile> config)
: m_ptm_fd(ptm_fd)
, m_notifier(ptm_fd, CNotifier::Read)
+ , m_config(config)
{
set_frame_shape(FrameShape::Container);
set_frame_shadow(FrameShadow::Sunken);
set_frame_thickness(2);
- m_cursor_blink_timer.set_interval(500);
+ dbgprintf("Terminal: Load config file from %s\n", m_config->file_name().characters());
+ m_cursor_blink_timer.set_interval(m_config->read_num_entry("Text",
+ "CursorBlinkInterval",
+ 500));
m_cursor_blink_timer.on_timeout = [this] {
m_cursor_blink_state = !m_cursor_blink_state;
update_cursor();
};
- set_font(Font::default_fixed_width_font());
+ auto font_entry = m_config->read_entry("Text", "Font", "default");
+ if (font_entry == "default")
+ set_font(Font::default_fixed_width_font());
+ else
+ set_font(Font::load_from_file(font_entry));
+
m_notifier.on_ready_to_read = [this]{
byte buffer[BUFSIZ];
ssize_t nread = read(m_ptm_fd, buffer, sizeof(buffer));
@@ -53,7 +62,8 @@ Terminal::Terminal(int ptm_fd)
m_line_height = font().glyph_height() + m_line_spacing;
- set_size(80, 25);
+ set_size(m_config->read_num_entry("Window", "Width", 80),
+ m_config->read_num_entry("Window", "Height", 25));
}
Terminal::Line::Line(word columns)
diff --git a/Applications/Terminal/Terminal.h b/Applications/Terminal/Terminal.h
index 97f4ddd3ba..52484080d7 100644
--- a/Applications/Terminal/Terminal.h
+++ b/Applications/Terminal/Terminal.h
@@ -8,12 +8,13 @@
#include <LibGUI/GFrame.h>
#include <LibCore/CNotifier.h>
#include <LibCore/CTimer.h>
+#include <LibCore/CConfigFile.h>
class Font;
class Terminal final : public GFrame {
public:
- explicit Terminal(int ptm_fd);
+ explicit Terminal(int ptm_fd, RetainPtr<CConfigFile> config);
virtual ~Terminal() override;
void create_window();
@@ -26,6 +27,8 @@ public:
void set_opacity(float);
+ RetainPtr<CConfigFile> config() const { return m_config; }
+
private:
typedef Vector<unsigned, 4> ParamVector;
@@ -42,6 +45,7 @@ private:
void invalidate_cursor();
void set_window_title(const String&);
+
void inject_string(const String&);
void unimplemented_escape();
void unimplemented_xterm_escape();
@@ -165,4 +169,5 @@ private:
int m_glyph_width { 0 };
CTimer m_cursor_blink_timer;
+ RetainPtr<CConfigFile> m_config;
};
diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp
index 0a1eacbb1d..ba0d95f7c5 100644
--- a/Applications/Terminal/main.cpp
+++ b/Applications/Terminal/main.cpp
@@ -94,7 +94,8 @@ int main(int argc, char** argv)
window->set_double_buffering_enabled(false);
window->set_should_exit_event_loop_on_close(true);
- Terminal terminal(ptm_fd);
+ RetainPtr<CConfigFile> config = CConfigFile::get_for_app("Terminal");
+ Terminal terminal(ptm_fd, config);
window->set_has_alpha_channel(true);
window->set_main_widget(&terminal);
window->move_to(300, 300);
@@ -119,6 +120,9 @@ int main(int argc, char** argv)
slider->set_range(0, 100);
slider->set_value(100);
+ auto new_opacity = config->read_num_entry("Window", "Opacity", 255);
+ terminal.set_opacity((float)new_opacity / 255.0);
+
auto menubar = make<GMenuBar>();
auto app_menu = make<GMenu>("Terminal");
@@ -136,6 +140,9 @@ int main(int argc, char** argv)
GFontDatabase::the().for_each_fixed_width_font([&] (const String& font_name) {
font_menu->add_action(GAction::create(font_name, [&terminal] (const GAction& action) {
terminal.set_font(GFontDatabase::the().get_by_name(action.text()));
+ auto metadata = GFontDatabase::the().get_metadata_by_name(action.text());
+ terminal.config()->write_entry("Text", "Font", metadata.path);
+ terminal.config()->sync();
terminal.force_repaint();
}));
});
@@ -149,5 +156,6 @@ int main(int argc, char** argv)
app.set_menubar(move(menubar));
+ config->sync();
return app.exec();
}