1/*
2 * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#include "executorproblemsetwidget.h"
18#include "ui_executorproblemsetwidget.h"
19#include "../settings.h"
20#include "../mainwindow.h"
21
22ExecutorProblemSetWidget::ExecutorProblemSetWidget(const QString& name, const QString& group, QWidget *parent):
23 SettingsWidget(name,group,parent),
24 ui(new Ui::ExecutorProblemSetWidget)
25{
26 ui->setupUi(this);
27}
28
29ExecutorProblemSetWidget::~ExecutorProblemSetWidget()
30{
31 delete ui;
32}
33
34void ExecutorProblemSetWidget::doLoad()
35{
36 ui->grpProblemSet->setChecked(pSettings->executor().enableProblemSet());
37 ui->grpCompetitiveCompanion->setChecked(pSettings->executor().enableCompetitiveCompanion());
38 ui->spinPortNumber->setValue(pSettings->executor().competivieCompanionPort());
39 ui->chkIgnoreSpacesWhenValidatingCases->setChecked(pSettings->executor().ignoreSpacesWhenValidatingCases());
40
41 ui->cbFont->setCurrentFont(QFont(pSettings->executor().caseEditorFontName()));
42 ui->spinFontSize->setValue(pSettings->executor().caseEditorFontSize());
43 ui->chkOnlyMonospaced->setChecked(pSettings->executor().caseEditorFontOnlyMonospaced());
44 ui->grpEnableTimeout->setChecked(pSettings->executor().enableCaseTimeout());
45
46 ui->spinCaseTimeout->setValue(pSettings->executor().caseTimeout());
47}
48
49void ExecutorProblemSetWidget::doSave()
50{
51 pSettings->executor().setEnableProblemSet(ui->grpProblemSet->isChecked());
52 pSettings->executor().setEnableCompetitiveCompanion(ui->grpCompetitiveCompanion->isChecked());
53 pSettings->executor().setCompetivieCompanionPort(ui->spinPortNumber->value());
54 pSettings->executor().setIgnoreSpacesWhenValidatingCases(ui->chkIgnoreSpacesWhenValidatingCases->isChecked());
55 pSettings->executor().setCaseEditorFontName(ui->cbFont->currentFont().family());
56 pSettings->executor().setCaseEditorFontOnlyMonospaced(ui->chkOnlyMonospaced->isChecked());
57 pSettings->executor().setCaseEditorFontSize(ui->spinFontSize->value());
58 pSettings->executor().setEnableCaseTimeout(ui->grpEnableTimeout->isChecked());
59 pSettings->executor().setCaseTimeout(ui->spinCaseTimeout->value());
60 pSettings->executor().save();
61 pMainWindow->applySettings();
62}
63
64void ExecutorProblemSetWidget::on_chkOnlyMonospaced_stateChanged(int )
65{
66 if (ui->chkOnlyMonospaced->isChecked()) {
67 ui->cbFont->setFontFilters(QFontComboBox::FontFilter::MonospacedFonts);
68 } else {
69 ui->cbFont->setFontFilters(QFontComboBox::FontFilter::AllFonts);
70 }
71}
72
73