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 <kapplication.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, TQT_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, TQT_SIGNAL(returnPressed()), TQT_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, TQT_SIGNAL(clicked()),
95 TQT_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, TQT_SIGNAL(clicked()), TQT_SLOT(accept()));
111 TQPushButton *clear = bBox->
addButton(KStdGuiItem::clear());
112 connect( clear, TQT_SIGNAL(clicked()), TQT_SLOT(
slotClear()));
117 connect( cancel, TQT_SIGNAL(clicked()), TQT_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.
void enableButtonOK(bool state)
Enable or disable (gray out) the OK button.
virtual void setCompletionObject(KCompletion *, bool hsig=true)
Reimplemented for internal reasons, the API is not affected.
KLineEditDlg(const TQString &_text, const TQString &_value, TQWidget *parent) KDE_DEPRECATED
Create a dialog that asks for a single line of text.
void enableButton(ButtonCode id, bool state)
Enable or disable (gray out) a general action button.
void cancel()
Force closing the dialog, setting its result code to the one Esc would set.
A dialog base class with standard buttons and predefined layouts.
KLineEdit * edit
The line edit widget.
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.
Show User defined button 1.
static int spacingHint()
Return the number of pixels you shall use between widgets inside a dialog according to the KDE standa...
void slotTextChanged(const TQString &)
Enables and disables the OK button depending on the state returned by the lineedit's TQValidator...
void setAutoDeleteCompletionObject(bool autoDelete)
KLineEdit * lineEdit() const
TQFrame * plainPage()
Retrieve the empty page when the predefined layout is used in Plain mode.
void user1Clicked()
The User1 button was pressed.
An enhanced TQLineEdit widget for inputting text.
virtual void setCaption(const TQString &caption)
Make a KDE compliant caption.
Provides a set of standardized KGuiItems.
virtual void setText(const TQString &)
Re-implemented to enable text squeezing.