mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[gps] Move bearing line symbol setting to GPS pane in options
This is an infrequently changed setting
This commit is contained in:
parent
2223e19f63
commit
aaa74227c5
@ -39,15 +39,15 @@
|
||||
#include "qgsmessagebar.h"
|
||||
#include "qgsbearingutils.h"
|
||||
#include "qgsgpsbearingitem.h"
|
||||
#include "qgssymbollayerutils.h"
|
||||
#include "qgslocaldefaultsettings.h"
|
||||
#include "qgsprojectdisplaysettings.h"
|
||||
#include "qgsbearingnumericformat.h"
|
||||
#include "qgspolygon.h"
|
||||
#include "qgslinesymbol.h"
|
||||
#include "qgsgpsconnection.h"
|
||||
#include "qgscoordinateutils.h"
|
||||
#include "qgsgui.h"
|
||||
#include "qgslinesymbol.h"
|
||||
#include "qgssymbollayerutils.h"
|
||||
|
||||
// QWT Charting widget
|
||||
|
||||
@ -230,28 +230,8 @@ QgsGpsInformationWidget::QgsGpsInformationWidget( QgsMapCanvas *mapCanvas, QWidg
|
||||
#endif
|
||||
mPlot->replot();
|
||||
|
||||
mBearingLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
|
||||
|
||||
const QgsSettings mySettings;
|
||||
|
||||
QDomDocument doc;
|
||||
QDomElement elem;
|
||||
const QString symbolXml = mySettings.value( QStringLiteral( "bearingLineSymbol" ), QVariant(), QgsSettings::Gps ).toString();
|
||||
if ( !symbolXml.isEmpty() )
|
||||
{
|
||||
doc.setContent( symbolXml );
|
||||
elem = doc.documentElement();
|
||||
std::unique_ptr< QgsLineSymbol > bearingSymbol( QgsSymbolLayerUtils::loadSymbol<QgsLineSymbol>( elem, QgsReadWriteContext() ) );
|
||||
if ( bearingSymbol )
|
||||
mBearingLineStyleButton->setSymbol( bearingSymbol.release() );
|
||||
}
|
||||
|
||||
connect( mBearingLineStyleButton, &QgsSymbolButton::changed, this, [ = ]
|
||||
{
|
||||
if ( mMapBearingItem )
|
||||
mMapBearingItem->setSymbol( std::unique_ptr< QgsSymbol >( mBearingLineStyleButton->clonedSymbol< QgsLineSymbol >() ) );
|
||||
} );
|
||||
|
||||
// Restore state
|
||||
|
||||
mCheckShowMarker->setChecked( mySettings.value( QStringLiteral( "showMarker" ), "true", QgsSettings::Gps ).toBool() );
|
||||
@ -288,7 +268,7 @@ QgsGpsInformationWidget::QgsGpsInformationWidget( QgsMapCanvas *mapCanvas, QWidg
|
||||
mRotateMapCheckBox->setChecked( mySettings.value( QStringLiteral( "rotateMap" ), false, QgsSettings::Gps ).toBool() );
|
||||
mSpinMapRotateInterval->setValue( mySettings.value( QStringLiteral( "rotateMapInterval" ), 0, QgsSettings::Gps ).toInt() );
|
||||
mShowBearingLineCheck->setChecked( mySettings.value( QStringLiteral( "showBearingLine" ), false, QgsSettings::Gps ).toBool() );
|
||||
connect( mShowBearingLineCheck, &QgsCollapsibleGroupBox::toggled, this, [ = ]( bool checked )
|
||||
connect( mShowBearingLineCheck, &QCheckBox::toggled, this, [ = ]( bool checked )
|
||||
{
|
||||
if ( !checked )
|
||||
{
|
||||
@ -424,11 +404,6 @@ QgsGpsInformationWidget::~QgsGpsInformationWidget()
|
||||
mySettings.setValue( QStringLiteral( "rotateMapInterval" ), mSpinMapRotateInterval->value(), QgsSettings::Gps );
|
||||
mySettings.setValue( QStringLiteral( "showBearingLine" ), mShowBearingLineCheck->isChecked(), QgsSettings::Gps );
|
||||
|
||||
QDomDocument doc;
|
||||
const QDomElement elem = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "Symbol" ), mBearingLineStyleButton->symbol(), doc, QgsReadWriteContext() );
|
||||
doc.appendChild( elem );
|
||||
mySettings.setValue( QStringLiteral( "bearingLineSymbol" ), doc.toString(), QgsSettings::Gps );
|
||||
|
||||
if ( mMapCanvas )
|
||||
mMapCanvas->removeInteractionBlocker( this );
|
||||
}
|
||||
@ -458,7 +433,9 @@ void QgsGpsInformationWidget::setConnection( QgsGpsConnection *connection )
|
||||
void QgsGpsInformationWidget::gpsSettingsChanged()
|
||||
{
|
||||
updateTrackAppearance();
|
||||
updateBearingAppearance();
|
||||
|
||||
QgsSettings settings;
|
||||
int acquisitionInterval = 0;
|
||||
if ( QgsGpsConnection::settingsGpsConnectionType.exists() )
|
||||
{
|
||||
@ -468,7 +445,6 @@ void QgsGpsInformationWidget::gpsSettingsChanged()
|
||||
else
|
||||
{
|
||||
// legacy settings
|
||||
QgsSettings settings;
|
||||
acquisitionInterval = settings.value( QStringLiteral( "acquisitionInterval" ), 0, QgsSettings::Gps ).toInt();
|
||||
mDistanceThreshold = settings.value( QStringLiteral( "distanceThreshold" ), 0, QgsSettings::Gps ).toDouble();
|
||||
}
|
||||
@ -509,6 +485,32 @@ void QgsGpsInformationWidget::updateTrackAppearance()
|
||||
mRubberBand->update();
|
||||
}
|
||||
|
||||
void QgsGpsInformationWidget::updateBearingAppearance()
|
||||
{
|
||||
if ( !mMapBearingItem )
|
||||
return;
|
||||
|
||||
QDomDocument doc;
|
||||
QDomElement elem;
|
||||
QString bearingLineSymbolXml = QgsGpsInformationWidget::settingBearingLineSymbol.value();
|
||||
if ( bearingLineSymbolXml.isEmpty() )
|
||||
{
|
||||
QgsSettings settings;
|
||||
bearingLineSymbolXml = settings.value( QStringLiteral( "bearingLineSymbol" ), QVariant(), QgsSettings::Gps ).toString();
|
||||
}
|
||||
|
||||
if ( !bearingLineSymbolXml.isEmpty() )
|
||||
{
|
||||
doc.setContent( bearingLineSymbolXml );
|
||||
elem = doc.documentElement();
|
||||
std::unique_ptr< QgsLineSymbol > bearingSymbol( QgsSymbolLayerUtils::loadSymbol<QgsLineSymbol>( elem, QgsReadWriteContext() ) );
|
||||
if ( bearingSymbol )
|
||||
{
|
||||
mMapBearingItem->setSymbol( std::move( bearingSymbol ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QgsGpsInformationWidget::mBtnPosition_clicked()
|
||||
{
|
||||
mStackedWidget->setCurrentIndex( 0 );
|
||||
@ -1100,7 +1102,7 @@ void QgsGpsInformationWidget::displayGPSInformation( const QgsGpsInformation &in
|
||||
if ( ! mMapBearingItem )
|
||||
{
|
||||
mMapBearingItem = new QgsGpsBearingItem( mMapCanvas );
|
||||
mMapBearingItem->setSymbol( std::unique_ptr< QgsSymbol >( mBearingLineStyleButton->clonedSymbol< QgsLineSymbol >() ) );
|
||||
updateBearingAppearance();
|
||||
}
|
||||
|
||||
mMapBearingItem->setGpsPosition( myNewCenter );
|
||||
|
@ -62,6 +62,7 @@ class APP_EXPORT QgsGpsInformationWidget: public QgsPanelWidget, public QgsMapCa
|
||||
static const inline QgsSettingsEntryString settingLastLogFolder = QgsSettingsEntryString( QStringLiteral( "last-log-folder" ), QgsSettings::Prefix::GPS, QString(), QStringLiteral( "Last used folder for GPS log files" ) );
|
||||
static const inline QgsSettingsEntryDouble settingGpsTrackWidth = QgsSettingsEntryDouble( QStringLiteral( "track-width" ), QgsSettings::Prefix::GPS, 2, QStringLiteral( "GPS track width" ) );
|
||||
static const inline QgsSettingsEntryColor settingGpsTrackColor = QgsSettingsEntryColor( QStringLiteral( "track-color" ), QgsSettings::Prefix::GPS, QColor( Qt::red ), QStringLiteral( "GPS track color" ) );
|
||||
static const inline QgsSettingsEntryString settingBearingLineSymbol = QgsSettingsEntryString( QStringLiteral( "bearing-line-symbol" ), QgsSettings::Prefix::GPS, QString(), QStringLiteral( "Line symbol to use for GPS bearing line" ), Qgis::SettingsOptions(), 0 );
|
||||
|
||||
QgsGpsInformationWidget( QgsMapCanvas *mapCanvas, QWidget *parent = nullptr );
|
||||
~QgsGpsInformationWidget() override;
|
||||
@ -89,6 +90,7 @@ class APP_EXPORT QgsGpsInformationWidget: public QgsPanelWidget, public QgsMapCa
|
||||
void layerEditStateChanged();
|
||||
void gpsSettingsChanged();
|
||||
void updateTrackAppearance();
|
||||
void updateBearingAppearance();
|
||||
void mBtnPosition_clicked();
|
||||
void mBtnSignal_clicked();
|
||||
void mBtnSatellites_clicked();
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "qgsgpsdetector.h"
|
||||
#include "qgsgpsconnection.h"
|
||||
#include "qgsgpsinformationwidget.h"
|
||||
#include "qgslinesymbol.h"
|
||||
|
||||
const int MAXACQUISITIONINTERVAL = 3000; // max gps information acquisition suspension interval (in seconds)
|
||||
const int MAXDISTANCETHRESHOLD = 200; // max gps distance threshold (in meters)
|
||||
@ -57,6 +58,7 @@ QgsGpsOptionsWidget::QgsGpsOptionsWidget( QWidget *parent )
|
||||
connect( mRadInternal, &QRadioButton::toggled, mBtnRefreshDevices, &QWidget::setDisabled );
|
||||
|
||||
mGpsMarkerSymbolButton->setSymbolType( Qgis::SymbolType::Marker );
|
||||
mBearingLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
|
||||
|
||||
const QString defaultSymbol = QgsGpsMarker::settingLocationMarkerSymbol.value();
|
||||
QDomDocument symbolDoc;
|
||||
@ -66,6 +68,25 @@ QgsGpsOptionsWidget::QgsGpsOptionsWidget( QWidget *parent )
|
||||
if ( gpsMarkerSymbol )
|
||||
mGpsMarkerSymbolButton->setSymbol( gpsMarkerSymbol.release() );
|
||||
|
||||
|
||||
QgsSettings settings;
|
||||
QDomDocument doc;
|
||||
QDomElement elem;
|
||||
QString bearingLineSymbolXml = QgsGpsInformationWidget::settingBearingLineSymbol.value();
|
||||
if ( bearingLineSymbolXml.isEmpty() )
|
||||
{
|
||||
bearingLineSymbolXml = settings.value( QStringLiteral( "bearingLineSymbol" ), QVariant(), QgsSettings::Gps ).toString();
|
||||
}
|
||||
|
||||
if ( !bearingLineSymbolXml.isEmpty() )
|
||||
{
|
||||
doc.setContent( bearingLineSymbolXml );
|
||||
elem = doc.documentElement();
|
||||
std::unique_ptr< QgsLineSymbol > bearingSymbol( QgsSymbolLayerUtils::loadSymbol<QgsLineSymbol>( elem, QgsReadWriteContext() ) );
|
||||
if ( bearingSymbol )
|
||||
mBearingLineStyleButton->setSymbol( bearingSymbol.release() );
|
||||
}
|
||||
|
||||
mCheckRotateLocationMarker->setChecked( QgsGpsMarker::settingRotateLocationMarker.value() );
|
||||
|
||||
mSpinGpsdPort->setValue( 2947 );
|
||||
@ -120,7 +141,6 @@ QgsGpsOptionsWidget::QgsGpsOptionsWidget( QWidget *parent )
|
||||
else
|
||||
{
|
||||
// legacy settings
|
||||
QgsSettings settings;
|
||||
const QString portMode = settings.value( QStringLiteral( "portMode" ), "scanPorts", QgsSettings::Gps ).toString();
|
||||
|
||||
if ( portMode == QLatin1String( "scanPorts" ) )
|
||||
@ -198,6 +218,14 @@ void QgsGpsOptionsWidget::apply()
|
||||
}
|
||||
QgsGpsMarker::settingRotateLocationMarker.setValue( mCheckRotateLocationMarker->isChecked() );
|
||||
|
||||
if ( QgsSymbol *lineSymbol = mBearingLineStyleButton->symbol() )
|
||||
{
|
||||
QDomDocument doc;
|
||||
const QDomElement elem = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "gps-bearing-symbol" ), lineSymbol, doc, QgsReadWriteContext() );
|
||||
doc.appendChild( elem );
|
||||
QgsGpsInformationWidget::settingBearingLineSymbol.setValue( doc.toString( 0 ) );
|
||||
}
|
||||
|
||||
QgsGpsConnection::settingsGpsSerialDevice.setValue( mCboDevices->currentData().toString() );
|
||||
|
||||
if ( mRadAutodetect->isChecked() )
|
||||
|
@ -63,6 +63,7 @@ QgsSettingsRegistryApp::QgsSettingsRegistryApp()
|
||||
addSettingsEntry( &QgsGpsInformationWidget::settingLastLogFolder );
|
||||
addSettingsEntry( &QgsGpsInformationWidget::settingGpsTrackColor );
|
||||
addSettingsEntry( &QgsGpsInformationWidget::settingGpsTrackWidth );
|
||||
addSettingsEntry( &QgsGpsInformationWidget::settingBearingLineSymbol );
|
||||
|
||||
addSettingsEntry( &QgsGpsMarker::settingLocationMarkerSymbol );
|
||||
addSettingsEntry( &QgsGpsMarker::settingRotateLocationMarker );
|
||||
|
@ -621,38 +621,6 @@ gray = no data
|
||||
<property name="verticalSpacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item row="4" column="0">
|
||||
<widget class="QgsCollapsibleGroupBox" name="mShowBearingLineCheck">
|
||||
<property name="title">
|
||||
<string>Show Bearing Line</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,1">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Line style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QgsSymbolButton" name="mBearingLineStyleButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QgsCollapsibleGroupBox" name="mLogFileGroupBox">
|
||||
<property name="enabled">
|
||||
@ -793,6 +761,26 @@ gray = no data
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<spacer name="verticalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="mShowBearingLineCheck">
|
||||
<property name="text">
|
||||
<string>Show bearing line</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="mCheckShowMarker">
|
||||
<property name="text">
|
||||
@ -803,7 +791,7 @@ gray = no data
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QgsCollapsibleGroupBoxBasic" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Map Centering and Rotation</string>
|
||||
@ -932,19 +920,6 @@ gray = no data
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<spacer name="verticalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
@ -1131,11 +1106,6 @@ gray = no data
|
||||
<header>qgsscrollarea.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsSymbolButton</class>
|
||||
<extends>QToolButton</extends>
|
||||
<header>qgssymbolbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QgsCollapsibleGroupBoxBasic</class>
|
||||
<extends>QGroupBox</extends>
|
||||
@ -1190,8 +1160,6 @@ gray = no data
|
||||
<tabstop>radNeverRecenter</tabstop>
|
||||
<tabstop>mRotateMapCheckBox</tabstop>
|
||||
<tabstop>mSpinMapRotateInterval</tabstop>
|
||||
<tabstop>mShowBearingLineCheck</tabstop>
|
||||
<tabstop>mBearingLineStyleButton</tabstop>
|
||||
<tabstop>mLogFileGroupBox</tabstop>
|
||||
<tabstop>mLogFilename</tabstop>
|
||||
<tabstop>mGPSPlainTextEdit</tabstop>
|
||||
|
@ -194,7 +194,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QgsCollapsibleGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>GPS Track Visualization</string>
|
||||
@ -286,7 +286,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="8" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -348,6 +348,35 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Bearing Line</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3" columnstretch="1,2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Line style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QgsSymbolButton" name="mBearingLineStyleButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user