29 #include <QDialogButtonBox>
30 #include <QFileDialog>
31 #include <QMessageBox>
32 #include <QPushButton>
34 #include <IceUtil/UUID.h>
38 #include <MemoryX/gui-plugins/SceneEditor/ui_SceneEditorConfigDialog.h>
39 #include <MemoryX/interface/components/PriorKnowledgeInterface.h>
40 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
51 workingMemoryProxyFinder->setSearchMask(
"WorkingMemory");
52 workingMemoryProxyFinder->showSearchMaskField(
true);
53 workingMemoryProxyFinder->showLabels(
false);
54 ui->workingMemoryGridLayout->addWidget(workingMemoryProxyFinder, 0, 1, 1, 2);
57 workingMemoryUpdatesTopicFinder->setSearchMask(
"WorkingMemoryUpdates");
58 workingMemoryUpdatesTopicFinder->showSearchMaskField(
false);
59 workingMemoryUpdatesTopicFinder->showLabels(
false);
60 ui->workingMemoryGridLayout->addWidget(workingMemoryUpdatesTopicFinder, 1, 1, 1, 2);
62 priorKnowledgeProxyFinder =
64 priorKnowledgeProxyFinder->setSearchMask(
"PriorKnowledge");
65 priorKnowledgeProxyFinder->showSearchMaskField(
true);
66 priorKnowledgeProxyFinder->showLabels(
false);
67 ui->priorKnowledgeGridLayout->addWidget(priorKnowledgeProxyFinder, 0, 1, 1, 2);
69 connect(ui->buttonBox, SIGNAL(accepted()),
this, SLOT(verifyConfiguration()));
70 ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(
false);
72 std::filesystem::path currentPath(std::filesystem::current_path());
73 std::filesystem::path defaultFile(
"SceneEditor.ini");
74 this->ui->settingsFileLineEdit->setText(
75 QString::fromStdString((currentPath / defaultFile).
string()));
77 ui->fileBrowserToolButton, SIGNAL(released()),
this, SLOT(fileBrowserToolButtonReleased()));
88 return "SceneEditorConfigDialog" + IceUtil::generateUUID();
94 workingMemoryProxyFinder->setIceManager(this->getIceManager());
95 workingMemoryUpdatesTopicFinder->setIceManager(this->getIceManager());
96 priorKnowledgeProxyFinder->setIceManager(this->getIceManager());
107 QObject::disconnect();
113 this->setName(this->getDefaultName());
119 return this->workingMemoryProxyFinder->getSelectedProxyName().toStdString();
125 return this->workingMemoryUpdatesTopicFinder->getSelectedProxyName().toStdString();
131 return this->priorKnowledgeProxyFinder->getSelectedProxyName().toStdString();
135 gui::dialog::SceneEditorConfigDialog::verifyConfiguration()
137 if (this->getWorkingMemoryName().length() == 0)
139 QMessageBox::critical(
140 this, tr(
"Invalid Configuration"), tr(
"The WorkingMemory name must not be empty."));
142 else if (this->getWorkingMemoryUpdatesTopic().length() == 0)
144 QMessageBox::critical(
this,
145 tr(
"Invalid Configuration"),
146 tr(
"The WorkingMemory updates topic name must not be empty."));
148 else if (!this->isTopicAvailable(this->getWorkingMemoryUpdatesTopic()))
150 QMessageBox::critical(
152 tr(
"Invalid Configuration"),
153 tr(
"The WorkingMemory updates topic name does not name an avaiable topic."));
155 else if (this->getPriorMemoryName().length() == 0)
157 QMessageBox::critical(
158 this, tr(
"Invalid Configuration"), tr(
"The PriorMemory name must not be empty."));
160 else if (this->ui->settingsFileLineEdit->text().length() == 0)
162 QMessageBox::critical(
this,
163 tr(
"Invalid Configuration"),
164 tr(
"The settings file path name must not be empty."));
175 this->ui->retranslateUi(
this);
181 return this->ui->settingsFileLineEdit->text();
185 gui::dialog::SceneEditorConfigDialog::fileBrowserToolButtonReleased()
187 std::filesystem::path currentPath(this->ui->settingsFileLineEdit->text().toStdString());
189 QFileDialog::getSaveFileName(
this,
190 tr(
"Open settings file"),
191 QString::fromStdString(currentPath.remove_filename().string()),
192 tr(
"Settings (*.ini)"),
194 QFileDialog::DontConfirmOverwrite);
196 if (!filePath.endsWith(
".ini", Qt::CaseSensitivity::CaseInsensitive) && !filePath.isEmpty())
198 filePath.append(
".ini");
201 this->ui->settingsFileLineEdit->setText(filePath);
205 gui::dialog::SceneEditorConfigDialog::isTopicAvailable(std::string topicName)
207 return this->workingMemoryUpdatesTopicFinder->getProxyNameList(
"*").contains(
208 QString::fromStdString(topicName));