mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
UI: Copy the default config to the user's config directory
Currently only used on the Qt chrome.
This commit is contained in:
parent
5da1dae67e
commit
b61b1374f0
Notes:
sideshowbarker
2024-07-18 02:44:13 +09:00
Author: https://github.com/circl-lastname Commit: https://github.com/LadybirdBrowser/ladybird/commit/b61b1374f04 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/672
5 changed files with 31 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "Settings.h"
|
||||
#include "StringUtils.h"
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <Ladybird/DefaultSettings.h>
|
||||
|
||||
namespace Ladybird {
|
||||
|
@ -29,6 +30,11 @@ Settings::Settings()
|
|||
set_search_engine(move(default_search_engine));
|
||||
}
|
||||
|
||||
ByteString Settings::directory()
|
||||
{
|
||||
return LexicalPath::dirname(ak_byte_string_from_qstring(m_qsettings->fileName()));
|
||||
}
|
||||
|
||||
Optional<QPoint> Settings::last_position()
|
||||
{
|
||||
if (m_qsettings->contains("last_position"))
|
||||
|
|
|
@ -30,6 +30,8 @@ public:
|
|||
return &instance;
|
||||
}
|
||||
|
||||
ByteString directory();
|
||||
|
||||
Optional<QPoint> last_position();
|
||||
void set_last_position(QPoint const& last_position);
|
||||
|
||||
|
|
|
@ -153,6 +153,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
};
|
||||
#endif
|
||||
|
||||
copy_default_config_files(Ladybird::Settings::the()->directory());
|
||||
|
||||
RefPtr<WebView::Database> database;
|
||||
if (!disable_sql_database)
|
||||
database = TRY(WebView::Database::create());
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
#include "Utilities.h"
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/Platform.h>
|
||||
#include <LibCore/Directory.h>
|
||||
#include <LibCore/Environment.h>
|
||||
#include <LibCore/Resource.h>
|
||||
#include <LibCore/ResourceImplementationFile.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
|
@ -77,6 +79,24 @@ void platform_init()
|
|||
Core::ResourceImplementation::install(make<Core::ResourceImplementationFile>(MUST(String::from_byte_string(s_serenity_resource_root))));
|
||||
}
|
||||
|
||||
void copy_default_config_files(StringView config_path)
|
||||
{
|
||||
MUST(Core::Directory::create(config_path, Core::Directory::CreateDirectories::Yes));
|
||||
|
||||
auto config_resources = MUST(Core::Resource::load_from_uri("resource://ladybird/default-config"sv));
|
||||
|
||||
config_resources->for_each_descendant_file([config_path](Core::Resource const& resource) -> IterationDecision {
|
||||
auto file_path = ByteString::formatted("{}/{}", config_path, resource.filename());
|
||||
|
||||
if (Core::System::stat(file_path).is_error()) {
|
||||
auto file = MUST(Core::File::open(file_path, Core::File::OpenMode::Write));
|
||||
MUST(file->write_until_depleted(resource.data()));
|
||||
}
|
||||
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
|
||||
ErrorOr<Vector<ByteString>> get_paths_for_helper_process(StringView process_name)
|
||||
{
|
||||
auto application_path = TRY(application_directory());
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <AK/Vector.h>
|
||||
|
||||
void platform_init();
|
||||
void copy_default_config_files(StringView config_path);
|
||||
ErrorOr<ByteString> application_directory();
|
||||
ErrorOr<Vector<ByteString>> get_paths_for_helper_process(StringView process_name);
|
||||
|
||||
|
|
Loading…
Reference in a new issue