mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
Ladybird: Add Settings class
This commit is contained in:
parent
1b682e4b2c
commit
a838004725
Notes:
sideshowbarker
2024-07-17 11:30:05 +09:00
Author: https://github.com/filiphsps Commit: https://github.com/SerenityOS/serenity/commit/a838004725 Pull-request: https://github.com/SerenityOS/serenity/pull/16583 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/awesomekling ✅ Reviewed-by: https://github.com/linusg
@ -53,6 +53,7 @@ set(SOURCES
|
||||
main.cpp
|
||||
WebView.cpp
|
||||
History.cpp
|
||||
Settings.cpp
|
||||
Tab.cpp
|
||||
)
|
||||
|
||||
|
26
Ladybird/Settings.cpp
Normal file
26
Ladybird/Settings.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Filiph Sandström <filiph.sandstrom@filfatstudios.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "Settings.h"
|
||||
|
||||
namespace Browser {
|
||||
|
||||
Settings::Settings()
|
||||
{
|
||||
m_qsettings = new QSettings("Serenity", "Ladybird");
|
||||
}
|
||||
|
||||
QString Settings::homepage()
|
||||
{
|
||||
return m_qsettings->value("homepage", "https://www.serenityos.org/").toString();
|
||||
}
|
||||
|
||||
void Settings::set_homepage(QString const& homepage)
|
||||
{
|
||||
m_qsettings->setValue("homepage", homepage);
|
||||
}
|
||||
|
||||
}
|
27
Ladybird/Settings.h
Normal file
27
Ladybird/Settings.h
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Filiph Sandström <filiph.sandstrom@filfatstudios.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define AK_DONT_REPLACE_STD
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <QSettings>
|
||||
|
||||
namespace Browser {
|
||||
|
||||
class Settings {
|
||||
public:
|
||||
Settings();
|
||||
|
||||
QString homepage();
|
||||
void set_homepage(QString const& homepage);
|
||||
|
||||
private:
|
||||
QSettings* m_qsettings;
|
||||
};
|
||||
|
||||
}
|
@ -8,11 +8,13 @@
|
||||
#include "Tab.h"
|
||||
#include "BrowserWindow.h"
|
||||
#include "History.h"
|
||||
#include "Settings.h"
|
||||
#include <QCoreApplication>
|
||||
#include <QPoint>
|
||||
#include <QToolTip>
|
||||
|
||||
extern String s_serenity_resource_root;
|
||||
extern Browser::Settings* s_settings;
|
||||
|
||||
Tab::Tab(QMainWindow* window)
|
||||
: m_window(window)
|
||||
@ -100,7 +102,7 @@ void Tab::forward()
|
||||
|
||||
void Tab::home()
|
||||
{
|
||||
navigate("https://www.serenityos.org/");
|
||||
navigate(s_settings->homepage());
|
||||
}
|
||||
|
||||
void Tab::reload()
|
||||
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "BrowserWindow.h"
|
||||
#include "Settings.h"
|
||||
#include "WebView.h"
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
@ -14,6 +15,7 @@
|
||||
#include <QWidget>
|
||||
|
||||
extern void initialize_web_engine();
|
||||
Browser::Settings* s_settings;
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
@ -25,6 +27,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
args_parser.add_positional_argument(url, "URL to open", "url", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
|
||||
s_settings = new Browser::Settings();
|
||||
|
||||
Core::EventLoop event_loop;
|
||||
|
||||
QApplication app(arguments.argc, arguments.argv);
|
||||
|
Loading…
Reference in New Issue
Block a user