Skip to content

Commit

Permalink
Merge pull request #428 from in3otd/issue_311
Browse files Browse the repository at this point in the history
Fix for Issue 311
  • Loading branch information
guitorri committed Jan 30, 2016
2 parents 01f4822 + 6a87745 commit 3d09abf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
20 changes: 16 additions & 4 deletions qucs/qucs/dialogs/newprojdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
-------------------
begin : Sun Aug 24 2003
copyright : (C) 2003 by Michael Margraf
(C) 2016 Qucs Team
email : michael.margraf@alumni.tu-berlin.de
***************************************************************************/

Expand All @@ -24,8 +25,8 @@
#include <QGridLayout>


NewProjDialog::NewProjDialog(QWidget *parent, const char *name)
: QDialog(parent, name, true)
NewProjDialog::NewProjDialog(QWidget *parent)
: QDialog(parent)
{
setWindowTitle(tr("Create new project"));

Expand All @@ -35,13 +36,15 @@ NewProjDialog::NewProjDialog(QWidget *parent, const char *name)

ProjName = new QLineEdit(this);
ProjName->setMinimumWidth(250);
gbox->addMultiCellWidget(ProjName,0,0,1,2);
connect(ProjName, SIGNAL(textChanged(const QString&)), SLOT(slotTextChanged(const QString&)));
gbox->addWidget(ProjName, 0, 1, 1, 2);
OpenProj = new QCheckBox(tr("open new project"));
OpenProj->setChecked(true);
gbox->addMultiCellWidget(OpenProj,1,1,1,2);
gbox->addWidget(OpenProj, 1, 1, 1, 2);

ButtonOk = new QPushButton(tr("Create"));
gbox->addWidget(ButtonOk,2,1);
ButtonOk->setEnabled(false);
ButtonCancel = new QPushButton(tr("Cancel"));
gbox->addWidget(ButtonCancel,2,2);

Expand All @@ -52,6 +55,15 @@ NewProjDialog::NewProjDialog(QWidget *parent, const char *name)
setFocusProxy(ProjName);
}

void NewProjDialog::slotTextChanged(const QString &text){
/* avoid creating project with empty name */
if (text.isEmpty()) {
ButtonOk->setEnabled(false);
} else {
ButtonOk->setEnabled(true);
}
}

NewProjDialog::~NewProjDialog()
{
delete gbox;
Expand Down
5 changes: 4 additions & 1 deletion qucs/qucs/dialogs/newprojdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ class QGridLayout;
class NewProjDialog : public QDialog {
Q_OBJECT
public:
NewProjDialog(QWidget *parent=0, const char *name=0);
NewProjDialog(QWidget *parent=0);
~NewProjDialog();

QLineEdit *ProjName;
QCheckBox *OpenProj;

private slots:
void slotTextChanged(const QString &);

private:
QPushButton *ButtonOk, *ButtonCancel;
QGridLayout *gbox;
Expand Down

0 comments on commit 3d09abf

Please sign in to comment.