mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
MailSettings: Add basic mail settings dialog
MailSettings: Add a GML file for Mail settings MailSettings: Add an AF desktop file for Mail Settings MailSettings: Unveil /res in mail settings, fix GML MailSettings: Mail settings texteditor->textbox MailSettings: Update mail username to correct category in settings Modified Mail settings GML to properly represent ports >100 MailSettings: Update/fix mail settings GML MailSettings: Adjust GML, add icons for mail settings MailSettings: Change Okay button to OK MailSettings: Change mail setting reset button to revert MailSettings: Fix incorrect variable names in mail settings MailSettings: Add newlines af EOF of all mail setting files MailSettings: Mail settings linting issues fixed MailSettings: Increase size of icon features Code cleaning/styling changes as per gunnarbeutner review Made settings descriptions more friendly per sin-ack review MailSettings: Fixes as per PR comments MailSettings: Fix checkbox weirdness MailSettings: Adjust width of checkbox MailSettings: Remove unneccessary update() call MailSettings: Replace port SpinBox with ComboBox MailSettings: Add colons to labels, remove port 110 option MailSettings: Remove custom model, use ItemListModel MailSettings: Change relative icon paths to absolute ones
This commit is contained in:
parent
1bfd405353
commit
8e3431d56d
11 changed files with 370 additions and 0 deletions
5
Base/res/apps/MailSettings.af
Normal file
5
Base/res/apps/MailSettings.af
Normal file
|
@ -0,0 +1,5 @@
|
|||
[App]
|
||||
Name=Mail Settings
|
||||
Executable=/bin/MailSettings
|
||||
Category=Settings
|
||||
Description=Configure the Mail application
|
BIN
Base/res/graphics/mail-server-settings.png
Normal file
BIN
Base/res/graphics/mail-server-settings.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 828 B |
BIN
Base/res/graphics/mail-user-settings.png
Normal file
BIN
Base/res/graphics/mail-user-settings.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 732 B |
BIN
Base/res/icons/16x16/app-mail-settings.png
Normal file
BIN
Base/res/icons/16x16/app-mail-settings.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 521 B |
BIN
Base/res/icons/32x32/app-mail-settings.png
Normal file
BIN
Base/res/icons/32x32/app-mail-settings.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 610 B |
|
@ -18,6 +18,7 @@ add_subdirectory(KeyboardMapper)
|
|||
add_subdirectory(KeyboardSettings)
|
||||
add_subdirectory(Magnifier)
|
||||
add_subdirectory(Mail)
|
||||
add_subdirectory(MailSettings)
|
||||
add_subdirectory(MouseSettings)
|
||||
add_subdirectory(PDFViewer)
|
||||
add_subdirectory(Piano)
|
||||
|
|
17
Userland/Applications/MailSettings/CMakeLists.txt
Normal file
17
Userland/Applications/MailSettings/CMakeLists.txt
Normal file
|
@ -0,0 +1,17 @@
|
|||
serenity_component(
|
||||
MailSettings
|
||||
RECOMMENDED
|
||||
TARGETS MailSettings
|
||||
)
|
||||
|
||||
compile_gml(MailSettingsWindow.gml MailSettingsWindowGML.h mail_settings_window_gml)
|
||||
|
||||
set(SOURCES
|
||||
main.cpp
|
||||
MailSettingsWindow.cpp
|
||||
MailSettingsWindow.h
|
||||
MailSettingsWindowGML.h
|
||||
)
|
||||
|
||||
serenity_app(MailSettings ICON app-mail-settings)
|
||||
target_link_libraries(MailSettings LibGUI)
|
127
Userland/Applications/MailSettings/MailSettingsWindow.cpp
Normal file
127
Userland/Applications/MailSettings/MailSettingsWindow.cpp
Normal file
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
* Copyright (c) 2021, The SerenityOS developers
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "MailSettingsWindow.h"
|
||||
#include <Applications/MailSettings/MailSettingsWindowGML.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/CheckBox.h>
|
||||
#include <LibGUI/ComboBox.h>
|
||||
#include <LibGUI/ItemListModel.h>
|
||||
#include <LibGUI/Label.h>
|
||||
#include <LibGUI/TabWidget.h>
|
||||
#include <LibGUI/TextBox.h>
|
||||
#include <LibGUI/Widget.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void MailSettingsWindow::reset_default_values()
|
||||
{
|
||||
m_server_inputbox->set_text("");
|
||||
m_port_combobox->set_text("993");
|
||||
m_tls_checkbox->set_checked(false);
|
||||
m_email_inputbox->set_text("");
|
||||
}
|
||||
|
||||
void MailSettingsWindow::write_values()
|
||||
{
|
||||
m_server = m_server_inputbox->get_text();
|
||||
m_port = m_port_combobox->text();
|
||||
m_tls = m_tls_checkbox->is_checked();
|
||||
m_email = m_email_inputbox->get_text();
|
||||
|
||||
m_config->write_entry("Connection", "Server", m_server);
|
||||
m_config->write_entry("Connection", "Port", m_port);
|
||||
m_config->write_bool_entry("Connection", "TLS", m_tls);
|
||||
m_config->write_entry("User", "Username", m_email);
|
||||
m_config->sync();
|
||||
}
|
||||
|
||||
MailSettingsWindow::MailSettingsWindow()
|
||||
{
|
||||
m_config = Core::ConfigFile::get_for_app("Mail");
|
||||
if (unveil(m_config->filename().characters(), "rwc") < 0) {
|
||||
perror("unveil");
|
||||
GUI::Application::the()->quit();
|
||||
}
|
||||
|
||||
if (unveil("/res", "r") < 0) {
|
||||
perror("unveil");
|
||||
GUI::Application::the()->quit();
|
||||
}
|
||||
|
||||
if (unveil(nullptr, nullptr)) {
|
||||
perror("unveil");
|
||||
GUI::Application::the()->quit();
|
||||
}
|
||||
|
||||
//Common port values for email fetching
|
||||
m_common_ports.append("143");
|
||||
m_common_ports.append("993");
|
||||
|
||||
auto& main_widget = set_main_widget<GUI::Widget>();
|
||||
main_widget.set_fill_with_background_color(true);
|
||||
main_widget.set_layout<GUI::VerticalBoxLayout>();
|
||||
main_widget.layout()->set_margins({ 4, 4, 4, 4 });
|
||||
main_widget.layout()->set_spacing(6);
|
||||
|
||||
auto& tab_widget = main_widget.add<GUI::TabWidget>();
|
||||
auto& mail_widget = tab_widget.add_tab<GUI::Widget>("Mail");
|
||||
mail_widget.load_from_gml(mail_settings_window_gml);
|
||||
|
||||
auto& server_settings_image_label = *main_widget.find_descendant_of_type_named<GUI::Label>("server_settings_image_label");
|
||||
server_settings_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/mail-server-settings.png"));
|
||||
|
||||
auto& user_settings_image_label = *main_widget.find_descendant_of_type_named<GUI::Label>("user_settings_image_label");
|
||||
user_settings_image_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/graphics/mail-user-settings.png"));
|
||||
|
||||
m_server_inputbox = *main_widget.find_descendant_of_type_named<GUI::TextBox>("server_input");
|
||||
m_server_inputbox->set_text(m_config->read_entry("Connection", "Server", ""));
|
||||
|
||||
m_port_combobox = *main_widget.find_descendant_of_type_named<GUI::ComboBox>("port_input");
|
||||
m_port_combobox->set_text(m_config->read_entry("Connection", "Port", "993"));
|
||||
m_port_combobox->set_only_allow_values_from_model(false);
|
||||
m_port_combobox->set_model(*GUI::ItemListModel<String>::create(m_common_ports));
|
||||
|
||||
m_tls_checkbox = *main_widget.find_descendant_of_type_named<GUI::CheckBox>("tls_input");
|
||||
m_tls_checkbox->set_checked(m_config->read_bool_entry("Connection", "TLS", false));
|
||||
|
||||
m_email_inputbox = *main_widget.find_descendant_of_type_named<GUI::TextBox>("email_input");
|
||||
m_email_inputbox->set_text(m_config->read_entry("User", "Username", ""));
|
||||
|
||||
auto& button_container = main_widget.add<GUI::Widget>();
|
||||
button_container.set_shrink_to_fit(true);
|
||||
button_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||
button_container.layout()->set_spacing(6);
|
||||
|
||||
m_reset_button = button_container.add<GUI::Button>("Defaults");
|
||||
m_reset_button->set_fixed_width(75);
|
||||
m_reset_button->on_click = [this](auto) {
|
||||
reset_default_values();
|
||||
};
|
||||
|
||||
button_container.layout()->add_spacer();
|
||||
|
||||
m_ok_button = button_container.add<GUI::Button>("OK");
|
||||
m_ok_button->set_fixed_width(75);
|
||||
m_ok_button->on_click = [&](auto) {
|
||||
write_values();
|
||||
GUI::Application::the()->quit();
|
||||
};
|
||||
|
||||
m_cancel_button = button_container.add<GUI::Button>("Cancel");
|
||||
m_cancel_button->set_fixed_width(75);
|
||||
m_cancel_button->on_click = [&](auto) {
|
||||
GUI::Application::the()->quit();
|
||||
};
|
||||
|
||||
m_apply_button = button_container.add<GUI::Button>("Apply");
|
||||
m_apply_button->set_fixed_width(75);
|
||||
m_apply_button->on_click = [&](auto) {
|
||||
write_values();
|
||||
};
|
||||
}
|
146
Userland/Applications/MailSettings/MailSettingsWindow.gml
Normal file
146
Userland/Applications/MailSettings/MailSettingsWindow.gml
Normal file
|
@ -0,0 +1,146 @@
|
|||
@GUI::Frame {
|
||||
fill_with_background_color: true
|
||||
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
margins: [10, 10, 10, 10]
|
||||
spacing: 5
|
||||
}
|
||||
|
||||
@GUI::GroupBox {
|
||||
title: "Server Settings"
|
||||
fixed_height: 170
|
||||
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
margins: [8, 16, 8, 8]
|
||||
spacing: 2
|
||||
}
|
||||
|
||||
@GUI::Widget {
|
||||
layout: @GUI::HorizontalBoxLayout {
|
||||
spacing: 16
|
||||
}
|
||||
|
||||
@GUI::Label {
|
||||
fixed_width: 32
|
||||
fixed_height: 32
|
||||
name: "server_settings_image_label"
|
||||
}
|
||||
|
||||
@GUI::Label {
|
||||
text: "These settings specify the mail server from which you would like to fetch your mail."
|
||||
text_alignment: "CenterLeft"
|
||||
}
|
||||
}
|
||||
|
||||
@GUI::Widget {
|
||||
layout: @GUI::HorizontalBoxLayout {
|
||||
spacing: 16
|
||||
}
|
||||
|
||||
@GUI::Widget {
|
||||
fixed_width: 32
|
||||
}
|
||||
|
||||
@GUI::Label {
|
||||
text: "Server Address:"
|
||||
fixed_width: 80
|
||||
name: "server_label"
|
||||
text_alignment: "CenterLeft"
|
||||
}
|
||||
|
||||
@GUI::TextBox {
|
||||
name: "server_input"
|
||||
}
|
||||
}
|
||||
@GUI::Widget {
|
||||
layout: @GUI::HorizontalBoxLayout {
|
||||
spacing: 16
|
||||
}
|
||||
|
||||
@GUI::Widget {
|
||||
fixed_width: 32
|
||||
}
|
||||
|
||||
@GUI::Label {
|
||||
text: "Server Port:"
|
||||
fixed_width: 80
|
||||
name: "port_label"
|
||||
text_alignment: "CenterLeft"
|
||||
}
|
||||
|
||||
@GUI::ComboBox {
|
||||
name: "port_input"
|
||||
}
|
||||
}
|
||||
@GUI::Widget {
|
||||
layout: @GUI::HorizontalBoxLayout {
|
||||
spacing: 16
|
||||
}
|
||||
|
||||
@GUI::Widget {
|
||||
fixed_width: 32
|
||||
}
|
||||
|
||||
@GUI::Label {
|
||||
text: "Use TLS:"
|
||||
fixed_width: 80
|
||||
text_alignment: "CenterLeft"
|
||||
name: "tls_label"
|
||||
}
|
||||
|
||||
@GUI::CheckBox {
|
||||
name: "tls_input"
|
||||
fixed_width: 14
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@GUI::GroupBox {
|
||||
title: "User Settings"
|
||||
fixed_height: 110
|
||||
|
||||
layout: @GUI::VerticalBoxLayout {
|
||||
margins: [8, 16, 8, 8]
|
||||
spacing: 2
|
||||
}
|
||||
|
||||
@GUI::Widget {
|
||||
layout: @GUI::HorizontalBoxLayout {
|
||||
spacing: 16
|
||||
}
|
||||
|
||||
@GUI::Label {
|
||||
fixed_width: 32
|
||||
fixed_height: 32
|
||||
name: "user_settings_image_label"
|
||||
}
|
||||
|
||||
@GUI::Label {
|
||||
text: "These settings specify the credentials which will be used to send and receive mail, and how you identify yourself to recipients."
|
||||
text_alignment: "CenterLeft"
|
||||
}
|
||||
}
|
||||
|
||||
@GUI::Widget {
|
||||
layout: @GUI::HorizontalBoxLayout {
|
||||
spacing: 16
|
||||
}
|
||||
|
||||
@GUI::Widget {
|
||||
fixed_width: 32
|
||||
}
|
||||
|
||||
@GUI::Label {
|
||||
autosize: true
|
||||
text: "Email Address:"
|
||||
fixed_width: 80
|
||||
text_alignment: "CenterLeft"
|
||||
}
|
||||
|
||||
@GUI::TextBox {
|
||||
name: "email_input"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
37
Userland/Applications/MailSettings/MailSettingsWindow.h
Normal file
37
Userland/Applications/MailSettings/MailSettingsWindow.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2021, The SerenityOS developers
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibGUI/TextEditor.h>
|
||||
#include <LibGUI/Window.h>
|
||||
|
||||
class MailSettingsWindow final : public GUI::Window {
|
||||
C_OBJECT(MailSettingsWindow)
|
||||
|
||||
private:
|
||||
MailSettingsWindow();
|
||||
|
||||
void reset_default_values();
|
||||
void write_values();
|
||||
|
||||
String m_server;
|
||||
String m_port;
|
||||
bool m_tls { false };
|
||||
String m_email;
|
||||
Vector<String> m_common_ports;
|
||||
RefPtr<Core::ConfigFile> m_config;
|
||||
|
||||
RefPtr<GUI::TextBox> m_server_inputbox;
|
||||
RefPtr<GUI::ComboBox> m_port_combobox;
|
||||
RefPtr<GUI::CheckBox> m_tls_checkbox;
|
||||
RefPtr<GUI::TextBox> m_email_inputbox;
|
||||
|
||||
RefPtr<GUI::Button> m_reset_button;
|
||||
RefPtr<GUI::Button> m_ok_button;
|
||||
RefPtr<GUI::Button> m_cancel_button;
|
||||
RefPtr<GUI::Button> m_apply_button;
|
||||
};
|
37
Userland/Applications/MailSettings/main.cpp
Normal file
37
Userland/Applications/MailSettings/main.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2021, The SerenityOS developers
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "MailSettingsWindow.h"
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/Icon.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (pledge("stdio rpath cpath wpath recvfd sendfd unix proc exec", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto app = GUI::Application::construct(argc, argv);
|
||||
|
||||
if (pledge("stdio rpath cpath wpath recvfd sendfd proc exec", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto app_icon = GUI::Icon::default_icon("app-mail-settings");
|
||||
|
||||
auto window = MailSettingsWindow::construct();
|
||||
window->set_title("Mail Settings");
|
||||
window->resize(400, 480);
|
||||
window->set_resizable(false);
|
||||
window->set_minimizable(false);
|
||||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
|
||||
window->show();
|
||||
return app->exec();
|
||||
}
|
Loading…
Reference in a new issue