diff --git a/guilib/include/rtabmap/gui/PreferencesDialog.h b/guilib/include/rtabmap/gui/PreferencesDialog.h index 22dfd8e9..6fc26cb6 100644 --- a/guilib/include/rtabmap/gui/PreferencesDialog.h +++ b/guilib/include/rtabmap/gui/PreferencesDialog.h @@ -37,6 +37,7 @@ class QGroupBox; class QMainWindow; class QLineEdit; class QSlider; +class QProgressDialog; namespace rtabmap { @@ -155,6 +156,7 @@ private slots: void updateKpROI(); void changeWorkingDirectory(); void changeDictionaryPath(); + void readSettingsEnd(); protected: virtual void showEvent ( QShowEvent * event ); @@ -175,9 +177,6 @@ protected: private: bool validateForm(); - bool validatePanelGeneral(); - bool validatePanelFourier(); - bool validatePanelSurf(); void setupTreeView(); void setupSignals(); void setupPredictionPanel(); @@ -188,6 +187,7 @@ private: void addParameter(const QObject * object, const QString & value); void addParameters(const QGroupBox * box); QList getGroupBoxes(); + void readSettingsBegin(); protected: rtabmap::ParametersMap _parameters; @@ -201,6 +201,8 @@ private: //For Bayes filter prediction parameters QList _predictionLCSliders; // Sliders used to setup the prediction bool _predictionPanelInitialized; + + QProgressDialog * _progressDialog; }; Q_DECLARE_OPERATORS_FOR_FLAGS(PreferencesDialog::PANEL_FLAGS) diff --git a/guilib/src/MainWindow.cpp b/guilib/src/MainWindow.cpp index 3bc7d8e6..2cdd79df 100644 --- a/guilib/src/MainWindow.cpp +++ b/guilib/src/MainWindow.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #define LOG_FILE_NAME "LogRtabmap.txt" #define SHARE_SHOW_LOG_FILE "share/rtabmap/ShowLogs.m" @@ -79,6 +80,12 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) : initGuiResource(); + QPixmap pixmap(":images/RTAB-Map.png"); + QSplashScreen splash(pixmap); + splash.show(); + splash.showMessage(tr("Loading...")); + QApplication::processEvents(); + this->setWindowTitle(tr("Constant-Time Appearance-Based Mapping")); this->setWindowIconText(tr("RTAB-Map")); @@ -227,6 +234,8 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent) : this->applyPrefSettings(PreferencesDialog::kPanelAll); _ui->statsToolBox->setWorkingDirectory(_preferencesDialog->getWorkingDirectory()); + + splash.close(); } MainWindow::~MainWindow() diff --git a/guilib/src/PreferencesDialog.cpp b/guilib/src/PreferencesDialog.cpp index 02ab646e..74b895da 100644 --- a/guilib/src/PreferencesDialog.cpp +++ b/guilib/src/PreferencesDialog.cpp @@ -205,6 +205,10 @@ PreferencesDialog::PreferencesDialog(QWidget * parent) : _obsoletePanels = kPanelAll; _initialized = true; + + _progressDialog = new QProgressDialog(this); + _progressDialog->setWindowTitle(tr("Read parameters...")); + _progressDialog->setMaximum(2); } PreferencesDialog::~PreferencesDialog() { @@ -744,33 +748,7 @@ void PreferencesDialog::writeCoreSettings(const QString & filePath) bool PreferencesDialog::validateForm() { - if( validatePanelGeneral() && - validatePanelFourier() && - validatePanelSurf() ) - { - return true; - } - - return false; -} - -bool PreferencesDialog::validatePanelGeneral() -{ - /*if(_ui->general_spinBox_hardThr->value() < _ui->general_spinBox_softThr->value()) - { - QMessageBox::warning(this, tr("Settings validator"), tr("The hard threshold must be bigger than the soft threshold.")); - return false; - }*/ - return true; -} - -bool PreferencesDialog::validatePanelFourier() -{ - return true; -} - -bool PreferencesDialog::validatePanelSurf() -{ + //TODO... return true; } @@ -781,19 +759,31 @@ QString PreferencesDialog::getParamMessage() void PreferencesDialog::showEvent ( QShowEvent * event ) { - QProgressDialog statusDialog; - statusDialog.setWindowTitle(tr("Read parameters...")); - statusDialog.setLabelText(this->getParamMessage()); - statusDialog.setMaximum(2); - statusDialog.setWindowModality(Qt::WindowModal); - statusDialog.show(); + this->readSettingsBegin(); +} + +void PreferencesDialog::readSettingsBegin() +{ + _progressDialog->setLabelText(this->getParamMessage()); + _progressDialog->show(); + + // this will let the MainThread to display the progress dialog before reading the parameters... + QTimer::singleShot(10, this, SLOT(readSettingsEnd())); +} + +void PreferencesDialog::readSettingsEnd() +{ + QApplication::processEvents(); this->readSettings(); - statusDialog.setValue(1); - statusDialog.setLabelText(tr("Reading GUI settings...")); + + _progressDialog->setValue(1); + _progressDialog->setLabelText(tr("Reading GUI settings...")); + this->setupPredictionPanel(); this->setupKpRoiPanel(); - statusDialog.setValue(2); + + _progressDialog->setValue(2); // this will make closing... } void PreferencesDialog::saveWindowGeometry(const QString & windowName, const QWidget * window) @@ -1587,7 +1577,7 @@ void PreferencesDialog::setHardThr(int value) } else { - this->readSettings(); + this->readSettingsBegin(); } } } @@ -1605,7 +1595,7 @@ void PreferencesDialog::setReactivationThr(int value) } else { - this->readSettings(); + this->readSettingsBegin(); } } } @@ -1622,7 +1612,7 @@ void PreferencesDialog::setImgRate(double value) } else { - this->readSettings(); + this->readSettingsBegin(); } } } @@ -1639,7 +1629,7 @@ void PreferencesDialog::setAutoRestart(bool value) } else { - this->readSettings(); + this->readSettingsBegin(); } } } @@ -1656,7 +1646,7 @@ void PreferencesDialog::setTimeLimit(double value) } else { - this->readSettings(); + this->readSettingsBegin(); } } }