packageadderview.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarXCore::core
19 * @author Cedric Seehausen (usdnr at kit dot edu)
20 * @date 2016
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25
26#include "packageadderview.h"
27
28#include <optional>
29
30#include <QMessageBox>
31
33
34#include <ArmarXGui/gui-plugins/ScenarioManager/gui/ui_packageadderview.h>
35
37 QDialog(parent), ui(new Ui::PackageAdderView), found(false)
38{
39 ui->setupUi(this);
40 ui->okButton->setDefault(true);
41}
42
47
48void
49PackageAdderView::on_okButton_clicked()
50{
51 if (found)
52 {
53 emit created(ui->packageName->text().toStdString());
54 accept();
55 }
56 else
57 {
58 QMessageBox msgBox;
59 msgBox.setText("Please insert a valid package name");
60 msgBox.exec();
61 }
62}
63
64void
65PackageAdderView::on_cancelButton_clicked()
66{
67 reject();
68}
69
70void
71PackageAdderView::on_packageName_textChanged(const QString& text)
72{
73 std::optional<std::string> configDir;
74 if (not text.isEmpty())
75 {
76 armarx::CMakePackageFinder pFinder(text.toStdString());
77 if (pFinder.packageFound())
78 {
79 configDir = pFinder.getConfigDir();
80 }
81 }
82
83 if (configDir.has_value())
84 {
85 ui->packagePath->setText(QString::fromStdString(configDir.value()));
86 ui->foundPackageLabel->setPixmap(QPixmap(":/icons/user-online.svg"));
87 found = true;
88 }
89 else
90 {
91 found = false;
92 ui->packagePath->setText("Cannot find package");
93 ui->foundPackageLabel->setPixmap(QPixmap(":/icons/dialog-cancel-5.svg"));
94 }
95}
PackageAdderView(QWidget *parent=0)
Constructor that sets up the ui.
void created(std::string name)
~PackageAdderView() override
Destructor.
ArmarX Headers.