summaryrefslogtreecommitdiffstats
path: root/krename/myinputdialog.cpp
blob: 83a4833a892fd64432034c6de06b3fe720d77c25 (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
107
108
109
/***************************************************************************
                          myinputdialog.cpp  -  description
                             -------------------
    begin                : Mit Apr 01 2002
    copyright            : (C) 2002 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 "myinputdialog.h"

#include <klineedit.h>
#include <kpushbutton.h>
#include <tdelocale.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqtooltip.h>

MyInputDialog::MyInputDialog( TQString filename, bool revertEnabled, TQWidget* parent )
    : TQDialog( parent, 0, true, 0 )
{
    // I do not think this has to be translated
    setCaption( "KRename" );

    MyInputDialogLayout = new TQVBoxLayout( this, 11, 6, "MyInputDialogLayout");
    Layout = new TQHBoxLayout( 0, 0, 6, "Layout");

    TextLabel1 = new TQLabel( this, "TextLabel1" );
    TextLabel1->setText( i18n( "Please input a new filename:" ) );

    text = new KLineEdit( this, "text" );
    text->setText( filename );

    TQSpacerItem* spacer = new TQSpacerItem( 20, 20, TQSizePolicy::Expanding, TQSizePolicy::Minimum );

    buttonKrename = new KPushButton( this, "buttonKrename" );
    buttonKrename->setText( i18n( "&Revert Changes" ) );
    buttonKrename->setEnabled( revertEnabled );

    buttonFilename = new KPushButton( this, "buttonFilename" );
    buttonFilename->setText( i18n("Use &Input Filename") );

    buttonOk = new KPushButton( this, "buttonOk" );
    buttonOk->setText( i18n( "&Ok" ) );
    buttonOk->setDefault( true );

    buttonCancel = new KPushButton( this, "buttonCancel" );
    buttonCancel->setText( i18n( "&Cancel" ) );

    text->setFocus();

    Layout->addWidget( buttonKrename );
    Layout->addWidget( buttonFilename );
    Layout->addItem( spacer );
    Layout->addWidget( buttonOk );
    Layout->addWidget( buttonCancel );

    MyInputDialogLayout->addWidget( TextLabel1 );
    MyInputDialogLayout->addWidget( text );
    MyInputDialogLayout->addLayout( Layout );

    connect( buttonCancel, TQT_SIGNAL( clicked() ), this, TQT_SLOT( reject() ) );
    connect( buttonOk, TQT_SIGNAL( clicked() ), this, TQT_SLOT( accept() ) );
    connect( buttonKrename, TQT_SIGNAL( clicked() ), this, TQT_SLOT( krename() ) );
    connect( buttonFilename, TQT_SIGNAL( clicked() ), this, TQT_SLOT( slotFilename() ) );

    TQToolTip::add( buttonKrename, i18n("Use the filename that is generated by "
                                       "KRename instead of your changes." ) );
}

MyInputDialog::~MyInputDialog()
{ }

 TQString MyInputDialog::filename() const
{
    return text->text();
}

void MyInputDialog::accept()
{
    if( text->text().isEmpty() )
        reject();
    else
        done( OK );
}

void MyInputDialog::reject()
{
    done( CANCEL );
}

void MyInputDialog::krename()
{
    done( USE_KRENAME );
}

void MyInputDialog::slotFilename()
{
    text->setText( m_oldfilename );
}