19 #include <QFileDialog> 21 #include <QMessageBox> 29 #include <ui_MultiplotConfigWidget.h> 44 currentConfigModified_(false),
45 maxHistoryLength_(maxHistoryLength) {
48 ui_->pushButtonClearHistory->setIcon(
50 append(
"/resource/16x16/clear_history.png"))));
51 ui_->pushButtonNew->setIcon(
53 append(
"/resource/16x16/add.png"))));
54 ui_->pushButtonOpen->setIcon(
56 append(
"/resource/16x16/open.png"))));
57 ui_->pushButtonSave->setIcon(
59 append(
"/resource/16x16/save.png"))));
60 ui_->pushButtonSaveAs->setIcon(
62 append(
"/resource/16x16/save_as.png"))));
64 ui_->pushButtonClearHistory->setEnabled(
false);
65 ui_->pushButtonSave->setEnabled(
false);
67 connect(
ui_->configComboBox, SIGNAL(editTextChanged(
const QString&)),
69 connect(
ui_->configComboBox, SIGNAL(currentUrlChanged(
const QString&)),
72 connect(
ui_->pushButtonClearHistory, SIGNAL(clicked()),
this,
74 connect(
ui_->pushButtonNew, SIGNAL(clicked()),
this,
76 connect(
ui_->pushButtonOpen, SIGNAL(clicked()),
this,
78 connect(
ui_->pushButtonSave, SIGNAL(clicked()),
this,
80 connect(
ui_->pushButtonSaveAs, SIGNAL(clicked()),
this,
100 connect(config, SIGNAL(changed()),
this, SLOT(
configChanged()));
116 ui_->configComboBox->setCurrentUrl(url);
123 return ui_->configComboBox->getCurrentUrl();
147 while (
ui_->configComboBox->count() > length)
148 ui_->configComboBox->removeItem(
ui_->configComboBox->count()-1);
157 ui_->configComboBox->clear();
160 ui_->configComboBox->addItem(history[i]);
166 for (
size_t i = 0; i <
ui_->configComboBox->count(); ++i)
167 history.append(
ui_->configComboBox->itemText(i));
173 if (!url.isEmpty()) {
177 if (!filePath.isEmpty()) {
178 QFileInfo fileInfo(filePath);
180 return fileInfo.isFile();
196 if (!filePath.isEmpty()) {
197 QFileInfo fileInfo(filePath);
199 if (fileInfo.isReadable()) {
202 if (settings.status() == QSettings::NoError) {
203 settings.beginGroup(
"rqt_multiplot");
211 url.toStdString() <<
"]");
220 url.toStdString() <<
"]");
237 if (!filePath.isEmpty()) {
240 if (settings.isWritable()) {
243 settings.beginGroup(
"rqt_multiplot");
249 if (settings.status() == QSettings::NoError) {
254 url.toStdString() <<
"]");
263 url.toStdString() <<
"]");
279 QMessageBox messageBox;
280 QMessageBox::StandardButtons buttons = QMessageBox::Save |
281 QMessageBox::Discard;
284 buttons |= QMessageBox::Cancel;
286 messageBox.setText(
"The configuration has been modified.");
287 messageBox.setInformativeText(
"Do you want to save your changes?");
288 messageBox.setStandardButtons(buttons);
289 messageBox.setDefaultButton(QMessageBox::Save);
291 switch (messageBox.exec()) {
292 case QMessageBox::Save:
294 QFileDialog dialog(
this,
"Save Configuration", QDir::homePath(),
295 "Multiplot configurations (*.xml)");
297 dialog.setAcceptMode(QFileDialog::AcceptSave);
298 dialog.setFileMode(QFileDialog::AnyFile);
299 dialog.selectFile(
"rqt_multiplot.xml");
301 if (dialog.exec() == QDialog::Accepted)
302 return saveConfig(
"file://"+dialog.selectedFiles().first());
308 case QMessageBox::Discard:
310 case QMessageBox::Cancel:
321 if (!url.isEmpty()) {
322 int index =
ui_->configComboBox->findText(url);
324 ui_->configComboBox->blockSignals(
true);
328 ui_->configComboBox->removeItem(
ui_->configComboBox->count()-1);
331 ui_->configComboBox->removeItem(index);
333 ui_->configComboBox->insertItem(0, url);
335 ui_->configComboBox->blockSignals(
false);
337 ui_->pushButtonClearHistory->setEnabled(
true);
342 ui_->configComboBox->blockSignals(
true);
344 QString url =
ui_->configComboBox->currentText();
346 while (
ui_->configComboBox->count())
347 ui_->configComboBox->removeItem(
ui_->configComboBox->count()-1);
350 ui_->configComboBox->insertItem(0, url);
352 ui_->configComboBox->blockSignals(
false);
354 ui_->pushButtonClearHistory->setEnabled(
false);
369 ui_->pushButtonSave->setEnabled(!
isFile(text));
374 ui_->pushButtonSave->setEnabled(
false);
385 ui_->pushButtonSave->setEnabled(
true);
388 ui_->pushButtonSave->setEnabled(
false);
392 ui_->pushButtonSave->setEnabled(
false);
398 QMessageBox messageBox;
400 messageBox.setText(
"The configuration file history will be cleared.");
401 messageBox.setInformativeText(
"Do you want to proceed?");
402 messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
403 messageBox.setDefaultButton(QMessageBox::No);
405 if (messageBox.exec() == QMessageBox::Yes)
416 QFileDialog dialog(
this,
"Open Configuration", QDir::homePath(),
417 "Multiplot configurations (*.xml)");
419 dialog.setAcceptMode(QFileDialog::AcceptOpen);
420 dialog.setFileMode(QFileDialog::ExistingFile);
422 if (dialog.exec() == QDialog::Accepted)
423 loadConfig(
"file://"+dialog.selectedFiles().first());
435 QFileDialog dialog(
this,
"Save Configuration", QDir::homePath(),
436 "Multiplot configurations (*.xml)");
438 dialog.setAcceptMode(QFileDialog::AcceptSave);
439 dialog.setFileMode(QFileDialog::AnyFile);
440 dialog.selectFile(
"rqt_multiplot.xml");
442 if (dialog.exec() == QDialog::Accepted)
443 saveConfig(
"file://"+dialog.selectedFiles().first());
QString getFilePath(const QModelIndex &index) const
void load(QSettings &settings)
void save(QSettings &settings) const
static const QSettings::Format format
ROSLIB_DECL std::string getPath(const std::string &package_name)
#define ROS_INFO_STREAM(args)
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)
#define ROS_ERROR_STREAM(args)