My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
optionsdialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  optionsdialog.cpp
3  --------------------
4  begin : Sun Apr 03 2005
5  copyright : (C) 2005 by Stefan Jahn
6  email : stefan@lkcc.org
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 
18 #ifdef HAVE_CONFIG_H
19 # include <config.h>
20 #endif
21 
22 #include <qlayout.h>
23 #include <qhbox.h>
24 #include <qhgroupbox.h>
25 #include <qpushbutton.h>
26 #include <qvbox.h>
27 #include <qlabel.h>
28 #include <qcombobox.h>
29 
30 #include "optionsdialog.h"
31 #include "qucstrans.h"
32 
33 extern struct TransUnit TransUnits[];
34 
36  : QDialog(parent, 0, false, Qt::WDestructiveClose)
37 {
38  setCaption("QucsTranscalc "+tr("Options"));
39 
40  // -------- create dialog widgets ------------
41  vLayout = new QVBoxLayout(this);
42  vLayout->setMargin(3);
43  vLayout->setSpacing(3);
44 
45  QHGroupBox * h = new QHGroupBox(tr("Units"), this);
46  vLayout->addWidget(h);
47  QVBox * l = new QVBox(h);
48  l->setSpacing(3);
49  QLabel * lfr = new QLabel(tr("Frequency"),l);
50  lfr->setAlignment (Qt::AlignRight);
51  QLabel * lle = new QLabel(tr("Length"),l);
52  lle->setAlignment (Qt::AlignRight);
53  QLabel * lre = new QLabel(tr("Resistance"),l);
54  lre->setAlignment (Qt::AlignRight);
55  QLabel * lan = new QLabel(tr("Angle"),l);
56  lan->setAlignment (Qt::AlignRight);
57  QVBox * r = new QVBox(h);
58  r->setSpacing(3);
59  for (int j = 0; j < 4; j++) {
60  units[j] = new QComboBox(r);
61  for (int i = 0; TransUnits[j].units[i] != NULL; i++)
62  units[j]->insertItem (TransUnits[j].units[i]);
63  }
64  units[0]->setCurrentItem (QucsSettings.freq_unit);
65  units[1]->setCurrentItem (QucsSettings.length_unit);
66  units[2]->setCurrentItem (QucsSettings.res_unit);
67  units[3]->setCurrentItem (QucsSettings.ang_unit);
68 
69  QHBox * h2 = new QHBox(this);
70  vLayout->addWidget(h2);
71 
72  QPushButton *ButtonSave = new QPushButton(tr("Save as Default"), h2);
73  connect(ButtonSave, SIGNAL(clicked()), SLOT(slotSave()));
74 
75  QPushButton *ButtonClose = new QPushButton(tr("Dismiss"), h2);
76  connect(ButtonClose, SIGNAL(clicked()), SLOT(slotClose()));
77  ButtonClose->setFocus();
78 }
79 
81 {
82  delete vLayout;
83 }
84 
85 void OptionsDialog::slotClose()
86 {
87  accept();
88 }
89 
90 void OptionsDialog::slotSave()
91 {
92  QucsSettings.freq_unit = units[0]->currentItem();
93  QucsSettings.length_unit = units[1]->currentItem();
94  QucsSettings.res_unit = units[2]->currentItem();
95  QucsSettings.ang_unit = units[3]->currentItem();
96  accept();
97 }