2021-12-26 23:18:28 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-09-15 22:19:59 +08:00
|
|
|
#include "projectoutputwidget.h"
|
|
|
|
#include "ui_projectoutputwidget.h"
|
|
|
|
#include "../mainwindow.h"
|
|
|
|
#include "../project.h"
|
2021-12-23 09:11:58 +08:00
|
|
|
#include "../iconsmanager.h"
|
2021-12-27 22:46:54 +08:00
|
|
|
#include "../systemconsts.h"
|
2021-09-15 22:19:59 +08:00
|
|
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
|
|
|
|
|
|
|
ProjectOutputWidget::ProjectOutputWidget(const QString &name, const QString &group, QWidget *parent) :
|
|
|
|
SettingsWidget(name,group,parent),
|
|
|
|
ui(new Ui::ProjectOutputWidget)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
ProjectOutputWidget::~ProjectOutputWidget()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectOutputWidget::doLoad()
|
|
|
|
{
|
|
|
|
ui->txtOutputDir->setText(pMainWindow->project()->options().exeOutput);
|
|
|
|
ui->txtObjOutputDir->setText(pMainWindow->project()->options().objectOutput);
|
|
|
|
ui->grpAutosaveCompileLog->setChecked(pMainWindow->project()->options().logOutputEnabled);
|
|
|
|
ui->txtCompileLog->setText(pMainWindow->project()->options().logOutput);
|
|
|
|
ui->grpOverrideOutput->setChecked(pMainWindow->project()->options().overrideOutput);
|
|
|
|
ui->txtOutputFilename->setText(pMainWindow->project()->options().overridenOutput);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ProjectOutputWidget::doSave()
|
|
|
|
{
|
|
|
|
pMainWindow->project()->options().exeOutput = ui->txtOutputDir->text();
|
|
|
|
pMainWindow->project()->options().objectOutput = ui->txtObjOutputDir->text();
|
|
|
|
pMainWindow->project()->options().logOutputEnabled = ui->grpAutosaveCompileLog->isChecked();
|
|
|
|
pMainWindow->project()->options().logOutput = ui->txtCompileLog->text();
|
|
|
|
pMainWindow->project()->options().overrideOutput = ui->grpOverrideOutput->isChecked();
|
|
|
|
pMainWindow->project()->options().overridenOutput = ui->txtOutputFilename->text();
|
|
|
|
pMainWindow->project()->saveOptions();
|
|
|
|
}
|
|
|
|
|
2022-04-08 22:14:18 +08:00
|
|
|
void ProjectOutputWidget::on_btnOutputDir_clicked()
|
2021-09-15 22:19:59 +08:00
|
|
|
{
|
|
|
|
QString dirName = QFileDialog::getExistingDirectory(
|
|
|
|
this,
|
|
|
|
tr("Executable output directory"),
|
|
|
|
pMainWindow->project()->directory());
|
|
|
|
if (!dirName.isEmpty())
|
2022-04-08 22:14:18 +08:00
|
|
|
ui->txtOutputDir->setText(extractRelativePath(pMainWindow->project()->folder(),dirName));
|
2021-09-15 22:19:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-08 22:14:18 +08:00
|
|
|
void ProjectOutputWidget::on_btnObjOutputDir_clicked()
|
2021-09-15 22:19:59 +08:00
|
|
|
{
|
|
|
|
QString dirName = QFileDialog::getExistingDirectory(
|
|
|
|
this,
|
|
|
|
tr("Object files output directory"),
|
|
|
|
pMainWindow->project()->directory());
|
|
|
|
if (!dirName.isEmpty())
|
2022-04-08 22:14:18 +08:00
|
|
|
ui->txtObjOutputDir->setText(extractRelativePath(pMainWindow->project()->folder(),dirName));
|
2021-09-15 22:19:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-08 22:14:18 +08:00
|
|
|
void ProjectOutputWidget::on_btnCompileLog_clicked()
|
2021-09-15 22:19:59 +08:00
|
|
|
{
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(
|
|
|
|
this,
|
|
|
|
tr("Log file"),
|
|
|
|
pMainWindow->project()->directory(),
|
2021-12-27 22:46:54 +08:00
|
|
|
tr("All files (%1)").arg(ALL_FILE_WILDCARD));
|
2021-09-15 22:19:59 +08:00
|
|
|
if (!fileName.isEmpty() ) {
|
2022-04-08 22:14:18 +08:00
|
|
|
ui->txtCompileLog->setText(extractRelativePath(pMainWindow->project()->folder(),fileName));
|
2021-09-15 22:19:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-23 09:11:58 +08:00
|
|
|
void ProjectOutputWidget::updateIcons(const QSize &size)
|
|
|
|
{
|
|
|
|
pIconsManager->setIcon(ui->btnCompileLog, IconsManager::ACTION_FILE_OPEN_FOLDER);
|
|
|
|
pIconsManager->setIcon(ui->btnObjOutputDir, IconsManager::ACTION_FILE_OPEN_FOLDER);
|
|
|
|
pIconsManager->setIcon(ui->btnOutputDir, IconsManager::ACTION_FILE_OPEN_FOLDER);
|
|
|
|
}
|
|
|
|
|