Qucs-GUI  0.0.19
/home/travis/build/Qucs/qucs/qucs/qucs/dialogs/settingsdialog.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                              settingsdialog.cpp
00003                             --------------------
00004     begin                : Mon Oct 20 2003
00005     copyright            : (C) 2003, 2004 by Michael Margraf
00006     email                : michael.margraf@alumni.tu-berlin.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 #include "settingsdialog.h"
00018 
00019 #include "node.h"
00020 #include "qucs.h"
00021 #include "mnemo.h"
00022 #include "schematic.h"
00023 
00024 #include <QGridLayout>
00025 #include <QVBoxLayout>
00026 #include <QHBoxLayout>
00027 #include <QLabel>
00028 #include <QWidget>
00029 #include <QLayout>
00030 #include <QRegExp>
00031 #include <QLineEdit>
00032 #include <QTextEdit>
00033 #include <QCheckBox>
00034 #include <QComboBox>
00035 #include <QTabWidget>
00036 #include <QValidator>
00037 #include <QPushButton>
00038 
00039 
00040 SettingsDialog::SettingsDialog(Schematic *Doc_)
00041     : QDialog(Doc_) 
00042 {
00043     Doc = Doc_;
00044     setWindowTitle(tr("Edit File Properties"));
00045 
00046     all = new QVBoxLayout(this);
00047     QTabWidget *t = new QTabWidget();
00048     all->addWidget(t);
00049 
00050     // ...........................................................
00051     QWidget *Tab1 = new QWidget(t);
00052     QGridLayout *gp = new QGridLayout(Tab1);
00053     Tab1->setLayout(gp);
00054 
00055     QLabel *l2 = new QLabel(tr("Data Set:"), Tab1);
00056     gp->addWidget(l2,0,0);
00057     Input_DataSet = new QLineEdit(Tab1);
00058     gp->addWidget(Input_DataSet,0,1,1,1);
00059 
00060     QLabel *l1 = new QLabel(tr("Data Display:"));
00061     gp->addWidget(l1,1,0);
00062     Input_DataDisplay = new QLineEdit(Tab1);
00063     gp->addWidget(Input_DataDisplay,1,1,1,1);
00064 
00065     Check_OpenDpl = new QCheckBox(tr("open data display after simulation"),
00066                                   Tab1);
00067     gp->addWidget(Check_OpenDpl,2,0,1,2);
00068 
00069     QLabel *l20 = new QLabel(tr("Octave Script:"), Tab1);
00070     gp->addWidget(l20,3,0);
00071     Input_Script = new QLineEdit(Tab1);
00072     gp->addWidget(Input_Script,3,1,1,1);
00073 
00074     Check_RunScript = new QCheckBox(tr("run script after simulation"),
00075                                     Tab1);
00076     gp->addWidget(Check_RunScript,4,0,1,2);
00077 
00078     t->addTab(Tab1, tr("Simulation"));
00079 
00080     // ...........................................................
00081     QWidget *Tab2 = new QWidget(t);
00082     QGridLayout *gp2 = new QGridLayout(Tab2);
00083     Check_GridOn = new QCheckBox(tr("show Grid"), Tab2);
00084     gp2->addWidget(Check_GridOn,0,0,1,1);
00085 
00086     valExpr = new QRegExpValidator(QRegExp("[1-9]\\d{0,2}"), this);
00087 
00088     QLabel *l3 = new QLabel(tr("horizontal Grid:"), Tab2);
00089     gp2->addWidget(l3,1,0);
00090     Input_GridX = new QLineEdit(Tab2);
00091     Input_GridX->setValidator(valExpr);
00092     gp2->addWidget(Input_GridX,1,1,1,1);
00093 
00094     QLabel *l4 = new QLabel(tr("vertical Grid:"), Tab2);
00095     gp2->addWidget(l4,2,0);
00096     Input_GridY = new QLineEdit(Tab2);
00097     Input_GridY->setValidator(valExpr);
00098     gp2->addWidget(Input_GridY,2,1,1,1);
00099 
00100     t->addTab(Tab2, tr("Grid"));
00101 
00102     // ...........................................................
00103     QWidget *Tab3 = new QWidget(t);
00104     QGridLayout *gp3 = new QGridLayout(Tab3);
00105     Combo_Frame = new QComboBox(Tab3);
00106     Combo_Frame->insertItem(tr("no Frame"));
00107     Combo_Frame->insertItem(tr("DIN A5 landscape"));
00108     Combo_Frame->insertItem(tr("DIN A5 portrait"));
00109     Combo_Frame->insertItem(tr("DIN A4 landscape"));
00110     Combo_Frame->insertItem(tr("DIN A4 portrait"));
00111     Combo_Frame->insertItem(tr("DIN A3 landscape"));
00112     Combo_Frame->insertItem(tr("DIN A3 portrait"));
00113     Combo_Frame->insertItem(tr("Letter landscape"));
00114     Combo_Frame->insertItem(tr("Letter portrait"));
00115     gp3->addWidget(Combo_Frame,0,0,1,2);
00116 
00117     Input_Frame0 = new QTextEdit(Tab3);
00118     Input_Frame0->setTextFormat(Qt::PlainText);
00119     Input_Frame0->setWordWrapMode(QTextOption::NoWrap);
00120     gp3->addWidget(Input_Frame0,1,0,2,2);
00121 
00122     Input_Frame1 = new QLineEdit(Tab3);
00123     gp3->addWidget(Input_Frame1,3,0,1,2);
00124 
00125     Input_Frame2 = new QLineEdit(Tab3);
00126     gp3->addWidget(Input_Frame2,4,0);
00127     Input_Frame3 = new QLineEdit(Tab3);
00128     gp3->addWidget(Input_Frame3,4,1);
00129 
00130     t->addTab(Tab3, tr("Frame"));
00131 
00132     // ...........................................................
00133     // buttons on the bottom of the dialog (independent of the TabWidget)
00134     QHBoxLayout *Butts = new QHBoxLayout();
00135     Butts->setSpacing(5);
00136     Butts->setMargin(5);
00137     all->addLayout(Butts);
00138 
00139     QPushButton *OkButt = new QPushButton(tr("OK"));
00140     Butts->addWidget(OkButt);
00141     connect(OkButt, SIGNAL(clicked()), SLOT(slotOK()));
00142     QPushButton *ApplyButt = new QPushButton(tr("Apply"));
00143     Butts->addWidget(ApplyButt);
00144     connect(ApplyButt, SIGNAL(clicked()), SLOT(slotApply()));
00145     QPushButton *CancelButt = new QPushButton(tr("Cancel"));
00146     Butts->addWidget(CancelButt);
00147     connect(CancelButt, SIGNAL(clicked()), SLOT(reject()));
00148 
00149     OkButt->setDefault(true);
00150 
00151     // ...........................................................
00152     // fill the fields with the QucsDoc-Properties
00153 
00154     Input_DataSet->setText(Doc->DataSet);
00155     Input_DataDisplay->setText(Doc->DataDisplay);
00156     Input_Script->setText(Doc->Script);
00157     Check_OpenDpl->setChecked(Doc->SimOpenDpl);
00158     Check_RunScript->setChecked(Doc->SimRunScript);
00159     Check_GridOn->setChecked(Doc->GridOn);
00160     Input_GridX->setText(QString::number(Doc->GridX));
00161     Input_GridY->setText(QString::number(Doc->GridY));
00162     Combo_Frame->setCurrentItem(Doc->showFrame);
00163 
00164     QString Text_;
00165     decode_String(Text_ = Doc->Frame_Text0);
00166     Input_Frame0->setText(Text_);
00167     decode_String(Text_ = Doc->Frame_Text1);
00168     Input_Frame1->setText(Text_);
00169     decode_String(Text_ = Doc->Frame_Text2);
00170     Input_Frame2->setText(Text_);
00171     decode_String(Text_ = Doc->Frame_Text3);
00172     Input_Frame3->setText(Text_);
00173 
00174     resize(250, 200);
00175 }
00176 
00177 SettingsDialog::~SettingsDialog()
00178 {
00179     delete all;
00180     delete valExpr;
00181 }
00182 
00183 // -----------------------------------------------------------
00184 // Close the dialog, applying any settings
00185 void SettingsDialog::slotOK()
00186 {
00187     slotApply();
00188     accept();
00189 }
00190 
00191 // -----------------------------------------------------------
00192 // Applies the settings chosen in the dialog
00193 void SettingsDialog::slotApply()
00194 {
00195     bool changed = false;
00196 
00197     if(Doc->DataSet != Input_DataSet->text())
00198     {
00199         Doc->DataSet = Input_DataSet->text();
00200         changed = true;
00201     }
00202 
00203     if(Doc->DataDisplay != Input_DataDisplay->text())
00204     {
00205         Doc->DataDisplay = Input_DataDisplay->text();
00206         changed = true;
00207     }
00208 
00209     if(Doc->Script != Input_Script->text())
00210     {
00211         Doc->Script = Input_Script->text();
00212         changed = true;
00213     }
00214 
00215     if(Doc->SimOpenDpl != Check_OpenDpl->isChecked())
00216     {
00217         Doc->SimOpenDpl = Check_OpenDpl->isChecked();
00218         changed = true;
00219     }
00220 
00221     if(Doc->SimRunScript != Check_RunScript->isChecked())
00222     {
00223         Doc->SimRunScript = Check_RunScript->isChecked();
00224         changed = true;
00225     }
00226 
00227     if(Doc->GridOn != Check_GridOn->isChecked())
00228     {
00229         Doc->GridOn = Check_GridOn->isChecked();
00230         changed = true;
00231     }
00232 
00233     if(Doc->GridX != Input_GridX->text().toInt())
00234     {
00235         Doc->GridX = Input_GridX->text().toInt();
00236         changed = true;
00237     }
00238 
00239     if(Doc->GridY != Input_GridY->text().toInt())
00240     {
00241         Doc->GridY = Input_GridY->text().toInt();
00242         changed = true;
00243     }
00244 
00245     if(Doc->showFrame != Combo_Frame->currentItem())
00246     {
00247         Doc->showFrame = Combo_Frame->currentItem();
00248         changed = true;
00249     }
00250 
00251     QString t;
00252     encode_String(Input_Frame0->text(), t);
00253     if(Doc->Frame_Text0 != t)
00254     {
00255         Doc->Frame_Text0 = t;
00256         changed = true;
00257     }
00258 
00259     encode_String(Input_Frame1->text(), t);
00260     if(Doc->Frame_Text1 != t)
00261     {
00262         Doc->Frame_Text1 = t;
00263         changed = true;
00264     }
00265 
00266     encode_String(Input_Frame2->text(), t);
00267     if(Doc->Frame_Text2 != t)
00268     {
00269         Doc->Frame_Text2 = t;
00270         changed = true;
00271     }
00272 
00273     encode_String(Input_Frame3->text(), t);
00274     if(Doc->Frame_Text3 != t)
00275     {
00276         Doc->Frame_Text3 = t;
00277         changed = true;
00278     }
00279 
00280     if(changed)
00281     {
00282         Doc->setChanged(true);
00283         Doc->viewport()->repaint();
00284     }
00285 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines