Skip to content

Commit

Permalink
[gui][sensors] Display sensor errors in a message bar within the proj…
Browse files Browse the repository at this point in the history
…ect properties
  • Loading branch information
nirvn committed Apr 1, 2023
1 parent 56e33a9 commit 0068efd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app/sensor/qgsprojectsensorsettingswidget.cpp
Expand Up @@ -41,6 +41,14 @@ QgsProjectSensorSettingsWidget::QgsProjectSensorSettingsWidget( QWidget *parent
mConnectedSensors << sensor->id();
}
}

connect( QgsProject::instance()->sensorManager(), &QgsSensorManager::sensorErrorOccurred, this, [ = ]( const QString & id )
{
if ( QgsAbstractSensor *sensor = QgsProject::instance()->sensorManager()->sensor( id ) )
{
mMessageBar->pushCritical( tr( "Sensor Error" ), QStringLiteral( "%1: %2" ).arg( sensor->name(), sensor->errorString() ) );
}
} );
}

void QgsProjectSensorSettingsWidget::cancel()
Expand Down
9 changes: 9 additions & 0 deletions src/ui/sensor/qgsprojectsensorettingswidgetbase.ui
Expand Up @@ -26,6 +26,9 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QgsMessageBar" name="mMessageBar" native="true"/>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
Expand All @@ -47,6 +50,12 @@
<header>qgspanelwidgetstack.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsMessageBar</class>
<extends>QWidget</extends>
<header>qgsmessagebar.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
Expand Down

0 comments on commit 0068efd

Please sign in to comment.