QGIS API Documentation  3.13.0-Master (740be229cb)
qgspasswordlineedit.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgspasswordlineedit.h
3  ------------------------
4  begin : March 13, 2017
5  copyright : (C) 2017 by Alexander Bruy
6  email : alexander dot bruy at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSPASSWORDLINEEDIT_H
19 #define QGSPASSWORDLINEEDIT_H
20 
21 #include <QLineEdit>
22 #include <QAction>
23 
24 #include "qgis_gui.h"
25 
33 class GUI_EXPORT QgsPasswordLineEdit : public QLineEdit
34 {
35  Q_OBJECT
36  Q_PROPERTY( bool showLockIcon READ showLockIcon WRITE setShowLockIcon )
37 
38  public:
39 
45  QgsPasswordLineEdit( QWidget *parent = nullptr, bool passwordVisible = false );
46 
51  void setShowLockIcon( bool visible );
52 
56  bool showLockIcon() const { return mLockIconVisible; }
57 
61  void setPasswordVisibility( bool visible );
62 
63  private slots:
64  void togglePasswordVisibility( bool toggled );
65 
66  private:
67 
68  QAction *mActionShowHidePassword = nullptr;
69  QAction *mActionLock = nullptr;
70 
71  QIcon mShowPasswordIcon;
72  QIcon mHidePasswordIcon;
73 
74  bool mLockIconVisible = false;
75  QSize mIconsSize;
76 };
77 
78 #endif // QGSPASSWORDLINEEDIT_H
bool showLockIcon() const
Returns if a lock icon shall be shown on the left of the widget.
QLineEdit subclass with built in support for showing/hiding entered password.