QgsLayoutItemPropertiesDialog::QgsLayoutItemPropertiesDialog( QWidget *parent, Qt::WindowFlags flags ) : QDialog( parent, flags ) { setupUi( this ); QgsGui::instance()->enableAutoGeometryRestore( this ); //make button exclusive QButtonGroup *buttonGroup = new QButtonGroup( this ); buttonGroup->addButton( mUpperLeftRadioButton ); buttonGroup->addButton( mUpperMiddleRadioButton ); buttonGroup->addButton( mUpperRightRadioButton ); buttonGroup->addButton( mMiddleLeftRadioButton ); buttonGroup->addButton( mMiddleRadioButton ); buttonGroup->addButton( mMiddleRightRadioButton ); buttonGroup->addButton( mLowerLeftRadioButton ); buttonGroup->addButton( mLowerMiddleRadioButton ); buttonGroup->addButton( mLowerRightRadioButton ); buttonGroup->setExclusive( true ); QgsSettings settings; double lastWidth = settings.value( QStringLiteral( "LayoutDesigner/lastItemWidth" ), QStringLiteral( "50" ) ).toDouble(); double lastHeight = settings.value( QStringLiteral( "LayoutDesigner/lastItemHeight" ), QStringLiteral( "50" ) ).toDouble(); QgsUnitTypes::LayoutUnit lastSizeUnit = settings.enumValue( QStringLiteral( "LayoutDesigner/lastSizeUnit" ), QgsUnitTypes::LayoutMillimeters ); setItemSize( QgsLayoutSize( lastWidth, lastHeight, lastSizeUnit ) ); mPosUnitsComboBox->linkToWidget( mXPosSpin ); mPosUnitsComboBox->linkToWidget( mYPosSpin ); mSizeUnitsComboBox->linkToWidget( mWidthSpin ); mSizeUnitsComboBox->linkToWidget( mHeightSpin ); mLockAspectRatio->setWidthSpinBox( mWidthSpin ); mLockAspectRatio->setHeightSpinBox( mHeightSpin ); }
QgsOffsetUserWidget::QgsOffsetUserWidget( QWidget *parent ) : QWidget( parent ) { setupUi( this ); mOffsetSpinBox->setDecimals( 6 ); // fill comboboxes mJoinStyleComboBox->addItem( tr( "Round" ), QgsGeometry::JoinStyleRound ); mJoinStyleComboBox->addItem( tr( "Miter" ), QgsGeometry::JoinStyleMiter ); mJoinStyleComboBox->addItem( tr( "Bevel" ), QgsGeometry::JoinStyleBevel ); mCapStyleComboBox->addItem( tr( "Round" ), QgsGeometry::CapRound ); mCapStyleComboBox->addItem( tr( "Flat" ), QgsGeometry::CapFlat ); mCapStyleComboBox->addItem( tr( "Square" ), QgsGeometry::CapSquare ); QgsSettings s; QgsGeometry::JoinStyle joinStyle = s.enumValue( QStringLiteral( "/qgis/digitizing/offset_join_style" ), QgsGeometry::JoinStyleRound ); int quadSegments = s.value( QStringLiteral( "/qgis/digitizing/offset_quad_seg" ), 8 ).toInt(); double miterLimit = s.value( QStringLiteral( "/qgis/digitizing/offset_miter_limit" ), 5.0 ).toDouble(); QgsGeometry::EndCapStyle capStyle = s.enumValue( QStringLiteral( "/qgis/digitizing/offset_cap_style" ), QgsGeometry::CapRound ); mJoinStyleComboBox->setCurrentIndex( mJoinStyleComboBox->findData( joinStyle ) ); mQuadrantSpinBox->setValue( quadSegments ); mMiterLimitSpinBox->setValue( miterLimit ); mCapStyleComboBox->setCurrentIndex( mCapStyleComboBox->findData( capStyle ) ); // connect signals mOffsetSpinBox->installEventFilter( this ); connect( mOffsetSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsOffsetUserWidget::offsetChanged ); connect( mJoinStyleComboBox, static_cast < void ( QComboBox::* )( int ) > ( &QComboBox::currentIndexChanged ), this, [ = ] { QgsSettings().setEnumValue( QStringLiteral( "/qgis/digitizing/offset_join_style" ), ( QgsGeometry::JoinStyle )mJoinStyleComboBox->currentData().toInt() ); emit offsetConfigChanged(); } ); connect( mQuadrantSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, [ = ]( const int quadSegments ) { QgsSettings().setValue( QStringLiteral( "/qgis/digitizing/offset_quad_seg" ), quadSegments ); emit offsetConfigChanged(); } ); connect( mMiterLimitSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, [ = ]( double miterLimit ) { QgsSettings().setValue( QStringLiteral( "/qgis/digitizing/offset_miter_limit" ), miterLimit ); emit offsetConfigChanged(); } ); connect( mCapStyleComboBox, static_cast < void ( QComboBox::* )( int ) > ( &QComboBox::currentIndexChanged ), this, [ = ] { QgsSettings().setEnumValue( QStringLiteral( "/qgis/digitizing/offset_cap_style" ), ( QgsGeometry::EndCapStyle ) mCapStyleComboBox->currentData().toInt() ); emit offsetConfigChanged(); } ); bool showAdvanced = s.value( QStringLiteral( "/qgis/digitizing/offset_show_advanced" ), false ).toBool(); mShowAdvancedButton->setChecked( showAdvanced ); mAdvancedConfigWidget->setVisible( showAdvanced ); connect( mShowAdvancedButton, &QToolButton::clicked, mAdvancedConfigWidget, &QWidget::setVisible ); connect( mShowAdvancedButton, &QToolButton::clicked, this, [ = ]( const bool clicked ) {QgsSettings().setValue( QStringLiteral( "/qgis/digitizing/offset_show_advanced" ), clicked );} ); // config focus setFocusProxy( mOffsetSpinBox ); }
void QgsMapToolOffsetCurve::updateGeometryAndRubberBand( double offset ) { if ( !mRubberBand || mOriginalGeometry.isNull() ) { return; } if ( !mLayer ) { return; } QgsGeometry offsetGeom; QgsSettings s; QgsGeometry::JoinStyle joinStyle = s.enumValue( QStringLiteral( "/qgis/digitizing/offset_join_style" ), QgsGeometry::JoinStyleRound ); int quadSegments = s.value( QStringLiteral( "/qgis/digitizing/offset_quad_seg" ), 8 ).toInt(); double miterLimit = s.value( QStringLiteral( "/qgis/digitizing/offset_miter_limit" ), 5.0 ).toDouble(); QgsGeometry::EndCapStyle capStyle = s.enumValue( QStringLiteral( "/qgis/digitizing/offset_cap_style" ), QgsGeometry::CapRound ); if ( QgsWkbTypes::geometryType( mOriginalGeometry.wkbType() ) == QgsWkbTypes::LineGeometry ) { offsetGeom = mManipulatedGeometry.offsetCurve( offset, quadSegments, joinStyle, miterLimit ); } else { offsetGeom = mManipulatedGeometry.buffer( offset, quadSegments, capStyle, joinStyle, miterLimit ); } if ( !offsetGeom ) { deleteRubberBandAndGeometry(); deleteUserInputWidget(); mLayer = nullptr; mGeometryModified = false; emit messageDiscarded(); emit messageEmitted( tr( "Creating offset geometry failed: %1" ).arg( offsetGeom.lastError() ), Qgis::Critical ); } else { mModifiedGeometry = offsetGeom; mRubberBand->setToGeometry( mModifiedGeometry, mLayer ); } }
QgsPgNewConnection::QgsPgNewConnection( QWidget *parent, const QString &connName, Qt::WindowFlags fl ) : QDialog( parent, fl ) , mOriginalConnName( connName ) { setupUi( this ); connect( btnConnect, &QPushButton::clicked, this, &QgsPgNewConnection::btnConnect_clicked ); connect( cb_geometryColumnsOnly, &QCheckBox::clicked, this, &QgsPgNewConnection::cb_geometryColumnsOnly_clicked ); connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsPgNewConnection::showHelp ); cbxSSLmode->addItem( tr( "disable" ), QgsDataSourceUri::SslDisable ); cbxSSLmode->addItem( tr( "allow" ), QgsDataSourceUri::SslAllow ); cbxSSLmode->addItem( tr( "prefer" ), QgsDataSourceUri::SslPrefer ); cbxSSLmode->addItem( tr( "require" ), QgsDataSourceUri::SslRequire ); cbxSSLmode->addItem( tr( "verify-ca" ), QgsDataSourceUri::SslVerifyCa ); cbxSSLmode->addItem( tr( "verify-full" ), QgsDataSourceUri::SslVerifyFull ); mAuthSettings->setDataprovider( QStringLiteral( "postgres" ) ); mAuthSettings->showStoreCheckboxes( true ); if ( !connName.isEmpty() ) { // populate the dialog with the information stored for the connection // populate the fields with the stored setting parameters QgsSettings settings; QString key = "/PostgreSQL/connections/" + connName; txtService->setText( settings.value( key + "/service" ).toString() ); txtHost->setText( settings.value( key + "/host" ).toString() ); QString port = settings.value( key + "/port" ).toString(); if ( port.length() == 0 ) { port = QStringLiteral( "5432" ); } txtPort->setText( port ); txtDatabase->setText( settings.value( key + "/database" ).toString() ); cb_publicSchemaOnly->setChecked( settings.value( key + "/publicOnly", false ).toBool() ); cb_geometryColumnsOnly->setChecked( settings.value( key + "/geometryColumnsOnly", true ).toBool() ); cb_dontResolveType->setChecked( settings.value( key + "/dontResolveType", false ).toBool() ); cb_allowGeometrylessTables->setChecked( settings.value( key + "/allowGeometrylessTables", false ).toBool() ); // Ensure that cb_publicSchemaOnly is set correctly cb_geometryColumnsOnly_clicked(); cb_useEstimatedMetadata->setChecked( settings.value( key + "/estimatedMetadata", false ).toBool() ); cbxSSLmode->setCurrentIndex( cbxSSLmode->findData( settings.enumValue( key + "/sslmode", QgsDataSourceUri::SslPrefer ) ) ); if ( settings.value( key + "/saveUsername" ).toString() == QLatin1String( "true" ) ) { mAuthSettings->setUsername( settings.value( key + "/username" ).toString() ); mAuthSettings->setStoreUsernameChecked( true ); } if ( settings.value( key + "/savePassword" ).toString() == QLatin1String( "true" ) ) { mAuthSettings->setPassword( settings.value( key + "/password" ).toString() ); mAuthSettings->setStorePasswordChecked( true ); } // Old save setting if ( settings.contains( key + "/save" ) ) { mAuthSettings->setUsername( settings.value( key + "/username" ).toString() ); mAuthSettings->setStoreUsernameChecked( ! mAuthSettings->username().isEmpty() ); if ( settings.value( key + "/save" ).toString() == QLatin1String( "true" ) ) mAuthSettings->setPassword( settings.value( key + "/password" ).toString() ); mAuthSettings->setStorePasswordChecked( true ); } QString authcfg = settings.value( key + "/authcfg" ).toString(); mAuthSettings->setConfigId( authcfg ); txtName->setText( connName ); } txtName->setValidator( new QRegExpValidator( QRegExp( "[^\\/]*" ), txtName ) ); }