mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
Ladybird: Allow for setting the hompage through SettingsDialog
This commit is contained in:
parent
91e5b6d4f5
commit
d60f8807e3
Notes:
sideshowbarker
2024-07-17 02:47:01 +09:00
Author: https://github.com/filiphsps Commit: https://github.com/SerenityOS/serenity/commit/d60f8807e3 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
@ -5,15 +5,44 @@
|
||||
*/
|
||||
|
||||
#include "SettingsDialog.h"
|
||||
#include "Settings.h"
|
||||
#include <QCloseEvent>
|
||||
#include <QLabel>
|
||||
|
||||
extern Browser::Settings* s_settings;
|
||||
|
||||
SettingsDialog::SettingsDialog(QMainWindow* window)
|
||||
: m_window(window)
|
||||
{
|
||||
m_layout = new QBoxLayout(QBoxLayout::Direction::TopToBottom, this);
|
||||
m_layout = new QFormLayout;
|
||||
m_homepage = new QLineEdit;
|
||||
m_ok_button = new QPushButton("&Save");
|
||||
|
||||
m_layout->addWidget(new QLabel("Homepage"));
|
||||
m_layout->addWidget(m_homepage);
|
||||
m_layout->addWidget(m_ok_button);
|
||||
|
||||
m_homepage->setText(s_settings->homepage());
|
||||
|
||||
QObject::connect(m_ok_button, &QPushButton::released, this, [this] {
|
||||
close();
|
||||
});
|
||||
|
||||
setWindowTitle("Settings");
|
||||
resize(340, 400);
|
||||
setFixedWidth(300);
|
||||
setLayout(m_layout);
|
||||
show();
|
||||
setFocus();
|
||||
}
|
||||
|
||||
void SettingsDialog::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
save();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void SettingsDialog::save()
|
||||
{
|
||||
// FIXME: Validate data.
|
||||
s_settings->set_homepage(m_homepage->text());
|
||||
}
|
||||
|
@ -4,9 +4,11 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QDialog>
|
||||
#include <QFormLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QMainWindow>
|
||||
#include <QPushButton>
|
||||
|
||||
#pragma once
|
||||
|
||||
@ -15,7 +17,13 @@ class SettingsDialog : public QDialog {
|
||||
public:
|
||||
explicit SettingsDialog(QMainWindow* window);
|
||||
|
||||
void save();
|
||||
|
||||
virtual void closeEvent(QCloseEvent*) override;
|
||||
|
||||
private:
|
||||
QBoxLayout* m_layout;
|
||||
QFormLayout* m_layout;
|
||||
QPushButton* m_ok_button { nullptr };
|
||||
QLineEdit* m_homepage { nullptr };
|
||||
QMainWindow* m_window { nullptr };
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user