Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
settingsdialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  settingsdialog.cpp
3  --------------------
4  begin : Mon Oct 20 2003
5  copyright : (C) 2003, 2004 by Michael Margraf
6  email : michael.margraf@alumni.tu-berlin.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 #include <QtGui>
18 #include "settingsdialog.h"
19 
20 #include "node.h"
21 #include "qucs.h"
22 #include "mnemo.h"
23 #include "schematic.h"
24 
25 #include <QGridLayout>
26 #include <QVBoxLayout>
27 #include <QHBoxLayout>
28 #include <QLabel>
29 #include <QWidget>
30 #include <QLayout>
31 #include <QRegExp>
32 #include <QLineEdit>
33 #include <QTextEdit>
34 #include <QCheckBox>
35 #include <QComboBox>
36 #include <QTabWidget>
37 #include <QValidator>
38 #include <QPushButton>
39 
40 
42  : QDialog(Doc_) //, 0, TRUE, Qt::WDestructiveClose)
43 {
44  Doc = Doc_;
45  setWindowTitle(tr("Edit File Properties"));
46 
47  all = new QVBoxLayout(this);
48  QTabWidget *t = new QTabWidget();
49  all->addWidget(t);
50 
51  // ...........................................................
52  QWidget *Tab1 = new QWidget(t);
53  QGridLayout *gp = new QGridLayout(Tab1);
54  Tab1->setLayout(gp);
55 
56  QLabel *l2 = new QLabel(tr("Data Set:"), Tab1);
57  gp->addWidget(l2,0,0);
58  Input_DataSet = new QLineEdit(Tab1);
59  gp->addWidget(Input_DataSet,0,1,1,1);
60 
61  QLabel *l1 = new QLabel(tr("Data Display:"));
62  gp->addWidget(l1,1,0);
63  Input_DataDisplay = new QLineEdit(Tab1);
64  gp->addWidget(Input_DataDisplay,1,1,1,1);
65 
66  Check_OpenDpl = new QCheckBox(tr("open data display after simulation"),
67  Tab1);
68  gp->addWidget(Check_OpenDpl,2,0,1,2);
69 
70  QLabel *l20 = new QLabel(tr("Octave Script:"), Tab1);
71  gp->addWidget(l20,3,0);
72  Input_Script = new QLineEdit(Tab1);
73  gp->addWidget(Input_Script,3,1,1,1);
74 
75  Check_RunScript = new QCheckBox(tr("run script after simulation"),
76  Tab1);
77  gp->addWidget(Check_RunScript,4,0,1,2);
78 
79  t->addTab(Tab1, tr("Simulation"));
80 
81  // ...........................................................
82  QWidget *Tab2 = new QWidget(t);
83  QGridLayout *gp2 = new QGridLayout(Tab2);
84  Check_GridOn = new QCheckBox(tr("show Grid"), Tab2);
85  gp2->addWidget(Check_GridOn,0,0,1,1);
86 
87  valExpr = new QRegExpValidator(QRegExp("[1-9]\\d{0,2}"), this);
88 
89  QLabel *l3 = new QLabel(tr("horizontal Grid:"), Tab2);
90  gp2->addWidget(l3,1,0);
91  Input_GridX = new QLineEdit(Tab2);
92  Input_GridX->setValidator(valExpr);
93  gp2->addWidget(Input_GridX,1,1,1,1);
94 
95  QLabel *l4 = new QLabel(tr("vertical Grid:"), Tab2);
96  gp2->addWidget(l4,2,0);
97  Input_GridY = new QLineEdit(Tab2);
98  Input_GridY->setValidator(valExpr);
99  gp2->addWidget(Input_GridY,2,1,1,1);
100 
101  t->addTab(Tab2, tr("Grid"));
102 
103  // ...........................................................
104  QWidget *Tab3 = new QWidget(t);
105  QGridLayout *gp3 = new QGridLayout(Tab3);
106  Combo_Frame = new QComboBox(Tab3);
107  Combo_Frame->insertItem(tr("no Frame"));
108  Combo_Frame->insertItem(tr("DIN A5 landscape"));
109  Combo_Frame->insertItem(tr("DIN A5 portrait"));
110  Combo_Frame->insertItem(tr("DIN A4 landscape"));
111  Combo_Frame->insertItem(tr("DIN A4 portrait"));
112  Combo_Frame->insertItem(tr("DIN A3 landscape"));
113  Combo_Frame->insertItem(tr("DIN A3 portrait"));
114  Combo_Frame->insertItem(tr("Letter landscape"));
115  Combo_Frame->insertItem(tr("Letter portrait"));
116  gp3->addWidget(Combo_Frame,0,0,1,2);
117 
118  Input_Frame0 = new QTextEdit(Tab3);
119  Input_Frame0->setTextFormat(Qt::PlainText);
120  Input_Frame0->setWordWrapMode(QTextOption::NoWrap);
121  gp3->addWidget(Input_Frame0,1,0,2,2);
122 
123  Input_Frame1 = new QLineEdit(Tab3);
124  gp3->addWidget(Input_Frame1,3,0,1,2);
125 
126  Input_Frame2 = new QLineEdit(Tab3);
127  gp3->addWidget(Input_Frame2,4,0);
128  Input_Frame3 = new QLineEdit(Tab3);
129  gp3->addWidget(Input_Frame3,4,1);
130 
131  t->addTab(Tab3, tr("Frame"));
132 
133  // ...........................................................
134  // buttons on the bottom of the dialog (independent of the TabWidget)
135  QHBoxLayout *Butts = new QHBoxLayout();
136  Butts->setSpacing(5);
137  Butts->setMargin(5);
138  all->addLayout(Butts);
139 
140  QPushButton *OkButt = new QPushButton(tr("OK"));
141  Butts->addWidget(OkButt);
142  connect(OkButt, SIGNAL(clicked()), SLOT(slotOK()));
143  QPushButton *ApplyButt = new QPushButton(tr("Apply"));
144  Butts->addWidget(ApplyButt);
145  connect(ApplyButt, SIGNAL(clicked()), SLOT(slotApply()));
146  QPushButton *CancelButt = new QPushButton(tr("Cancel"));
147  Butts->addWidget(CancelButt);
148  connect(CancelButt, SIGNAL(clicked()), SLOT(reject()));
149 
150  OkButt->setDefault(true);
151 
152  // ...........................................................
153  // fill the fields with the QucsDoc-Properties
154 
155  Input_DataSet->setText(Doc->DataSet);
156  Input_DataDisplay->setText(Doc->DataDisplay);
157  Input_Script->setText(Doc->Script);
158  Check_OpenDpl->setChecked(Doc->SimOpenDpl);
159  Check_RunScript->setChecked(Doc->SimRunScript);
160  Check_GridOn->setChecked(Doc->GridOn);
161  Input_GridX->setText(QString::number(Doc->GridX));
162  Input_GridY->setText(QString::number(Doc->GridY));
163  Combo_Frame->setCurrentItem(Doc->showFrame);
164 
165  QString Text_;
166  decode_String(Text_ = Doc->Frame_Text0);
167  Input_Frame0->setText(Text_);
168  decode_String(Text_ = Doc->Frame_Text1);
169  Input_Frame1->setText(Text_);
170  decode_String(Text_ = Doc->Frame_Text2);
171  Input_Frame2->setText(Text_);
172  decode_String(Text_ = Doc->Frame_Text3);
173  Input_Frame3->setText(Text_);
174 
175  resize(250, 200);
176 }
177 
179 {
180  delete all;
181  delete valExpr;
182 }
183 
184 // -----------------------------------------------------------
185 // Close the dialog, applying any settings
187 {
188  slotApply();
189  accept();
190 }
191 
192 // -----------------------------------------------------------
193 // Applies the settings chosen in the dialog
195 {
196  bool changed = false;
197 
198  if(Doc->DataSet != Input_DataSet->text())
199  {
200  Doc->DataSet = Input_DataSet->text();
201  changed = true;
202  }
203 
204  if(Doc->DataDisplay != Input_DataDisplay->text())
205  {
206  Doc->DataDisplay = Input_DataDisplay->text();
207  changed = true;
208  }
209 
210  if(Doc->Script != Input_Script->text())
211  {
212  Doc->Script = Input_Script->text();
213  changed = true;
214  }
215 
216  if(Doc->SimOpenDpl != Check_OpenDpl->isChecked())
217  {
218  Doc->SimOpenDpl = Check_OpenDpl->isChecked();
219  changed = true;
220  }
221 
222  if(Doc->SimRunScript != Check_RunScript->isChecked())
223  {
224  Doc->SimRunScript = Check_RunScript->isChecked();
225  changed = true;
226  }
227 
228  if(Doc->GridOn != Check_GridOn->isChecked())
229  {
230  Doc->GridOn = Check_GridOn->isChecked();
231  changed = true;
232  }
233 
234  if(Doc->GridX != Input_GridX->text().toInt())
235  {
236  Doc->GridX = Input_GridX->text().toInt();
237  changed = true;
238  }
239 
240  if(Doc->GridY != Input_GridY->text().toInt())
241  {
242  Doc->GridY = Input_GridY->text().toInt();
243  changed = true;
244  }
245 
246  if(Doc->showFrame != Combo_Frame->currentItem())
247  {
248  Doc->showFrame = Combo_Frame->currentItem();
249  changed = true;
250  }
251 
252  QString t;
253  encode_String(Input_Frame0->text(), t);
254  if(Doc->Frame_Text0 != t)
255  {
256  Doc->Frame_Text0 = t;
257  changed = true;
258  }
259 
260  encode_String(Input_Frame1->text(), t);
261  if(Doc->Frame_Text1 != t)
262  {
263  Doc->Frame_Text1 = t;
264  changed = true;
265  }
266 
267  encode_String(Input_Frame2->text(), t);
268  if(Doc->Frame_Text2 != t)
269  {
270  Doc->Frame_Text2 = t;
271  changed = true;
272  }
273 
274  encode_String(Input_Frame3->text(), t);
275  if(Doc->Frame_Text3 != t)
276  {
277  Doc->Frame_Text3 = t;
278  changed = true;
279  }
280 
281  if(changed)
282  {
283  Doc->setChanged(true);
284  Doc->viewport()->repaint();
285  }
286 }
QLineEdit * Input_DataDisplay
QCheckBox * Check_GridOn
SettingsDialog(Schematic *)
QVBoxLayout * all
QComboBox * Combo_Frame
QLineEdit * Input_Frame3
QString Frame_Text0
Definition: schematic.h:136
QString Script
Definition: qucsdoc.h:54
QRegExpValidator * valExpr
QCheckBox * Check_OpenDpl
bool GridOn
Definition: qucsdoc.h:64
bool SimOpenDpl
Definition: qucsdoc.h:61
QCheckBox * Check_RunScript
bool SimRunScript
Definition: qucsdoc.h:62
QLineEdit * Input_Script
QLineEdit * Input_Frame2
QLineEdit * Input_Frame1
void encode_String(const QString &Input, QString &Output)
Definition: mnemo.cpp:58
QTextEdit * Input_Frame0
int GridX
Definition: schematic.h:131
QString Frame_Text1
Definition: schematic.h:136
Schematic * Doc
QLineEdit * Input_GridY
QString Frame_Text2
Definition: schematic.h:136
int showFrame
Definition: schematic.h:135
QString DataSet
Definition: qucsdoc.h:52
QLineEdit * Input_DataSet
int GridY
Definition: schematic.h:131
QLineEdit * Input_GridX
void decode_String(QString &Output)
Definition: mnemo.cpp:82
QString Frame_Text3
Definition: schematic.h:136
QString DataDisplay
Definition: qucsdoc.h:53
void setChanged(bool, bool fillStack=false, char Op='*')
Definition: schematic.cpp:278