Skip to content
Permalink
Browse files

Use a proper color button, fix width widget in gps panel

  • Loading branch information
nyalldawson committed Jun 29, 2018
1 parent 6f9c956 commit a012770ce122797e0d26bc7b794f5a09ba59095d
@@ -72,7 +72,7 @@ QgsGpsInformationWidget::QgsGpsInformationWidget( QgsMapCanvas *thepCanvas, QWid
{
setupUi( this );
connect( mConnectButton, &QPushButton::toggled, this, &QgsGpsInformationWidget::mConnectButton_toggled );
connect( mBtnTrackColor, &QPushButton::clicked, this, &QgsGpsInformationWidget::mBtnTrackColor_clicked );
connect( mBtnTrackColor, &QgsColorButton::colorChanged, this, &QgsGpsInformationWidget::trackColorChanged );
connect( mSpinTrackWidth, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsGpsInformationWidget::mSpinTrackWidth_valueChanged );
connect( mBtnPosition, &QToolButton::clicked, this, &QgsGpsInformationWidget::mBtnPosition_clicked );
connect( mBtnSignal, &QToolButton::clicked, this, &QgsGpsInformationWidget::mBtnSignal_clicked );
@@ -187,12 +187,14 @@ QgsGpsInformationWidget::QgsGpsInformationWidget( QgsMapCanvas *thepCanvas, QWid
#endif
mpPlot->replot();

mBtnTrackColor->setAllowOpacity( true );
mBtnTrackColor->setColorDialogTitle( tr("Track Color") );
// Restore state
QgsSettings mySettings;
mGroupShowMarker->setChecked( mySettings.value( QStringLiteral( "gps/showMarker" ), "true" ).toBool() );
mSliderMarkerSize->setValue( mySettings.value( QStringLiteral( "gps/markerSize" ), "12" ).toInt() );
mSpinTrackWidth->setValue( mySettings.value( QStringLiteral( "gps/trackWidth" ), "2" ).toInt() );
mTrackColor = mySettings.value( QStringLiteral( "gps/trackColor" ), QColor( Qt::red ) ).value<QColor>();
mBtnTrackColor->setColor( mySettings.value( QStringLiteral( "gps/trackColor" ), QColor( Qt::red ) ).value<QColor>() );
QString myPortMode = mySettings.value( QStringLiteral( "gps/portMode" ), "scanPorts" ).toString();

mSpinMapExtentMultiplier->setValue( mySettings.value( QStringLiteral( "gps/mapExtentMultiplier" ), "50" ).toInt() );
@@ -311,7 +313,7 @@ QgsGpsInformationWidget::~QgsGpsInformationWidget()
QgsSettings mySettings;
mySettings.setValue( QStringLiteral( "gps/lastPort" ), mCboDevices->currentData().toString() );
mySettings.setValue( QStringLiteral( "gps/trackWidth" ), mSpinTrackWidth->value() );
mySettings.setValue( QStringLiteral( "gps/trackColor" ), mTrackColor );
mySettings.setValue( QStringLiteral( "gps/trackColor" ), mBtnTrackColor->color() );
mySettings.setValue( QStringLiteral( "gps/markerSize" ), mSliderMarkerSize->value() );
mySettings.setValue( QStringLiteral( "gps/showMarker" ), mGroupShowMarker->isChecked() );
mySettings.setValue( QStringLiteral( "gps/autoAddVertices" ), mCbxAutoAddVertices->isChecked() );
@@ -364,18 +366,18 @@ void QgsGpsInformationWidget::mSpinTrackWidth_valueChanged( int value )
if ( mpRubberBand )
{
mpRubberBand->setWidth( value );
mpRubberBand->update();
}
}

void QgsGpsInformationWidget::mBtnTrackColor_clicked()
void QgsGpsInformationWidget::trackColorChanged( const QColor& color )
{
QColor myColor = QColorDialog::getColor( mTrackColor, this );
if ( myColor.isValid() ) // check that a color was picked
if ( color.isValid() ) // check that a color was picked
{
mTrackColor = myColor;
if ( mpRubberBand )
{
mpRubberBand->setColor( myColor );
mpRubberBand->setColor( color );
mpRubberBand->update();
}
}
}
@@ -1096,7 +1098,7 @@ void QgsGpsInformationWidget::createRubberBand()
delete mpRubberBand;
}
mpRubberBand = new QgsRubberBand( mpCanvas, QgsWkbTypes::LineGeometry );
mpRubberBand->setColor( mTrackColor );
mpRubberBand->setColor( mBtnTrackColor->color() );
mpRubberBand->setWidth( mSpinTrackWidth->value() );
mpRubberBand->show();
}
@@ -57,7 +57,7 @@ class QgsGpsInformationWidget: public QWidget, private Ui::QgsGpsInformationWidg
void updateCloseFeatureButton( QgsMapLayer *lyr );
void layerEditStateChanged();
// void setTrackColor(); // no longer used
void mBtnTrackColor_clicked();
void trackColorChanged( const QColor &color );
void mSpinTrackWidth_valueChanged( int value );
void mBtnPosition_clicked();
void mBtnSignal_clicked();
@@ -112,7 +112,6 @@ class QgsGpsInformationWidget: public QWidget, private Ui::QgsGpsInformationWidg
QgsVectorLayer *mpLastLayer = nullptr;
QFile *mLogFile = nullptr;
QTextStream mLogFileTextStream;
QColor mTrackColor;
QIntValidator *mAcquisitionIntValidator = nullptr;
QIntValidator *mDistanceThresholdValidator = nullptr;
nmeaPOS mLastNmeaPosition;
@@ -1031,46 +1031,59 @@ gray = no data
<property name="title">
<string>Track</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>2</number>
</property>
<layout class="QGridLayout" name="gridLayout_16" columnstretch="0,1">
<property name="topMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Line width</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="mSpinTrackWidth">
<property name="toolTip">
<string>Track width in pixels</string>
</property>
<property name="suffix">
<string> px</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="mCbxAutoAddVertices">
<property name="text">
<string>Automatically add points</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QSpinBox" name="mSpinTrackWidth">
<property name="toolTip">
<string>Track width in pixels</string>
</property>
<property name="suffix">
<string> width</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mBtnTrackColor">
<property name="styleSheet">
<string/>
</property>
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
</layout>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Line color</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QgsColorButton" name="mBtnTrackColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
@@ -1301,6 +1314,11 @@ gray = no data
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsColorButton</class>
<extends>QToolButton</extends>
<header>qgscolorbutton.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>mBtnCloseFeature</tabstop>

0 comments on commit a012770

Please sign in to comment.
You can’t perform that action at this time.