File indexing completed on 2024-05-19 05:41:56
0001 /* 0002 // Copyright 2023 Codethink Ltd <codethink@codethink.co.uk> 0003 // SPDX-License-Identifier: Apache-2.0 0004 // 0005 // Licensed under the Apache License, Version 2.0 (the "License"); 0006 // you may not use this file except in compliance with the License. 0007 // You may obtain a copy of the License at 0008 // 0009 // http://www.apache.org/licenses/LICENSE-2.0 0010 // 0011 // Unless required by applicable law or agreed to in writing, software 0012 // distributed under the License is distributed on an "AS IS" BASIS, 0013 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0014 // See the License for the specific language governing permissions and 0015 // limitations under the License. 0016 */ 0017 0018 #include <projectsettingsdialog.h> 0019 #include <ui_projectsettingsdialog.h> 0020 0021 #include <QDebug> 0022 #include <QFileDialog> 0023 0024 ProjectSettingsDialog::ProjectSettingsDialog(Codethink::lvtprj::ProjectFile& projectFile): 0025 ui(std::make_unique<Ui::ProjectSettingsDialog>()), d_projectFile(projectFile) 0026 { 0027 ui->setupUi(this); 0028 0029 ui->projectNameValue->setText(QString::fromStdString(d_projectFile.projectName())); 0030 ui->sourceCodePathValue->setText(QString::fromStdString(d_projectFile.sourceCodePath().string())); 0031 0032 auto *applyBtn = ui->buttonBox->button(QDialogButtonBox::StandardButton::Apply); 0033 connect(applyBtn, &QPushButton::clicked, this, &ProjectSettingsDialog::applyChanges); 0034 connect(ui->searchSourceCodePathButton, &QPushButton::clicked, this, &ProjectSettingsDialog::searchSourceCodePath); 0035 } 0036 0037 ProjectSettingsDialog::~ProjectSettingsDialog() = default; 0038 0039 void ProjectSettingsDialog::applyChanges() 0040 { 0041 d_projectFile.setProjectName(ui->projectNameValue->text().toStdString()); 0042 d_projectFile.setSourceCodePath(ui->sourceCodePathValue->text().toStdString()); 0043 close(); 0044 } 0045 0046 void ProjectSettingsDialog::searchSourceCodePath() 0047 { 0048 auto dir = QFileDialog::getExistingDirectory(this, tr("Source Directory"), QDir::homePath()); 0049 if (dir.isEmpty()) { 0050 // User hits cancel 0051 return; 0052 } 0053 ui->sourceCodePathValue->setText(dir); 0054 }