30 #include <qtabwidget.h>
32 #include <qcolordialog.h>
33 #include <qfontdialog.h>
34 #include <qvalidator.h>
35 #include <qpushbutton.h>
36 #include <qlineedit.h>
37 #include <qlistview.h>
38 #include <qcombobox.h>
39 #include <qmessagebox.h>
40 #include <qcheckbox.h>
44 : QDialog(parent, name, TRUE, Qt::WDestructiveClose)
47 setCaption(tr(
"Edit Qucs Properties"));
49 Expr.setPattern(
"[\\w_]+");
52 all =
new QVBoxLayout(
this);
53 QTabWidget *
t =
new QTabWidget(
this);
57 QWidget *Tab1 =
new QWidget(t);
58 QGridLayout *gp =
new QGridLayout(Tab1,6,2,6,6);
60 gp->addWidget(
new QLabel(tr(
"Font (set after reload):"), Tab1), 0,0);
62 connect(
FontButton, SIGNAL(clicked()), SLOT(slotFontDialog()));
65 gp->addWidget(
new QLabel(tr(
"Document Background Color:"), Tab1) ,1,0);
67 connect(
BGColorButton, SIGNAL(clicked()), SLOT(slotBGColorDialog()));
70 gp->addWidget(
new QLabel(tr(
"Language (set after reload):"), Tab1) ,2,0);
94 val200 =
new QIntValidator(0, 200,
this);
95 gp->addWidget(
new QLabel(tr(
"maximum undo operations:"), Tab1) ,3,0);
100 gp->addWidget(
new QLabel(tr(
"text editor:"), Tab1) ,4,0);
104 gp->addWidget(
new QLabel(tr(
"start wiring when clicking open node:"), Tab1) ,5,0);
109 t->addTab(Tab1, tr(
"Settings"));
112 QWidget *Tab3 =
new QWidget(t);
113 QGridLayout *gp3 =
new QGridLayout(Tab3,5,3,5,5);
115 gp3->addMultiCellWidget(
new QLabel(tr(
"Colors for Syntax Highlighting:"), Tab3), 0,0,0,1);
120 connect(
ColorComment, SIGNAL(clicked()), SLOT(slotColorComment()));
126 connect(
ColorString, SIGNAL(clicked()), SLOT(slotColorString()));
129 ColorInteger =
new QPushButton(tr(
"Integer Number"), Tab3);
132 connect(
ColorInteger, SIGNAL(clicked()), SLOT(slotColorInteger()));
135 ColorReal =
new QPushButton(tr(
"Real Number"), Tab3);
138 connect(
ColorReal, SIGNAL(clicked()), SLOT(slotColorReal()));
144 connect(
ColorCharacter, SIGNAL(clicked()), SLOT(slotColorCharacter()));
150 connect(
ColorDataType, SIGNAL(clicked()), SLOT(slotColorDataType()));
156 connect(
ColorAttribute, SIGNAL(clicked()), SLOT(slotColorAttribute()));
162 connect(
ColorDirective, SIGNAL(clicked()), SLOT(slotColorDirective()));
165 ColorTask =
new QPushButton(tr(
"Task"), Tab3);
168 connect(
ColorTask, SIGNAL(clicked()), SLOT(slotColorTask()));
171 t->addTab(Tab3, tr(
"Source Code Editor"));
174 QWidget *Tab2 =
new QWidget(t);
175 QGridLayout *gp2 =
new QGridLayout(Tab2,5,3,3,3);
177 QLabel *l7 =
new QLabel(
178 tr(
"Register filename extensions here in order to\nopen files with an appropriate program.")
180 gp2->addMultiCellWidget(l7,0,0,0,2);
186 connect(
List_Suffix, SIGNAL(clicked(QListViewItem*)),
187 SLOT(slotEditSuffix(QListViewItem*)));
193 (*it).section(
'/',0,0), (*it).section(
'/',1,1));
197 QLabel *l5 =
new QLabel(tr(
"Suffix:"), Tab2);
198 gp2->addWidget(l5,1,1);
204 QLabel *l6 =
new QLabel(tr(
"Program:"), Tab2);
205 gp2->addWidget(l6,2,1);
209 QHBox *h =
new QHBox(Tab2);
211 gp2->addMultiCellWidget(h,3,3,1,2);
213 QPushButton *AddButt =
new QPushButton(tr(
"Set"), h);
214 connect(AddButt, SIGNAL(clicked()), SLOT(slotAdd()));
215 QPushButton *RemoveButt =
new QPushButton(tr(
"Remove"), h);
216 connect(RemoveButt, SIGNAL(clicked()), SLOT(slotRemove()));
218 gp2->setRowStretch(4,5);
219 t->addTab(Tab2, tr(
"File Types"));
223 QHBox *Butts =
new QHBox(
this);
224 Butts->setSpacing(3);
226 all->addWidget(Butts);
228 QPushButton *OkButt =
new QPushButton(tr(
"OK"), Butts);
229 connect(OkButt, SIGNAL(clicked()), SLOT(slotOK()));
230 QPushButton *ApplyButt =
new QPushButton(tr(
"Apply"), Butts);
231 connect(ApplyButt, SIGNAL(clicked()), SLOT(slotApply()));
232 QPushButton *CancelButt =
new QPushButton(tr(
"Cancel"), Butts);
233 connect(CancelButt, SIGNAL(clicked()), SLOT(reject()));
234 QPushButton *DefaultButt =
new QPushButton(tr(
"Default Values"), Butts);
235 connect(DefaultButt, SIGNAL(clicked()), SLOT(slotDefaultValues()));
237 OkButt->setDefault(
true);
264 void QucsSettingsDialog::slotEditSuffix(QListViewItem *Item)
278 void QucsSettingsDialog::slotAdd()
288 for(Item =
List_Suffix->firstChild(); Item!=0; Item = Item->itemBelow())
290 QMessageBox::critical(
this, tr(
"Error"),
291 tr(
"This suffix is already registered!"));
304 void QucsSettingsDialog::slotRemove()
307 if(Item == 0)
return;
317 void QucsSettingsDialog::slotOK()
324 void QucsSettingsDialog::slotApply()
326 bool changed =
false;
334 if(w->inherits(
"QTextEdit"))
335 ((
TextDoc*)w)->viewport()->setPaletteBackgroundColor(
338 ((
Schematic*)w)->viewport()->setPaletteBackgroundColor(
404 for(Item =
List_Suffix->firstChild(); Item!=0; Item = Item->itemBelow())
414 void QucsSettingsDialog::slotFontDialog()
417 QFont tmpFont = QFontDialog::getFont(&ok,
Font,
this);
425 void QucsSettingsDialog::slotBGColorDialog()
427 QColor
c = QColorDialog::getColor(
434 void QucsSettingsDialog::slotDefaultValues()
436 Font = QFont(
"Helvetica", 12);
439 BGColorButton->setPaletteBackgroundColor(QColor(255,250,225));
444 ColorReal->setPaletteForegroundColor(Qt::darkMagenta);
449 ColorTask->setPaletteForegroundColor(Qt::darkRed);
457 void QucsSettingsDialog::slotColorComment()
459 QColor c = QColorDialog::getColor(
466 void QucsSettingsDialog::slotColorString()
468 QColor c = QColorDialog::getColor(
475 void QucsSettingsDialog::slotColorInteger()
477 QColor c = QColorDialog::getColor(
484 void QucsSettingsDialog::slotColorReal()
486 QColor c = QColorDialog::getColor(
487 ColorReal->paletteForegroundColor(),
this);
493 void QucsSettingsDialog::slotColorCharacter()
495 QColor c = QColorDialog::getColor(
502 void QucsSettingsDialog::slotColorDataType()
504 QColor c = QColorDialog::getColor(
511 void QucsSettingsDialog::slotColorAttribute()
513 QColor c = QColorDialog::getColor(
520 void QucsSettingsDialog::slotColorDirective()
522 QColor c = QColorDialog::getColor(
529 void QucsSettingsDialog::slotColorTask()
531 QColor c = QColorDialog::getColor(
532 ColorTask->paletteForegroundColor(),
this);