Skip to content
Permalink
Browse files

[auth] Use new auth settings widget in http connections dialogs

  • Loading branch information
elpaso committed Oct 2, 2017
1 parent c57b9e7 commit 7ee03a6a0bb36538ff4e609a85da139b52206d11
@@ -15,7 +15,7 @@
* *
***************************************************************************/
#include "qgsnewhttpconnection.h"
#include "qgsauthconfigselect.h"
#include "qgsauthsettingswidget.h"
#include "qgssettings.h"
#include "qgshelp.h"

@@ -60,9 +60,6 @@ QgsNewHttpConnection::QgsNewHttpConnection( QWidget *parent, ConnectionTypes typ
cmbVersion->addItem( tr( "1.1" ) );
cmbVersion->addItem( tr( "2.0" ) );

mAuthConfigSelect = new QgsAuthConfigSelect( this );
tabAuth->insertTab( 1, mAuthConfigSelect, tr( "Configurations" ) );

if ( !connectionName.isEmpty() )
{
// populate the dialog with the information stored for the connection
@@ -77,15 +74,10 @@ QgsNewHttpConnection::QgsNewHttpConnection( QWidget *parent, ConnectionTypes typ

updateServiceSpecificSettings();

txtUserName->setText( settings.value( credentialsKey + "/username" ).toString() );
txtPassword->setText( settings.value( credentialsKey + "/password" ).toString() );

QString authcfg = settings.value( credentialsKey + "/authcfg" ).toString();
mAuthConfigSelect->setConfigId( authcfg );
if ( !authcfg.isEmpty() )
{
tabAuth->setCurrentIndex( tabAuth->indexOf( mAuthConfigSelect ) );
}
// Authentication
mAuthSettings->setUsername( settings.value( credentialsKey + "/username" ).toString() );
mAuthSettings->setPassword( settings.value( credentialsKey + "/password" ).toString() );
mAuthSettings->setConfigId( settings.value( credentialsKey + "/authcfg" ).toString() );
}

if ( !( mTypes & ConnectionWms ) && !( mTypes & ConnectionWcs ) )
@@ -188,7 +180,7 @@ bool QgsNewHttpConnection::validate()
return false;
}

if ( !txtPassword->text().isEmpty() &&
if ( ! mAuthSettings->password().isEmpty() &&
QMessageBox::question( this,
tr( "Saving passwords" ),
trUtf8( "WARNING: You have entered a password. It will be stored in unsecured plain text in your project files and your home directory (Unix-like OS) or user profile (Windows). If you want to avoid this, press Cancel and either:\n\na) Don't provide a password in the connection settings — it will be requested interactively when needed;\nb) Use the Configuration tab to add your credentials in an HTTP Basic Authentication method and store them in an encrypted database." ),
@@ -372,10 +364,10 @@ void QgsNewHttpConnection::accept()
settings.setValue( wfsKey + "/maxnumfeatures", txtMaxNumFeatures->text() );
}

settings.setValue( credentialsKey + "/username", txtUserName->text() );
settings.setValue( credentialsKey + "/password", txtPassword->text() );
settings.setValue( credentialsKey + "/username", mAuthSettings->username() );
settings.setValue( credentialsKey + "/password", mAuthSettings->password() );

settings.setValue( credentialsKey + "/authcfg", mAuthConfigSelect->configId() );
settings.setValue( credentialsKey + "/authcfg", mAuthSettings->configId() );

settings.setValue( mBaseKey + "/selected", txtName->text() );

@@ -23,7 +23,7 @@
#include "qgsguiutils.h"
#include "qgis_gui.h"

class QgsAuthConfigSelect;
class QgsAuthSettingsWidget;

/** \ingroup gui
* \brief Dialog to allow the user to configure and save connection
@@ -139,7 +139,6 @@ class GUI_EXPORT QgsNewHttpConnection : public QDialog, private Ui::QgsNewHttpCo
QString mBaseKey;
QString mCredentialsBaseKey;
QString mOriginalConnName; //store initial name to delete entry in case of rename
QgsAuthConfigSelect *mAuthConfigSelect = nullptr;
void showHelp();

};
@@ -20,12 +20,14 @@ QT5_WRAP_CPP(GEONODE_MOC_SRCS ${GEONODE_MOC_HDRS})
INCLUDE_DIRECTORIES(
${CMAKE_SOURCE_DIR}/src/core
${CMAKE_SOURCE_DIR}/src/core/raster
${CMAKE_SOURCE_DIR}/src/core/auth
${CMAKE_SOURCE_DIR}/src/core/geocms/geonode
${CMAKE_SOURCE_DIR}/src/core/geometry
${CMAKE_SOURCE_DIR}/src/core/metadata
${CMAKE_SOURCE_DIR}/src/core/symbology
${CMAKE_SOURCE_DIR}/src/core/expression
${CMAKE_SOURCE_DIR}/src/gui
${CMAKE_SOURCE_DIR}/src/gui/auth

${CMAKE_BINARY_DIR}/src/core
${CMAKE_BINARY_DIR}/src/gui
@@ -26,7 +26,7 @@
<string>Connection details</string>
</property>
<layout class="QGridLayout">
<item row="8" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<widget class="QGroupBox" name="mWfsOptionsGroupBox">
<property name="title">
<string>WFS Options</string>
@@ -77,96 +77,14 @@
</layout>
</widget>
</item>
<item row="18" column="0" colspan="2">
<item row="16" column="0" colspan="2">
<widget class="QPushButton" name="mTestConnectionButton">
<property name="text">
<string>&amp;Test Connection</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="QTabWidget" name="tabAuth">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Authentication</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>If the service requires basic authentication, enter a user name and optional password</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;User name</string>
</property>
<property name="buddy">
<cstring>txtUserName</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="txtUserName"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Password</string>
</property>
<property name="buddy">
<cstring>txtPassword</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QgsPasswordLineEdit" name="txtPassword">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item row="12" column="0" colspan="2">
<item row="10" column="0" colspan="2">
<widget class="QGroupBox" name="mWmsOptionsGroupBox">
<property name="title">
<string>WMS Options</string>
@@ -209,7 +127,7 @@
<item row="1" column="0">
<widget class="QLabel" name="lblDpiMode">
<property name="text">
<string>DPI-Mode</string>
<string>&amp;DPI-Mode</string>
</property>
<property name="buddy">
<cstring>cmbDpiMode</cstring>
@@ -241,7 +159,7 @@
<item row="0" column="0">
<widget class="QLabel" name="TextLabel1_2">
<property name="text">
<string>Name</string>
<string>&amp;Name</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@@ -273,7 +191,7 @@
<item row="1" column="0">
<widget class="QLabel" name="TextLabel1">
<property name="text">
<string>URL</string>
<string>UR&amp;L</string>
</property>
<property name="margin">
<number>5</number>
@@ -292,6 +210,18 @@
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QGroupBox" name="mAuthGroupBox">
<property name="title">
<string>Authentication</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QgsAuthSettingsWidget" name="mAuthSettings" native="true"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
@@ -307,16 +237,12 @@
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>QgsPasswordLineEdit</class>
<extends>QLineEdit</extends>
<header>qgspasswordlineedit.h</header>
<class>QgsAuthSettingsWidget</class>
<extends>QWidget</extends>
<header>auth/qgsauthsettingswidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabAuth</tabstop>
<tabstop>txtUserName</tabstop>
<tabstop>txtPassword</tabstop>
</tabstops>
<resources/>
<connections>
<connection>

0 comments on commit 7ee03a6

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