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 "projectprecompilewidget.h" |
18 | #include "ui_projectprecompilewidget.h" |
19 | #include "../mainwindow.h" |
20 | #include "../project.h" |
21 | #include "../iconsmanager.h" |
22 | |
23 | #include <QFileDialog> |
24 | |
25 | ProjectPreCompileWidget::ProjectPreCompileWidget(const QString &name, const QString &group, QWidget *parent) : |
26 | SettingsWidget(name,group,parent), |
27 | ui(new Ui::ProjectPreCompileWidget) |
28 | { |
29 | ui->setupUi(this); |
30 | } |
31 | |
32 | ProjectPreCompileWidget::~ProjectPreCompileWidget() |
33 | { |
34 | delete ui; |
35 | } |
36 | |
37 | void ProjectPreCompileWidget::doLoad() |
38 | { |
39 | ui->grpPrecompileHeader->setChecked(pMainWindow->project()->options().usePrecompiledHeader); |
40 | ui->txtPrecompileHeader->setText(pMainWindow->project()->options().precompiledHeader); |
41 | } |
42 | |
43 | void ProjectPreCompileWidget::doSave() |
44 | { |
45 | pMainWindow->project()->options().usePrecompiledHeader = ui->grpPrecompileHeader->isChecked(); |
46 | pMainWindow->project()->options().precompiledHeader = ui->txtPrecompileHeader->text(); |
47 | pMainWindow->project()->saveOptions(); |
48 | } |
49 | |
50 | void ProjectPreCompileWidget::on_btnBrowse_clicked() |
51 | { |
52 | QString fileName = QFileDialog::getOpenFileName( |
53 | this, |
54 | tr("Precompiled header" ), |
55 | pMainWindow->project()->directory(), |
56 | tr("header files (*.h)" )); |
57 | if (!fileName.isEmpty() && QFileInfo(fileName).exists()) { |
58 | ui->txtPrecompileHeader->setText(fileName); |
59 | } |
60 | } |
61 | |
62 | void ProjectPreCompileWidget::updateIcons(const QSize &/*size*/) |
63 | { |
64 | pIconsManager->setIcon(ui->btnBrowse, IconsManager::ACTION_FILE_OPEN_FOLDER); |
65 | } |
66 | |
67 | |