summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/Browser/DownloadWidget.cpp16
-rw-r--r--Userland/Applications/Browser/DownloadWidget.h1
-rw-r--r--Userland/Applications/Browser/Tab.cpp2
3 files changed, 18 insertions, 1 deletions
diff --git a/Userland/Applications/Browser/DownloadWidget.cpp b/Userland/Applications/Browser/DownloadWidget.cpp
index 6f3f41d395..a9a9b17cc5 100644
--- a/Userland/Applications/Browser/DownloadWidget.cpp
+++ b/Userland/Applications/Browser/DownloadWidget.cpp
@@ -7,12 +7,14 @@
#include "DownloadWidget.h"
#include <AK/NumberFormat.h>
#include <AK/StringBuilder.h>
+#include <LibCore/ConfigFile.h>
#include <LibCore/File.h>
#include <LibCore/FileStream.h>
#include <LibCore/StandardPaths.h>
#include <LibDesktop/Launcher.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h>
+#include <LibGUI/CheckBox.h>
#include <LibGUI/ImageWidget.h>
#include <LibGUI/Label.h>
#include <LibGUI/MessageBox.h>
@@ -35,6 +37,9 @@ DownloadWidget::DownloadWidget(const URL& url)
m_destination_path = builder.to_string();
}
+ auto browser_config = Core::ConfigFile::get_for_app("Browser");
+ auto close_on_finish = browser_config->read_bool_entry("Preferences", "CloseDownloadWidgetOnFinish", false);
+
m_elapsed_timer.start();
m_download = Web::ResourceLoader::the().protocol_client().start_request("GET", url);
VERIFY(m_download);
@@ -82,6 +87,14 @@ DownloadWidget::DownloadWidget(const URL& url)
destination_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
destination_label.set_fixed_height(16);
+ m_close_on_finish_checkbox = add<GUI::CheckBox>("Close when finished");
+ m_close_on_finish_checkbox->set_checked(close_on_finish);
+
+ m_close_on_finish_checkbox->on_checked = [&]() {
+ auto browser_config = Core::ConfigFile::get_for_app("Browser");
+ browser_config->write_bool_entry("Preferences", "CloseDownloadWidgetOnFinish", m_close_on_finish_checkbox->is_checked());
+ };
+
auto& button_container = add<GUI::Widget>();
auto& button_container_layout = button_container.set_layout<GUI::HorizontalBoxLayout>();
button_container_layout.add_spacer();
@@ -156,6 +169,9 @@ void DownloadWidget::did_finish(bool success)
window()->close();
return;
}
+
+ if (m_close_on_finish_checkbox->is_checked())
+ window()->close();
}
}
diff --git a/Userland/Applications/Browser/DownloadWidget.h b/Userland/Applications/Browser/DownloadWidget.h
index 2071cf650e..37da49801f 100644
--- a/Userland/Applications/Browser/DownloadWidget.h
+++ b/Userland/Applications/Browser/DownloadWidget.h
@@ -34,6 +34,7 @@ private:
RefPtr<GUI::Label> m_progress_label;
RefPtr<GUI::Button> m_cancel_button;
RefPtr<GUI::Button> m_close_button;
+ RefPtr<GUI::CheckBox> m_close_on_finish_checkbox;
OwnPtr<Core::OutputFileStream> m_output_file_stream;
Core::ElapsedTimer m_elapsed_timer;
};
diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp
index 9d180b6010..875d364a23 100644
--- a/Userland/Applications/Browser/Tab.cpp
+++ b/Userland/Applications/Browser/Tab.cpp
@@ -57,7 +57,7 @@ URL url_from_user_input(const String& input)
void Tab::start_download(const URL& url)
{
auto window = GUI::Window::construct(&this->window());
- window->resize(300, 150);
+ window->resize(300, 170);
window->set_title(String::formatted("0% of {}", url.basename()));
window->set_resizable(false);
window->set_main_widget<DownloadWidget>(url);