/* Constructor setups the GUI. */ QucsLib::QucsLib() { // set application icon setIcon (QPixmap(QucsSettings.BitmapDir + "big.qucs.xpm")); setCaption("Qucs Library Tool " PACKAGE_VERSION); QMenuBar * menuBar = new QMenuBar (this); // create file menu QPopupMenu * fileMenu = new QPopupMenu (); QAction * manageLib = new QAction ("Manage User Libraries...", tr("Manage User &Libraries..."), CTRL+Key_M, this); manageLib->addTo (fileMenu); connect(manageLib, SIGNAL(activated()), SLOT(slotManageLib())); fileMenu->insertSeparator(); QAction * fileQuit = new QAction ("Quit", tr("&Quit"), CTRL+Key_Q, this); fileQuit->addTo (fileMenu); connect(fileQuit, SIGNAL(activated()), SLOT(slotQuit())); // create help menu QPopupMenu * helpMenu = new QPopupMenu (); QAction * helpHelp = new QAction (tr("Help"), tr("&Help"), Key_F1, this); helpHelp->addTo (helpMenu); connect(helpHelp, SIGNAL(activated()), SLOT(slotHelp())); QAction * helpAbout = new QAction (tr("About"), tr("About"), 0, helpMenu); helpAbout->addTo (helpMenu); connect(helpAbout, SIGNAL(activated()), SLOT(slotAbout())); // setup menu bar menuBar->insertItem (tr("&File"), fileMenu); menuBar->insertSeparator (); menuBar->insertItem (tr("&Help"), helpMenu); // main box QVBoxLayout * all = new QVBoxLayout (this); all->setSpacing (0); all->setMargin (0); // reserve space for menubar QWidget * Space = new QWidget (this); Space->setFixedSize(5, menuBar->height() + 2); all->addWidget (Space); // main layout QHBox * h = new QHBox (this); h->setSpacing (5); h->setMargin (3); all->addWidget (h); // library and component choice QVGroupBox * LibGroup = new QVGroupBox (tr("Component Selection"), h); Library = new QComboBox (LibGroup); connect(Library, SIGNAL(activated(int)), SLOT(slotSelectLibrary(int))); CompList = new QListBox(LibGroup); connect(CompList, SIGNAL(highlighted(QListBoxItem*)), SLOT(slotShowComponent(QListBoxItem*))); QHBox * h1 = new QHBox (LibGroup); QPushButton * SearchButton = new QPushButton (tr("Search..."), h1); connect(SearchButton, SIGNAL(clicked()), SLOT(slotSearchComponent())); h1->setStretchFactor(new QWidget(h1), 5); // stretchable placeholder // component display QVGroupBox *CompGroup = new QVGroupBox (tr("Component"), h); CompDescr = new QTextEdit(CompGroup); CompDescr->setTextFormat(Qt::PlainText); CompDescr->setReadOnly(true); CompDescr->setWordWrap(QTextEdit::NoWrap); Symbol = new SymbolWidget (CompGroup); QHBox * h2 = new QHBox (CompGroup); QPushButton * CopyButton = new QPushButton (tr("Copy to clipboard"), h2); connect(CopyButton, SIGNAL(clicked()), SLOT(slotCopyToClipBoard())); QPushButton * ShowButton = new QPushButton (tr("Show Model"), h2); connect(ShowButton, SIGNAL(clicked()), SLOT(slotShowModel())); // ...................................................... putLibrariesIntoCombobox(); }
MyWidget::MyWidget( QWidget *parent, const char *name ) : QWidget( parent, name ) { setCaption("Color Codes"); // icons are handled differently on OSX #ifndef __APPLE__ setIcon(QPixmap(":/bitmaps/big.qucs.xpm")); #endif // -------- create menubar ------------------- QAction *fileExit = new QAction(tr("E&xit"), this); fileExit->setShortcut(Qt::CTRL+Qt::Key_Q); connect(fileExit, SIGNAL(activated()), qApp, SLOT(quit())); QMenu *fileMenu = new QMenu(tr("&File")); fileMenu->addAction(fileExit); QAction *help = new QAction(tr("Help..."), this); help->setShortcut(Qt::Key_F1); connect(help, SIGNAL(activated()), this, SLOT(slotHelpIntro())); QAction *about = new QAction(tr("&About ResistorCodes..."), this); connect(about, SIGNAL(activated()), this, SLOT(slotHelpAbout())); QAction *aboutQt = new QAction(tr("&About Qt..."), this); connect(aboutQt, SIGNAL(activated()), this, SLOT(slotHelpAboutQt())); QMenu *helpMenu = new QMenu(tr("&Help")); helpMenu->addAction(help); helpMenu->addAction(about); helpMenu->addSeparator(); helpMenu->addAction(aboutQt); QMenuBar *menuBar = new QMenuBar(this); menuBar->addMenu(fileMenu); menuBar->insertSeparator(); menuBar->addMenu(helpMenu); res= new QResistor(); //--------------------resistance displayin ui ---------------------------------// resBox = new MyResistanceBox (this); connect(res, SIGNAL(valueModified(QResistor*)),resBox,SLOT(update(QResistor*))); //-------------------color displaying ui---------------------------------------------// colorBox = new MyColorBox(this); connect(res, SIGNAL(valueModified(QResistor*)),colorBox,SLOT(update(QResistor*))); //-------------------paste the configuration to clipboard--------------------------------------------// connect(res, SIGNAL(valueModified(QResistor*)),this,SLOT(slotConfiguration())); //-------------------switching buttons ui--------------------------------------// QPushButton *calcColor = new QPushButton(QPixmap(":/bitmaps/next.png")," To Colors", this, "calcColor" ); connect(calcColor, SIGNAL(clicked()),this,SLOT(setResistanceValue())); QPushButton *calcResistance = new QPushButton(QPixmap(":/bitmaps/previous.png")," To Resistance", this, "calcResistance" ); connect(calcResistance, SIGNAL(clicked()),this,SLOT(setColorValue())); QPushButton *quit = new QPushButton( "Quit", this, "quit" ); connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) ); QHBoxLayout *buttonBox = new QHBoxLayout; buttonBox->addWidget(calcColor); buttonBox->addWidget(calcResistance); buttonBox->addWidget(quit); //--------------------packing all of them together---------------------------------------// QGridLayout *grid = new QGridLayout(this); grid->setMargin(10); #ifndef __APPLE__ QWidget *Space = new QWidget(this); // reserve space for menubar Space->setFixedSize(1, menuBar->height()); grid->addWidget(Space, 0,0); #endif grid->addWidget( resBox, 1, 0 ); grid->addLayout( buttonBox, 2, 0 ); grid->addWidget( colorBox, 3, 0 ); }
FilterDialog::FilterDialog (QWidget * parent) : QDialog (parent) { // set application icon ///setIcon (QPixmap(QucsSettings.BitmapDir + "big.qucs.xpm")); setCaption("Qucs Filter " PACKAGE_VERSION); all = new Q3VBoxLayout(this); // -------- create menubar ------------------- Q3PopupMenu *fileMenu = new Q3PopupMenu(); fileMenu->insertItem(tr("E&xit"), this, SLOT(slotQuit()), Qt::CTRL+Qt::Key_Q); Q3PopupMenu *helpMenu = new Q3PopupMenu(); helpMenu->insertItem( tr("&About Qucs Filter..."), this, SLOT(slotHelpAbout()), 0); helpMenu->insertItem(tr("About Qt..."), this, SLOT(slotHelpAboutQt()), 0); QMenuBar *bar = new QMenuBar(this); bar->insertItem(tr("&File"), fileMenu); bar->insertSeparator (); bar->insertItem(tr("&Help"), helpMenu); all->addWidget(bar); // reserve space for menubar all->addSpacing (bar->height() + 2); QTabWidget *t = new QTabWidget(this); all->addWidget(t); // ........................................................... QWidget *Tab1 = new QWidget(t); Q3GridLayout *gp1 = new Q3GridLayout(Tab1,12,6,5,5); FilterName = new QComboBox(FALSE, Tab1); gp1->addWidget(FilterName,0,0); TformName = new QComboBox(FALSE, Tab1); gp1->addWidget(TformName,0,1); OrderBox = new QCheckBox(tr("Specify order"), Tab1); gp1->addWidget(OrderBox,1,0); Q3HBox *h1 = new Q3HBox(Tab1); h1->setSpacing (5); OrderCombo = new QComboBox(FALSE, h1); OrderCombo->setEnabled(TRUE); SubOrderCombo = new QComboBox(FALSE, h1); SubOrderCombo->setEnabled(FALSE); SubOrderCombo->insertItem( tr( "b" ) ); SubOrderCombo->insertItem( tr( "c" ) ); gp1->addWidget(h1,1,1); CutoffLabel = new QLabel(tr("Cutoff/Center"),Tab1); gp1->addWidget(CutoffLabel,2,0); EnterCutoff = new QLineEdit(Tab1); gp1->addWidget(EnterCutoff,2,1); CutoffCombo = new QComboBox(Tab1); CutoffCombo->insertItem( tr( "Hz" ) ); CutoffCombo->insertItem( tr( "kHz" ) ); CutoffCombo->insertItem( tr( "MHz" ) ); CutoffCombo->insertItem( tr( "GHz" ) ); gp1->addWidget(CutoffCombo,2,2); RippleLabel = new QLabel(tr("Ripple"),Tab1); gp1->addWidget(RippleLabel,3,0); EnterRipple = new QLineEdit(Tab1); gp1->addWidget(EnterRipple,3,1); RippleUnitLabel = new QLabel(tr("dB"),Tab1); gp1->addWidget(RippleUnitLabel,3,2); AngleLabel = new QLabel(tr("Angle"),Tab1); gp1->addWidget(AngleLabel,3,3); EnterAngle = new QLineEdit(Tab1); gp1->addWidget(EnterAngle,3,4); AngleUnitLabel = new QLabel(tr("°"),Tab1); gp1->addWidget(AngleUnitLabel,3,5); ZinLabel = new QLabel(tr("Zin"),Tab1); gp1->addWidget(ZinLabel,7,0); EnterZin = new QLineEdit(Tab1); gp1->addWidget(EnterZin,7,1); OhmLabel = new QLabel(tr("Ohm"),Tab1); gp1->addWidget(OhmLabel,7,2); ZoutLabel = new QLabel(tr("Zout"),Tab1); ZoutLabel->setEnabled(false); gp1->addWidget(ZoutLabel,7,3); EnterZout = new QLineEdit(Tab1); gp1->addWidget(EnterZout,7,4); OhmLabel_2 = new QLabel(tr("Ohm"),Tab1); gp1->addWidget(OhmLabel_2,7,5); StopbandLabel = new QLabel(tr("Stopband corner"),Tab1); gp1->addWidget(StopbandLabel,5,0); EnterStopband = new QLineEdit(Tab1); gp1->addWidget(EnterStopband,5,1); StopbandCombo = new QComboBox(FALSE, Tab1); StopbandCombo->insertItem( tr( "Hz" ) ); StopbandCombo->insertItem( tr( "kHz" ) ); StopbandCombo->insertItem( tr( "MHz" ) ); StopbandCombo->insertItem( tr( "GHz" ) ); gp1->addWidget(StopbandCombo,5,2); BandwidthLabel = new QLabel(tr("Bandwidth"),Tab1); BandwidthLabel->setEnabled(FALSE); gp1->addWidget(BandwidthLabel,4,0); EnterBandwidth = new QLineEdit(Tab1); gp1->addWidget(EnterBandwidth,4,1); BandwidthCombo = new QComboBox(FALSE, Tab1); BandwidthCombo->setEnabled(FALSE); BandwidthCombo->insertItem( tr( "Hz" ) ); BandwidthCombo->insertItem( tr( "kHz" ) ); BandwidthCombo->insertItem( tr( "MHz" ) ); BandwidthCombo->insertItem( tr( "GHz" ) ); gp1->addWidget(BandwidthCombo,4,2); AttenuationLabel = new QLabel(tr("Attenuation"),Tab1); gp1->addWidget(AttenuationLabel,6,0); EnterAttenuation = new QLineEdit(Tab1); gp1->addWidget(EnterAttenuation,6,1); dBLabel = new QLabel(tr("dB"),Tab1); gp1->addWidget(dBLabel,6,2); DualBox = new QCheckBox(tr("dual"),Tab1); gp1->addMultiCellWidget(DualBox,8,8,0,2); CauerPoleBox = new QCheckBox(tr("Stopband is first pole"),Tab1); CauerPoleBox->setEnabled(FALSE); gp1->addMultiCellWidget(CauerPoleBox,9,9,0,2); OptimizeCauerBox = new QCheckBox(tr("Optimize cauer"),Tab1); OptimizeCauerBox->setEnabled(FALSE); gp1->addMultiCellWidget(OptimizeCauerBox,10,10,0,2); EqualInductorBox = new QCheckBox(tr("Equal inductors"),Tab1); EqualInductorBox->setEnabled(FALSE); gp1->addMultiCellWidget(EqualInductorBox,8,8,3,5); UseCrossBox = new QCheckBox(tr("+ rather than T"),Tab1); UseCrossBox->setEnabled(FALSE); gp1->addMultiCellWidget(UseCrossBox,9,9,3,5); Cboxes = new Q3VButtonGroup(tr("Optimize C"),Tab1); Cmin = new QRadioButton(tr("Cmin"),Cboxes); Cmax = new QRadioButton(tr("Cmax"),Cboxes); NoC = new QRadioButton(tr("noC"),Cboxes); gp1->addMultiCellWidget(Cboxes,11,11,0,2); Lboxes = new Q3VButtonGroup(tr("Optimize L"),Tab1); Lmin = new QRadioButton(tr("Lmin"),Lboxes); Lmax = new QRadioButton(tr("Lmax"),Lboxes); NoL = new QRadioButton(tr("noL"),Lboxes); gp1->addMultiCellWidget(Lboxes,11,11,3,5); t->addTab(Tab1, tr("LC Filters")); // ........................................................... QWidget *Tab2 = new QWidget(t); t->addTab(Tab2, tr("Microstrip Filters")); // ........................................................... QWidget *Tab3 = new QWidget(t); t->addTab(Tab3, tr("Active Filters")); // reserve space for vertical resizing all->addStretch(); // ........................................................... // buttons on the bottom of the dialog (independent of the TabWidget) Q3HBox *Butts = new Q3HBox(this); Butts->setSpacing(3); Butts->setMargin(3); all->addWidget(Butts); cancelButton = new QPushButton(tr("Exit"),Butts); okButton = new QPushButton(tr("Calculate"),Butts); okButton->setEnabled(FALSE); // signals and slots connections connect( cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) ); connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); }
QucsFilter::QucsFilter() { // set application icon setIcon (QPixmap(QucsSettings.BitmapDir + "big.qucs.xpm")); setCaption("Qucs Filter " PACKAGE_VERSION); // -------- create menubar ------------------- QPopupMenu *fileMenu = new QPopupMenu(); fileMenu->insertItem(tr("E&xit"), this, SLOT(slotQuit()), CTRL+Key_Q); QPopupMenu *helpMenu = new QPopupMenu(); helpMenu->insertItem(tr("Help..."), this, SLOT(slotHelpIntro()), Key_F1); helpMenu->insertSeparator(); helpMenu->insertItem( tr("&About QucsFilter..."), this, SLOT(slotHelpAbout()), 0); helpMenu->insertItem(tr("About Qt..."), this, SLOT(slotHelpAboutQt()), 0); QMenuBar *bar = new QMenuBar(this); bar->insertItem(tr("&File"), fileMenu); bar->insertSeparator (); bar->insertItem(tr("&Help"), helpMenu); // ------- create main windows widgets -------- gbox = new QGridLayout(this, 10,3,5,5); QWidget *Space = new QWidget(this); // reserve space for menubar Space->setFixedSize(5, bar->height()); gbox->addWidget(Space, 0,0); QLabel *Label1 = new QLabel(tr("Filter type:"), this); gbox->addWidget(Label1, 1,0); ComboType = new QComboBox(this); ComboType->insertItem("Bessel"); ComboType->insertItem("Butterworth"); ComboType->insertItem("Chebyshev"); ComboType->insertItem("Cauer"); gbox->addWidget(ComboType, 1,1); connect(ComboType, SIGNAL(activated(int)), SLOT(slotTypeChanged(int))); QLabel *Label2 = new QLabel(tr("Filter class:"), this); gbox->addWidget(Label2, 2,0); ComboClass = new QComboBox(this); ComboClass->insertItem(tr("Low pass")); ComboClass->insertItem(tr("High pass")); ComboClass->insertItem(tr("Band pass")); ComboClass->insertItem(tr("Band stop")); gbox->addWidget(ComboClass, 2,1); connect(ComboClass, SIGNAL(activated(int)), SLOT(slotClassChanged(int))); IntVal = new QIntValidator(1, 200, this); DoubleVal = new QDoubleValidator(this); LabelOrder = new QLabel(tr("Order:"), this); gbox->addWidget(LabelOrder, 3,0); EditOrder = new QLineEdit("3", this); EditOrder->setValidator(IntVal); gbox->addWidget(EditOrder, 3,1); LabelStart = new QLabel(tr("Corner frequency:"), this); gbox->addWidget(LabelStart, 4,0); EditCorner = new QLineEdit("1", this); EditCorner->setValidator(DoubleVal); gbox->addWidget(EditCorner, 4,1); ComboCorner = new QComboBox(this); ComboCorner->insertItem("Hz"); ComboCorner->insertItem("kHz"); ComboCorner->insertItem("MHz"); ComboCorner->insertItem("GHz"); ComboCorner->setCurrentItem(3); gbox->addWidget(ComboCorner, 4,2); LabelStop = new QLabel(tr("Stop frequency:"), this); gbox->addWidget(LabelStop, 5,0); EditStop = new QLineEdit("2", this); EditStop->setValidator(DoubleVal); gbox->addWidget(EditStop, 5,1); ComboStop = new QComboBox(this); ComboStop->insertItem("Hz"); ComboStop->insertItem("kHz"); ComboStop->insertItem("MHz"); ComboStop->insertItem("GHz"); ComboStop->setCurrentItem(3); gbox->addWidget(ComboStop, 5,2); LabelBandStop = new QLabel(tr("Stop band frequency:"), this); gbox->addWidget(LabelBandStop, 6,0); EditBandStop = new QLineEdit("3", this); EditBandStop->setValidator(DoubleVal); gbox->addWidget(EditBandStop, 6,1); ComboBandStop = new QComboBox(this); ComboBandStop->insertItem("Hz"); ComboBandStop->insertItem("kHz"); ComboBandStop->insertItem("MHz"); ComboBandStop->insertItem("GHz"); ComboBandStop->setCurrentItem(3); gbox->addWidget(ComboBandStop, 6,2); LabelRipple = new QLabel(tr("Pass band ripple:"), this); gbox->addWidget(LabelRipple, 7,0); EditRipple = new QLineEdit("1", this); EditRipple->setValidator(DoubleVal); gbox->addWidget(EditRipple, 7,1); LabelRipple_dB = new QLabel("dB", this); gbox->addWidget(LabelRipple_dB, 7,2); LabelAtten = new QLabel(tr("Stop band attenuation:"), this); gbox->addWidget(LabelAtten, 8,0); EditAtten = new QLineEdit("20", this); EditAtten->setValidator(DoubleVal); gbox->addWidget(EditAtten, 8,1); LabelAtten_dB = new QLabel("dB", this); gbox->addWidget(LabelAtten_dB, 8,2); QLabel *Label9 = new QLabel(tr("Impedance:"), this); gbox->addWidget(Label9, 9,0); EditImpedance = new QLineEdit("50", this); EditImpedance->setValidator(DoubleVal); gbox->addWidget(EditImpedance, 9,1); QLabel *Label10 = new QLabel("Ohm", this); gbox->addWidget(Label10, 9,2); QPushButton *ButtonGo = new QPushButton(tr("Calculate and put into Clipboard"), this); connect(ButtonGo, SIGNAL(clicked()), SLOT(slotCalculate())); gbox->addMultiCellWidget(ButtonGo, 10,10,0,2); LabelResult = new QLabel(this); ResultState = 100; slotShowResult(); LabelResult->setAlignment(Qt::AlignHCenter); gbox->addMultiCellWidget(LabelResult, 11,11,0,2); // ------- finally set initial state -------- slotTypeChanged(0); slotClassChanged(0); }