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