9 setWindowTitle(
"Color Configuration for UltraScan" );
10 setAttribute( Qt::WA_DeleteOnClose );
12 QGridLayout* mainLayout =
new QGridLayout(
this );
13 mainLayout->setSpacing( 2 );
14 mainLayout->setColumnStretch( 0, 99 );
15 mainLayout->setColumnStretch( 1, 0 );
17 QGridLayout* leftColumn =
new QGridLayout;
18 leftColumn->setSpacing( 2 );
19 leftColumn->setRowStretch( 1, 99 );
29 tr(
"X-axis" ), (
"Y-axis" ) );
35 const int ArraySize = 21;
36 double x[ ArraySize ];
37 double y[ ArraySize ];
39 for (
int i = 0; i < ArraySize; i++)
41 x[ i ] = 1.0 + i * 0.2 / ( ArraySize - 1 );
42 y[ i ] = 1.0 + (double) i / ( ArraySize - 1 );
45 curve->setData( x, y, ArraySize );
47 leftColumn->addLayout(
us_plot, row++, 0, 3, 2 );
57 for (
int i = 1; i <= 15; i++ )
59 s.sprintf(
"%d pixels", i * 2 );
68 leftColumn->addWidget(
lbl_example, row++, 0, 1, 2 );
70 QHBoxLayout* labelLine =
new QHBoxLayout();
75 le_edit->setAlignment( Qt::AlignCenter );
77 labelLine->addWidget(
le_edit );
80 lbl_text->setAlignment( Qt::AlignCenter );
82 leftColumn->addLayout( labelLine, row++, 0, 1, 2 );
86 QHBoxLayout* pbLine =
new QHBoxLayout();
92 pb_active->setToolTip( tr(
"Click on another window for inactive colors" ) );
98 leftColumn->addLayout( pbLine, row++, 0, 1, 2 );
103 QHBoxLayout* progressLine =
new QHBoxLayout();
106 lbl_progress->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
111 progress->setMinimumWidth( 2 * width );
112 progressLine->addWidget(
progress );
114 leftColumn->addLayout( progressLine, row++, 0, 1, 2 );
118 QHBoxLayout* lcdLine =
new QHBoxLayout;
120 lbl_lcd->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
121 lbl_lcd->setMinimumWidth( width );
126 lcd->setMinimumWidth( 2 * width );
127 lcdLine->addWidget(
lcd );
129 leftColumn->addLayout( lcdLine, row++, 0, 1, 2 );
132 QHBoxLayout* counterLine =
new QHBoxLayout();
134 lbl_counter->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
139 cnt->setIncSteps ( QwtCounter::Button1, 1 );
140 cnt->setIncSteps ( QwtCounter::Button2, 20 );
141 cnt->setMinimumWidth( 2 * width );
142 connect(
cnt, SIGNAL( valueChanged(
double ) ), SLOT(
updateWidgets(
double ) ) );
143 counterLine->addWidget(
cnt );
145 leftColumn->addLayout( counterLine, row++, 0, 1, 2 );
148 QGridLayout* rightColumn =
new QGridLayout;
149 rightColumn->setSpacing( 2 );
155 rightColumn->addWidget(
lbl_style, row, 0 );
157 QStringList styles = QStyleFactory::keys();
167 connect(
cmbb_style, SIGNAL( activated (
const QString& ) ),
170 rightColumn->addWidget(
cmbb_style, row++, 1 );
174 rightColumn->addWidget(
lbl_assign, row++, 0, 1, 2 );
180 rightColumn->addWidget(
le_choice, row++, 1 );
184 QHBoxLayout* color1 =
new QHBoxLayout;
194 rightColumn->addLayout( color1 , row , 0 );
195 rightColumn->addWidget(
pb_color1, row++, 1 );
197 QHBoxLayout* color2 =
new QHBoxLayout;
207 rightColumn->addLayout( color2 , row , 0 );
208 rightColumn->addWidget(
pb_color2, row++, 1 );
210 QHBoxLayout* color3 =
new QHBoxLayout;
220 rightColumn->addLayout( color3 , row , 0 );
221 rightColumn->addWidget(
pb_color3, row++, 1 );
223 QHBoxLayout* color4 =
new QHBoxLayout;
233 rightColumn->addLayout( color4 , row , 0 );
234 rightColumn->addWidget(
pb_color4, row++, 1 );
236 QHBoxLayout* color5 =
new QHBoxLayout;
246 rightColumn->addLayout( color5 , row , 0 );
247 rightColumn->addWidget(
pb_color5, row++, 1 );
249 QHBoxLayout* color6 =
new QHBoxLayout;
259 rightColumn->addLayout( color6 , row , 0 );
260 rightColumn->addWidget(
pb_color6, row++, 1 );
265 rightColumn->addWidget(
lbl_choices, row++, 0, 1, 2 );
273 schemes->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Expanding );
274 schemes->setMaximumWidth( 160 );
275 schemes->setMinimumWidth( 160 );
284 rightColumn->setRowStretch( row, 99 );
285 rightColumn->addWidget(
schemes, row, 0 );
288 elements->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Expanding );
301 connect(
elements, SIGNAL( currentRowChanged(
int ) ),
304 rightColumn->addWidget(
elements, row++, 1 );
312 rightColumn->addWidget(
le_save_as, row++, 1 );
316 QHBoxLayout* buttonBar =
new QHBoxLayout;
331 connect(
schemes, SIGNAL( itemSelectionChanged() ),
335 buttonBar->addWidget(
pb_help );
336 connect(
pb_help, SIGNAL( clicked() ), SLOT(
help() ) );
339 buttonBar->addWidget(
pb_quit );
340 connect(
pb_quit, SIGNAL( clicked() ), SLOT( close() ) );
342 mainLayout->addLayout( leftColumn , 0, 0 );
343 mainLayout->addLayout( rightColumn, 0, 1 );
344 mainLayout->addLayout( buttonBar , 1, 0, 1, 2 );
370 QApplication::setStyle(
current.guiStyle );
384 grid ->setMajPen ( QPen(
current.plotMajorGrid ) );
385 grid ->setMinPen ( QPen(
current.plotMinorGrid ) );
387 pick ->setRubberBandPen ( QPen(
current.plotPicker ) );
388 pick ->setTrackerPen ( QPen(
current.plotPicker ) );
420 c = p.color( QPalette::Active, QPalette::Window );
421 p.setColor( QPalette::Window, c );
425 c = p.color( QPalette::Active, QPalette::WindowText );
426 p.setColor( QPalette::Window, c );
430 c = p.color( QPalette::Active, QPalette::Light );
431 p.setColor( QPalette::Window, c );
434 lbl_color4->setText( tr(
"Medium Shadow:" ) );
435 c = p.color( QPalette::Active, QPalette::Dark );
436 p.setColor( QPalette::Window, c );
439 lbl_color5->setText( tr(
"Medium Highlight:" ) );
440 c = p.color( QPalette::Active, QPalette::Midlight );
441 p.setColor( QPalette::Window, c );
444 p.setColor( QPalette::Window, Qt::gray );
462 c = p.color( QPalette::Active, QPalette::ButtonText );
463 p.setColor( QPalette::Window, c );
466 lbl_color2->setText( tr(
"Active Background:" ) );
467 c = p.color( QPalette::Active, QPalette::Button );
468 p.setColor( QPalette::Window, c );
472 c = p.color( QPalette::Inactive, QPalette::ButtonText );
473 p.setColor( QPalette::Window, c );
476 lbl_color4->setText( tr(
"Inactive Background:" ) );
477 c = p.color( QPalette::Inactive, QPalette::Button );
478 p.setColor( QPalette::Window, c );
501 c = p.color( QPalette::Disabled, QPalette::ButtonText );
502 p.setColor( QPalette::Window, c );
506 c = p.color( QPalette::Disabled, QPalette::Button );
507 p.setColor( QPalette::Window, c );
511 c = p.color( QPalette::Disabled, QPalette::Light );
512 p.setColor( QPalette::Window, c );
515 p.setColor( QPalette::Window, Qt::gray );
538 c = p.color( QPalette::Active, QPalette::Window );
539 p.setColor( QPalette::Window, c );
543 c = p.color( QPalette::Active, QPalette::WindowText );
544 p.setColor( QPalette::Window, c );
548 c = p.color( QPalette::Active, QPalette::Shadow );
549 p.setColor( QPalette::Window, c );
553 p.setColor( QPalette::Window,
current.plotPicker );
556 p.setColor( QPalette::Window, Qt::gray );
574 lbl_color1->setText( tr(
"Plot Background:" ) );
575 p.setColor( QPalette::Window,
current.plotBg );
579 p.setColor( QPalette::Window,
current.plotCurve );
582 lbl_color3->setText( tr(
"Major Grid Lines:" ) );
583 p.setColor( QPalette::Window,
current.plotMajorGrid );
586 lbl_color4->setText( tr(
"Minor Grid Lines" ) );
587 p.setColor( QPalette::Window,
current.plotMinorGrid );
590 p.setColor( QPalette::Window, Qt::gray );
612 c = p.color( QPalette::Active, QPalette::Window );
613 p.setColor( QPalette::Window, c );
617 c = p.color( QPalette::Active, QPalette::WindowText );
618 p.setColor( QPalette::Window, c );
621 p.setColor( QPalette::Window, Qt::gray );
648 lbl_color2->setText( tr(
"Default Background:" ) );
649 c = p.color( QPalette::Active, QPalette::Base );
650 p.setColor( QPalette::Window, c );
654 c = p.color( QPalette::Active, QPalette::Text );
655 p.setColor( QPalette::Window, c );
658 lbl_color3->setText( tr(
"Default Border:" ) );
659 c = p.color( QPalette::Active, QPalette::Light );
660 p.setColor( QPalette::Window, c );
663 lbl_color4->setText( tr(
"Alternate Text:" ) );
664 c = p.color( QPalette::Active, QPalette::ButtonText );
665 p.setColor( QPalette::Window, c );
668 lbl_color5->setText( tr(
"Alternate Background:" ) );
669 c = p.color( QPalette::Active, QPalette::Button );
670 p.setColor( QPalette::Window, c );
674 c = p.color( QPalette::Active, QPalette::Midlight );
675 p.setColor( QPalette::Window, c );
692 c = p.color( QPalette::Active, QPalette::Window );
693 p.setColor( QPalette::Window, c );
697 c = p.color( QPalette::Active, QPalette::WindowText );
698 p.setColor( QPalette::Window, c );
702 c = p.color( QPalette::Active, QPalette::Shadow );
703 p.setColor( QPalette::Window, c );
707 c = p.color( QPalette::Active, QPalette::Light );
708 p.setColor( QPalette::Window, c );
711 p.setColor( QPalette::Window, Qt::gray );
732 c = p.color( QPalette::Active, QPalette::Base );
733 p.setColor( QPalette::Window, c );
737 c = p.color( QPalette::Active, QPalette::Text );
738 p.setColor( QPalette::Window, c );
742 c = p.color( QPalette::Active, QPalette::Shadow );
743 p.setColor( QPalette::Window, c );
746 p.setColor( QPalette::Window, Qt::gray );
820 cnt ->setPalette( p );
836 QColor old =
color_field1->palette().color( QPalette::Window );
839 QColor c = QColorDialog::getColor( old );
841 if ( ! c.isValid() || c == old )
return;
846 p.setColor( QPalette::Window, c );
855 current.frameColor.setColor( QPalette::Active , QPalette::WindowText, c );
856 current.frameColor.setColor( QPalette::Inactive, QPalette::WindowText, c );
857 current.frameColor.setColor( QPalette::Disabled, QPalette::WindowText, c );
862 current.pushbColor.setColor( QPalette::Active , QPalette::ButtonText, c );
867 current.pushbColor.setColor( QPalette::Disabled, QPalette::ButtonText, c );
872 current.plotColor.setColor( QPalette::Active , QPalette::WindowText, c );
873 current.plotColor.setColor( QPalette::Inactive, QPalette::WindowText, c );
874 current.plotColor.setColor( QPalette::Disabled, QPalette::WindowText, c );
881 plot->setCanvasBackground( c );
886 current.labelColor.setColor( QPalette::Active , QPalette::WindowText, c );
887 current.labelColor.setColor( QPalette::Inactive, QPalette::WindowText, c );
888 current.labelColor.setColor( QPalette::Disabled, QPalette::WindowText, c );
893 current.normalColor.setColor( QPalette::Active , QPalette::Text, c );
894 current.normalColor.setColor( QPalette::Inactive, QPalette::Text, c );
895 current.normalColor.setColor( QPalette::Disabled, QPalette::Text, c );
900 current.lcdColor.setColor( QPalette::Active , QPalette::WindowText, c );
901 current.lcdColor.setColor( QPalette::Inactive, QPalette::WindowText, c );
902 current.lcdColor.setColor( QPalette::Disabled, QPalette::WindowText, c );
907 current.editColor.setColor( QPalette::Active , QPalette::Text, c );
908 current.editColor.setColor( QPalette::Inactive, QPalette::Text, c );
909 current.editColor.setColor( QPalette::Disabled, QPalette::Text, c );
918 QColor old =
color_field2->palette().color( QPalette::Window );
921 QColor c = QColorDialog::getColor( old );
923 if ( ! c.isValid() || c == old )
return;
928 p.setColor( QPalette::Window, c );
937 current.frameColor.setColor( QPalette::Active , QPalette::Window, c );
938 current.frameColor.setColor( QPalette::Inactive, QPalette::Window, c );
939 current.frameColor.setColor( QPalette::Disabled, QPalette::Window, c );
944 current.pushbColor.setColor( QPalette::Active , QPalette::Button, c );
949 current.pushbColor.setColor( QPalette::Disabled, QPalette::Button, c );
954 current.plotColor.setColor( QPalette::Active , QPalette::Window, c );
955 current.plotColor.setColor( QPalette::Inactive, QPalette::Window, c );
956 current.plotColor.setColor( QPalette::Disabled, QPalette::Window, c );
963 curve->setPen( QPen( c ) );
968 current.labelColor.setColor( QPalette::Active , QPalette::Window, c );
969 current.labelColor.setColor( QPalette::Inactive, QPalette::Window, c );
970 current.labelColor.setColor( QPalette::Disabled, QPalette::Window, c );
975 current.normalColor.setColor( QPalette::Active , QPalette::Base, c );
976 current.normalColor.setColor( QPalette::Inactive, QPalette::Base, c );
977 current.normalColor.setColor( QPalette::Disabled, QPalette::Base, c );
982 current.lcdColor.setColor( QPalette::Active , QPalette::Window, c );
983 current.lcdColor.setColor( QPalette::Inactive, QPalette::Window, c );
984 current.lcdColor.setColor( QPalette::Disabled, QPalette::Window, c );
989 current.editColor.setColor( QPalette::Active , QPalette::Base, c );
990 current.editColor.setColor( QPalette::Inactive, QPalette::Base, c );
991 current.editColor.setColor( QPalette::Disabled, QPalette::Base, c );
1000 QColor old =
color_field3->palette().color( QPalette::Window );
1003 QColor c = QColorDialog::getColor( old );
1005 if ( ! c.isValid() || c == old )
return;
1010 p.setColor( QPalette::Window, c );
1019 current.frameColor.setColor( QPalette::Active , QPalette::Light, c );
1020 current.frameColor.setColor( QPalette::Inactive, QPalette::Light, c );
1021 current.frameColor.setColor( QPalette::Disabled, QPalette::Light, c );
1026 current.pushbColor.setColor( QPalette::Inactive, QPalette::ButtonText, c );
1031 current.pushbColor.setColor( QPalette::Disabled, QPalette::Light, c );
1036 current.plotColor.setColor( QPalette::Active , QPalette::Text, c );
1037 current.plotColor.setColor( QPalette::Inactive, QPalette::Text, c );
1038 current.plotColor.setColor( QPalette::Disabled, QPalette::Text, c );
1045 grid->setMajPen( QPen( c ) );
1050 current.normalColor.setColor( QPalette::Active , QPalette::Shadow, c );
1051 current.normalColor.setColor( QPalette::Inactive, QPalette::Shadow, c );
1052 current.normalColor.setColor( QPalette::Disabled, QPalette::Shadow, c );
1057 current.lcdColor.setColor( QPalette::Active , QPalette::Dark, c );
1058 current.lcdColor.setColor( QPalette::Inactive, QPalette::Dark, c );
1059 current.lcdColor.setColor( QPalette::Disabled, QPalette::Dark, c );
1064 current.editColor.setColor( QPalette::Active , QPalette::Shadow, c );
1065 current.editColor.setColor( QPalette::Inactive, QPalette::Shadow, c );
1066 current.editColor.setColor( QPalette::Disabled, QPalette::Shadow, c );
1075 QColor old =
color_field4->palette().color( QPalette::Window );
1078 QColor c = QColorDialog::getColor( old );
1080 if ( ! c.isValid() || c == old )
return;
1085 p.setColor( QPalette::Window, c );
1094 current.frameColor.setColor( QPalette::Active , QPalette::Dark, c );
1095 current.frameColor.setColor( QPalette::Inactive, QPalette::Dark, c );
1096 current.frameColor.setColor( QPalette::Disabled, QPalette::Dark, c );
1101 current.pushbColor.setColor( QPalette::Inactive, QPalette::Button, c );
1107 pick ->setRubberBandPen( QPen( c ) );
1108 pick ->setTrackerPen ( QPen( c ) );
1114 grid->setMajPen( QPen( c ) );
1119 current.normalColor.setColor( QPalette::Active , QPalette::ButtonText, c );
1120 current.normalColor.setColor( QPalette::Inactive, QPalette::ButtonText, c );
1121 current.normalColor.setColor( QPalette::Disabled, QPalette::ButtonText, c );
1126 current.lcdColor.setColor( QPalette::Active , QPalette::Light, c );
1127 current.lcdColor.setColor( QPalette::Inactive, QPalette::Light, c );
1128 current.lcdColor.setColor( QPalette::Disabled, QPalette::Light, c );
1137 QColor old =
color_field5->palette().color( QPalette::Window );
1140 QColor c = QColorDialog::getColor( old );
1142 if ( ! c.isValid() || c == old )
return;
1147 p.setColor( QPalette::Window, c );
1156 current.frameColor.setColor( QPalette::Active , QPalette::Midlight, c );
1157 current.frameColor.setColor( QPalette::Inactive, QPalette::Midlight, c );
1158 current.frameColor.setColor( QPalette::Disabled, QPalette::Midlight, c );
1163 current.normalColor.setColor( QPalette::Active , QPalette::Button, c );
1164 current.normalColor.setColor( QPalette::Inactive, QPalette::Button, c );
1165 current.normalColor.setColor( QPalette::Disabled, QPalette::Button, c );
1174 QColor old =
color_field6->palette().color( QPalette::Window );
1177 QColor c = QColorDialog::getColor( old );
1179 if ( ! c.isValid() || c == old )
return;
1184 p.setColor( QPalette::Window, c );
1192 current.normalColor.setColor( QPalette::Active , QPalette::Midlight, c );
1193 current.normalColor.setColor( QPalette::Inactive, QPalette::Midlight, c );
1194 current.normalColor.setColor( QPalette::Disabled, QPalette::Midlight, c );
1213 cnt->setValue( 35 );
1216 int index =
current.plotMargin / 2 - 1;
1225 lcd->display( newval );
1232 current.plotMargin = ( index + 1 ) * 2;
1259 QString custom =
le_save_as->text().replace( QRegExp(
"[ \t/]" ),
"" );
1261 if ( custom.size() == 0 )
1263 QMessageBox::warning(
this,
1264 tr(
"Save scheme" ),
1265 tr(
"A scheme name must be specified." ) );
1273 QSettings settings(
"UTHSCSA",
"UltraScan" );
1274 QStringList schemeList = settings.value(
"schemeList" ).toStringList();
1277 if ( ! schemeList.contains( custom ) )
1279 schemeList << custom;
1280 settings.setValue(
"schemeList", schemeList );
1283 QString set =
"schemes/" + custom +
"/";
1286 settings.setValue( set +
"plotMargin" ,
current.plotMargin );
1287 settings.setValue( set +
"plotCurve" ,
current.plotCurve );
1288 settings.setValue( set +
"plotBg" ,
current.plotBg );
1289 settings.setValue( set +
"plotMajGrid" ,
current.plotMajorGrid );
1290 settings.setValue( set +
"plotMinGrid" ,
current.plotMinorGrid );
1291 settings.setValue( set +
"plotPicker" ,
current.plotPicker );
1293 settings.setValue( set +
"frameColor" ,
current.frameColor );
1294 settings.setValue( set +
"pushbColor" ,
current.pushbColor );
1295 settings.setValue( set +
"labelColor" ,
current.labelColor );
1296 settings.setValue( set +
"editColor" ,
current.editColor );
1297 settings.setValue( set +
"normalColor" ,
current.normalColor );
1298 settings.setValue( set +
"lcdColor" ,
current.lcdColor );
1299 settings.setValue( set +
"plotColor" ,
current.plotColor );
1309 schemes->addItem( tr(
"Current Scheme" ) );
1310 schemes->addItem( tr(
"UltraScan Default" ) );
1314 QSettings settings(
"UTHSCSA",
"UltraScan" );
1315 QStringList schemeList = settings.value(
"schemeList" ).toStringList();
1317 for (
int i = 0; i < schemeList.size(); i++ )
1319 schemes->addItem( schemeList[ i ] );
1320 if ( schemeList[ i ] == active )
1322 schemes->setCurrentRow( i + 2 );
1330 int result = QMessageBox::warning(
this,
1332 tr(
"Do you really want to delete the\n\"%1\" color scheme?" ).
1333 arg(
schemes->currentItem()->text() ),
1334 QMessageBox::Yes, QMessageBox::No );
1337 if ( result == QMessageBox::Yes )
1339 QString s =
schemes->currentItem()->text();
1341 QSettings settings(
"UTHSCSA",
"UltraScan" );
1342 QStringList schemeList = settings.value(
"schemeList" ).toStringList();
1343 schemeList.removeAll( s );
1344 settings.setValue(
"schemeList", schemeList );
1346 QString custom =
"schemes/" + s +
"/";
1348 settings.remove( custom +
"frameColor" );
1349 settings.remove( custom +
"pushbColor" );
1350 settings.remove( custom +
"labelColor" );
1351 settings.remove( custom +
"editColor" );
1352 settings.remove( custom +
"normalColor" );
1353 settings.remove( custom +
"lcdColor" );
1354 settings.remove( custom +
"plotColor" );
1356 settings.remove( custom +
"plotMargin" );
1358 settings.remove( custom +
"plotCurve" );
1359 settings.remove( custom +
"plotBg" );
1360 settings.remove( custom +
"plotMajGrid" );
1361 settings.remove( custom +
"plotMinGrid" );
1362 settings.remove( custom +
"plotPicker" );
1371 switch (
schemes->currentRow() )
1389 current.plotCurve = Qt::yellow;
1390 current.plotBg = Qt::darkBlue;
1391 current.plotMajorGrid = Qt::white;
1392 current.plotMinorGrid = Qt::lightGray;
1393 current.plotPicker = Qt::white;
1398 QString custom =
"schemes/" +
schemes->currentItem()->text() +
"/";
1400 QSettings settings(
"UTHSCSA",
"UltraScan" );
1401 current.frameColor = settings.value( custom +
"frameColor" ).value<QPalette>();
1402 current.pushbColor = settings.value( custom +
"pushbColor" ).value<QPalette>();
1403 current.labelColor = settings.value( custom +
"labelColor" ).value<QPalette>();
1404 current.editColor = settings.value( custom +
"editColor" ).value<QPalette>();
1405 current.normalColor = settings.value( custom +
"normalColor" ).value<QPalette>();
1406 current.lcdColor = settings.value( custom +
"lcdColor" ).value<QPalette>();
1407 current.plotColor = settings.value( custom +
"plotColor" ).value<QPalette>();
1409 current.plotMargin = settings.value( custom +
"plotMargin" ).toInt();
1411 current.plotCurve = settings.value( custom +
"plotCurve" ).value<QColor>();
1412 current.plotBg = settings.value( custom +
"plotBg" ).value<QColor>();
1413 current.plotMajorGrid = settings.value( custom +
"plotMajGrid" ).value<QColor>();
1414 current.plotMinorGrid = settings.value( custom +
"plotMinGrid" ).value<QColor>();
1415 current.plotPicker = settings.value( custom +
"plotPicker" ).value<QColor>();
1427 QApplication::setStyle( QStyleFactory::create( styleName ) );