TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

passdlg.h 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /* This file is part of the KDE libraries
  2. Copyright (C) 2000 David Faure <faure@kde.org>
  3. Copyright (C) 2000 Dawit Alemayehu <adawit@kde.org>
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License version 2 as published by the Free Software Foundation.
  7. This library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Library General Public License for more details.
  11. You should have received a copy of the GNU Library General Public
  12. License along with this library; see the file COPYING.LIB. If
  13. not, write to the Free Software Foundation, Inc., 51 Franklin Street,
  14. Fifth Floor, Boston, MA 02110-1301, USA.
  15. */
  16. #ifndef __tdeio_pass_dlg_h__
  17. #define __tdeio_pass_dlg_h__
  18. #include <kdialogbase.h>
  19. class TQGridLayout;
  20. namespace TDEIO {
  21. /**
  22. * A dialog for requesting a login and a password from the end user.
  23. *
  24. * KIO-Slave authors are encouraged to use SlaveBase::openPassDlg
  25. * instead of directly instantiating this dialog.
  26. * @short dialog for requesting login and password from the end user
  27. */
  28. class TDEIO_EXPORT PasswordDialog : public KDialogBase
  29. {
  30. Q_OBJECT
  31. public:
  32. /**
  33. * Create a password dialog.
  34. *
  35. * @param prompt instructional text to be shown.
  36. * @param user username, if known initially.
  37. * @param enableKeep if true, shows checkbox that makes password persistent until KDE is shutdown.
  38. * @param modal if true, the dialog will be modal (default:true).
  39. * @param parent the parent widget (default:NULL).
  40. * @param name the dialog name (default:NULL).
  41. */
  42. PasswordDialog( const TQString& prompt, const TQString& user,
  43. bool enableKeep = false, bool modal=true,
  44. TQWidget* parent=0, const char* name=0 );
  45. /**
  46. * Destructor
  47. */
  48. ~PasswordDialog();
  49. /**
  50. * Sets the prompt to show to the user.
  51. * @param prompt instructional text to be shown.
  52. */
  53. void setPrompt( const TQString& prompt );
  54. /**
  55. * Adds a comment line to the dialog.
  56. *
  57. * This function allows you to add one additional comment
  58. * line to this widget. Calling this function after a
  59. * comment has already been added will not have any effect.
  60. *
  61. * @param label label for comment (ex:"Command:")
  62. * @param comment the actual comment text.
  63. */
  64. void addCommentLine( const TQString& label, const TQString comment );
  65. /**
  66. * Returns the password entered by the user.
  67. * @return the password
  68. */
  69. TQString password() const;
  70. /**
  71. * Returns the username entered by the user.
  72. * @return the user name
  73. */
  74. TQString username() const;
  75. /**
  76. * Determines whether supplied authorization should
  77. * persist even after the application has been closed.
  78. * @return true to keep the password
  79. */
  80. bool keepPassword() const;
  81. /**
  82. * Check or uncheck the "keep password" checkbox.
  83. * This can be used to check it before showing the dialog, to tell
  84. * the user that the password is stored already (e.g. in the wallet).
  85. * enableKeep must have been set to true in the constructor.
  86. */
  87. void setKeepPassword( bool b );
  88. /**
  89. * Sets the username field read-only and sets the
  90. * focus to the password field.
  91. *
  92. * @param readOnly true to set the user field to read-only
  93. */
  94. void setUserReadOnly( bool readOnly );
  95. /**
  96. * @deprecated. Use setUserReadOnly(bool).
  97. */
  98. KDE_DEPRECATED void setEnableUserField( bool enable, bool=false ) {
  99. setUserReadOnly( !enable );
  100. };
  101. /**
  102. * Presets the password.
  103. * @param password the password to set
  104. * @since 3.1
  105. */
  106. void setPassword( const TQString& password );
  107. /**
  108. * Presets a number of login+password pairs that the user can choose from.
  109. * The passwords can be empty if you simply want to offer usernames to choose from.
  110. * This is incompatible with setUserReadOnly(true).
  111. * @param knownLogins map of known logins: the keys are usernames, the values are passwords.
  112. * @since 3.4
  113. */
  114. void setKnownLogins( const TQMap<TQString, TQString>& knownLogins );
  115. /**
  116. * A convienence static method for obtaining authorization
  117. * information from the end user.
  118. *
  119. *
  120. * @param user username
  121. * @param pass password
  122. * @param keep pointer to flag that indicates whether to keep password (can be null)
  123. * @param prompt text to display to user.
  124. * @param readOnly make the username field read-only.
  125. * @param caption set the title bar to given text.
  126. * @param comment extra comment to display to user.
  127. * @param label optinal label for extra comment.
  128. *
  129. * @return Accepted/Rejected based on the user choice.
  130. */
  131. static int getNameAndPassword( TQString& user, TQString& pass, bool* keep,
  132. const TQString& prompt = TQString::null,
  133. bool readOnly = false,
  134. const TQString& caption = TQString::null,
  135. const TQString& comment = TQString::null,
  136. const TQString& label = TQString::null );
  137. private slots:
  138. void slotKeep( bool );
  139. void slotActivated( const TQString& userName );
  140. private:
  141. void init( const TQString&, const TQString&, bool );
  142. protected:
  143. virtual void virtual_hook( int id, void* data );
  144. private:
  145. struct PasswordDialogPrivate;
  146. PasswordDialogPrivate* d;
  147. };
  148. }
  149. #endif