Warning, file /frameworks/kwidgetsaddons/src/kpasswordlineedit.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2017 Montel Laurent <montel@kde.org> 0003 SPDX-FileCopyrightText: 2015 Elvis Angelaccio <elvis.angelaccio@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 #ifndef KPASSWORDLINEEDIT_H 0009 #define KPASSWORDLINEEDIT_H 0010 0011 #include <QLineEdit> 0012 #include <QWidget> 0013 #include <kwidgetsaddons_export.h> 0014 #include <memory> 0015 class QAction; 0016 0017 /** 0018 * @class KPasswordLineEdit kpasswordlineedit.h KPasswordLineEdit 0019 * 0020 * A lineedit which allows to display password 0021 * 0022 * \section usage Usage Example 0023 * 0024 * Get password 0025 * 0026 * \code 0027 * KPasswordLineEdit *passwordLineEdit = new KPasswordLineEdit(parent); 0028 * QString password = passwordLineEdit->password(); 0029 * \endcode 0030 * 0031 * @author Laurent Montel <montel@kde.org> 0032 * @since 5.37 0033 */ 0034 class KWIDGETSADDONS_EXPORT KPasswordLineEdit : public QWidget 0035 { 0036 Q_OBJECT 0037 Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged) 0038 Q_PROPERTY(bool clearButtonEnabled READ isClearButtonEnabled WRITE setClearButtonEnabled) 0039 Q_PROPERTY(QLineEdit::EchoMode echoMode READ echoMode WRITE setEchoMode NOTIFY echoModeChanged) 0040 public: 0041 /** 0042 * Constructs a lineedit password widget. 0043 * @since 5.37 0044 * 0045 * @param parent Passed to lower level constructor. 0046 */ 0047 explicit KPasswordLineEdit(QWidget *parent = nullptr); 0048 /** 0049 * Destructs the lineedit password widget. 0050 */ 0051 ~KPasswordLineEdit() override; 0052 0053 /** 0054 * Assign password 0055 */ 0056 void setPassword(const QString &password); 0057 0058 /** 0059 * Returns the password entered. 0060 */ 0061 QString password() const; 0062 0063 /** 0064 * Clear text 0065 */ 0066 void clear(); 0067 0068 /** 0069 * Show/hide clear button (false by default) 0070 */ 0071 void setClearButtonEnabled(bool clear); 0072 0073 /** 0074 * Inform if we show or not clear button 0075 */ 0076 bool isClearButtonEnabled() const; 0077 0078 /** 0079 * Change echo mode (QLineEdit::Password by default) 0080 */ 0081 void setEchoMode(QLineEdit::EchoMode mode); 0082 0083 /** 0084 * Return echo mode 0085 */ 0086 QLineEdit::EchoMode echoMode() const; 0087 0088 /** 0089 * Whether to show the visibility trailing action in the line edit. 0090 * Default is true. This can be used to honor the lineedit_reveal_password 0091 * kiosk key, for example: 0092 * \code 0093 * passwordLineEdit.setRevealPasswordAvailable(KAuthorized::authorize(QStringLiteral("lineedit_reveal_password"))); 0094 * \endcode 0095 */ 0096 void setRevealPasswordAvailable(bool reveal); 0097 0098 /** 0099 * Whether the visibility trailing action in the line edit is visible. 0100 */ 0101 bool isRevealPasswordAvailable() const; 0102 0103 /** 0104 * @internal 0105 * Returns the QAction 0106 */ 0107 QAction *toggleEchoModeAction() const; 0108 0109 /** 0110 * Returns the lineedit widget. 0111 */ 0112 QLineEdit *lineEdit() const; 0113 0114 Q_SIGNALS: 0115 /** 0116 * When we click on visibility icon echo mode is switched between Normal echo mode and Password echo mode 0117 */ 0118 void echoModeChanged(QLineEdit::EchoMode echoMode); 0119 void passwordChanged(const QString &password); 0120 0121 private: 0122 std::unique_ptr<class KPasswordLineEditPrivate> const d; 0123 }; 0124 0125 #endif