diff --git a/guilib/include/rtabmap/gui/PreferencesDialog.h b/guilib/include/rtabmap/gui/PreferencesDialog.h index 4ec95eda..f3f7224b 100644 --- a/guilib/include/rtabmap/gui/PreferencesDialog.h +++ b/guilib/include/rtabmap/gui/PreferencesDialog.h @@ -97,11 +97,12 @@ public: virtual QString getIniFilePath() const; void init(); + // save stuff + void saveSettings(); void saveWindowGeometry(const QWidget * window); void loadWindowGeometry(QWidget * window); void saveMainWindowState(const QMainWindow * mainWindow); void loadMainWindowState(QMainWindow * mainWindow, bool & maximized); - void saveWidgetState(const QWidget * widget); void loadWidgetState(QWidget * widget); @@ -207,7 +208,6 @@ signals: public slots: void setInputRate(double value); void setDetectionRate(double value); - void setHardThr(int value); void setTimeLimit(float value); void setSLAMMode(bool enabled); void selectSourceImage(Src src = kSrcUndef, bool checked = true); @@ -260,9 +260,11 @@ protected: virtual bool readCoreSettings(const QString & filePath = QString()); virtual void writeSettings(const QString & filePath = QString()); - virtual void writeGuiSettings(const QString & filePath = QString()); - virtual void writeCameraSettings(const QString & filePath = QString()); - virtual void writeCoreSettings(const QString & filePath = QString()); + virtual void writeGuiSettings(const QString & filePath = QString()) const; + virtual void writeCameraSettings(const QString & filePath = QString()) const; + virtual void writeCoreSettings(const QString & filePath = QString()) const; + + QString getTmpIniFilePath() const; private: bool validateForm(); diff --git a/guilib/src/MainWindow.cpp b/guilib/src/MainWindow.cpp index 541021be..9658211a 100644 --- a/guilib/src/MainWindow.cpp +++ b/guilib/src/MainWindow.cpp @@ -364,6 +364,11 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) : qRegisterMetaType("rtabmap::ParametersMap"); connect(_preferencesDialog, SIGNAL(settingsChanged(rtabmap::ParametersMap)), this, SLOT(applyPrefSettings(rtabmap::ParametersMap))); // config GUI modified + connect(_preferencesDialog, SIGNAL(settingsChanged(PreferencesDialog::PANEL_FLAGS)), this, SLOT(configGUIModified())); + if(prefDialog == 0) + { + connect(_preferencesDialog, SIGNAL(settingsChanged(rtabmap::ParametersMap)), this, SLOT(configGUIModified())); + } connect(_ui->imageView_source, SIGNAL(configChanged()), this, SLOT(configGUIModified())); connect(_ui->imageView_loopClosure, SIGNAL(configChanged()), this, SLOT(configGUIModified())); connect(_ui->imageView_odometry, SIGNAL(configChanged()), this, SLOT(configGUIModified())); @@ -492,7 +497,7 @@ void MainWindow::closeEvent(QCloseEvent* event) { QMessageBox::Button b=QMessageBox::question(this, tr("RTAB-Map"), - tr("There are unsaved GUI changes. Save them?"), + tr("There are unsaved changes. Save them?"), QMessageBox::Save | QMessageBox::Cancel | QMessageBox::Discard); if(b == QMessageBox::Save) { @@ -2252,6 +2257,7 @@ void MainWindow::saveConfigGUI() _preferencesDialog->saveWidgetState(_exportDialog); _preferencesDialog->saveWidgetState(_postProcessingDialog); _preferencesDialog->saveWidgetState(_ui->graphicsView_graphView); + _preferencesDialog->saveSettings(); this->setWindowModified(false); } diff --git a/guilib/src/PreferencesDialog.cpp b/guilib/src/PreferencesDialog.cpp index 0d961ea0..0c3e99a0 100644 --- a/guilib/src/PreferencesDialog.cpp +++ b/guilib/src/PreferencesDialog.cpp @@ -545,6 +545,8 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) : } PreferencesDialog::~PreferencesDialog() { + // remove tmp ini file + QFile::remove(getTmpIniFilePath()); delete _ui; } @@ -558,11 +560,16 @@ void PreferencesDialog::init() } this->readSettings(); - this->writeSettings();// This will create the ini file if not exist + this->writeSettings(getTmpIniFilePath()); _initialized = true; } +void PreferencesDialog::saveSettings() +{ + writeSettings(); +} + void PreferencesDialog::setupTreeView() { if(_indexModel) @@ -753,6 +760,8 @@ void PreferencesDialog::closeEvent(QCloseEvent *event) UDEBUG(""); _parameters.clear(); _obsoletePanels = kPanelDummy; + this->readGuiSettings(getTmpIniFilePath()); + this->readCameraSettings(getTmpIniFilePath()); event->accept(); } @@ -766,6 +775,8 @@ void PreferencesDialog::closeDialog ( QAbstractButton * button ) case QDialogButtonBox::RejectRole: _parameters.clear(); _obsoletePanels = kPanelDummy; + this->readGuiSettings(getTmpIniFilePath()); + this->readCameraSettings(getTmpIniFilePath()); this->reject(); break; @@ -775,7 +786,7 @@ void PreferencesDialog::closeDialog ( QAbstractButton * button ) { if(validateForm()) { - writeSettings(); + writeSettings(getTmpIniFilePath()); this->accept(); } } @@ -799,7 +810,7 @@ void PreferencesDialog::resetApply ( QAbstractButton * button ) updateBasicParameter();// make that changes without editing finished signal are updated. if(validateForm()) { - writeSettings(); + writeSettings(getTmpIniFilePath()); } break; @@ -995,6 +1006,11 @@ QString PreferencesDialog::getIniFilePath() const return privatePath + "/rtabmap.ini"; } +QString PreferencesDialog::getTmpIniFilePath() const +{ + return getIniFilePath()+".tmp"; +} + void PreferencesDialog::loadConfigFrom() { QString path = QFileDialog::getOpenFileName(this, tr("Load settings..."), this->getWorkingDirectory(), "*.ini"); @@ -1246,7 +1262,9 @@ bool PreferencesDialog::saveConfigTo() QString path = QFileDialog::getSaveFileName(this, tr("Save settings..."), this->getWorkingDirectory()+QDir::separator()+"config.ini", "*.ini"); if(!path.isEmpty()) { - this->writeSettings(path); + writeGuiSettings(path); + writeCameraSettings(path); + writeCoreSettings(path); return true; } return false; @@ -1288,7 +1306,7 @@ void PreferencesDialog::writeSettings(const QString & filePath) _obsoletePanels = kPanelDummy; } -void PreferencesDialog::writeGuiSettings(const QString & filePath) +void PreferencesDialog::writeGuiSettings(const QString & filePath) const { QString path = getIniFilePath(); if(!filePath.isEmpty()) @@ -1346,7 +1364,7 @@ void PreferencesDialog::writeGuiSettings(const QString & filePath) settings.endGroup(); // rtabmap } -void PreferencesDialog::writeCameraSettings(const QString & filePath) +void PreferencesDialog::writeCameraSettings(const QString & filePath) const { QString path = getIniFilePath(); if(!filePath.isEmpty()) @@ -1404,7 +1422,7 @@ void PreferencesDialog::writeCameraSettings(const QString & filePath) settings.endGroup(); } -void PreferencesDialog::writeCoreSettings(const QString & filePath) +void PreferencesDialog::writeCoreSettings(const QString & filePath) const { QString path = getIniFilePath(); if(!filePath.isEmpty()) @@ -1611,7 +1629,7 @@ void PreferencesDialog::readSettingsEnd() { QApplication::processEvents(); - this->readSettings(); + this->readSettings(getTmpIniFilePath()); _progressDialog->setValue(1); if(this->isVisible()) @@ -2026,7 +2044,7 @@ void PreferencesDialog::selectSourceImage(Src src, bool ckecked) if(validateForm()) { - this->writeSettings(); + this->writeSettings(getTmpIniFilePath()); } else { @@ -2077,7 +2095,7 @@ void PreferencesDialog::selectSourceDatabase(bool user, bool ckecked) if(validateForm()) { - this->writeSettings(); + this->writeSettings(getTmpIniFilePath()); } else { @@ -2144,7 +2162,7 @@ void PreferencesDialog::selectSourceRGBD(Src src, bool ckecked) // Even if there is no change, MainWindow should be notified makeObsoleteSourcePanel(); - this->writeSettings(); + this->writeSettings(getTmpIniFilePath()); } else { @@ -3210,24 +3228,6 @@ bool PreferencesDialog::isSLAMMode() const } /*** SETTERS ***/ -void PreferencesDialog::setHardThr(int value) -{ - double dValue = double(value)/100; - ULOGGER_DEBUG("PreferencesDialog::setHardThr(%f)", dValue); - if(_ui->general_doubleSpinBox_hardThr->value() != dValue) - { - _ui->general_doubleSpinBox_hardThr->setValue(dValue); - if(validateForm()) - { - this->writeSettings(); - } - else - { - this->readSettingsBegin(); - } - } -} - void PreferencesDialog::setInputRate(double value) { ULOGGER_DEBUG("imgRate=%2.2f", value); @@ -3236,7 +3236,7 @@ void PreferencesDialog::setInputRate(double value) _ui->general_doubleSpinBox_imgRate->setValue(value); if(validateForm()) { - this->writeSettings(); + this->writeSettings(getTmpIniFilePath()); } else { @@ -3253,7 +3253,7 @@ void PreferencesDialog::setDetectionRate(double value) _ui->general_doubleSpinBox_detectionRate->setValue(value); if(validateForm()) { - this->writeSettings(); + this->writeSettings(getTmpIniFilePath()); } else { @@ -3270,7 +3270,7 @@ void PreferencesDialog::setTimeLimit(float value) _ui->general_doubleSpinBox_timeThr->setValue(value); if(validateForm()) { - this->writeSettings(); + this->writeSettings(getTmpIniFilePath()); } else { @@ -3287,7 +3287,7 @@ void PreferencesDialog::setSLAMMode(bool enabled) _ui->general_checkBox_SLAM_mode->setChecked(enabled); if(validateForm()) { - this->writeSettings(); + this->writeSettings(getTmpIniFilePath()); } else { diff --git a/guilib/src/ui/mainWindow.ui b/guilib/src/ui/mainWindow.ui index 7aba5432..a5d04de4 100644 --- a/guilib/src/ui/mainWindow.ui +++ b/guilib/src/ui/mainWindow.ui @@ -37,6 +37,8 @@ + + @@ -178,7 +180,6 @@ - @@ -1119,7 +1120,7 @@ - Save GUI config + Save config