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 "projectdllhostwidget.h"
18#include "ui_projectdllhostwidget.h"
19#include "../project.h"
20#include "../mainwindow.h"
21#include "../iconsmanager.h"
22#include "../systemconsts.h"
23
24#include <QFileDialog>
25
26ProjectDLLHostWidget::ProjectDLLHostWidget(const QString &name, const QString &group, QWidget *parent) :
27 SettingsWidget(name,group,parent),
28 ui(new Ui::ProjectDLLHostWidget)
29{
30 ui->setupUi(this);
31}
32
33ProjectDLLHostWidget::~ProjectDLLHostWidget()
34{
35 delete ui;
36}
37
38void ProjectDLLHostWidget::doLoad()
39{
40 ui->txtHost->setText(pMainWindow->project()->options().hostApplication);
41}
42
43void ProjectDLLHostWidget::doSave()
44{
45 pMainWindow->project()->options().hostApplication = ui->txtHost->text();
46}
47
48void ProjectDLLHostWidget::on_btnBrowse_clicked()
49{
50 QString filename = QFileDialog::getOpenFileName(
51 this,
52 tr("Choose host application"),
53 pMainWindow->project()->directory(),
54 tr("All files (%1)").arg(ALL_FILE_WILDCARD));
55 if (!filename.isEmpty() && fileExists(filename)) {
56 ui->txtHost->setText(filename);
57 }
58}
59
60void ProjectDLLHostWidget::updateIcons(const QSize &/*size*/)
61{
62 pIconsManager->setIcon(ui->btnBrowse, IconsManager::ACTION_FILE_OPEN_FOLDER);
63}
64
65