summaryrefslogtreecommitdiff
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
parent63486b8438a9d1ec001adc1476a75b276ee308b3 (diff)
downloadserenity-e3f81bce498523cc722524fc795f33e7d5c23c3e.zip
IRC client setttings, Terminal settings, more WM settings
-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
-rw-r--r--Base/home/anon/IRCClient.ini7
-rw-r--r--Base/home/anon/Terminal.ini2
-rw-r--r--Base/home/anon/WindowManager.ini3
-rw-r--r--LibGUI/GFontDatabase.h16
-rw-r--r--Servers/WindowServer/WSCompositor.cpp3
-rw-r--r--Servers/WindowServer/WSWindowManager.cpp41
-rw-r--r--Servers/WindowServer/WSWindowManager.h5
13 files changed, 90 insertions, 54 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();
}
diff --git a/Base/home/anon/IRCClient.ini b/Base/home/anon/IRCClient.ini
new file mode 100644
index 0000000000..bb883aa7bd
--- /dev/null
+++ b/Base/home/anon/IRCClient.ini
@@ -0,0 +1,7 @@
+[User]
+Nickname=anon_seren1ty
+
+[Connection]
+Server=chat.freenode.net
+Port=6667
+AutoJoinChannels=#serenityos
diff --git a/Base/home/anon/Terminal.ini b/Base/home/anon/Terminal.ini
new file mode 100644
index 0000000000..b8edb79301
--- /dev/null
+++ b/Base/home/anon/Terminal.ini
@@ -0,0 +1,2 @@
+[Window]
+Opacity=150
diff --git a/Base/home/anon/WindowManager.ini b/Base/home/anon/WindowManager.ini
index 2d5f54b422..8efe5831fc 100644
--- a/Base/home/anon/WindowManager.ini
+++ b/Base/home/anon/WindowManager.ini
@@ -31,3 +31,6 @@ HighlightWindowBorder2=250,187,187
HighlightWindowTitle=255,255,255
MenuSelectionColor=132,53,26
+
+[Input]
+DoubleClickSpeed=250
diff --git a/LibGUI/GFontDatabase.h b/LibGUI/GFontDatabase.h
index 5cc37cc243..e1de0baec5 100644
--- a/LibGUI/GFontDatabase.h
+++ b/LibGUI/GFontDatabase.h
@@ -6,6 +6,12 @@
class Font;
+struct Metadata {
+ String path;
+ bool is_fixed_width;
+ int glyph_height;
+};
+
class GFontDatabase {
public:
static GFontDatabase& the();
@@ -14,15 +20,13 @@ public:
void for_each_font(Function<void(const String&)>);
void for_each_fixed_width_font(Function<void(const String&)>);
+ Metadata get_metadata_by_name(const String& name) const {
+ return m_name_to_metadata.get(name);
+ };
+
private:
GFontDatabase();
~GFontDatabase();
- struct Metadata {
- String path;
- bool is_fixed_width;
- int glyph_height;
- };
-
HashMap<String, Metadata> m_name_to_metadata;
};
diff --git a/Servers/WindowServer/WSCompositor.cpp b/Servers/WindowServer/WSCompositor.cpp
index 6e3f842577..ef2b1fd87e 100644
--- a/Servers/WindowServer/WSCompositor.cpp
+++ b/Servers/WindowServer/WSCompositor.cpp
@@ -77,7 +77,8 @@ void WSCompositor::compose()
if (wm.any_opaque_window_contains_rect(dirty_rect))
continue;
m_back_painter->fill_rect(dirty_rect, wm.m_background_color);
- m_back_painter->blit(dirty_rect.location(), *m_wallpaper, dirty_rect);
+ if (m_wallpaper)
+ m_back_painter->blit(dirty_rect.location(), *m_wallpaper, dirty_rect);
}
auto compose_window = [&] (WSWindow& window) -> IterationDecision {
diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp
index 52d943ddb8..0a534ab43d 100644
--- a/Servers/WindowServer/WSWindowManager.cpp
+++ b/Servers/WindowServer/WSWindowManager.cpp
@@ -38,10 +38,9 @@ WSWindowManager::WSWindowManager()
{
s_the = this;
-
m_username = getlogin();
- reload_config();
+ reload_config(false);
struct AppMenuItem {
const char *binary_name;
@@ -63,13 +62,7 @@ WSWindowManager::WSWindowManager()
}
m_system_menu->add_item(make<WSMenuItem>(*m_system_menu, WSMenuItem::Separator));
- m_system_menu->add_item(make<WSMenuItem>(*m_system_menu, 100, "640x480"));
- m_system_menu->add_item(make<WSMenuItem>(*m_system_menu, 101, "800x600"));
- m_system_menu->add_item(make<WSMenuItem>(*m_system_menu, 102, "1024x768"));
- m_system_menu->add_item(make<WSMenuItem>(*m_system_menu, 103, "1280x720"));
- m_system_menu->add_item(make<WSMenuItem>(*m_system_menu, 104, "1440x900"));
- m_system_menu->add_item(make<WSMenuItem>(*m_system_menu, 105, "1920x1080"));
- m_system_menu->add_item(make<WSMenuItem>(*m_system_menu, 106, "2560x1440"));
+ m_system_menu->add_item(make<WSMenuItem>(*m_system_menu, 100, "Reload WM Config File"));
m_system_menu->add_item(make<WSMenuItem>(*m_system_menu, WSMenuItem::Separator));
m_system_menu->add_item(make<WSMenuItem>(*m_system_menu, 200, "About..."));
m_system_menu->on_item_activation = [this, apps] (WSMenuItem& item) {
@@ -82,25 +75,7 @@ WSWindowManager::WSWindowManager()
}
switch (item.identifier()) {
case 100:
- set_resolution(640, 480);
- break;
- case 101:
- set_resolution(800, 600);
- break;
- case 102:
- set_resolution(1024, 768);
- break;
- case 103:
- set_resolution(1280, 720);
- break;
- case 104:
- set_resolution(1440, 900);
- break;
- case 105:
- set_resolution(1920, 1080);
- break;
- case 106:
- set_resolution(2560, 1440);
+ reload_config(true);
break;
}
if (item.identifier() == 200) {
@@ -137,10 +112,16 @@ WSWindowManager::~WSWindowManager()
{
}
-void WSWindowManager::reload_config()
+void WSWindowManager::reload_config(bool set_screen)
{
m_wm_config = CConfigFile::get_for_app("WindowManager");
+ m_double_click_speed = m_wm_config->read_num_entry("Input", "DoubleClickSpeed", 250);
+
+ if (set_screen)
+ set_resolution(m_wm_config->read_num_entry("Screen", "Width", 1920),
+ m_wm_config->read_num_entry("Screen", "Height", 1080));
+
m_arrow_cursor = WSCursor::create(*GraphicsBitmap::load_from_file(m_wm_config->read_entry("Cursor", "Arrow", "")), { 2, 2 });
m_resize_horizontally_cursor = WSCursor::create(*GraphicsBitmap::load_from_file(m_wm_config->read_entry("Cursor", "ResizeH", "")));
m_resize_vertically_cursor = WSCursor::create(*GraphicsBitmap::load_from_file(m_wm_config->read_entry("Cursor", "ResizeV", "")));
@@ -669,7 +650,7 @@ void WSWindowManager::process_event_for_doubleclick(WSWindow& window, WSMouseEve
// FIXME: It might be a sensible idea to also add a distance travel check.
// If the pointer moves too far, it's not a double click.
- if (elapsed_since_last_click < 250) {
+ if (elapsed_since_last_click < m_double_click_speed) {
#if defined(DOUBLECLICK_DEBUG)
dbgprintf("Transforming MouseUp to MouseDoubleClick!\n");
#endif
diff --git a/Servers/WindowServer/WSWindowManager.h b/Servers/WindowServer/WSWindowManager.h
index b76db2a558..328fe63dd2 100644
--- a/Servers/WindowServer/WSWindowManager.h
+++ b/Servers/WindowServer/WSWindowManager.h
@@ -42,7 +42,7 @@ public:
virtual ~WSWindowManager() override;
RetainPtr<CConfigFile> wm_config() const { return m_wm_config; }
- void set_wm_config(Retained<CConfigFile> conf) { m_wm_config = conf; }
+ void reload_config(bool);
void add_window(WSWindow&);
void remove_window(WSWindow&);
@@ -156,8 +156,6 @@ private:
void tell_wm_listener_about_window_rect(WSWindow& listener, WSWindow&);
void pick_new_active_window();
- void reload_config();
-
RetainPtr<WSCursor> m_arrow_cursor;
RetainPtr<WSCursor> m_resize_horizontally_cursor;
RetainPtr<WSCursor> m_resize_vertically_cursor;
@@ -199,6 +197,7 @@ private:
CElapsedTimer m_middle_click_clock;
};
DoubleClickInfo m_double_click_info;
+ unsigned int m_double_click_speed;
WeakPtr<WSWindow> m_active_window;
WeakPtr<WSWindow> m_hovered_window;