| 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 "environmentprogramswidget.h" |
| 18 | #include "ui_environmentprogramswidget.h" |
| 19 | #include "../settings.h" |
| 20 | #include "../iconsmanager.h" |
| 21 | #include "../systemconsts.h" |
| 22 | |
| 23 | #include <QFileDialog> |
| 24 | |
| 25 | EnvironmentProgramsWidget::EnvironmentProgramsWidget(const QString& name, const QString& group, QWidget *parent) : |
| 26 | SettingsWidget(name,group,parent), |
| 27 | ui(new Ui::EnvironmentProgramsWidget) |
| 28 | { |
| 29 | ui->setupUi(this); |
| 30 | } |
| 31 | |
| 32 | EnvironmentProgramsWidget::~EnvironmentProgramsWidget() |
| 33 | { |
| 34 | delete ui; |
| 35 | } |
| 36 | |
| 37 | void EnvironmentProgramsWidget::doLoad() |
| 38 | { |
| 39 | ui->txtTerminal->setText(pSettings->environment().terminalPath()); |
| 40 | } |
| 41 | |
| 42 | void EnvironmentProgramsWidget::doSave() |
| 43 | { |
| 44 | pSettings->environment().setTerminalPath(ui->txtTerminal->text()); |
| 45 | pSettings->environment().save(); |
| 46 | } |
| 47 | |
| 48 | void EnvironmentProgramsWidget::updateIcons(const QSize &) |
| 49 | { |
| 50 | pIconsManager->setIcon(ui->btnChooseTerminal,IconsManager::ACTION_FILE_OPEN_FOLDER); |
| 51 | } |
| 52 | |
| 53 | void EnvironmentProgramsWidget::on_btnChooseTerminal_clicked() |
| 54 | { |
| 55 | QString filename = QFileDialog::getOpenFileName( |
| 56 | this, |
| 57 | tr("Choose Terminal Program" ), |
| 58 | QString(), |
| 59 | tr("All files (%1)" ).arg(ALL_FILE_WILDCARD)); |
| 60 | if (!filename.isEmpty() && fileExists(filename) ) { |
| 61 | ui->txtTerminal->setText(filename); |
| 62 | } |
| 63 | } |
| 64 | |