summaryrefslogtreecommitdiffstats
path: root/krename/wizard.cpp
blob: cca96fc8fef323bc28e3c8fdde3ce90361803420 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/***************************************************************************
                          wizard.cpp  -  description
                             -------------------
    begin                : Die Mai 15 15:34:19 CEST 2001
    copyright            : (C) 2001 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.                                   *
 *                                                                         *
 ***************************************************************************/

// Own includes
#include "wizard.h"
#include "krenameimpl.h"

// KDE includes
#include <tdeapplication.h>
#include <kiconloader.h>
#include <tdelocale.h>
#include <tdemenubar.h>
#include <tdemessagebox.h>
#include <tdestartupinfo.h>

// TQt includes
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqpushbutton.h>
#include <tqsizepolicy.h>
#include <tqvbox.h>

wizard::wizard( KRenameImpl* impl, TQRect r, TQWidget* parent,  const char* name )
    : KWizard( parent, name )
{
    setIcon( BarIcon( "krename" ) );
    menuBar = new KMenuBar(this);

    krename = impl ? impl : new KRenameImpl( this, menuBar, this->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 ) ) );

    if( impl )
    {
        krename->changeParent( this, menuBar, this->finishButton(), r );
        krename->setWizardMode( true );
    } else
        krename->setup( true );
    
    // Tell TDEStartupInfo that KRename has been loaded completly
    TDEStartupInfoId id;
    id.initId( kapp->startupId() );
    TDEStartupInfo::sendFinish( id );
    
    // Disable ESC key
    cancelButton()->setAccel( TQKeySequence() );
}

wizard::~wizard()
{
}

void wizard::slotAddPage( TQWidget* page, const TQString & title )
{
    // exclude page 3 from wizard
    if( krename->title( 2 ) == title )
    {
        page->hide();
        return;
    }

    TQString t = title + i18n(" - Step %1 of %2").arg( pageCount()+1 ).arg( 3 );
        
    TQVBox* layout = new TQVBox( this );
   
    new TQLabel( TQString( t ).remove( title.find( "&" ), 1 ), layout );

    TQFrame* hbar1 = new TQFrame( layout, "<hr>", 0 );
    hbar1->setFrameStyle( TQFrame::Sunken + TQFrame::HLine );

    page->reparent( layout, TQPoint( 0, 0 ) );
    addPage( layout, t );
    setHelpEnabled( layout, false );
}

void wizard::slotShowPage( int page )
{
    showPage( this->page( page - 1 ) );
}

void wizard::slotEnableFinish( bool b )
{
    setFinishEnabled( page( pageCount() - 1), b );
}

void wizard::accept()
{
/** do nothing */
}