/*************************************************************************** tabs.cpp - description ------------------- begin : Die Mai 20 2003 copyright : (C) 2003 by Dominik Seichter email : domseichter@web.de ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "tabs.h" #include "krenameimpl.h" #include "kmyhistorycombo.h" // TQt includes #include #include #include // KDE includes #include #include #include #include #include #include #include tabs::tabs(KRenameImpl* impl, TQRect r, TQWidget *parent, const char *name ) : TQDialog(parent,name) { setIcon( BarIcon( "krename" ) ); TQVBoxLayout* tqlayout = new TQVBoxLayout( this, 6, 6 ); TQHBoxLayout* buttons = new TQHBoxLayout( 0, 6, 6 ); TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Expanding ); tab = new TQTabWidget( this ); finishButton = new KPushButton( i18n("&Finish"), this ); finishButton->setIconSet( SmallIconSet( "finish" ) ); finishButton->setDefault( true ); cancelButton = new KPushButton( i18n("&Cancel"), this ); cancelButton->setIconSet( SmallIconSet( "button_cancel" ) ); buttons->addItem( spacer ); buttons->addWidget( finishButton ); buttons->addWidget( cancelButton ); tqlayout->addWidget( tab ); tqlayout->addLayout( buttons ); tqlayout->setStretchFactor( tab, 2 ); menuBar = new KMenuBar( this ); tqlayout->setMenuBar( menuBar ); connect( cancelButton, TQT_SIGNAL( clicked() ), this, TQT_SLOT( close() ) ); krename = impl ? impl : new KRenameImpl( this, menuBar, finishButton ); connect( krename, TQT_SIGNAL( pageDone( TQWidget*, const TQString & ) ), this, TQT_SLOT( slotAddPage( TQWidget*, const TQString & ) ) ); connect( krename, TQT_SIGNAL( showPage( int ) ), this, TQT_SLOT( slotShowPage( int ) ) ); connect( krename, TQT_SIGNAL( enableFinish( bool ) ), this, TQT_SLOT( slotEnableFinish( bool ) ) ); connect( tab, TQT_SIGNAL( currentChanged( TQWidget* ) ), this, TQT_SLOT( slotTabChanged() ) ); if( impl ) { krename->changeParent( this, menuBar, finishButton, r ); krename->setWizardMode( false ); } else krename->setup( false ); // Tell KStartupInfo that KRename has been loaded completly KStartupInfoId id; id.initId( kapp->startupId() ); KStartupInfo::sendFinish( id ); } tabs::~tabs() { } void tabs::slotAddPage( TQWidget* page, const TQString & title ) { tab->addTab( page, title ); } void tabs::slotShowPage( int page ) { tab->setCurrentPage( page - 1 ); } void tabs::slotEnableFinish( bool b ) { finishButton->setEnabled( b ); } void tabs::slotTabChanged() { if( tab->currentPageIndex() == tab->count() - 1 ) { krename->filename->setFocus(); krename->filename->lineEdit()->selectAll(); } } void tabs::keyPressEvent( TQKeyEvent *e ) { // ESC should not close KRename if( e->key() == TQt::Key_Escape ) e->accept(); else e->ignore(); }