config_zcm.cpp
Go to the documentation of this file.
1 #include "config_zcm.h"
2 #include "ui_config_zcm.h"
3 
4 #include <QFileDialog>
5 #include <QMessageBox>
6 #include <QSettings>
7 #include <QFileInfo>
8 
9 ConfigZCM::ConfigZCM(QString prefix, QWidget* parent)
10  : QWidget(parent), ui(new Ui::ConfigZCM), _prefix(prefix)
11 {
12  ui->setupUi(this);
13 
14  QSettings settings;
15  auto libs = settings.value(_prefix + "::manual_libs", {}).toStringList();
16  for (auto const& lib : libs)
17  {
18  ui->listWidgetLibs->addItem(lib);
19  }
20 
21  bool is_manual = settings.value(_prefix + "::is_manual", false).toBool();
22  ui->radioManualLibrary->setChecked(is_manual);
23 }
24 
26 {
27  QSettings settings;
28 
29  QStringList libs;
30  for (int row = 0; row < ui->listWidgetLibs->count(); row++)
31  {
32  libs << ui->listWidgetLibs->item(row)->text();
33  }
34  settings.setValue(_prefix + "::manual_libs", libs);
35  settings.setValue(_prefix + "::is_manual", ui->radioManualLibrary->isChecked());
36  delete ui;
37 }
38 
39 QString ConfigZCM::getLibraries() const
40 {
41  if (ui->radioEnvironmentLibrary->isChecked())
42  {
43  return getenv("PJ_ZCMTYPES_LIB_PATH");
44  }
45  else
46  {
47  QStringList libs;
48  for (int row = 0; row < ui->listWidgetLibs->count(); row++)
49  {
50  libs << ui->listWidgetLibs->item(row)->text();
51  }
52  return libs.join(":");
53  }
54 }
55 
57 {
58  if (checked)
59  {
60  ui->radioManualLibrary->setChecked(false);
61  }
62 }
63 
65 {
66  if (checked)
67  {
68  ui->radioEnvironmentLibrary->setChecked(false);
69  }
70  ui->manualWidget->setEnabled(checked);
71 }
72 
74 {
75  QSettings settings;
76  auto dir = settings.value(_prefix + "::load_dir", QDir::currentPath()).toString();
77  auto files = QFileDialog::getOpenFileNames(this, "Zcm libraries", dir, "*.so *.dll");
78  for (auto filename : files)
79  {
80  if (ui->listWidgetLibs->findItems(filename, Qt::MatchExactly).empty())
81  {
82  ui->listWidgetLibs->addItem(filename);
83  }
84  }
85  ui->listWidgetLibs->sortItems();
86  if (!files.empty())
87  {
88  settings.setValue(_prefix + "::load_dir",
89  QFileInfo(files.front()).dir().absolutePath());
90  }
91 }
92 
94 {
95  auto items = ui->listWidgetLibs->selectedItems();
96  for (auto item : items)
97  {
98  ui->listWidgetLibs->removeItemWidget(item);
99  delete item;
100  }
101 }
ConfigZCM
Definition: config_zcm.h:10
config_zcm.h
ConfigZCM::on_radioManualLibrary_toggled
void on_radioManualLibrary_toggled(bool checked)
Definition: config_zcm.cpp:64
ConfigZCM::on_radioEnvironmentLibrary_toggled
void on_radioEnvironmentLibrary_toggled(bool checked)
Definition: config_zcm.cpp:56
Ui
Definition: cheatsheet_dialog.h:6
ConfigZCM::getLibraries
QString getLibraries() const
Definition: config_zcm.cpp:39
sol::lib
lib
Definition: sol.hpp:7809
ConfigZCM::on_pushButtonRemove_clicked
void on_pushButtonRemove_clicked()
Definition: config_zcm.cpp:93
ConfigZCM::_prefix
QString _prefix
Definition: config_zcm.h:31
ConfigZCM::ui
Ui::ConfigZCM * ui
Definition: config_zcm.h:30
ConfigZCM::on_pushButtonAdd_clicked
void on_pushButtonAdd_clicked()
Definition: config_zcm.cpp:73
ConfigZCM::ConfigZCM
ConfigZCM(QString prefix, QWidget *parent=nullptr)
Definition: config_zcm.cpp:9
ConfigZCM::~ConfigZCM
~ConfigZCM()
Definition: config_zcm.cpp:25


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:43