Qucs-GUI  0.0.18
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
qucssettingsdialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qucssettingsdialog.cpp
3  ------------------------
4  begin : Sun May 23 2004
5  copyright : (C) 2003 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 #ifdef HAVE_CONFIG_H
19 # include <config.h>
20 #endif
21 
22 #include "qucssettingsdialog.h"
23 #include <iostream>
24 #include <QGridLayout>
25 #include <QVBoxLayout>
26 #include "main.h"
27 #include "textdoc.h"
28 #include "schematic.h"
29 
30 #include <QWidget>
31 #include <QLabel>
32 #include <QTabWidget>
33 #include <QLayout>
34 #include <QColorDialog>
35 #include <QFontDialog>
36 #include <QValidator>
37 #include <QPushButton>
38 #include <QLineEdit>
39 #include <QComboBox>
40 #include <QMessageBox>
41 #include <QCheckBox>
42 
43 using namespace std;
44 
46  : QDialog(parent, name)
47 {
48  App = parent;
49  setWindowTitle(tr("Edit Qucs Properties"));
50 
51  Expr.setPattern("[\\w_]+");
52  Validator = new QRegExpValidator(Expr, this);
53 
54  all = new QVBoxLayout(this); // to provide the neccessary size
55  QTabWidget *t = new QTabWidget();
56  all->addWidget(t);
57 
58  // ...........................................................
59  // The application setings tab
60  QWidget *appSettingsTab = new QWidget(t);
61  QGridLayout *appSettingsGrid = new QGridLayout(appSettingsTab);
62 
63  appSettingsGrid->addWidget(new QLabel(tr("Font (set after reload):"), appSettingsTab), 0,0);
64  FontButton = new QPushButton(appSettingsTab);
65  connect(FontButton, SIGNAL(clicked()), SLOT(slotFontDialog()));
66  appSettingsGrid->addWidget(FontButton,0,1);
67 
68  appSettingsGrid->addWidget(new QLabel(tr("Document Background Color:"), appSettingsTab) ,1,0);
69  BGColorButton = new QPushButton(" ", appSettingsTab);
70  connect(BGColorButton, SIGNAL(clicked()), SLOT(slotBGColorDialog()));
71  appSettingsGrid->addWidget(BGColorButton,1,1);
72 
73  appSettingsGrid->addWidget(new QLabel(tr("Language (set after reload):"), appSettingsTab) ,2,0);
74  LanguageCombo = new QComboBox(appSettingsTab);
75  LanguageCombo->insertItem(tr("system language"));
76  LanguageCombo->insertItem(tr("English")+" (en)");
77  LanguageCombo->insertItem(tr("German")+" (de)");
78  LanguageCombo->insertItem(tr("French")+" (fr)");
79  LanguageCombo->insertItem(tr("Spanish")+" (es)");
80  LanguageCombo->insertItem(tr("Italian")+" (it)");
81  LanguageCombo->insertItem(tr("Polish")+" (pl)");
82  LanguageCombo->insertItem(tr("Romanian")+" (ro)");
83  LanguageCombo->insertItem(tr("Japanese")+" (jp)");
84  LanguageCombo->insertItem(tr("Swedish")+" (sv)");
85  LanguageCombo->insertItem(tr("Hungarian")+" (hu)");
86  LanguageCombo->insertItem(tr("Hebrew")+" (he)");
87  LanguageCombo->insertItem(tr("Portuguese-BR")+" (pt_BR)");
88  LanguageCombo->insertItem(tr("Portuguese-PT")+" (pt_PT)");
89  LanguageCombo->insertItem(tr("Turkish")+" (tr)");
90  LanguageCombo->insertItem(tr("Ukrainian")+" (uk)");
91  LanguageCombo->insertItem(tr("Russian")+" (ru)");
92  LanguageCombo->insertItem(tr("Czech")+" (cs)");
93  LanguageCombo->insertItem(tr("Catalan")+" (ca)");
94  LanguageCombo->insertItem(tr("Arabic")+" (ar)");
95  LanguageCombo->insertItem(tr("Kazakh")+" (kk)");
96  appSettingsGrid->addWidget(LanguageCombo,2,1);
97 
98  val200 = new QIntValidator(0, 200, this);
99  appSettingsGrid->addWidget(new QLabel(tr("maximum undo operations:"), appSettingsTab) ,3,0);
100  undoNumEdit = new QLineEdit(appSettingsTab);
101  undoNumEdit->setValidator(val200);
102  appSettingsGrid->addWidget(undoNumEdit,3,1);
103 
104  appSettingsGrid->addWidget(new QLabel(tr("text editor:"), appSettingsTab) ,4,0);
105  editorEdit = new QLineEdit(appSettingsTab);
106  editorEdit->setToolTip(tr("Set to qucs, qucsedit or the path to your favorite text editor."));
107  appSettingsGrid->addWidget(editorEdit,4,1);
108 
109  appSettingsGrid->addWidget(new QLabel(tr("start wiring when clicking open node:"), appSettingsTab) ,5,0);
110  checkWiring = new QCheckBox(appSettingsTab);
111  appSettingsGrid->addWidget(checkWiring,5,1);
112 
113 
114  appSettingsGrid->addWidget(new QLabel(tr("Load documents from future versions ")));
115  checkLoadFromFutureVersions = new QCheckBox(appSettingsTab);
116  appSettingsGrid->addWidget(checkLoadFromFutureVersions,6,1);
118 
119  t->addTab(appSettingsTab, tr("Settings"));
120 
121  // ...........................................................
122  // The source code editor settings tab
123  QWidget *editorTab = new QWidget(t);
124  QGridLayout *editorGrid = new QGridLayout(editorTab);
125 
126  editorGrid->addMultiCellWidget(new QLabel(tr("Colors for Syntax Highlighting:"), editorTab), 0,0,0,1);
127 
128  ColorComment = new QPushButton(tr("Comment"), editorTab);
129  ColorComment->setPaletteForegroundColor(QucsSettings.Comment);
130  ColorComment->setPaletteBackgroundColor(QucsSettings.BGColor);
131  connect(ColorComment, SIGNAL(clicked()), SLOT(slotColorComment()));
132  editorGrid->addWidget(ColorComment,1,0);
133 
134  ColorString = new QPushButton(tr("String"), editorTab);
135  ColorString->setPaletteForegroundColor(QucsSettings.String);
136  ColorString->setPaletteBackgroundColor(QucsSettings.BGColor);
137  connect(ColorString, SIGNAL(clicked()), SLOT(slotColorString()));
138  editorGrid->addWidget(ColorString,1,1);
139 
140  ColorInteger = new QPushButton(tr("Integer Number"), editorTab);
141  ColorInteger->setPaletteForegroundColor(QucsSettings.Integer);
142  ColorInteger->setPaletteBackgroundColor(QucsSettings.BGColor);
143  connect(ColorInteger, SIGNAL(clicked()), SLOT(slotColorInteger()));
144  editorGrid->addWidget(ColorInteger,1,2);
145 
146  ColorReal = new QPushButton(tr("Real Number"), editorTab);
147  ColorReal->setPaletteForegroundColor(QucsSettings.Real);
148  ColorReal->setPaletteBackgroundColor(QucsSettings.BGColor);
149  connect(ColorReal, SIGNAL(clicked()), SLOT(slotColorReal()));
150  editorGrid->addWidget(ColorReal,2,0);
151 
152  ColorCharacter = new QPushButton(tr("Character"), editorTab);
153  ColorCharacter->setPaletteForegroundColor(QucsSettings.Character);
154  ColorCharacter->setPaletteBackgroundColor(QucsSettings.BGColor);
155  connect(ColorCharacter, SIGNAL(clicked()), SLOT(slotColorCharacter()));
156  editorGrid->addWidget(ColorCharacter,2,1);
157 
158  ColorDataType = new QPushButton(tr("Data Type"), editorTab);
159  ColorDataType->setPaletteForegroundColor(QucsSettings.Type);
160  ColorDataType->setPaletteBackgroundColor(QucsSettings.BGColor);
161  connect(ColorDataType, SIGNAL(clicked()), SLOT(slotColorDataType()));
162  editorGrid->addWidget(ColorDataType,2,2);
163 
164  ColorAttribute = new QPushButton(tr("Attribute"), editorTab);
165  ColorAttribute->setPaletteForegroundColor(QucsSettings.Attribute);
166  ColorAttribute->setPaletteBackgroundColor(QucsSettings.BGColor);
167  connect(ColorAttribute, SIGNAL(clicked()), SLOT(slotColorAttribute()));
168  editorGrid->addWidget(ColorAttribute,3,0);
169 
170  ColorDirective = new QPushButton(tr("Directive"), editorTab);
171  ColorDirective->setPaletteForegroundColor(QucsSettings.Directive);
172  ColorDirective->setPaletteBackgroundColor(QucsSettings.BGColor);
173  connect(ColorDirective, SIGNAL(clicked()), SLOT(slotColorDirective()));
174  editorGrid->addWidget(ColorDirective,3,1);
175 
176  ColorTask = new QPushButton(tr("Task"), editorTab);
177  ColorTask->setPaletteForegroundColor(QucsSettings.Task);
178  ColorTask->setPaletteBackgroundColor(QucsSettings.BGColor);
179  connect(ColorTask, SIGNAL(clicked()), SLOT(slotColorTask()));
180  editorGrid->addWidget(ColorTask,3,2);
181 
182 
183  t->addTab(editorTab, tr("Source Code Editor"));
184 
185  // ...........................................................
186  // The file types tab
187  QWidget *fileTypesTab = new QWidget(t);
188  QGridLayout *fileTypesGrid = new QGridLayout(fileTypesTab);
189 
190  QLabel *note = new QLabel(
191  tr("Register filename extensions here in order to\nopen files with an appropriate program."));
192  fileTypesGrid->addWidget(note,0,0,1,2);
193 
194  // the fileTypesTableWidget displays information on the file types
195  fileTypesTableWidget = new QTableWidget(fileTypesTab);
196  fileTypesTableWidget->setColumnCount(2);
197 
198  QTableWidgetItem *item1 = new QTableWidgetItem();
199  QTableWidgetItem *item2 = new QTableWidgetItem();
200 
201  fileTypesTableWidget->setHorizontalHeaderItem(0, item1);
202  fileTypesTableWidget->setHorizontalHeaderItem(1, item2);
203 
204  item1->setText(tr("Suffix"));
205  item2->setText(tr("Program"));
206 
207  fileTypesTableWidget->horizontalHeader()->setStretchLastSection(true);
208  fileTypesTableWidget->verticalHeader()->hide();
209  connect(fileTypesTableWidget, SIGNAL(cellClicked(int,int)), SLOT(slotTableClicked(int,int)));
210  fileTypesGrid->addWidget(fileTypesTableWidget,1,0,3,1);
211 
212  // fill listview with already registered file extensions
213  QStringList::Iterator it = QucsSettings.FileTypes.begin();
214  while(it != QucsSettings.FileTypes.end())
215  {
216  int row = fileTypesTableWidget->rowCount();
217  fileTypesTableWidget->setRowCount(row+1);
218  QTableWidgetItem *suffix = new QTableWidgetItem(QString((*it).section('/',0,0)));
219  QTableWidgetItem *program = new QTableWidgetItem(QString((*it).section('/',1,1)));
220  suffix->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
221  program->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
222  fileTypesTableWidget->setItem(row, 0, suffix);
223  fileTypesTableWidget->setItem(row, 1, program);
224  it++;
225  }
226 
227  QLabel *l5 = new QLabel(tr("Suffix:"), fileTypesTab);
228  fileTypesGrid->addWidget(l5,1,1);
229  Input_Suffix = new QLineEdit(fileTypesTab);
230  Input_Suffix->setValidator(Validator);
231  fileTypesGrid->addWidget(Input_Suffix,1,2);
232 // connect(Input_Suffix, SIGNAL(returnPressed()), SLOT(slotGotoProgEdit())); //not implemented
233 
234  QLabel *l6 = new QLabel(tr("Program:"), fileTypesTab);
235  fileTypesGrid->addWidget(l6,2,1);
236  Input_Program = new QLineEdit(fileTypesTab);
237  fileTypesGrid->addWidget(Input_Program,2,2);
238 
239  QPushButton *AddButt = new QPushButton(tr("Set"));
240  fileTypesGrid->addWidget(AddButt,3,1);
241  connect(AddButt, SIGNAL(clicked()), SLOT(slotAddFileType()));
242  QPushButton *RemoveButt = new QPushButton(tr("Remove"));
243  fileTypesGrid->addWidget(RemoveButt,3,2);
244  connect(RemoveButt, SIGNAL(clicked()), SLOT(slotRemoveFileType()));
245 
246  fileTypesGrid->setRowStretch(3,4);
247  t->addTab(fileTypesTab, tr("File Types"));
248 
249  // ...........................................................
250  // The locations tab
251  QWidget *locationsTab = new QWidget(t);
252  QGridLayout *locationsGrid = new QGridLayout(locationsTab);
253 
254  QLabel *note2 = new QLabel(
255  tr("Edit the standard paths and external applications"));
256  locationsGrid->addWidget(note2,0,0,1,2);
257 
258  locationsGrid->addWidget(new QLabel(tr("Qucs Home:"), locationsTab) ,1,0);
259  homeEdit = new QLineEdit(locationsTab);
260  locationsGrid->addWidget(homeEdit,1,1);
261  QPushButton *HomeButt = new QPushButton("...");
262  locationsGrid->addWidget(HomeButt, 1, 2);
263  connect(HomeButt, SIGNAL(clicked()), SLOT(slotHomeDirBrowse()));
264 
265  locationsGrid->addWidget(new QLabel(tr("AdmsXml Path:"), locationsTab) ,2,0);
266  admsXmlEdit = new QLineEdit(locationsTab);
267  locationsGrid->addWidget(admsXmlEdit,2,1);
268  QPushButton *AdmsXmlButt = new QPushButton("...");
269  locationsGrid->addWidget(AdmsXmlButt, 2, 2);
270  connect(AdmsXmlButt, SIGNAL(clicked()), SLOT(slotAdmsXmlDirBrowse()));
271 
272  locationsGrid->addWidget(new QLabel(tr("ASCO Path:"), locationsTab) ,3,0);
273  ascoEdit = new QLineEdit(locationsTab);
274  locationsGrid->addWidget(ascoEdit,3,1);
275  QPushButton *ascoButt = new QPushButton("...");
276  locationsGrid->addWidget(ascoButt, 3, 2);
277  connect(ascoButt, SIGNAL(clicked()), SLOT(slotAscoDirBrowse()));
278 
279  locationsGrid->addWidget(new QLabel(tr("Octave Path:"), locationsTab) ,4,0);
280  octaveEdit = new QLineEdit(locationsTab);
281  locationsGrid->addWidget(octaveEdit,4,1);
282  QPushButton *OctaveButt = new QPushButton("...");
283  locationsGrid->addWidget(OctaveButt, 4, 2);
284  connect(OctaveButt, SIGNAL(clicked()), SLOT(slotOctaveDirBrowse()));
285 
286 
287  // the pathsTableWidget displays the path list
288  pathsTableWidget = new QTableWidget(locationsTab);
289  pathsTableWidget->setColumnCount(1);
290 
291  QTableWidgetItem *pitem1 = new QTableWidgetItem();
292 
293  pathsTableWidget->setHorizontalHeaderItem(0, pitem1);
294 
295  pitem1->setText(tr("Subcircuit Search Path List"));
296 
297  pathsTableWidget->horizontalHeader()->setStretchLastSection(true);
298  pathsTableWidget->verticalHeader()->hide();
299  // allow multiple items to be selected
300  pathsTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
301  connect(pathsTableWidget, SIGNAL(cellClicked(int,int)), SLOT(slotPathTableClicked(int,int)));
302  locationsGrid->addWidget(pathsTableWidget,5,0,3,2);
303 
304  QPushButton *AddPathButt = new QPushButton("Add Path");
305  locationsGrid->addWidget(AddPathButt, 5, 2);
306  connect(AddPathButt, SIGNAL(clicked()), SLOT(slotAddPath()));
307 
308  QPushButton *AddPathSubFolButt = new QPushButton("Add Path With SubFolders");
309  locationsGrid->addWidget(AddPathSubFolButt, 6, 2);
310  connect(AddPathSubFolButt, SIGNAL(clicked()), SLOT(slotAddPathWithSubFolders()));
311 
312  QPushButton *RemovePathButt = new QPushButton("Remove Path");
313  locationsGrid->addWidget(RemovePathButt , 7, 2);
314  connect(RemovePathButt, SIGNAL(clicked()), SLOT(slotRemovePath()));
315 
316  // create a copy of the current global path list
317  currentPaths = QStringList(qucsPathList);
318  makePathTable();
319 
320  t->addTab(locationsTab, tr("Locations"));
321 
322  // ...........................................................
323  // buttons on the bottom of the dialog (independent of the TabWidget)
324 
325  QHBoxLayout *Butts = new QHBoxLayout();
326  Butts->setSpacing(3);
327  Butts->setMargin(3);
328  all->addLayout(Butts);
329 
330  QPushButton *OkButt = new QPushButton(tr("OK"));
331  Butts->addWidget(OkButt);
332  connect(OkButt, SIGNAL(clicked()), SLOT(slotOK()));
333  QPushButton *ApplyButt = new QPushButton(tr("Apply"));
334  Butts->addWidget(ApplyButt);
335  connect(ApplyButt, SIGNAL(clicked()), SLOT(slotApply()));
336  QPushButton *CancelButt = new QPushButton(tr("Cancel"));
337  Butts->addWidget(CancelButt);
338  connect(CancelButt, SIGNAL(clicked()), SLOT(reject()));
339  QPushButton *DefaultButt = new QPushButton(tr("Default Values"));
340  Butts->addWidget(DefaultButt);
341  connect(DefaultButt, SIGNAL(clicked()), SLOT(slotDefaultValues()));
342 
343 
344 
345  OkButt->setDefault(true);
346 
347  // ...........................................................
348  // fill the fields with the Qucs-Properties
350  FontButton->setText(Font.toString());
351  BGColorButton->setPaletteBackgroundColor(QucsSettings.BGColor);
352  undoNumEdit->setText(QString::number(QucsSettings.maxUndo));
353  editorEdit->setText(QucsSettings.Editor);
354  checkWiring->setChecked(QucsSettings.NodeWiring);
355 
356  for(int z=LanguageCombo->count()-1; z>=0; z--)
357  if(LanguageCombo->text(z).section('(',1,1).remove(')') == QucsSettings.Language)
358  LanguageCombo->setCurrentItem(z);
359 
361  homeEdit->setText(QucsSettings.QucsHomeDir.canonicalPath());
362  admsXmlEdit->setText(QucsSettings.AdmsXmlBinDir.canonicalPath());
363  ascoEdit->setText(QucsSettings.AscoBinDir.canonicalPath());
364  octaveEdit->setText(QucsSettings.OctaveBinDir.canonicalPath());
365 
366 
367  resize(300, 200);
368 }
369 
371 {
372  delete all;
373  delete val200;
374  delete Validator;
375 }
376 
377 // -----------------------------------------------------------
379 {
380  QModelIndexList indexes = fileTypesTableWidget->selectionModel()->selection().indexes();
381  if (indexes.count())
382  {
383  fileTypesTableWidget->item(indexes.at(0).row(),0)->setText(Input_Suffix->text());
384  fileTypesTableWidget->item(indexes.at(0).row(),1)->setText(Input_Program->text());
385  fileTypesTableWidget->selectionModel()->clear();
386  return;
387  }
388 
389  //check before append
390  for(int r=0; r < fileTypesTableWidget->rowCount(); r++)
391  if(fileTypesTableWidget->item(r,0)->text() == Input_Suffix->text())
392  {
393  QMessageBox::critical(this, tr("Error"),
394  tr("This suffix is already registered!"));
395  return;
396  }
397 
398  int row = fileTypesTableWidget->rowCount();
399  fileTypesTableWidget->setRowCount(row+1);
400 
401  QTableWidgetItem *newSuffix = new QTableWidgetItem(QString(Input_Suffix->text()));
402  newSuffix->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
403  fileTypesTableWidget->setItem(row, 0, newSuffix);
404 
405  QTableWidgetItem *newProgram = new QTableWidgetItem(Input_Program->text());
406  fileTypesTableWidget->setItem(row, 1, newProgram);
407  newProgram->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
408 
409  Input_Suffix->setFocus();
410  Input_Suffix->clear();
411  Input_Program->clear();
412 }
413 
414 // -----------------------------------------------------------
416 {
417  QModelIndexList indexes = fileTypesTableWidget->selectionModel()->selection().indexes();
418  if (indexes.count())
419  {
420  fileTypesTableWidget->removeRow(indexes.at(0).row());
421  fileTypesTableWidget->selectionModel()->clear();
422  Input_Suffix->setText("");
423  Input_Program->setText("");
424  return;
425  }
426 }
427 
428 // -----------------------------------------------------------
429 // Applies any changed settings and closes the dialog
431 {
432  slotApply();
433  accept();
434 }
435 
436 // -----------------------------------------------------------
437 // Applies any changed settings
439 {
440  bool changed = false;
441 
442  if(QucsSettings.BGColor != BGColorButton->paletteBackgroundColor())
443  {
444  QucsSettings.BGColor = BGColorButton->paletteBackgroundColor();
445 
446  int No=0;
447  QWidget *w;
448  while((w=App->DocumentTab->page(No++)) != 0)
449  if(w->inherits("QTextEdit"))
450  ((TextDoc*)w)->viewport()->setPaletteBackgroundColor(
452  else
453  ((Schematic*)w)->viewport()->setPaletteBackgroundColor(
455  changed = true;
456  }
457 
459 
461  LanguageCombo->currentText().section('(',1,1).remove(')');
462 
463  if(QucsSettings.Comment != ColorComment->paletteForegroundColor())
464  {
465  QucsSettings.Comment = ColorComment->paletteForegroundColor();
466  changed = true;
467  }
468  if(QucsSettings.String != ColorString->paletteForegroundColor())
469  {
470  QucsSettings.String = ColorString->paletteForegroundColor();
471  changed = true;
472  }
473  if(QucsSettings.Integer != ColorInteger->paletteForegroundColor())
474  {
475  QucsSettings.Integer = ColorInteger->paletteForegroundColor();
476  changed = true;
477  }
478  if(QucsSettings.Real != ColorReal->paletteForegroundColor())
479  {
480  QucsSettings.Real = ColorReal->paletteForegroundColor();
481  changed = true;
482  }
483  if(QucsSettings.Character != ColorCharacter->paletteForegroundColor())
484  {
485  QucsSettings.Character = ColorCharacter->paletteForegroundColor();
486  changed = true;
487  }
488  if(QucsSettings.Type != ColorDataType->paletteForegroundColor())
489  {
490  QucsSettings.Type = ColorDataType->paletteForegroundColor();
491  changed = true;
492  }
493  if(QucsSettings.Attribute != ColorAttribute->paletteForegroundColor())
494  {
495  QucsSettings.Attribute = ColorAttribute->paletteForegroundColor();
496  changed = true;
497  }
498  if(QucsSettings.Directive != ColorDirective->paletteForegroundColor())
499  {
500  QucsSettings.Directive = ColorDirective->paletteForegroundColor();
501  changed = true;
502  }
503  if(QucsSettings.Task != ColorTask->paletteForegroundColor())
504  {
505  QucsSettings.Task = ColorTask->paletteForegroundColor();
506  changed = true;
507  }
508 
509  bool ok;
510  if(QucsSettings.maxUndo != undoNumEdit->text().toUInt(&ok))
511  {
512  QucsSettings.maxUndo = undoNumEdit->text().toInt(&ok);
513  changed = true;
514  }
515  if(QucsSettings.Editor != editorEdit->text())
516  {
517  QucsSettings.Editor = editorEdit->text();
518  changed = true;
519  }
520  if(QucsSettings.NodeWiring != (unsigned)checkWiring->isChecked())
521  {
522  QucsSettings.NodeWiring = checkWiring->isChecked();
523  changed = true;
524  }
525 
526  QucsSettings.FileTypes.clear();
527  for (int row=0; row < fileTypesTableWidget->rowCount(); row++)
528  {
529  QucsSettings.FileTypes.append(fileTypesTableWidget->item(row,0)->text()
530  +"/"+
531  fileTypesTableWidget->item(row,1)->text());
532  }
533 
537  QucsSettings.AscoBinDir = ascoEdit->text();
539 
541 
542  saveApplSettings(App); // also sets the small and large font
543 
544  if(changed)
545  {
546  App->readProjects();
548  App->repaint();
549  }
550 
551  // update the schenatic filelist hash
555 
556 }
557 
558 
559 // -----------------------------------------------------------
561 {
562  bool ok;
563  QFont tmpFont = QFontDialog::getFont(&ok, Font, this);
564  if(ok)
565  {
566  Font = tmpFont;
567  FontButton->setText(Font.toString());
568  }
569 }
570 
571 // -----------------------------------------------------------
573 {
574  QColor c = QColorDialog::getColor(
575  BGColorButton->paletteBackgroundColor(), this);
576  if(c.isValid())
577  BGColorButton->setPaletteBackgroundColor(c);
578 }
579 
580 // -----------------------------------------------------------
582 {
583  //Font = QFont("Helvetica", 12);
584  FontButton->setText(Font.toString());
585  LanguageCombo->setCurrentItem(0);
586  BGColorButton->setPaletteBackgroundColor(QColor(255,250,225));
587 
588  ColorComment->setPaletteForegroundColor(Qt::gray);
589  ColorString->setPaletteForegroundColor(Qt::red);
590  ColorInteger->setPaletteForegroundColor(Qt::blue);
591  ColorReal->setPaletteForegroundColor(Qt::darkMagenta);
592  ColorCharacter->setPaletteForegroundColor(Qt::magenta);
593  ColorDataType->setPaletteForegroundColor(Qt::darkRed);
594  ColorAttribute->setPaletteForegroundColor(Qt::darkCyan);
595  ColorDirective->setPaletteForegroundColor(Qt::darkCyan);
596  ColorTask->setPaletteForegroundColor(Qt::darkRed);
597 
598  undoNumEdit->setText("20");
599  editorEdit->setText(QucsSettings.BinDir + "qucs");
600  checkWiring->setChecked(false);
601 }
602 
603 // -----------------------------------------------------------
605 {
606  QColor c = QColorDialog::getColor(
607  ColorComment->paletteForegroundColor(), this);
608  if(c.isValid())
609  ColorComment->setPaletteForegroundColor(c);
610 }
611 
612 // -----------------------------------------------------------
614 {
615  QColor c = QColorDialog::getColor(
616  ColorString->paletteForegroundColor(), this);
617  if(c.isValid())
618  ColorString->setPaletteForegroundColor(c);
619 }
620 
621 // -----------------------------------------------------------
623 {
624  QColor c = QColorDialog::getColor(
625  ColorInteger->paletteForegroundColor(), this);
626  if(c.isValid())
627  ColorInteger->setPaletteForegroundColor(c);
628 }
629 
630 // -----------------------------------------------------------
632 {
633  QColor c = QColorDialog::getColor(
634  ColorReal->paletteForegroundColor(), this);
635  if(c.isValid())
636  ColorReal->setPaletteForegroundColor(c);
637 }
638 
639 // -----------------------------------------------------------
641 {
642  QColor c = QColorDialog::getColor(
643  ColorCharacter->paletteForegroundColor(), this);
644  if(c.isValid())
645  ColorCharacter->setPaletteForegroundColor(c);
646 }
647 
648 // -----------------------------------------------------------
650 {
651  QColor c = QColorDialog::getColor(
652  ColorDataType->paletteForegroundColor(), this);
653  if(c.isValid())
654  ColorDataType->setPaletteForegroundColor(c);
655 }
656 
657 // -----------------------------------------------------------
659 {
660  QColor c = QColorDialog::getColor(
661  ColorAttribute->paletteForegroundColor(), this);
662  if(c.isValid())
663  ColorAttribute->setPaletteForegroundColor(c);
664 }
665 
666 // -----------------------------------------------------------
668 {
669  QColor c = QColorDialog::getColor(
670  ColorDirective->paletteForegroundColor(), this);
671  if(c.isValid())
672  ColorDirective->setPaletteForegroundColor(c);
673 }
674 
675 // -----------------------------------------------------------
677 {
678  QColor c = QColorDialog::getColor(
679  ColorTask->paletteForegroundColor(), this);
680  if(c.isValid())
681  ColorTask->setPaletteForegroundColor(c);
682 }
683 
685 {
686  Input_Suffix->setText(fileTypesTableWidget->item(row,0)->text());
687  Input_Program->setText(fileTypesTableWidget->item(row,1)->text());
688 }
689 
690 // -----------------------------------------------------------
691 // The locations tab slots
692 
694 {
695  QFileDialog fileDialog( this, tr("Select the home directory"), homeEdit->text() );
696  fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
697  fileDialog.setFileMode(QFileDialog::DirectoryOnly);
698  fileDialog.exec();
699  homeEdit->setText(fileDialog.selectedFile());
700 }
701 
703 {
704  QFileDialog fileDialog( this, tr("Select the admsXml bin directory"), admsXmlEdit->text() );
705  fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
706  fileDialog.setFileMode(QFileDialog::DirectoryOnly);
707  fileDialog.exec();
708  admsXmlEdit->setText(fileDialog.selectedFile());
709 }
710 
712 {
713  QFileDialog fileDialog( this, tr("Select the ASCO bin directory"), ascoEdit->text() );
714  fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
715  fileDialog.setFileMode(QFileDialog::DirectoryOnly);
716  fileDialog.exec();
717  ascoEdit->setText(fileDialog.selectedFile());
718 }
719 
721 {
722  QFileDialog fileDialog( this, tr("Select the octave bin directory"), octaveEdit->text() );
723  fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
724  fileDialog.setFileMode(QFileDialog::DirectoryOnly);
725  fileDialog.exec();
726  octaveEdit->setText(fileDialog.selectedFile());
727 }
728 
730 {
731  //Input_Path->setText(fileTypesTableWidget->item(row,0)->text());
732 }
733 
735 {
736  QFileDialog fileDialog( this, tr("Select a directory"), QucsSettings.QucsWorkDir.canonicalPath());
737  fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
738  fileDialog.setFileMode(QFileDialog::DirectoryOnly);
739 
740  if (fileDialog.exec())
741  {
742  currentPaths.append(fileDialog.selectedFile());
743  // reconstruct the table again
744  makePathTable();
745  }
746  else
747  {
748  // user cancelled
749  }
750 }
751 
753 {
754  // open a file dialog to select the top level directory
755  QFileDialog fileDialog( this, tr("Select a directory"), QucsSettings.QucsWorkDir.canonicalPath());
756  fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
757  fileDialog.setFileMode(QFileDialog::DirectoryOnly);
758 
759  QString path;
760  QFileInfo pathfinfo;
761 
762  if (fileDialog.exec())
763  {
764  // Iterate through the directories
765  QDirIterator pathIter(fileDialog.selectedFile(), QDirIterator::Subdirectories);
766  while (pathIter.hasNext())
767  {
768  path = pathIter.next();
769  pathfinfo = pathIter.fileInfo();
770 
771  if (pathfinfo.isDir() && !pathfinfo.isSymLink() && !path.endsWith("."))
772  {
773  QDir thispath(path);
774  currentPaths.append(thispath.canonicalPath());
775  }
776  }
777  makePathTable();
778  }
779  else
780  {
781  // user cancelled
782  }
783 
784 
785 }
786 
788 {
789  //Input_Path->setText(fileTypesTableWidget->item(row,0)->text());
790  // get the selected items from the table
791  QList<QTableWidgetItem *> selectedPaths = pathsTableWidget->selectedItems();
792 
793  foreach (QTableWidgetItem * item, selectedPaths)
794  {
795  QString path = item->text();
796  //removedPaths.append(path);
797  int pathind = currentPaths.indexOf(path,0);
798  if (pathind != -1)
799  {
800  currentPaths.removeAt(pathind);
801  }
802  }
803 
804  makePathTable();
805 }
806 
807 // makePathTable()
808 //
809 // Reconstructs the table containing the list of search paths
810 // in the locations tab
812 {
813  // remove all the paths from the table if present
814  pathsTableWidget->clearContents();
815  pathsTableWidget->setRowCount(0);
816 
817  // fill listview with the list of paths
818  foreach (QString pathstr, currentPaths)
819  {
820  int row = pathsTableWidget->rowCount();
821  pathsTableWidget->setRowCount(row+1);
822  QTableWidgetItem *path = new QTableWidgetItem(pathstr);
823  path->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
824  pathsTableWidget->setItem(row, 0, path);
825  }
826 }
QDir AdmsXmlBinDir
Definition: main.h:67
void readProjectFiles()
Definition: qucs.cpp:1222
QDir QucsWorkDir
Definition: main.h:65
void updateSpiceNameHash(void)
Definition: qucs.cpp:3018
Definition of the TextDoc class.
QTableWidget * pathsTableWidget
QFont font
Definition: main.h:46
QColor Real
Definition: main.h:52
QIntValidator * val200
tQucsSettings QucsSettings
Definition: main.cpp:52
QColor Directive
Definition: main.h:52
QPushButton * ColorInteger
QPushButton * ColorTask
QColor Integer
Definition: main.h:52
QColor Type
Definition: main.h:52
QColor String
Definition: main.h:52
QColor Attribute
Definition: main.h:52
QStringList qucsPathList
Definition: main.cpp:56
QucsSettingsDialog(QucsApp *parent=0, const char *name=0)
QString BinDir
Definition: main.h:57
QString Language
Definition: main.h:49
Definitions and declarations for the main application.
QPushButton * BGColorButton
QucsApp * QucsMain
Definition: main.cpp:54
QDir AscoBinDir
Definition: main.h:68
QColor Comment
Definition: main.h:52
QPushButton * ColorReal
unsigned int NodeWiring
Definition: main.h:64
QPushButton * ColorCharacter
QPushButton * ColorComment
void slotTableClicked(int, int)
bool saveApplSettings(QucsApp *qucs)
Definition: main.cpp:127
QPushButton * ColorAttribute
QPushButton * ColorDirective
bool IgnoreFutureVersion
Definition: main.h:77
QDir QucsHomeDir
Definition: main.h:66
QPushButton * ColorDataType
QRegExpValidator * Validator
QTableWidget * fileTypesTableWidget
QTabWidget * DocumentTab
Definition: qucs.h:164
QColor Task
Definition: main.h:52
QColor Character
Definition: main.h:52
void slotPathTableClicked(int, int)
QString Editor
Definition: main.h:56
QCheckBox * checkLoadFromFutureVersions
QDir OctaveBinDir
Definition: main.h:69
unsigned int maxUndo
Definition: main.h:55
The TextDoc class definition.
Definition: textdoc.h:49
QPushButton * FontButton
void readProjects()
Definition: qucs.cpp:1107
Definition: qucs.h:61
QPushButton * ColorString
QColor BGColor
Definition: main.h:48
void updatePathList(void)
Definition: qucs.cpp:3058
QStringList FileTypes
Definition: main.h:72
void updateSchNameHash(void)
Definition: qucs.cpp:2958