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 "executorgeneralwidget.h"
18#include "ui_executorgeneralwidget.h"
19#include "../settings.h"
20#include "../iconsmanager.h"
21#include "../systemconsts.h"
22
23#include <QFileDialog>
24
25ExecutorGeneralWidget::ExecutorGeneralWidget(const QString& name, const QString& group, QWidget *parent):
26 SettingsWidget(name,group,parent),
27 ui(new Ui::ExecutorGeneralWidget)
28{
29 ui->setupUi(this);
30}
31
32ExecutorGeneralWidget::~ExecutorGeneralWidget()
33{
34 delete ui;
35}
36
37void ExecutorGeneralWidget::doLoad()
38{
39 ui->chkPauseConsole->setChecked(pSettings->executor().pauseConsole());
40 ui->chkMinimizeOnRun->setChecked(pSettings->executor().minimizeOnRun());
41 ui->grpExecuteParameters->setChecked(pSettings->executor().useParams());
42 ui->txtExecuteParamaters->setText(pSettings->executor().params());
43 ui->grpRedirectInput->setChecked(pSettings->executor().redirectInput());
44 ui->txtRedirectInputFile->setText(pSettings->executor().inputFilename());
45}
46
47void ExecutorGeneralWidget::doSave()
48{
49 pSettings->executor().setPauseConsole(ui->chkPauseConsole->isChecked());
50 pSettings->executor().setMinimizeOnRun(ui->chkMinimizeOnRun->isChecked());
51 pSettings->executor().setUseParams(ui->grpExecuteParameters->isChecked());
52 pSettings->executor().setParams(ui->txtExecuteParamaters->text());
53 pSettings->executor().setRedirectInput(ui->grpRedirectInput->isChecked());
54 pSettings->executor().setInputFilename(ui->txtRedirectInputFile->text());
55
56 pSettings->executor().save();
57}
58
59void ExecutorGeneralWidget::on_btnBrowse_clicked()
60{
61 QString filename = QFileDialog::getOpenFileName(
62 this,
63 tr("Choose input file"),
64 QString(),
65 tr("All files (%1)").arg(ALL_FILE_WILDCARD));
66 if (!filename.isEmpty() && fileExists(filename)) {
67 ui->txtRedirectInputFile->setText(filename);
68 }
69}
70
71void ExecutorGeneralWidget::updateIcons(const QSize &/*size*/)
72{
73 pIconsManager->setIcon(ui->btnBrowse,IconsManager::ACTION_FILE_OPEN_FOLDER);
74}
75
76