Skip to content

Commit

Permalink
Removed settings struct
Browse files Browse the repository at this point in the history
  • Loading branch information
domi4484 committed Apr 26, 2021
1 parent 00a7936 commit 95dfe0f
Show file tree
Hide file tree
Showing 37 changed files with 176 additions and 191 deletions.
Expand Up @@ -321,6 +321,7 @@ The contents of the reply will be returned after the request is completed or an
.. versionadded:: 3.6
%End

<<<<<<< HEAD
void requestAuthOpenBrowser( const QUrl &url ) const;
%Docstring
Forwards an external browser login ``url`` opening request to the authentication handler.
Expand All @@ -342,6 +343,9 @@ Forwards an external browser login closure request to the authentication handler

.. versionadded:: 3.20
%End
=======
const QgsSettingsEntryInteger settingsNetworkTimeout;
>>>>>>> 2087a7f4f8 (Removed settings struct)

signals:

Expand Down
11 changes: 4 additions & 7 deletions python/core/auto_generated/network/qgsnewsfeedparser.sip.in
Expand Up @@ -93,13 +93,10 @@ Returns the authentication configuration for the parser.
Returns the settings key used for a feed with the given ``baseUrl``.
%End

struct Settings
{
const QgsSettingsEntryInteger feedLastFetchTime;
const QgsSettingsEntryString feedLanguage;
const QgsSettingsEntryDouble feedLatitude;
const QgsSettingsEntryDouble feedLongitude;
};
const QgsSettingsEntryInteger settingsFeedLastFetchTime;
const QgsSettingsEntryString settingsFeedLanguage;
const QgsSettingsEntryDouble settingsFeedLatitude;
const QgsSettingsEntryDouble settingsFeedLongitude;

public slots:

Expand Down
11 changes: 4 additions & 7 deletions python/core/auto_generated/processing/qgsprocessing.sip.in
Expand Up @@ -53,13 +53,10 @@ Converts a source ``type`` to a string representation.

static const QString TEMPORARY_OUTPUT;

struct Settings
{
const QgsSettingsEntryBool preferFilenameAsLayerName;
const QgsSettingsEntryString tempPath;
const QgsSettingsEntryInteger defaultOutputVectorLayerExt;
const QgsSettingsEntryInteger defaultOutputRasterLayerExt;
};
const QgsSettingsEntryBool settingsPreferFilenameAsLayerName;
const QgsSettingsEntryString settingsTempPath;
const QgsSettingsEntryInteger settingsDefaultOutputVectorLayerExt;
const QgsSettingsEntryInteger settingsDefaultOutputRasterLayerExt;
};

/************************************************************************
Expand Down
13 changes: 5 additions & 8 deletions python/core/auto_generated/qgsapplication.sip.in
Expand Up @@ -1003,14 +1003,11 @@ Emits the signal to collect all the strings of .qgs to be included in ts file
.. versionadded:: 3.4
%End

struct Settings
{
const QgsSettingsEntryString localeUserLocale;
const QgsSettingsEntryBool localeOverrideFlag;
const QgsSettingsEntryString localeGlobalLocale;
const QgsSettingsEntryBool localeShowGroupSeparator;
const QgsSettingsEntryStringList searchPathsForSVG;
};
const QgsSettingsEntryString settingsLocaleUserLocale;
const QgsSettingsEntryBool settingsLocaleOverrideFlag;
const QgsSettingsEntryString settingsLocaleGlobalLocale;
const QgsSettingsEntryBool settingsLocaleShowGroupSeparator;
const QgsSettingsEntryStringList settingsSearchPathsForSVG;

%If (ANDROID)
//dummy method to workaround sip generation issue
Expand Down
5 changes: 1 addition & 4 deletions python/core/auto_generated/qgsgeometryoptions.sip.in
Expand Up @@ -118,10 +118,7 @@ Read the geometry options from ``node``.
.. versionadded:: 3.4
%End

struct Settings
{
const QgsSettingsEntryString geometryValidationDefaultChecks;
};
const QgsSettingsEntryString settingsGeometryValidationDefaultChecks;

signals:

Expand Down
Expand Up @@ -60,10 +60,7 @@ Since the paths are stored by order of preference, lower positions in the list t
Unregisters a localized path
%End

struct Settings
{
const QgsSettingsEntryStringList localizedDataPaths;
};
const QgsSettingsEntryStringList settingsLocalizedDataPaths;

private:
QgsLocalizedDataPathRegistry( const QgsLocalizedDataPathRegistry &other );
Expand Down
6 changes: 1 addition & 5 deletions python/core/auto_generated/qgsmaprendererjob.sip.in
Expand Up @@ -157,11 +157,7 @@ Returns map settings with which this job was started.




struct Settings
{
const QgsSettingsEntryBool logCanvasRefreshEvent;
};
const QgsSettingsEntryBool settingsLogCanvasRefreshEvent;

signals:

Expand Down
31 changes: 31 additions & 0 deletions python/core/auto_generated/settings/qgssettingsentry.sip.in
Expand Up @@ -84,6 +84,7 @@ Get settings entry key.
The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key.
%End

<<<<<<< HEAD
bool keyIsValid( const QString &key ) const;
%Docstring
Returns ``True`` if the provided key match the settings entry.
Expand All @@ -95,6 +96,8 @@ defined with the key "NewsFeed/%1/%2/content"
The ``key`` to check
%End

=======
>>>>>>> 7b8aad6203 (Removed settings struct)
QString definitionKey() const;
%Docstring
Returns settings entry defining key.
Expand All @@ -116,7 +119,11 @@ The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.

bool exists( const QStringList &dynamicKeyPartList ) const;
%Docstring
<<<<<<< HEAD
Returns ``True`` if the settings is contained in the underlying QSettings.
=======
Returns true if the settings is contained in the underlying QSettings.
>>>>>>> 7b8aad6203 (Removed settings struct)

The ``dynamicKeyParts`` argument specifies the list of dynamic parts of the settings key.
%End
Expand Down Expand Up @@ -297,11 +304,19 @@ The ``description`` argument specifies a description for the settings entry.
bool setValue( const QString &value, const QString &dynamicKeyPart = QString() ) const;
%Docstring
Set settings value.
<<<<<<< HEAD

The ``value`` to set.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End

=======

The ``value`` to set.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End

>>>>>>> 7b8aad6203 (Removed settings struct)
bool setValue( const QString &value, const QStringList &dynamicKeyPartList ) const;
%Docstring
Set settings value.
Expand Down Expand Up @@ -396,11 +411,19 @@ The ``description`` argument specifies a description for the settings entry.
bool setValue( const QStringList &value, const QString &dynamicKeyPart = QString() ) const;
%Docstring
Set settings value.
<<<<<<< HEAD

The ``value`` to set.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End

=======

The ``value`` to set.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End

>>>>>>> 7b8aad6203 (Removed settings struct)
bool setValue( const QStringList &value, const QStringList &dynamicKeyPartList ) const;
%Docstring
Set settings value.
Expand Down Expand Up @@ -645,11 +668,19 @@ The ``description`` argument specifies a description for the settings entry.
bool setValue( double value, const QString &dynamicKeyPart = QString() ) const;
%Docstring
Set settings value.
<<<<<<< HEAD

The ``value`` to set.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End

=======

The ``value`` to set.
The ``dynamicKeyPart`` argument specifies the dynamic part of the settings key.
%End

>>>>>>> 7b8aad6203 (Removed settings struct)
bool setValue( double value, const QStringList &dynamicKeyPartList ) const;
%Docstring
Set settings value.
Expand Down
Expand Up @@ -31,6 +31,7 @@ Constructor for QgsSettingsRegistry.

virtual ~QgsSettingsRegistry();

<<<<<<< HEAD
QList<const QgsSettingsEntryBase *> getChildSettingsEntries() const;
%Docstring
Returns the list of registered :py:class:`QgsSettingsEntryBase`.
Expand All @@ -55,6 +56,13 @@ Returns the list of registered child QgsSettingsRegistry.

protected:

=======
const QgsSettingsEntryBase *getSettingsEntry( const QString &key );
%Docstring
Returns the :py:class:`QgsSettingsEntry` with the given ``key`` or None if not found.
%End

>>>>>>> 7b8aad6203 (Removed settings struct)
void addSettingsEntry( const QgsSettingsEntryBase *settingsEntry );
%Docstring
Add ``settingsEntry`` to the register.
Expand Down
12 changes: 6 additions & 6 deletions src/app/main.cpp
Expand Up @@ -968,16 +968,16 @@ int main( int argc, char *argv[] )
{
/* Translation file for QGIS.
*/
QString myUserTranslation = QgsApplication::Settings::localeUserLocale.value();
QString myGlobalLocale = QgsApplication::Settings::localeGlobalLocale.value();
QString myUserTranslation = QgsApplication::settingsLocaleUserLocale.value();
QString myGlobalLocale = QgsApplication::settingsLocaleGlobalLocale.value();
bool myShowGroupSeparatorFlag = false; // Default to false
bool myLocaleOverrideFlag = QgsApplication::Settings::localeOverrideFlag.value();
bool myLocaleOverrideFlag = QgsApplication::settingsLocaleOverrideFlag.value();

// Override Show Group Separator if the global override flag is set
if ( myLocaleOverrideFlag )
{
// Default to false again
myShowGroupSeparatorFlag = QgsApplication::Settings::localeShowGroupSeparator.value();
myShowGroupSeparatorFlag = QgsApplication::settingsLocaleShowGroupSeparator.value();
}

//
Expand All @@ -991,7 +991,7 @@ int main( int argc, char *argv[] )
//
if ( !translationCode.isNull() && !translationCode.isEmpty() )
{
QgsApplication::Settings::localeUserLocale.setValue( translationCode );
QgsApplication::settingsLocaleUserLocale.setValue( translationCode );
}
else
{
Expand All @@ -1000,7 +1000,7 @@ int main( int argc, char *argv[] )
translationCode = QLocale().name();
//setting the locale/userLocale when the --lang= option is not set will allow third party
//plugins to always use the same locale as the QGIS, otherwise they can be out of sync
QgsApplication::Settings::localeUserLocale.setValue( translationCode );
QgsApplication::settingsLocaleUserLocale.setValue( translationCode );
}
else
{
Expand Down
20 changes: 10 additions & 10 deletions src/app/options/qgsoptions.cpp
Expand Up @@ -475,7 +475,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
cmbScanZipInBrowser->setCurrentIndex( index );

// log rendering events, for userspace debugging
mLogCanvasRefreshChkBx->setChecked( QgsMapRendererJob::Settings::logCanvasRefreshEvent.value() );
mLogCanvasRefreshChkBx->setChecked( QgsMapRendererJob::settingsLogCanvasRefreshEvent.value() );

//set the default projection behavior radio buttons
const QgsOptions::UnknownLayerCrsBehavior mode = QgsSettings().enumValue( QStringLiteral( "/projections/unknownCrsBehavior" ), QgsOptions::UnknownLayerCrsBehavior::NoAction, QgsSettings::App );
Expand Down Expand Up @@ -1015,9 +1015,9 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
//
QString currentLocale = QLocale().name();
lblSystemLocale->setText( tr( "Detected active locale on your system: %1" ).arg( currentLocale ) );
QString userLocale = QgsApplication::Settings::localeUserLocale.value();
bool showGroupSeparator = QgsApplication::Settings::localeShowGroupSeparator.value();
QString globalLocale = QgsApplication::Settings::localeGlobalLocale.value();
QString userLocale = QgsApplication::settingsLocaleUserLocale.value();
bool showGroupSeparator = QgsApplication::settingsLocaleShowGroupSeparator.value();
QString globalLocale = QgsApplication::settingsLocaleGlobalLocale.value();
const QStringList language18nList( i18nList() );
for ( const auto &l : language18nList )
{
Expand All @@ -1044,7 +1044,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti

cboTranslation->setCurrentIndex( cboTranslation->findData( userLocale ) );
cboGlobalLocale->setCurrentIndex( cboGlobalLocale->findData( globalLocale ) );
grpLocale->setChecked( QgsApplication::Settings::localeOverrideFlag.value() );
grpLocale->setChecked( QgsApplication::settingsLocaleOverrideFlag.value() );
cbShowGroupSeparator->setChecked( showGroupSeparator );


Expand Down Expand Up @@ -1673,7 +1673,7 @@ void QgsOptions::saveOptions()
mSettings->setValue( QStringLiteral( "/Raster/cumulativeCutUpper" ), mRasterCumulativeCutUpperDoubleSpinBox->value() / 100.0 );

// log rendering events, for userspace debugging
QgsMapRendererJob::Settings::logCanvasRefreshEvent.setValue( mLogCanvasRefreshChkBx->isChecked() );
QgsMapRendererJob::settingsLogCanvasRefreshEvent.setValue( mLogCanvasRefreshChkBx->isChecked() );

//check behavior so default projection when new layer is added with no
//projection defined...
Expand Down Expand Up @@ -1856,12 +1856,12 @@ void QgsOptions::saveOptions()
//
// Locale settings
//
QgsApplication::Settings::localeUserLocale.setValue( cboTranslation->currentData().toString() );
QgsApplication::Settings::localeOverrideFlag.setValue( grpLocale->isChecked() );
QgsApplication::Settings::localeGlobalLocale.setValue( cboGlobalLocale->currentData( ).toString() );
QgsApplication::settingsLocaleUserLocale.setValue( cboTranslation->currentData().toString() );
QgsApplication::settingsLocaleOverrideFlag.setValue( grpLocale->isChecked() );
QgsApplication::settingsLocaleGlobalLocale.setValue( cboGlobalLocale->currentData( ).toString() );

// Number settings
QgsApplication::Settings::localeShowGroupSeparator.setValue( cbShowGroupSeparator->isChecked( ) );
QgsApplication::settingsLocaleShowGroupSeparator.setValue( cbShowGroupSeparator->isChecked( ) );

QgsLocalDefaultSettings::setBearingFormat( mBearingFormat.get() );

Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsprojectproperties.cpp
Expand Up @@ -983,7 +983,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
}

cbtsLocale->addItem( QIcon( QStringLiteral( ":/images/flags/%1.svg" ).arg( QLatin1String( "en_US" ) ) ), QLocale( QStringLiteral( "en_US" ) ).nativeLanguageName(), QStringLiteral( "en_US" ) );
cbtsLocale->setCurrentIndex( cbtsLocale->findData( QgsApplication::Settings::localeUserLocale.value() ) );
cbtsLocale->setCurrentIndex( cbtsLocale->findData( QgsApplication::settingsLocaleUserLocale.value() ) );

connect( generateTsFileButton, &QPushButton::clicked, this, &QgsProjectProperties::onGenerateTsFileButton );

Expand Down
4 changes: 2 additions & 2 deletions src/core/network/qgsnetworkaccessmanager.cpp
Expand Up @@ -674,12 +674,12 @@ void QgsNetworkAccessManager::setupDefaultProxyAndCache( Qt::ConnectionType conn

int QgsNetworkAccessManager::timeout()
{
return Settings::networkTimeout.value();
return settingsNetworkTimeout.value();
}

void QgsNetworkAccessManager::setTimeout( const int time )
{
Settings::networkTimeout.setValue( time );
settingsNetworkTimeout.setValue( time );
}

QgsNetworkReplyContent QgsNetworkAccessManager::blockingGet( QNetworkRequest &request, const QString &authCfg, bool forceRefresh, QgsFeedback *feedback )
Expand Down
4 changes: 4 additions & 0 deletions src/core/network/qgsnetworkaccessmanager.h
Expand Up @@ -530,6 +530,10 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
*/
void requestAuthCloseBrowser() const;

//! Settings entry network timeout
static const inline QgsSettingsEntryInteger settingsNetworkTimeout = QgsSettingsEntryInteger( QStringLiteral( "/qgis/networkAndProxy/networkTimeout" ), QgsSettings::NoSection, 60000, QObject::tr( "Network timeout" ) );


signals:

/**
Expand Down
14 changes: 7 additions & 7 deletions src/core/network/qgsnewsfeedparser.cpp
Expand Up @@ -40,22 +40,22 @@ QgsNewsFeedParser::QgsNewsFeedParser( const QUrl &feedUrl, const QString &authcf

QUrlQuery query( feedUrl );

const qint64 after = Settings::feedLastFetchTime.value( mSettingsKey );
const qint64 after = settingsFeedLastFetchTime.value( mSettingsKey );
if ( after > 0 )
query.addQueryItem( QStringLiteral( "after" ), qgsDoubleToString( after, 0 ) );

QString feedLanguage = Settings::feedLanguage.value( mSettingsKey );
QString feedLanguage = settingsFeedLanguage.value( mSettingsKey );
if ( feedLanguage.isEmpty() )
{
feedLanguage = QgsSettings().value( QgsApplication::Settings::localeUserLocale.key(), QStringLiteral( "en_US" ) ).toString().left( 2 );
feedLanguage = QgsSettings().value( QgsApplication::settingsLocaleUserLocale.key(), QStringLiteral( "en_US" ) ).toString().left( 2 );
}
if ( !feedLanguage.isEmpty() && feedLanguage != QLatin1String( "C" ) )
query.addQueryItem( QStringLiteral( "lang" ), feedLanguage );

if ( Settings::feedLatitude.exists( mSettingsKey ) && Settings::feedLongitude.exists( mSettingsKey ) )
if ( settingsFeedLatitude.exists( mSettingsKey ) && settingsFeedLongitude.exists( mSettingsKey ) )
{
const double feedLat = Settings::feedLatitude.value( mSettingsKey );
const double feedLong = Settings::feedLongitude.value( mSettingsKey );
const double feedLat = settingsFeedLatitude.value( mSettingsKey );
const double feedLong = settingsFeedLongitude.value( mSettingsKey );

// hack to allow testing using local files
if ( feedUrl.isLocalFile() )
Expand Down Expand Up @@ -169,7 +169,7 @@ void QgsNewsFeedParser::fetch()

void QgsNewsFeedParser::onFetch( const QString &content )
{
Settings::feedLastFetchTime.setValue( mFetchStartTime, mSettingsKey );
settingsFeedLastFetchTime.setValue( mFetchStartTime, mSettingsKey );

const QVariant json = QgsJsonUtils::parseJson( content );

Expand Down

0 comments on commit 95dfe0f

Please sign in to comment.