Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MetaSearch] mask password when opening connection properties dialog (#42760) #42767

Merged
merged 1 commit into from Apr 17, 2021

Conversation

tomkralidis
Copy link
Contributor

Description

Fixes #42760

@tomkralidis tomkralidis added Bug Either a bug report, or a bug fix. Let's hope for the latter! MetaSearch labels Apr 12, 2021
@Gustry
Copy link
Contributor

Gustry commented Apr 12, 2021

@tomkralidis
Copy link
Contributor Author

What about https://qgis.org/api/classQgsPasswordLineEdit.html ?

I couldn't get this working (NoSuchWidgetError). Is there a difference in using QgsPasswordLineEdit vs. QLineEdit ?

@github-actions github-actions bot added this to the 3.20.0 milestone Apr 12, 2021
@agiudiceandrea
Copy link
Contributor

I couldn't get this working (NoSuchWidgetError). Is there a difference in using QgsPasswordLineEdit vs. QLineEdit ?

Hi @tomkralidis, in order to correctly use QgsPasswordLineEdit it seems you need to have the following lines in newconnectiondialog.ui (note the <header>qgis.gui</header> property):

 <customwidgets>
  <customwidget>
   <class>QgsPasswordLineEdit</class>
   <extends>QLineEdit</extends>
   <header>qgis.gui</header>
  </customwidget>
 </customwidgets>

QgsPasswordLineEdit is different from QLineEdit as the former allow the user to toggle the password visibility
image

@tomkralidis
Copy link
Contributor Author

Thanks @agiudiceandrea . PR updated to use QgsPasswordLineEdit

@tomkralidis tomkralidis changed the title [MetaSearch]: mask password when opening connection properties dialog (#42760) [MetaSearch] mask password when opening connection properties dialog (#42760) Apr 13, 2021
<widget class="QLineEdit" name="lePassword"/>
<widget class="QgsPasswordLineEdit" name="lePassword">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
Copy link
Contributor

@Gustry Gustry Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking, but the QgsPasswordLineEdit will do it for you when it is needed :)
https://github.com/qgis/QGIS/blob/master/src/gui/qgspasswordlineedit.cpp#L54

@Gustry
Copy link
Contributor

Gustry commented Apr 13, 2021

Thanks @agiudiceandrea, indeed you might need to use the "Promote widget" for instance in QtDesigner https://doc.qt.io/qt-5/designer-using-custom-widgets.html it will add these lines.

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Apr 13, 2021

you might need to use the "Promote widget" for instance in QtDesigner ... it will add these lines.

@Gustry the issue with QT Designer and QGIS custom widgets (at least on Windows / OSGeo4W) is that if you use e.g. a QgsPasswordLineEdit widget, the QT Designer adds the following lines to the .ui file

 <customwidgets>
  <customwidget>
   <class>QgsPasswordLineEdit</class>
   <extends>QLineEdit</extends>
   <header>qgspasswordlineedit.h</header>
  </customwidget>
 </customwidgets>

The <header>qgspasswordlineedit.h</header> property leads (sometimes) to the NoSuchWidgetError error if the form is used in Python, while it's ok in C++.

Substituting <header>qgspasswordlineedit.h</header> with <header>qgis.gui</header> fixes the issue in Python.

See #38472 (comment)

Comment on lines 71 to 75
<widget class="QgsPasswordLineEdit" name="lePassword">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<widget class="QgsPasswordLineEdit" name="lePassword">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
<widget class="QgsPasswordLineEdit" name="lePassword"/>

According to the discussion on gitter @tomkralidis ?
Otherwise, I was thinking the "eye" graphic icon might not be synchronized with the status of showing or not the password :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Gustry makes sense. Changes pushed.

Copy link
Contributor

@Gustry Gustry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tomkralidis tomkralidis merged commit 2a5fd3d into qgis:master Apr 17, 2021
@tomkralidis tomkralidis deleted the issue-42760 branch April 17, 2021 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! MetaSearch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Metasearch show password when opening connection properties dialog
3 participants