KDevelop API Documentation

addenvvardlg.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2001 Bernd Gehrmann <bernd@kdevelop.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
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"
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:52 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003