File indexing completed on 2024-04-21 04:43:21

0001 /*
0002     Copyright (C) 2014-2019 Harald Sitter <sitter@kde.org>
0003 
0004     This program is free software; you can redistribute it and/or
0005     modify it under the terms of the GNU Library General Public
0006     License as published by the Free Software Foundation; either
0007     version 2 of the License, or (at your option) version 3.
0008 
0009     This library is distributed in the hope that it will be useful,
0010     but WITHOUT ANY WARRANTY; without even the implied warranty of
0011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012     Library General Public License for more details.
0013 
0014     You should have received a copy of the GNU Library General Public License
0015     along with this library; see the file COPYING.LIB.  If not, write to
0016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017     Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #include "settings.h"
0021 #include "ui_settings.h"
0022 
0023 #include <QApplication>
0024 
0025 Settings::Settings(QWidget *parent)
0026     : QDialog(parent)
0027     , ui(new Ui::Settings)
0028 {
0029     ui->setupUi(this);
0030     ui->devicePreference->load();
0031     ui->backendSelection->load();
0032 
0033     // Force first tab regardless of what the UI file wants.
0034     ui->tabs->setCurrentIndex(0);
0035 
0036     connect(ui->buttonBox, &QDialogButtonBox::accepted,
0037             this, [=] {
0038         save();
0039         qApp->quit();
0040     });
0041     connect(ui->buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked,
0042             this, &Settings::save);
0043     connect(ui->buttonBox, &QDialogButtonBox::rejected,
0044             qApp, &QApplication::quit);
0045 }
0046 
0047 Settings::~Settings()
0048 {
0049     delete ui;
0050 }
0051 
0052 void Settings::save()
0053 {
0054     ui->devicePreference->save();
0055     ui->backendSelection->save();
0056 }