Smb4K – Samba (SMB) share advanced browser
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.

136 lines
5.7KB

  1. /***************************************************************************
  2. smb4kauthoptions - The configuration page for the authentication
  3. settings of Smb4K
  4. -------------------
  5. begin : Sa Nov 15 2003
  6. copyright : (C) 2003-2007 by Alexander Reinholdt
  7. email : dustpuppy@users.berlios.de
  8. ***************************************************************************/
  9. /***************************************************************************
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. * This program is distributed in the hope that it will be useful, but *
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of *
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
  18. * General Public License for more details. *
  19. * *
  20. * You should have received a copy of the GNU General Public License *
  21. * along with this program; if not, write to the *
  22. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, *
  23. * MA 02110-1301 USA *
  24. ***************************************************************************/
  25. // TQt includes
  26. #include <tqcheckbox.h>
  27. #include <tqlayout.h>
  28. #include <tqgroupbox.h>
  29. #include <tqbuttongroup.h>
  30. #include <tqlabel.h>
  31. #include <tqwhatsthis.h>
  32. // KDE includes
  33. #include <tdelocale.h>
  34. #include <klineedit.h>
  35. // application specific includes
  36. #include "smb4kauthoptions.h"
  37. Smb4KAuthOptions::Smb4KAuthOptions( TQWidget *parent, const char *name )
  38. : TQWidget( parent, name )
  39. {
  40. //
  41. // Default Authentication
  42. //
  43. TQGridLayout *grid = new TQGridLayout( this );
  44. grid->setSpacing( 10 );
  45. TQButtonGroup *password_group = new TQButtonGroup( 1, Qt::Horizontal,
  46. i18n( "Password Storage" ), this );
  47. TQCheckBox *use_wallet = new TQCheckBox( i18n( "Save the authentication data in a wallet" ),
  48. password_group, "kcfg_UseWallet" );
  49. (void) new TQCheckBox( i18n( "If no wallet is used, remember authentication data during run time" ),
  50. password_group, "kcfg_RememberPasswords" );
  51. TQGroupBox *login_box = new TQGroupBox( 1, Qt::Horizontal, i18n( "Default Login" ),
  52. this, "DefaultLoginBox" );
  53. // login_box->setInsideMargin( 10 );
  54. TQCheckBox *default_auth = new TQCheckBox( i18n( "Use default login" ),
  55. login_box, "kcfg_UseDefaultLogin" );
  56. TQWidget *auth_widget = new TQWidget( login_box, "DefaultAuthWidget" );
  57. TQGridLayout *auth_grid = new TQGridLayout( auth_widget );
  58. auth_grid->setSpacing( 5 );
  59. TQLabel *login = new TQLabel( i18n( "User:" ), auth_widget );
  60. KLineEdit *default_login = new KLineEdit( auth_widget, "DefaultUserName" );
  61. default_login->setMinimumWidth( 150 );
  62. TQWhatsThis::add( default_login, i18n( "This login name is used by default to authenticate to a remote server." ) );
  63. TQLabel *password = new TQLabel( i18n( "Password:" ), auth_widget );
  64. KLineEdit *default_password = new KLineEdit( auth_widget, "DefaultPassword" );
  65. default_password->setEchoMode( KLineEdit::Password );
  66. default_password->setMinimumWidth( 150 );
  67. TQWhatsThis::add( default_password, i18n( "This password is used by default to authenticate to a remote server. It may be empty." ) );
  68. auth_grid->addWidget( login, 0, 0 );
  69. auth_grid->addWidget( default_login, 0, 1 );
  70. auth_grid->addWidget( password, 1, 0 );
  71. auth_grid->addWidget( default_password, 1, 1 );
  72. TQSpacerItem *spacer2 = new TQSpacerItem( 0, 0, TQSizePolicy::Preferred, TQSizePolicy::Expanding );
  73. grid->addWidget( password_group, 0, 0, 0 );
  74. grid->addWidget( login_box, 1, 0, 0 );
  75. grid->addItem( spacer2, 2, 0 );
  76. connect( use_wallet, TQT_SIGNAL( stateChanged( int ) ),
  77. this, TQT_SLOT( slotTDEWalletButtonState( int ) ) );
  78. connect( default_auth, TQT_SIGNAL( stateChanged( int ) ),
  79. this, TQT_SLOT( slotDefaultAuthButtonState( int ) ) );
  80. slotTDEWalletButtonState( use_wallet->state() );
  81. slotDefaultAuthButtonState( default_auth->state() );
  82. }
  83. Smb4KAuthOptions::~Smb4KAuthOptions()
  84. {
  85. }
  86. /////////////////////////////////////////////////////////////////////////////
  87. // TQT_SLOT IMPLEMENTATIONS
  88. /////////////////////////////////////////////////////////////////////////////
  89. void Smb4KAuthOptions::slotTDEWalletButtonState( int state )
  90. {
  91. if ( state == TQCheckBox::On )
  92. {
  93. static_cast<TQCheckBox *>( TQT_TQWIDGET(child( "DefaultLoginBox", TQGROUPBOX_OBJECT_NAME_STRING, true )) )->setEnabled( true );
  94. }
  95. else if ( state == TQCheckBox::Off )
  96. {
  97. static_cast<TQCheckBox *>( TQT_TQWIDGET(child( "DefaultLoginBox", TQGROUPBOX_OBJECT_NAME_STRING, true )) )->setEnabled( false );
  98. }
  99. }
  100. void Smb4KAuthOptions::slotDefaultAuthButtonState( int state )
  101. {
  102. if ( state == TQCheckBox::On )
  103. {
  104. static_cast<TQCheckBox *>( TQT_TQWIDGET(child( "DefaultAuthWidget", TQWIDGET_OBJECT_NAME_STRING, true )) )->setEnabled( true );
  105. }
  106. else if ( state == TQCheckBox::Off )
  107. {
  108. static_cast<TQCheckBox *>( TQT_TQWIDGET(child( "DefaultAuthWidget", TQWIDGET_OBJECT_NAME_STRING, true )) )->setEnabled( false );
  109. }
  110. }
  111. #include "smb4kauthoptions.moc"