Skip to content
Permalink
Browse files

[auth] Add connection cache clear options

This fixes a bug that required to restart
QGIS after a connection failed due to SSL
errors (the connection auth was cached).

Also:

- added a tab for content and connection
  auth cache configuration
- user feedback on (both) caches cleared
- changed icon for content cache clear to
  a trash bin (after users enquiries about
  what was that "back/undo" icon for)
  • Loading branch information
elpaso committed Oct 23, 2017
1 parent 67b9341 commit 8643177421bc59cc658fd54690817ccb51dd8847
Showing with 126 additions and 71 deletions.
  1. +16 −0 src/app/qgsoptions.cpp
  2. +6 −0 src/app/qgsoptions.h
  3. +104 −71 src/ui/qgsoptionsbase.ui
@@ -377,6 +377,15 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
connect( mBrowseCacheDirectory, &QAbstractButton::clicked, this, &QgsOptions::browseCacheDirectory );
connect( mClearCache, &QAbstractButton::clicked, this, &QgsOptions::clearCache );

// Access (auth) cache settings
mAutoClearAccessCache->setChecked( mSettings->value( QStringLiteral( "clear_auth_cache_on_errors" ), true, QgsSettings::Section::Auth ).toBool( ) );
connect( mClearAccessCache, &QAbstractButton::clicked, this, &QgsOptions::clearAccessCache );

connect( mAutoClearAccessCache, &QCheckBox::clicked, this, [ = ]( bool checked )
{
mSettings->setValue( QStringLiteral( "clear_auth_cache_on_errors" ), checked, QgsSettings::Section::Auth );
} );

//wms search server
leWmsSearch->setText( mSettings->value( QStringLiteral( "/qgis/WMSSearchUrl" ), "http://geopole.org/wms/search?search=%1&type=rss" ).toString() );

@@ -1978,6 +1987,13 @@ void QgsOptions::browseCacheDirectory()
void QgsOptions::clearCache()
{
QgsNetworkAccessManager::instance()->cache()->clear();
QMessageBox::information( this, tr( "Cache cleared" ), tr( "Content cache has been cleared" ) );
}

void QgsOptions::clearAccessCache()
{
QgsNetworkAccessManager::instance()->clearAccessCache();
QMessageBox::information( this, tr( "Cache cleared" ), tr( "Connection authentication cache has been cleared" ) );
}

void QgsOptions::mOptionsStackedWidget_currentChanged( int indx )
@@ -186,6 +186,12 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
void browseCacheDirectory();
void clearCache();

/**
* \brief clearAuthenticationConnectionCache clears the QNetworkAccessManager
* authentication connection cache
*/
void clearAccessCache();

/**
* Let the user add a scale to the list of scales
* used in scale combobox
@@ -308,7 +308,7 @@
<item>
<widget class="QStackedWidget" name="mOptionsStackedWidget">
<property name="currentIndex">
<number>0</number>
<number>12</number>
</property>
<widget class="QWidget" name="mOptionsPageGeneral">
<layout class="QVBoxLayout" name="verticalLayout_3">
@@ -337,15 +337,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>580</width>
<height>672</height>
<width>866</width>
<height>822</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_28">
<item>
<widget class="QgsCollapsibleGroupBox" name="grpLocale">
<property name="title">
<string>O&amp;verride system locale</string>
<string>Override system &amp;locale</string>
</property>
<property name="checkable">
<bool>true</bool>
@@ -1032,7 +1032,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>537</width>
<width>846</width>
<height>1128</height>
</rect>
</property>
@@ -1562,8 +1562,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>499</width>
<height>754</height>
<width>866</width>
<height>822</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_27">
@@ -1930,7 +1930,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>672</width>
<width>846</width>
<height>1043</height>
</rect>
</property>
@@ -2681,8 +2681,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<height>322</height>
<width>866</width>
<height>822</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_46">
@@ -2832,8 +2832,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>340</height>
<width>866</width>
<height>822</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_25">
@@ -3175,8 +3175,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>623</width>
<height>734</height>
<width>866</width>
<height>822</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_30">
@@ -3619,8 +3619,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>491</width>
<height>610</height>
<width>866</width>
<height>822</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_39">
@@ -3888,8 +3888,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>548</width>
<height>785</height>
<width>866</width>
<height>822</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_31">
@@ -4466,8 +4466,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>431</width>
<height>376</height>
<width>866</width>
<height>822</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
@@ -4605,8 +4605,8 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<rect>
<x>0</x>
<y>0</y>
<width>418</width>
<height>544</height>
<width>866</width>
<height>822</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_15">
@@ -4755,7 +4755,7 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<item row="3" column="0">
<widget class="QRadioButton" name="radUseGlobalProjection">
<property name="text">
<string>Use a default CRS</string>
<string>&amp;Use a default CRS</string>
</property>
</widget>
</item>
@@ -4947,53 +4947,88 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<property name="title">
<string>Cache settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Directory</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="mCacheDirectory"/>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="mBrowseCacheDirectory">
<property name="toolTip">
<string>Select folder</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionFileOpen.svg</normaloff>:/images/themes/default/mActionFileOpen.svg</iconset>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Size [KiB]</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="mCacheSize"/>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="mClearCache">
<property name="toolTip">
<string>Clear</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionUndo.svg</normaloff>:/images/themes/default/mActionUndo.svg</iconset>
<layout class="QVBoxLayout" name="verticalLayout_19">
<item>
<widget class="QTabWidget" name="tabContentCache">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Content</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="4" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Size [KiB]</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Directory</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="mCacheDirectory"/>
</item>
<item row="4" column="1">
<widget class="QSpinBox" name="mCacheSize"/>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="mBrowseCacheDirectory">
<property name="toolTip">
<string>Select folder</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionFileOpen.svg</normaloff>:/images/themes/default/mActionFileOpen.svg</iconset>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QToolButton" name="mClearCache">
<property name="toolTip">
<string>Clear cache</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionDeleteSelected.svg</normaloff>:/images/themes/default/mActionDeleteSelected.svg</iconset>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Authentication</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QCheckBox" name="mAutoClearAccessCache">
<property name="text">
<string>Automatically clear the connection authentication cache on SSL errors</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="mClearAccessCache">
<property name="text">
<string>Clear authentication connection cache</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@@ -5610,9 +5645,7 @@ The bigger the number, the faster zooming with the mouse wheel will be.</string>
<tabstop>mDefaultTileMaxRetrySpinBox</tabstop>
<tabstop>leUserAgent</tabstop>
<tabstop>mCacheDirectory</tabstop>
<tabstop>mBrowseCacheDirectory</tabstop>
<tabstop>mCacheSize</tabstop>
<tabstop>mClearCache</tabstop>
<tabstop>grpProxy</tabstop>
<tabstop>mProxyTypeComboBox</tabstop>
<tabstop>leProxyHost</tabstop>

0 comments on commit 8643177

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