addenvvardlg.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <qlabel.h>
00021 #include <qlayout.h>
00022 #include <qpushbutton.h>
00023 #include <kbuttonbox.h>
00024 #include <klocale.h>
00025 #include <kstdguiitem.h>
00026 #include <kdeversion.h>
00027
00028 #include "addenvvardlg.h"
00029
00030
00031 AddEnvvarDialog::AddEnvvarDialog(QWidget *parent, const char *name)
00032 : QDialog(parent, name, true)
00033 {
00034 setCaption(i18n("Add Environment Variable"));
00035
00036 QLabel *varname_label = new QLabel(i18n("&Name:"), this);
00037 varname_edit = new QLineEdit(this);
00038 varname_edit->setFocus();
00039 varname_label->setBuddy(varname_edit);
00040
00041 connect( varname_edit, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotTextChanged() ) );
00042 QLabel *value_label = new QLabel(i18n("&Value:"), this);
00043 value_edit = new QLineEdit(this);
00044 value_label->setBuddy(value_edit);
00045 QFontMetrics fm(value_edit->fontMetrics());
00046 value_edit->setMinimumWidth(fm.width('X')*35);
00047 connect( value_edit, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotTextChanged() ) );
00048
00049
00050 QVBoxLayout *layout = new QVBoxLayout(this, 10);
00051
00052 QGridLayout *grid = new QGridLayout(2, 2);
00053 layout->addLayout(grid);
00054 grid->addWidget(varname_label, 0, 0);
00055 grid->addWidget(varname_edit, 0, 1);
00056 grid->addWidget(value_label, 1, 0);
00057 grid->addWidget(value_edit, 1, 1);
00058
00059 QFrame *frame = new QFrame(this);
00060 frame->setFrameStyle(QFrame::HLine | QFrame::Sunken);
00061 layout->addWidget(frame, 0);
00062
00063 KButtonBox *buttonbox = new KButtonBox(this);
00064 buttonbox->addStretch();
00065 #if KDE_IS_VERSION( 3, 2, 90 )
00066 m_pOk = buttonbox->addButton( KStdGuiItem::ok());
00067 QPushButton *cancel = buttonbox->addButton(KStdGuiItem::cancel());
00068 #else
00069 m_pOk = buttonbox->addButton( KStdGuiItem::ok().text());
00070 QPushButton *cancel = buttonbox->addButton(KStdGuiItem::cancel().text());
00071 #endif
00072 m_pOk->setDefault(true);
00073 connect( m_pOk, SIGNAL(clicked()), this, SLOT(accept()) );
00074 connect( cancel, SIGNAL(clicked()), this, SLOT(reject()) );
00075 buttonbox->layout();
00076 layout->addWidget(buttonbox, 0);
00077 slotTextChanged();
00078 }
00079
00080
00081 AddEnvvarDialog::~AddEnvvarDialog()
00082 {}
00083
00084 void AddEnvvarDialog::slotTextChanged()
00085 {
00086 m_pOk->setEnabled( !varname_edit->text().isEmpty() && !value_edit->text().isEmpty() );
00087 }
00088
00089 #include "addenvvardlg.moc"
This file is part of the documentation for KDevelop Version 3.1.2.