Skip to content

Commit 7ee03a6

Browse files
committed
[auth] Use new auth settings widget in http connections dialogs
1 parent c57b9e7 commit 7ee03a6

File tree

4 files changed

+34
-115
lines changed

4 files changed

+34
-115
lines changed

src/gui/qgsnewhttpconnection.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* *
1616
***************************************************************************/
1717
#include "qgsnewhttpconnection.h"
18-
#include "qgsauthconfigselect.h"
18+
#include "qgsauthsettingswidget.h"
1919
#include "qgssettings.h"
2020
#include "qgshelp.h"
2121

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

63-
mAuthConfigSelect = new QgsAuthConfigSelect( this );
64-
tabAuth->insertTab( 1, mAuthConfigSelect, tr( "Configurations" ) );
65-
6663
if ( !connectionName.isEmpty() )
6764
{
6865
// populate the dialog with the information stored for the connection
@@ -77,15 +74,10 @@ QgsNewHttpConnection::QgsNewHttpConnection( QWidget *parent, ConnectionTypes typ
7774

7875
updateServiceSpecificSettings();
7976

80-
txtUserName->setText( settings.value( credentialsKey + "/username" ).toString() );
81-
txtPassword->setText( settings.value( credentialsKey + "/password" ).toString() );
82-
83-
QString authcfg = settings.value( credentialsKey + "/authcfg" ).toString();
84-
mAuthConfigSelect->setConfigId( authcfg );
85-
if ( !authcfg.isEmpty() )
86-
{
87-
tabAuth->setCurrentIndex( tabAuth->indexOf( mAuthConfigSelect ) );
88-
}
77+
// Authentication
78+
mAuthSettings->setUsername( settings.value( credentialsKey + "/username" ).toString() );
79+
mAuthSettings->setPassword( settings.value( credentialsKey + "/password" ).toString() );
80+
mAuthSettings->setConfigId( settings.value( credentialsKey + "/authcfg" ).toString() );
8981
}
9082

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

191-
if ( !txtPassword->text().isEmpty() &&
183+
if ( ! mAuthSettings->password().isEmpty() &&
192184
QMessageBox::question( this,
193185
tr( "Saving passwords" ),
194186
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()
372364
settings.setValue( wfsKey + "/maxnumfeatures", txtMaxNumFeatures->text() );
373365
}
374366

375-
settings.setValue( credentialsKey + "/username", txtUserName->text() );
376-
settings.setValue( credentialsKey + "/password", txtPassword->text() );
367+
settings.setValue( credentialsKey + "/username", mAuthSettings->username() );
368+
settings.setValue( credentialsKey + "/password", mAuthSettings->password() );
377369

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

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

src/gui/qgsnewhttpconnection.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include "qgsguiutils.h"
2424
#include "qgis_gui.h"
2525

26-
class QgsAuthConfigSelect;
26+
class QgsAuthSettingsWidget;
2727

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

145144
};

src/providers/geonode/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ QT5_WRAP_CPP(GEONODE_MOC_SRCS ${GEONODE_MOC_HDRS})
2020
INCLUDE_DIRECTORIES(
2121
${CMAKE_SOURCE_DIR}/src/core
2222
${CMAKE_SOURCE_DIR}/src/core/raster
23+
${CMAKE_SOURCE_DIR}/src/core/auth
2324
${CMAKE_SOURCE_DIR}/src/core/geocms/geonode
2425
${CMAKE_SOURCE_DIR}/src/core/geometry
2526
${CMAKE_SOURCE_DIR}/src/core/metadata
2627
${CMAKE_SOURCE_DIR}/src/core/symbology
2728
${CMAKE_SOURCE_DIR}/src/core/expression
2829
${CMAKE_SOURCE_DIR}/src/gui
30+
${CMAKE_SOURCE_DIR}/src/gui/auth
2931

3032
${CMAKE_BINARY_DIR}/src/core
3133
${CMAKE_BINARY_DIR}/src/gui

src/ui/qgsnewhttpconnectionbase.ui

Lines changed: 22 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<string>Connection details</string>
2727
</property>
2828
<layout class="QGridLayout">
29-
<item row="8" column="0" colspan="2">
29+
<item row="6" column="0" colspan="2">
3030
<widget class="QGroupBox" name="mWfsOptionsGroupBox">
3131
<property name="title">
3232
<string>WFS Options</string>
@@ -77,96 +77,14 @@
7777
</layout>
7878
</widget>
7979
</item>
80-
<item row="18" column="0" colspan="2">
80+
<item row="16" column="0" colspan="2">
8181
<widget class="QPushButton" name="mTestConnectionButton">
8282
<property name="text">
8383
<string>&amp;Test Connection</string>
8484
</property>
8585
</widget>
8686
</item>
87-
<item row="7" column="0" colspan="2">
88-
<widget class="QTabWidget" name="tabAuth">
89-
<property name="sizePolicy">
90-
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
91-
<horstretch>0</horstretch>
92-
<verstretch>0</verstretch>
93-
</sizepolicy>
94-
</property>
95-
<property name="currentIndex">
96-
<number>0</number>
97-
</property>
98-
<widget class="QWidget" name="tab">
99-
<attribute name="title">
100-
<string>Authentication</string>
101-
</attribute>
102-
<layout class="QGridLayout" name="gridLayout_3">
103-
<item row="0" column="0" colspan="2">
104-
<widget class="QLabel" name="label">
105-
<property name="sizePolicy">
106-
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
107-
<horstretch>0</horstretch>
108-
<verstretch>0</verstretch>
109-
</sizepolicy>
110-
</property>
111-
<property name="text">
112-
<string>If the service requires basic authentication, enter a user name and optional password</string>
113-
</property>
114-
<property name="textFormat">
115-
<enum>Qt::PlainText</enum>
116-
</property>
117-
<property name="wordWrap">
118-
<bool>true</bool>
119-
</property>
120-
</widget>
121-
</item>
122-
<item row="1" column="0">
123-
<widget class="QLabel" name="label_2">
124-
<property name="text">
125-
<string>&amp;User name</string>
126-
</property>
127-
<property name="buddy">
128-
<cstring>txtUserName</cstring>
129-
</property>
130-
</widget>
131-
</item>
132-
<item row="1" column="1">
133-
<widget class="QLineEdit" name="txtUserName"/>
134-
</item>
135-
<item row="2" column="0">
136-
<widget class="QLabel" name="label_3">
137-
<property name="text">
138-
<string>Password</string>
139-
</property>
140-
<property name="buddy">
141-
<cstring>txtPassword</cstring>
142-
</property>
143-
</widget>
144-
</item>
145-
<item row="2" column="1">
146-
<widget class="QgsPasswordLineEdit" name="txtPassword">
147-
<property name="echoMode">
148-
<enum>QLineEdit::Password</enum>
149-
</property>
150-
</widget>
151-
</item>
152-
<item row="3" column="1">
153-
<spacer name="verticalSpacer">
154-
<property name="orientation">
155-
<enum>Qt::Vertical</enum>
156-
</property>
157-
<property name="sizeHint" stdset="0">
158-
<size>
159-
<width>0</width>
160-
<height>0</height>
161-
</size>
162-
</property>
163-
</spacer>
164-
</item>
165-
</layout>
166-
</widget>
167-
</widget>
168-
</item>
169-
<item row="12" column="0" colspan="2">
87+
<item row="10" column="0" colspan="2">
17088
<widget class="QGroupBox" name="mWmsOptionsGroupBox">
17189
<property name="title">
17290
<string>WMS Options</string>
@@ -209,7 +127,7 @@
209127
<item row="1" column="0">
210128
<widget class="QLabel" name="lblDpiMode">
211129
<property name="text">
212-
<string>DPI-Mode</string>
130+
<string>&amp;DPI-Mode</string>
213131
</property>
214132
<property name="buddy">
215133
<cstring>cmbDpiMode</cstring>
@@ -241,7 +159,7 @@
241159
<item row="0" column="0">
242160
<widget class="QLabel" name="TextLabel1_2">
243161
<property name="text">
244-
<string>Name</string>
162+
<string>&amp;Name</string>
245163
</property>
246164
<property name="wordWrap">
247165
<bool>true</bool>
@@ -273,7 +191,7 @@
273191
<item row="1" column="0">
274192
<widget class="QLabel" name="TextLabel1">
275193
<property name="text">
276-
<string>URL</string>
194+
<string>UR&amp;L</string>
277195
</property>
278196
<property name="margin">
279197
<number>5</number>
@@ -292,6 +210,18 @@
292210
</item>
293211
</layout>
294212
</item>
213+
<item row="4" column="0">
214+
<widget class="QGroupBox" name="mAuthGroupBox">
215+
<property name="title">
216+
<string>Authentication</string>
217+
</property>
218+
<layout class="QVBoxLayout" name="verticalLayout">
219+
<item>
220+
<widget class="QgsAuthSettingsWidget" name="mAuthSettings" native="true"/>
221+
</item>
222+
</layout>
223+
</widget>
224+
</item>
295225
</layout>
296226
</widget>
297227
</item>
@@ -307,16 +237,12 @@
307237
<layoutdefault spacing="6" margin="11"/>
308238
<customwidgets>
309239
<customwidget>
310-
<class>QgsPasswordLineEdit</class>
311-
<extends>QLineEdit</extends>
312-
<header>qgspasswordlineedit.h</header>
240+
<class>QgsAuthSettingsWidget</class>
241+
<extends>QWidget</extends>
242+
<header>auth/qgsauthsettingswidget.h</header>
243+
<container>1</container>
313244
</customwidget>
314245
</customwidgets>
315-
<tabstops>
316-
<tabstop>tabAuth</tabstop>
317-
<tabstop>txtUserName</tabstop>
318-
<tabstop>txtPassword</tabstop>
319-
</tabstops>
320246
<resources/>
321247
<connections>
322248
<connection>

0 commit comments

Comments
 (0)