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.

123 lines
3.9KB

  1. /***************************************************************************
  2. tabs.cpp - description
  3. -------------------
  4. begin : Die Mai 20 2003
  5. copyright : (C) 2003 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 "tabs.h"
  17. #include "krenameimpl.h"
  18. #include "kmyhistorycombo.h"
  19. // TQt includes
  20. #include <tqlayout.h>
  21. #include <tqsizepolicy.h>
  22. #include <tqtabwidget.h>
  23. // KDE includes
  24. #include <tdeapplication.h>
  25. #include <kiconloader.h>
  26. #include <tdelocale.h>
  27. #include <tdemenubar.h>
  28. #include <tdemessagebox.h>
  29. #include <kpushbutton.h>
  30. #include <tdestartupinfo.h>
  31. tabs::tabs(KRenameImpl* impl, TQRect r, TQWidget *parent, const char *name )
  32. : TQDialog(parent,name)
  33. {
  34. setIcon( BarIcon( "krename" ) );
  35. TQVBoxLayout* layout = new TQVBoxLayout( this, 6, 6 );
  36. TQHBoxLayout* buttons = new TQHBoxLayout( 0, 6, 6 );
  37. TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Expanding );
  38. tab = new TQTabWidget( this );
  39. finishButton = new KPushButton( i18n("&Finish"), this );
  40. finishButton->setIconSet( SmallIconSet( "go-last" ) );
  41. finishButton->setDefault( true );
  42. cancelButton = new KPushButton( i18n("&Cancel"), this );
  43. cancelButton->setIconSet( SmallIconSet( "button_cancel" ) );
  44. buttons->addItem( spacer );
  45. buttons->addWidget( finishButton );
  46. buttons->addWidget( cancelButton );
  47. layout->addWidget( tab );
  48. layout->addLayout( buttons );
  49. layout->setStretchFactor( tab, 2 );
  50. menuBar = new KMenuBar( this );
  51. layout->setMenuBar( menuBar );
  52. connect( cancelButton, TQT_SIGNAL( clicked() ), this, TQT_SLOT( close() ) );
  53. krename = impl ? impl : new KRenameImpl( this, menuBar, finishButton );
  54. connect( krename, TQT_SIGNAL( pageDone( TQWidget*, const TQString & ) ), this, TQT_SLOT( slotAddPage( TQWidget*, const TQString & ) ) );
  55. connect( krename, TQT_SIGNAL( showPage( int ) ), this, TQT_SLOT( slotShowPage( int ) ) );
  56. connect( krename, TQT_SIGNAL( enableFinish( bool ) ), this, TQT_SLOT( slotEnableFinish( bool ) ) );
  57. connect( tab, TQT_SIGNAL( currentChanged( TQWidget* ) ), this, TQT_SLOT( slotTabChanged() ) );
  58. if( impl )
  59. {
  60. krename->changeParent( this, menuBar, finishButton, r );
  61. krename->setWizardMode( false );
  62. } else
  63. krename->setup( false );
  64. // Tell TDEStartupInfo that KRename has been loaded completly
  65. TDEStartupInfoId id;
  66. id.initId( kapp->startupId() );
  67. TDEStartupInfo::sendFinish( id );
  68. }
  69. tabs::~tabs()
  70. {
  71. }
  72. void tabs::slotAddPage( TQWidget* page, const TQString & title )
  73. {
  74. tab->addTab( page, title );
  75. }
  76. void tabs::slotShowPage( int page )
  77. {
  78. tab->setCurrentPage( page - 1 );
  79. }
  80. void tabs::slotEnableFinish( bool b )
  81. {
  82. finishButton->setEnabled( b );
  83. }
  84. void tabs::slotTabChanged()
  85. {
  86. if( tab->currentPageIndex() == tab->count() - 1 )
  87. {
  88. krename->filename->setFocus();
  89. krename->filename->lineEdit()->selectAll();
  90. }
  91. }
  92. void tabs::keyPressEvent( TQKeyEvent *e )
  93. {
  94. // ESC should not close KRename
  95. if( e->key() == TQt::Key_Escape )
  96. e->accept();
  97. else
  98. e->ignore();
  99. }
  100. #include "tabs.moc"