21 #include <tqvalidator.h>
22 #include <tqpushbutton.h>
23 #include <tqlineedit.h>
26 #undef Unsorted // Required for --enable-final (tqdir.h)
27 #include <tqfiledialog.h>
29 #include <kbuttonbox.h>
31 #include <tdeapplication.h>
32 #include <klineedit.h>
33 #include <kstdguiitem.h>
35 #include "klineeditdlg.h"
39 :
KDialogBase( Plain, TQString::null, Ok|Cancel|User1, Ok, parent, 0L, true,
43 TQLabel *label =
new TQLabel(_text,
plainPage() );
44 topLayout->addWidget( label, 1 );
47 edit->setMinimumWidth(
edit->sizeHint().width() * 3);
48 label->setBuddy(
edit);
50 connect(
edit, TQ_SIGNAL(textChanged(
const TQString&)),
52 topLayout->addWidget(
edit, 1 );
56 if ( _value.isEmpty() )
61 edit->setSelection(0,
edit->text().length());
69 TQWidget *parent,
bool _file_mode )
70 : TQDialog( parent, 0L, true )
72 TQGridLayout *layout =
new TQGridLayout(
this, 4, 3, 10);
74 TQLabel *label =
new TQLabel(_text,
this);
75 layout->addWidget(label, 0, 0, AlignLeft);
78 edit->setMinimumWidth(
edit->sizeHint().width() * 3);
79 connect(
edit, TQ_SIGNAL(returnPressed()), TQ_SLOT(accept()) );
82 completion =
new KURLCompletion();
88 layout->addMultiCellWidget(
edit, 1, 1, 0, _file_mode ? 1 : 2);
89 layout->setColStretch(1, 1);
92 TQPushButton *browse =
new TQPushButton(i18n(
"&Browse..."),
this);
93 layout->addWidget(browse, 1, 2, AlignCenter);
94 connect(browse, TQ_SIGNAL(clicked()),
95 TQ_SLOT(slotBrowse()));
98 TQFrame *hLine =
new TQFrame(
this);
99 hLine->setFrameStyle(TQFrame::Sunken|TQFrame::HLine);
100 layout->addMultiCellWidget(hLine, 2, 2, 0, 2);
103 layout->addMultiCellWidget(bBox, 3, 3, 0, 2);
105 TQPushButton *ok = bBox->
addButton(KStdGuiItem::ok());
106 ok->setDefault(
true);
107 connect( ok, TQ_SIGNAL(clicked()), TQ_SLOT(accept()));
112 connect( clear, TQ_SIGNAL(clicked()), TQ_SLOT(
slotClear()));
117 connect(
cancel, TQ_SIGNAL(clicked()), TQ_SLOT(reject()));
124 edit->setSelection(0,
edit->text().length());
130 KLineEditDlg::~KLineEditDlg()
142 if (
edit->validator() ) {
143 TQString str =
edit->text();
144 int index =
edit->cursorPosition();
145 on = (
edit->validator()->validate( str, index )
146 == TQValidator::Acceptable );
148 on = !
text.isEmpty();
160 bool *ok, TQWidget *parent, TQValidator *_validator )
163 dlg.
lineEdit()->setValidator( _validator );
166 bool ok_ = dlg.exec() == TQDialog::Accepted;
171 return TQString::null;
175 const TQString& _value,
176 bool *ok, TQWidget *parent, TQValidator *_validator )
180 dlg.
lineEdit()->setValidator( _validator );
183 bool ok_ = dlg.exec() == TQDialog::Accepted;
188 return TQString::null;
191 void KLineEditDlg::virtual_hook(
int id,
void* data )
192 { KDialogBase::virtual_hook(
id, data ); }
194 #include "klineeditdlg.moc"
void slotClear()
Clears the edit widget.
KLineEdit * lineEdit() const
KLineEditDlg(const TQString &_text, const TQString &_value, TQWidget *parent) KDE_DEPRECATED
Create a dialog that asks for a single line of text.
void cancel()
Force closing the dialog, setting its result code to the one Esc would set.
void enableButtonOK(bool state)
Enable or disable (gray out) the OK button.
void enableButton(ButtonCode id, bool state)
Enable or disable (gray out) a general action button.
@ User1
Show User defined button 1.
void slotTextChanged(const TQString &)
Enables and disables the OK button depending on the state returned by the lineedit's TQValidator.
virtual void setCaption(const TQString &caption)
Make a KDE compliant caption.
virtual void setCompletionObject(TDECompletion *, bool hsig=true)
Reimplemented for internal reasons, the API is not affected.
An enhanced TQLineEdit widget for inputting text.
Provides a set of standardized KGuiItems.
A dialog base class with standard buttons and predefined layouts.
static TQString getText(const TQString &text, const TQString &value, bool *ok, TQWidget *parent, TQValidator *validator=0) KDE_DEPRECATED
Static convenience function to get a textual input from the user.
void setAutoDeleteCompletionObject(bool autoDelete)
void user1Clicked()
The User1 button was pressed.
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
TQFrame * plainPage()
Retrieve the empty page when the predefined layout is used in Plain mode.
const TDEShortcut & completion()
KLineEdit * edit
The line edit widget.
TDEAction * clear(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name)
Clear the content of the focus widget.
virtual void setText(const TQString &)
Re-implemented to enable text squeezing.