2022-07-14 04:08:30 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Filiph Sandström <filiph.sandstrom@filfatstudios.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SettingsDialog.h"
|
2022-07-14 04:36:11 +00:00
|
|
|
#include "Settings.h"
|
|
|
|
#include <QCloseEvent>
|
|
|
|
#include <QLabel>
|
|
|
|
|
|
|
|
extern Browser::Settings* s_settings;
|
2022-07-14 04:08:30 +00:00
|
|
|
|
|
|
|
SettingsDialog::SettingsDialog(QMainWindow* window)
|
|
|
|
: m_window(window)
|
|
|
|
{
|
2022-10-01 18:46:24 +00:00
|
|
|
m_layout = new QFormLayout(this);
|
2023-01-20 23:30:05 +00:00
|
|
|
m_new_tab_page = new QLineEdit(this);
|
2022-10-01 18:46:24 +00:00
|
|
|
m_ok_button = new QPushButton("&Save", this);
|
2022-07-14 04:36:11 +00:00
|
|
|
|
2023-01-20 23:30:05 +00:00
|
|
|
m_layout->addRow(new QLabel("Page on New Tab", this), m_new_tab_page);
|
2022-07-14 04:36:11 +00:00
|
|
|
m_layout->addWidget(m_ok_button);
|
|
|
|
|
|
|
|
QObject::connect(m_ok_button, &QPushButton::released, this, [this] {
|
|
|
|
close();
|
|
|
|
});
|
2022-07-14 04:08:30 +00:00
|
|
|
|
|
|
|
setWindowTitle("Settings");
|
2022-07-14 04:36:11 +00:00
|
|
|
setFixedWidth(300);
|
2023-01-29 13:23:58 +00:00
|
|
|
setFixedHeight(150);
|
2022-07-14 04:08:30 +00:00
|
|
|
setLayout(m_layout);
|
|
|
|
show();
|
|
|
|
setFocus();
|
|
|
|
}
|
2022-07-14 04:36:11 +00:00
|
|
|
|
|
|
|
void SettingsDialog::closeEvent(QCloseEvent* event)
|
|
|
|
{
|
|
|
|
save();
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::save()
|
|
|
|
{
|
|
|
|
// FIXME: Validate data.
|
2023-01-20 23:30:05 +00:00
|
|
|
s_settings->set_new_tab_page(m_new_tab_page->text());
|
2022-07-14 04:36:11 +00:00
|
|
|
}
|