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();
146 while (
ui_->configComboBox->count() > length)
147 ui_->configComboBox->removeItem(
ui_->configComboBox->count()-1);
156 ui_->configComboBox->clear();
159 ui_->configComboBox->addItem(history[i]);
165 for (
size_t i = 0; i <
ui_->configComboBox->count(); ++i)
166 history.append(
ui_->configComboBox->itemText(i));
172 if (!url.isEmpty()) {
176 if (!filePath.isEmpty()) {
177 QFileInfo fileInfo(filePath);
179 return fileInfo.isFile();
195 if (!filePath.isEmpty()) {
196 QFileInfo fileInfo(filePath);
198 if (fileInfo.isReadable()) {
201 if (settings.status() == QSettings::NoError) {
202 settings.beginGroup(
"rqt_multiplot");
210 url.toStdString() <<
"]");
219 url.toStdString() <<
"]");
236 if (!filePath.isEmpty()) {
239 if (settings.isWritable()) {
242 settings.beginGroup(
"rqt_multiplot");
248 if (settings.status() == QSettings::NoError) {
253 url.toStdString() <<
"]");
262 url.toStdString() <<
"]");
278 QMessageBox messageBox;
279 QMessageBox::StandardButtons buttons = QMessageBox::Save |
280 QMessageBox::Discard;
283 buttons |= QMessageBox::Cancel;
285 messageBox.setText(
"The configuration has been modified.");
286 messageBox.setInformativeText(
"Do you want to save your changes?");
287 messageBox.setStandardButtons(buttons);
288 messageBox.setDefaultButton(QMessageBox::Save);
290 switch (messageBox.exec()) {
291 case QMessageBox::Save:
293 QFileDialog dialog(
this,
"Save Configuration", QDir::homePath(),
294 "Multiplot configurations (*.xml)");
296 dialog.setAcceptMode(QFileDialog::AcceptSave);
297 dialog.setFileMode(QFileDialog::AnyFile);
298 dialog.selectFile(
"rqt_multiplot.xml");
300 if (dialog.exec() == QDialog::Accepted)
301 return saveConfig(
"file://"+dialog.selectedFiles().first());
307 case QMessageBox::Discard:
309 case QMessageBox::Cancel:
320 if (!url.isEmpty()) {
321 int index =
ui_->configComboBox->findText(url);
323 ui_->configComboBox->blockSignals(
true);
327 ui_->configComboBox->removeItem(
ui_->configComboBox->count()-1);
330 ui_->configComboBox->removeItem(index);
332 ui_->configComboBox->insertItem(0, url);
334 ui_->configComboBox->blockSignals(
false);
336 ui_->pushButtonClearHistory->setEnabled(
true);
341 ui_->configComboBox->blockSignals(
true);
343 QString url =
ui_->configComboBox->currentText();
345 while (
ui_->configComboBox->count())
346 ui_->configComboBox->removeItem(
ui_->configComboBox->count()-1);
349 ui_->configComboBox->insertItem(0, url);
351 ui_->configComboBox->blockSignals(
false);
353 ui_->pushButtonClearHistory->setEnabled(
false);
368 ui_->pushButtonSave->setEnabled(!
isFile(text));
373 ui_->pushButtonSave->setEnabled(
false);
384 ui_->pushButtonSave->setEnabled(
true);
387 ui_->pushButtonSave->setEnabled(
false);
391 ui_->pushButtonSave->setEnabled(
false);
397 QMessageBox messageBox;
399 messageBox.setText(
"The configuration file history will be cleared.");
400 messageBox.setInformativeText(
"Do you want to proceed?");
401 messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
402 messageBox.setDefaultButton(QMessageBox::No);
404 if (messageBox.exec() == QMessageBox::Yes)
415 QFileDialog dialog(
this,
"Open Configuration", QDir::homePath(),
416 "Multiplot configurations (*.xml)");
418 dialog.setAcceptMode(QFileDialog::AcceptOpen);
419 dialog.setFileMode(QFileDialog::ExistingFile);
421 if (dialog.exec() == QDialog::Accepted)
422 loadConfig(
"file://"+dialog.selectedFiles().first());
434 QFileDialog dialog(
this,
"Save Configuration", QDir::homePath(),
435 "Multiplot configurations (*.xml)");
437 dialog.setAcceptMode(QFileDialog::AcceptSave);
438 dialog.setFileMode(QFileDialog::AnyFile);
439 dialog.selectFile(
"rqt_multiplot.xml");
441 if (dialog.exec() == QDialog::Accepted)
442 saveConfig(
"file://"+dialog.selectedFiles().first());
void load(QSettings &settings)
void save(QSettings &settings) const
QString getFilePath(const QModelIndex &index) 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)