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 #include <ArmarXGui/gui-plugins/ScenarioManager/gui/ui_packageadderview.h>
31 #include <QMessageBox>
32 
34  QDialog(parent),
35  ui(new Ui::PackageAdderView),
36  found(false)
37 {
38  ui->setupUi(this);
39  ui->okButton->setDefault(true);
40 }
41 
43 {
44  delete ui;
45 }
46 
47 void PackageAdderView::on_okButton_clicked()
48 {
49  if (found)
50  {
51  emit created(ui->packageName->text().toStdString());
52  accept();
53  }
54  else
55  {
56  QMessageBox msgBox;
57  msgBox.setText("Please insert a valid package name");
58  msgBox.exec();
59  }
60 }
61 
62 void PackageAdderView::on_cancelButton_clicked()
63 {
64  reject();
65 }
66 
67 void PackageAdderView::on_packageName_textChanged(const QString& text)
68 {
69  std::optional<std::string> configDir;
70  if (not text.isEmpty())
71  {
72  armarx::CMakePackageFinder pFinder(text.toStdString());
73  if (pFinder.packageFound())
74  {
75  configDir = pFinder.getConfigDir();
76  }
77  }
78 
79  if (configDir.has_value())
80  {
81  ui->packagePath->setText(QString::fromStdString(configDir.value()));
82  ui->foundPackageLabel->setPixmap(QPixmap(":/icons/user-online.svg"));
83  found = true;
84  }
85  else
86  {
87  found = false;
88  ui->packagePath->setText("Cannot find package");
89  ui->foundPackageLabel->setPixmap(QPixmap(":/icons/dialog-cancel-5.svg"));
90  }
91 }
92 
packageadderview.h
PackageAdderView
View that allows the user to find and add new packages.
Definition: packageadderview.h:39
armarx::CMakePackageFinder
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
Definition: CMakePackageFinder.h:53
Ui
ArmarX Headers.
Definition: ArmarXMainWindow.h:58
CMakePackageFinder.h
PackageAdderView::PackageAdderView
PackageAdderView(QWidget *parent=0)
Constructor that sets up the ui.
Definition: packageadderview.cpp:33
PackageAdderView::~PackageAdderView
~PackageAdderView() override
Destructor.
Definition: packageadderview.cpp:42
PackageAdderView::created
void created(std::string name)