blob: f36542d8395338b0be4d4a862bc397cbf5ced55d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/*
* Copyright (c) 2022, Filiph Sandström <filiph.sandstrom@filfatstudios.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#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 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");
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());
}
|