Source Code (Use browser search to find items of interest.)
Class Index
kworldwatch'KInputLine (./kdetoys/kworldwatch/kinputline.h:11)
class KInputLine : public QDialog
{
Q_OBJECT
public:
KInputLine(QWidget *parent=0, QString text="", QString init="");
~KInputLine() {};
const char* getText() { return lineedit->text(); };
private:
QLabel *label;
QLineEdit *lineedit;
QPushButton *ok, *cancel;
};
kworldwatch'KInputLine::KInputLine() (./kdetoys/kworldwatch/kinputline.cpp:8)
KInputLine::KInputLine(QWidget *parent, QString text, QString init)
: QDialog(parent,"",TRUE)
{
int width = 200;
QFont f = kapp->font();
setFont(f);
label = new QLabel(text, this);
label->adjustSize();
if (label->width() > width)
width = label->width();
ok = new QPushButton(i18n("&OK"), this);
cancel = new QPushButton(i18n("&Cancel"), this);
ok->adjustSize();
cancel->adjustSize();
int btn_width = ok->width();
if (cancel->width() > btn_width)
btn_width = cancel->width();
if (8+2*btn_width > width)
width = 8+2*btn_width;
lineedit = new QLineEdit(this);
lineedit->setGeometry(8,label->height()+16, width, lineedit->height());
lineedit->setText(init);
label->move((width - label->width())/2, 8);
int btn_height = 24+label->height()+lineedit->height();
ok->setGeometry(width/2 - btn_width - 8, btn_height+8, btn_width, ok->height());
cancel->setGeometry(width/2 + 8, btn_height+8, btn_width, ok->height());
ok->setDefault(true);
connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
adjustSize();
setFixedSize(this->width(), this->height());
lineedit->setFocus();
}