Skip to content

Commit 3852e5d

Browse files
committed
[auth] Update wording of auth settings widget; add formatted warnings
1 parent 74e9242 commit 3852e5d

File tree

5 files changed

+115
-72
lines changed

5 files changed

+115
-72
lines changed

python/gui/auth/qgsauthsettingswidget.sip

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ class QgsAuthSettingsWidget : QWidget
2222
%End
2323
public:
2424

25+
enum WarningType
26+
{
27+
ProjectFile,
28+
UserSettings
29+
};
30+
2531
explicit QgsAuthSettingsWidget( QWidget *parent /TransferThis/ = 0,
2632
const QString &configId = QString(),
2733
const QString &username = QString(),
@@ -41,6 +47,7 @@ class QgsAuthSettingsWidget : QWidget
4147
%Docstring
4248
setWarningText set the text of the warning label
4349
\param warningText the text of the warning label
50+
.. seealso:: formattedWarning()
4451
%End
4552

4653
void setBasicText( const QString &basicText );
@@ -101,6 +108,14 @@ class QgsAuthSettingsWidget : QWidget
101108
:rtype: str
102109
%End
103110

111+
static const QString formattedWarning( WarningType warning );
112+
%Docstring
113+
warning text message based upon where credentials are stored
114+
\param enum of warning type
115+
:return: pre-formatted warning text
116+
:rtype: str
117+
%End
118+
104119
bool btnConvertToEncryptedIsEnabled( ) const;
105120
%Docstring
106121
convertButtonEnabled, mainly useful for unit tests
@@ -145,7 +160,6 @@ class QgsAuthSettingsWidget : QWidget
145160
:rtype: bool
146161
%End
147162

148-
149163
bool configurationTabIsSelected( );
150164
%Docstring
151165
configurationTabIsSelected

src/app/qgsoptions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
312312
mAuthSettings->setDataprovider( QStringLiteral( "proxy" ) );
313313
QString authcfg = mSettings->value( QStringLiteral( "proxy/authcfg" ) ).toString();
314314
mAuthSettings->setConfigId( authcfg );
315-
mAuthSettings->setWarningText( tr( "<b style=\"color:red\">Warning: credentials are stored unencrypted (in clear text) in the system settings!</b>" ) );
315+
mAuthSettings->setWarningText( mAuthSettings->formattedWarning( QgsAuthSettingsWidget::UserSettings ) );
316316

317317
//Web proxy settings
318318
grpProxy->setChecked( mSettings->value( QStringLiteral( "proxy/proxyEnabled" ), "0" ).toBool() );

src/gui/auth/qgsauthsettingswidget.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ QgsAuthSettingsWidget::QgsAuthSettingsWidget( QWidget *parent,
3939
mAuthConfigSelect->setConfigId( configId );
4040
}
4141
setBasicText( "" );
42+
// default to warning about basic settings stored in project file
43+
setWarningText( formattedWarning( ProjectFile ) );
4244
connect( btnConvertToEncrypted, &QPushButton::clicked, this, &QgsAuthSettingsWidget::convertToEncrypted );
4345
connect( txtUserName, &QLineEdit::textChanged, this, &QgsAuthSettingsWidget::userNameTextChanged );
4446
connect( txtPassword, &QLineEdit::textChanged, this, &QgsAuthSettingsWidget::passwordTextChanged );
@@ -99,6 +101,18 @@ const QString QgsAuthSettingsWidget::dataprovider() const
99101
return mDataprovider;
100102
}
101103

104+
const QString QgsAuthSettingsWidget::formattedWarning( WarningType warning )
105+
{
106+
QString out = tr( "<div>Warning: credentials stored as plain text in %1.</div>" );
107+
switch ( warning )
108+
{
109+
case ProjectFile:
110+
return out.arg( tr( "project file" ) );
111+
case UserSettings:
112+
return out.arg( tr( "user settings" ) );
113+
}
114+
}
115+
102116
const QString QgsAuthSettingsWidget::configId() const
103117
{
104118
return mAuthConfigSelect->configId();

src/gui/auth/qgsauthsettingswidget.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ class GUI_EXPORT QgsAuthSettingsWidget : public QWidget, private Ui::QgsAuthSett
3535

3636
public:
3737

38+
//! Type of certificate usage
39+
enum WarningType
40+
{
41+
ProjectFile,
42+
UserSettings
43+
};
44+
Q_ENUM( WarningType )
45+
3846
/**
3947
* Create a dialog for setting an associated authentication config, either
4048
* from existing configs, or creating/removing them from auth database
@@ -53,6 +61,7 @@ class GUI_EXPORT QgsAuthSettingsWidget : public QWidget, private Ui::QgsAuthSett
5361
/**
5462
* \brief setWarningText set the text of the warning label
5563
* \param warningText the text of the warning label
64+
* \see formattedWarning()
5665
*/
5766
void setWarningText( const QString &warningText );
5867

@@ -110,6 +119,13 @@ class GUI_EXPORT QgsAuthSettingsWidget : public QWidget, private Ui::QgsAuthSett
110119
*/
111120
const QString dataprovider( ) const;
112121

122+
/**
123+
* \brief warning text message based upon where credentials are stored
124+
* \param enum of warning type
125+
* \return pre-formatted warning text
126+
*/
127+
static const QString formattedWarning( WarningType warning );
128+
113129
/**
114130
* \brief convertButtonEnabled, mainly useful for unit tests
115131
* \return true if the convert button is enabled
@@ -151,7 +167,6 @@ class GUI_EXPORT QgsAuthSettingsWidget : public QWidget, private Ui::QgsAuthSett
151167
*/
152168
bool storeUsernameIsChecked( ) const;
153169

154-
155170
/**
156171
* \brief configurationTabIsSelected
157172
* \return true if the configuration tab is the currently selected tab

src/ui/auth/qgsauthsettingswidget.ui

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>315</width>
10-
<height>243</height>
9+
<width>226</width>
10+
<height>179</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -69,7 +69,7 @@
6969
</sizepolicy>
7070
</property>
7171
<property name="text">
72-
<string>Choose or create a configuration.</string>
72+
<string>Choose or create an authentication configuration</string>
7373
</property>
7474
<property name="textFormat">
7575
<enum>Qt::PlainText</enum>
@@ -101,7 +101,7 @@
101101
</sizepolicy>
102102
</property>
103103
<property name="text">
104-
<string>Credentials are encrypted and stored in the QGIS authentication database. </string>
104+
<string>Configurations store encrypted credentials in the QGIS authentication database.</string>
105105
</property>
106106
<property name="textFormat">
107107
<enum>Qt::PlainText</enum>
@@ -146,26 +146,66 @@
146146
<property name="spacing">
147147
<number>6</number>
148148
</property>
149-
<item row="6" column="1">
150-
<spacer name="verticalSpacer">
151-
<property name="orientation">
152-
<enum>Qt::Vertical</enum>
149+
<item row="4" column="0" colspan="3">
150+
<layout class="QHBoxLayout" name="horizontalLayout">
151+
<item>
152+
<widget class="QPushButton" name="btnConvertToEncrypted">
153+
<property name="sizePolicy">
154+
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
155+
<horstretch>0</horstretch>
156+
<verstretch>0</verstretch>
157+
</sizepolicy>
158+
</property>
159+
<property name="text">
160+
<string>Convert to configuration</string>
161+
</property>
162+
</widget>
163+
</item>
164+
</layout>
165+
</item>
166+
<item row="2" column="2">
167+
<widget class="QCheckBox" name="cbStorePassword">
168+
<property name="text">
169+
<string>Store</string>
153170
</property>
154-
<property name="sizeHint" stdset="0">
171+
<property name="checked">
172+
<bool>false</bool>
173+
</property>
174+
</widget>
175+
</item>
176+
<item row="3" column="0" colspan="3">
177+
<widget class="QLabel" name="lblWarning">
178+
<property name="styleSheet">
179+
<string notr="true">QLabel{color: rgb(255, 0, 0);font-weight: bold;}</string>
180+
</property>
181+
<property name="text">
182+
<string>Warning text!</string>
183+
</property>
184+
<property name="alignment">
185+
<set>Qt::AlignCenter</set>
186+
</property>
187+
<property name="wordWrap">
188+
<bool>true</bool>
189+
</property>
190+
</widget>
191+
</item>
192+
<item row="1" column="1">
193+
<widget class="QLineEdit" name="txtUserName">
194+
<property name="minimumSize">
155195
<size>
156-
<width>0</width>
196+
<width>80</width>
157197
<height>0</height>
158198
</size>
159199
</property>
160-
</spacer>
200+
</widget>
161201
</item>
162-
<item row="1" column="0">
163-
<widget class="QLabel" name="label_2">
202+
<item row="1" column="2">
203+
<widget class="QCheckBox" name="cbStoreUsername">
164204
<property name="text">
165-
<string>&amp;User name</string>
205+
<string>Store</string>
166206
</property>
167-
<property name="buddy">
168-
<cstring>txtUserName</cstring>
207+
<property name="checked">
208+
<bool>false</bool>
169209
</property>
170210
</widget>
171211
</item>
@@ -195,49 +235,26 @@
195235
</property>
196236
</widget>
197237
</item>
198-
<item row="1" column="1">
199-
<widget class="QLineEdit" name="txtUserName">
200-
<property name="minimumSize">
238+
<item row="6" column="1">
239+
<spacer name="verticalSpacer">
240+
<property name="orientation">
241+
<enum>Qt::Vertical</enum>
242+
</property>
243+
<property name="sizeHint" stdset="0">
201244
<size>
202-
<width>80</width>
245+
<width>0</width>
203246
<height>0</height>
204247
</size>
205248
</property>
206-
</widget>
207-
</item>
208-
<item row="1" column="2">
209-
<widget class="QCheckBox" name="cbStoreUsername">
210-
<property name="text">
211-
<string>Store</string>
212-
</property>
213-
<property name="checked">
214-
<bool>false</bool>
215-
</property>
216-
</widget>
217-
</item>
218-
<item row="2" column="2">
219-
<widget class="QCheckBox" name="cbStorePassword">
220-
<property name="text">
221-
<string>Store</string>
222-
</property>
223-
<property name="checked">
224-
<bool>false</bool>
225-
</property>
226-
</widget>
249+
</spacer>
227250
</item>
228-
<item row="3" column="0" colspan="3">
229-
<widget class="QLabel" name="lblWarning">
251+
<item row="1" column="0">
252+
<widget class="QLabel" name="label_2">
230253
<property name="text">
231-
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600; color:#ff0000;&quot;&gt;Warning: credentials stored unencrypted!&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
232-
</property>
233-
<property name="textFormat">
234-
<enum>Qt::RichText</enum>
235-
</property>
236-
<property name="alignment">
237-
<set>Qt::AlignCenter</set>
254+
<string>&amp;User name</string>
238255
</property>
239-
<property name="wordWrap">
240-
<bool>true</bool>
256+
<property name="buddy">
257+
<cstring>txtUserName</cstring>
241258
</property>
242259
</widget>
243260
</item>
@@ -257,23 +274,6 @@
257274
</property>
258275
</widget>
259276
</item>
260-
<item row="4" column="0" colspan="3">
261-
<layout class="QHBoxLayout" name="horizontalLayout">
262-
<item>
263-
<widget class="QPushButton" name="btnConvertToEncrypted">
264-
<property name="sizePolicy">
265-
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
266-
<horstretch>0</horstretch>
267-
<verstretch>0</verstretch>
268-
</sizepolicy>
269-
</property>
270-
<property name="text">
271-
<string>Convert to configuration</string>
272-
</property>
273-
</widget>
274-
</item>
275-
</layout>
276-
</item>
277277
</layout>
278278
</widget>
279279
</widget>

0 commit comments

Comments
 (0)