Skip to content

Commit

Permalink
Move copy settings to QgsOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
YoannQDQ committed Apr 17, 2023
1 parent f832f8b commit 39d004c
Show file tree
Hide file tree
Showing 4 changed files with 363 additions and 367 deletions.
45 changes: 39 additions & 6 deletions src/app/options/qgsoptions.cpp
Expand Up @@ -643,16 +643,33 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti

// set if base unit of measure tool should be changed
bool baseUnit = mSettings->value( QStringLiteral( "qgis/measure/keepbaseunit" ), true ).toBool();
if ( baseUnit )
{
mKeepBaseUnitCheckBox->setChecked( true );
}
mKeepBaseUnitCheckBox->setChecked( baseUnit );

mPlanimetricMeasurementsComboBox->setChecked( mSettings->value( QStringLiteral( "measure/planimetric" ), false, QgsSettings::Core ).toBool() );

// set the measure tool copy settings
connect( mSeparatorOther, &QRadioButton::toggled, mSeparatorCustom, &QLineEdit::setEnabled );
bool includeHeader = mSettings->value( QStringLiteral( "qgis/measure/clipboard_header" ), false ).toBool();
mIncludeHeader->setChecked( includeHeader );
const QString sep = mSettings->value( QStringLiteral( "qgis/measure/clipboard_separator" ), QStringLiteral( "\t" ) ).toString();

if ( sep.isEmpty() || sep == QStringLiteral( "\t" ) )
mSeparatorTab->setChecked( true );
else if ( sep == QStringLiteral( "," ) )
mSeparatorComma->setChecked( true );
else if ( sep == QStringLiteral( ";" ) )
mSeparatorSemicolon->setChecked( true );
else if ( sep == QStringLiteral( " " ) )
mSeparatorSpace->setChecked( true );
else if ( sep == QStringLiteral( ":" ) )
mSeparatorColon->setChecked( true );
else
{
mKeepBaseUnitCheckBox->setChecked( false );
mSeparatorOther->setChecked( true );
mSeparatorCustom->setText( sep );
}
mPlanimetricMeasurementsComboBox->setChecked( mSettings->value( QStringLiteral( "measure/planimetric" ), false, QgsSettings::Core ).toBool() );

// set the default icon size
cmbIconSize->setCurrentIndex( cmbIconSize->findText( mSettings->value( QStringLiteral( "qgis/iconSize" ), QGIS_ICON_SIZE ).toString() ) );

// set font size and family
Expand Down Expand Up @@ -1665,6 +1682,22 @@ void QgsOptions::saveOptions()
bool baseUnit = mKeepBaseUnitCheckBox->isChecked();
mSettings->setValue( QStringLiteral( "/qgis/measure/keepbaseunit" ), baseUnit );

mSettings->setValue( QStringLiteral( "/qgis/measure/clipboard_header" ), mIncludeHeader->isChecked() );
QString separator;
if ( mSeparatorTab->isChecked() )
separator = QStringLiteral( "\t" );
else if ( mSeparatorComma->isChecked() )
separator = QStringLiteral( "," );
else if ( mSeparatorSemicolon->isChecked() )
separator = QStringLiteral( ";" );
else if ( mSeparatorSpace->isChecked() )
separator = QStringLiteral( " " );
else if ( mSeparatorColon->isChecked() )
separator = QStringLiteral( ":" );
else
separator = mSeparatorCustom->text();
mSettings->setValue( QStringLiteral( "/qgis/measure/clipboard_separator" ), separator );

//set the color for selections
QColor myColor = pbnSelectionColor->color();
mSettings->setValue( QStringLiteral( "/qgis/default_selection_color_red" ), myColor.red() );
Expand Down
20 changes: 3 additions & 17 deletions src/app/qgsmeasuredialog.cpp
Expand Up @@ -67,10 +67,6 @@ QgsMeasureDialog::QgsMeasureDialog( QgsMeasureTool *tool, Qt::WindowFlags f )
mTable->setContextMenuPolicy( Qt::ActionsContextMenu );
mTable->addAction( copyAction );
}
else
{
mCopySettingsGroupBox->hide();
}

repopulateComboBoxUnits( mMeasureArea );
if ( mMeasureArea )
Expand Down Expand Up @@ -724,22 +720,12 @@ double QgsMeasureDialog::convertArea( double area, Qgis::AreaUnit toUnit ) const

void QgsMeasureDialog::copyMeasurements()
{
bool includeHeader = mIncludeHeader->isChecked();
bool includeHeader = QgsSettings().value( QStringLiteral( "qgis/measure/clipboard_header" ), false ).toBool();

// Get the separator
QString separator;
if ( mSeparatorTab->isChecked() )
QString separator = QgsSettings().value( QStringLiteral( "qgis/measure/clipboard_separator" ), QStringLiteral( "\t" ) ).toString();
if ( separator.isEmpty() )
separator = QStringLiteral( "\t" );
else if ( mSeparatorComma->isChecked() )
separator = QStringLiteral( "," );
else if ( mSeparatorSemicolon->isChecked() )
separator = QStringLiteral( ";" );
else if ( mSeparatorSpace->isChecked() )
separator = QStringLiteral( " " );
else if ( mSeparatorColon->isChecked() )
separator = QStringLiteral( ":" );
else
separator = mSeparatorCustom->text();

QClipboard *clipboard = QApplication::clipboard();
QString text;
Expand Down

0 comments on commit 39d004c

Please sign in to comment.