KRename – powerful batch renamer
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.

myinputdialog.cpp 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /***************************************************************************
  2. myinputdialog.cpp - description
  3. -------------------
  4. begin : Mit Apr 01 2002
  5. copyright : (C) 2002 by Dominik Seichter
  6. email : domseichter@web.de
  7. ***************************************************************************/
  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. ***************************************************************************/
  16. #include "myinputdialog.h"
  17. #include <klineedit.h>
  18. #include <kpushbutton.h>
  19. #include <tdelocale.h>
  20. #include <tqlabel.h>
  21. #include <tqlayout.h>
  22. #include <tqtooltip.h>
  23. MyInputDialog::MyInputDialog( TQString filename, bool revertEnabled, TQWidget* parent )
  24. : TQDialog( parent, 0, true, 0 )
  25. {
  26. // I do not think this has to be translated
  27. setCaption( "KRename" );
  28. MyInputDialogLayout = new TQVBoxLayout( this, 11, 6, "MyInputDialogLayout");
  29. Layout = new TQHBoxLayout( 0, 0, 6, "Layout");
  30. TextLabel1 = new TQLabel( this, "TextLabel1" );
  31. TextLabel1->setText( i18n( "Please input a new filename:" ) );
  32. text = new KLineEdit( this, "text" );
  33. text->setText( filename );
  34. TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
  35. buttonKrename = new KPushButton( this, "buttonKrename" );
  36. buttonKrename->setText( i18n( "&Revert Changes" ) );
  37. buttonKrename->setEnabled( revertEnabled );
  38. buttonFilename = new KPushButton( this, "buttonFilename" );
  39. buttonFilename->setText( i18n("Use &Input Filename") );
  40. buttonOk = new KPushButton( this, "buttonOk" );
  41. buttonOk->setText( i18n( "&Ok" ) );
  42. buttonOk->setDefault( true );
  43. buttonCancel = new KPushButton( this, "buttonCancel" );
  44. buttonCancel->setText( i18n( "&Cancel" ) );
  45. text->setFocus();
  46. Layout->addWidget( buttonKrename );
  47. Layout->addWidget( buttonFilename );
  48. Layout->addItem( spacer );
  49. Layout->addWidget( buttonOk );
  50. Layout->addWidget( buttonCancel );
  51. MyInputDialogLayout->addWidget( TextLabel1 );
  52. MyInputDialogLayout->addWidget( text );
  53. MyInputDialogLayout->addLayout( Layout );
  54. connect( buttonCancel, TQT_SIGNAL( clicked() ), this, TQT_SLOT( reject() ) );
  55. connect( buttonOk, TQT_SIGNAL( clicked() ), this, TQT_SLOT( accept() ) );
  56. connect( buttonKrename, TQT_SIGNAL( clicked() ), this, TQT_SLOT( krename() ) );
  57. connect( buttonFilename, TQT_SIGNAL( clicked() ), this, TQT_SLOT( slotFilename() ) );
  58. TQToolTip::add( buttonKrename, i18n("Use the filename that is generated by "
  59. "KRename instead of your changes." ) );
  60. }
  61. MyInputDialog::~MyInputDialog()
  62. { }
  63. TQString MyInputDialog::filename() const
  64. {
  65. return text->text();
  66. }
  67. void MyInputDialog::accept()
  68. {
  69. if( text->text().isEmpty() )
  70. reject();
  71. else
  72. done( OK );
  73. }
  74. void MyInputDialog::reject()
  75. {
  76. done( CANCEL );
  77. }
  78. void MyInputDialog::krename()
  79. {
  80. done( USE_KRENAME );
  81. }
  82. void MyInputDialog::slotFilename()
  83. {
  84. text->setText( m_oldfilename );
  85. }
  86. #include "myinputdialog.moc"