UltraScan III
us_gui_settings.cpp
Go to the documentation of this file.
1 #include "us_gui_settings.h"
2 #include "us_defines.h"
3 
4 // Fonts
6 {
7  QSettings settings( US3, "UltraScan" );
8  return settings.value( "fontFamily", "Helvetica" ).toString();
9 }
10 
11 void US_GuiSettings::set_fontFamily( const QString& fontFamily )
12 {
13  QSettings settings( US3, "UltraScan" );
14  if ( fontFamily == "Helvetica" )
15  settings.remove( "fontFamily" );
16  else
17  settings.setValue( "fontFamily", fontFamily );
18 }
19 
21 {
22  QSettings settings( US3, "UltraScan" );
23  return settings.value( "fontSize", 10 ).toInt();
24 }
25 
26 void US_GuiSettings::set_fontSize( int fontSize )
27 {
28  QSettings settings( US3, "UltraScan" );
29  if ( fontSize == 10 )
30  settings.remove( "fontSize" );
31  else
32  settings.setValue( "fontSize", fontSize );
33 }
34 
35 QString US_GuiSettings::guiStyle( void )
36 {
37  QSettings settings( US3, "UltraScan" );
38  QString defaultStyle;
39  QString os = OS;
40 
41  if ( os == "osx" ) defaultStyle = "Macintosh";
42  else if ( os == "win32" ) defaultStyle = "Windows";
43  else defaultStyle = "Plastique";
44 
45  return settings.value( "guiStyle", defaultStyle ).toString();
46 }
47 
48 void US_GuiSettings::set_guiStyle( const QString& style )
49 {
50  QSettings settings( US3, "UltraScan" );
51  QString defaultStyle;
52  QString os = OS;
53 
54  if ( os == "osx" ) defaultStyle = "Macintosh";
55  else if ( os == "win32" ) defaultStyle = "Windows";
56  else defaultStyle = "Plastique";
57 
58  if ( style == defaultStyle )
59  settings.remove( "guiStyle" );
60  else
61  settings.setValue( "guiStyle", style );
62 }
63 
64 // Misc
66 {
67  QSettings settings( US3, "UltraScan" );
68  return settings.value( "plotMargin", 10 ).toInt();
69 }
70 
71 void US_GuiSettings::set_plotMargin( int fontSize )
72 {
73  QSettings settings( US3, "UltraScan" );
74  if ( fontSize == 10 )
75  settings.remove( "plotMargin" );
76  else
77  settings.setValue( "plotMargin", fontSize );
78 }
79 
80 // Palettes
81 
82 // Label
84 {
85  QSettings settings( US3, "UltraScan" );
86  if ( settings.contains( "palettes/labelColor" ) )
87  return settings.value( "palettes/labelColor" ).value<QPalette>();
88  return labelColorDefault();
89 }
90 
92 {
93  QPalette p;
94  p.setColor( QPalette::Active, QPalette::WindowText, Qt::white ); // windowText/foreground
95  p.setColor( QPalette::Active, QPalette::Window, Qt::black ); // background
96  p.setColor( QPalette::Active, QPalette::Light, Qt::black ); // border
97  p.setColor( QPalette::Active, QPalette::Dark, Qt::black ); // border
98  p.setColor( QPalette::Active, QPalette::Text, Qt::white ); // text w/ Base
99  p.setColor( QPalette::Active, QPalette::Base, Qt::black ); // bg for text entry
100 
101  p.setColor( QPalette::Disabled, QPalette::WindowText, Qt::white ); // windowText/foreground
102  p.setColor( QPalette::Disabled, QPalette::Window, Qt::black ); // background
103  p.setColor( QPalette::Disabled, QPalette::Light, Qt::black ); // border
104  p.setColor( QPalette::Disabled, QPalette::Dark, Qt::black ); // border
105  p.setColor( QPalette::Disabled, QPalette::Text, Qt::white ); // text w/ Base
106  p.setColor( QPalette::Disabled, QPalette::Base, Qt::black ); // bg for text entry
107 
108  p.setColor( QPalette::Inactive, QPalette::WindowText, Qt::white ); // windowText/foreground
109  p.setColor( QPalette::Inactive, QPalette::Window, Qt::black ); // background
110  p.setColor( QPalette::Inactive, QPalette::Light, Qt::black ); // border
111  p.setColor( QPalette::Inactive, QPalette::Dark, Qt::black ); // border
112  p.setColor( QPalette::Inactive, QPalette::Text, Qt::white ); // text w/ Base
113  p.setColor( QPalette::Inactive, QPalette::Base, Qt::black ); // bg for text entry
114 
115  return p;
116 }
117 
118 void US_GuiSettings::set_labelColor( const QPalette& palette )
119 {
120  QSettings settings( US3, "UltraScan" );
121  settings.setValue( "palettes/labelColor", palette );
122 }
123 
124 // Edit
126 {
127  QSettings settings( US3, "UltraScan" );
128  if ( settings.contains( "palettes/editColor" ) )
129  return settings.value( "palettes/editColor" ).value<QPalette>();
130  return editColorDefault();
131 }
132 
134 {
135  QPalette p;
136  p.setColor( QPalette::Active, QPalette::WindowText, Qt::black ); // windowText/foreground
137  p.setColor( QPalette::Active, QPalette::Window, Qt::white ); // background
138  p.setColor( QPalette::Active, QPalette::Light, Qt::white ); // border
139  p.setColor( QPalette::Active, QPalette::Dark, Qt::darkGray ); // border
140  p.setColor( QPalette::Active, QPalette::Mid, Qt::black ); // Between light and dark
141  p.setColor( QPalette::Active, QPalette::Text, Qt::black ); // text w/ Base
142  p.setColor( QPalette::Active, QPalette::Base, Qt::white ); // bg for text entry
143  p.setColor( QPalette::Active, QPalette::HighlightedText, Qt::white ); // bg for selected text
144  p.setColor( QPalette::Active, QPalette::Highlight, Qt::darkBlue ); // selected text
145  p.setColor( QPalette::Active, QPalette::Button, Qt::lightGray ); // bg for button
146  p.setColor( QPalette::Active, QPalette::Midlight, Qt::lightGray ); // bg for text entry
147  p.setColor( QPalette::Active, QPalette::BrightText, Qt::red ); // contrast to WindowText
148  p.setColor( QPalette::Active, QPalette::ButtonText, Qt::black ); // fg for button
149  p.setColor( QPalette::Active, QPalette::Shadow, Qt::black ); // very dark
150 
151  p.setColor( QPalette::Disabled, QPalette::WindowText, Qt::black ); // windowText/foreground
152  p.setColor( QPalette::Disabled, QPalette::Window, Qt::lightGray ); // background
153  p.setColor( QPalette::Disabled, QPalette::Light, Qt::white ); // border
154  p.setColor( QPalette::Disabled, QPalette::Dark, Qt::darkGray ); // border
155  p.setColor( QPalette::Disabled, QPalette::Mid, Qt::black ); // Between light and dark
156  p.setColor( QPalette::Disabled, QPalette::Text, Qt::black ); // text w/ Base
157  p.setColor( QPalette::Disabled, QPalette::Base, Qt::lightGray ); // bg for text entry
158  p.setColor( QPalette::Disabled, QPalette::HighlightedText, Qt::white ); // bg for selected text
159  p.setColor( QPalette::Disabled, QPalette::Highlight, Qt::darkBlue ); // selected text
160  p.setColor( QPalette::Disabled, QPalette::Button, Qt::darkGray ); // bg for button
161  p.setColor( QPalette::Disabled, QPalette::Midlight, Qt::darkGray ); // bg for text entry
162  p.setColor( QPalette::Disabled, QPalette::BrightText, Qt::red ); // contrast to WindowText
163  p.setColor( QPalette::Disabled, QPalette::ButtonText, Qt::black ); // fg for button
164  p.setColor( QPalette::Disabled, QPalette::Shadow, Qt::black ); // very dark
165 
166  p.setColor( QPalette::Inactive, QPalette::WindowText, Qt::black ); // windowText/foreground
167  p.setColor( QPalette::Inactive, QPalette::Window, Qt::white ); // background
168  p.setColor( QPalette::Inactive, QPalette::Light, Qt::white ); // border
169  p.setColor( QPalette::Inactive, QPalette::Dark, Qt::darkBlue ); // border
170  p.setColor( QPalette::Inactive, QPalette::Mid, Qt::black ); // Between light and dark
171  p.setColor( QPalette::Inactive, QPalette::Text, Qt::black ); // text w/ Base
172  p.setColor( QPalette::Inactive, QPalette::Base, Qt::white ); // bg for text entry
173  p.setColor( QPalette::Inactive, QPalette::HighlightedText, Qt::white ); // bg for selected text
174  p.setColor( QPalette::Inactive, QPalette::Highlight, Qt::darkBlue ); // selected text
175  p.setColor( QPalette::Inactive, QPalette::Button, Qt::lightGray ); // bg for button
176  p.setColor( QPalette::Inactive, QPalette::Midlight, Qt::lightGray ); // bg for text entry
177  p.setColor( QPalette::Inactive, QPalette::BrightText, Qt::red ); // contrast to WindowText
178  p.setColor( QPalette::Inactive, QPalette::ButtonText, Qt::black ); // fg for button
179  p.setColor( QPalette::Inactive, QPalette::Shadow, Qt::black ); // very dark
180 
181  return p;
182 }
183 
184 void US_GuiSettings::set_editColor( const QPalette& palette )
185 {
186  QSettings settings( US3, "UltraScan" );
187  settings.setValue( "palettes/editColor", palette );
188 }
189 
190 // Frame
191 
193 {
194  QSettings settings( US3, "UltraScan" );
195  if ( settings.contains( "palettes/frameColor" ) )
196  return settings.value( "palettes/frameColor" ).value<QPalette>();
197  return frameColorDefault();
198 }
199 
201 {
202  QPalette p;
203  p.setColor( QPalette::Active, QPalette::WindowText, Qt::white ); // windowText/foreground
204  p.setColor( QPalette::Active, QPalette::Window, Qt::darkCyan ); // background
205  p.setColor( QPalette::Active, QPalette::Light, Qt::lightGray ); // border
206  p.setColor( QPalette::Active, QPalette::Dark, Qt::darkGray ); // border
207  p.setColor( QPalette::Active, QPalette::Mid, Qt::cyan ); // Between light and dark
208  p.setColor( QPalette::Active, QPalette::Midlight, Qt::white ); //
209  p.setColor( QPalette::Active, QPalette::Base, Qt::darkGray ); // bg for text entry
210 
211  p.setColor( QPalette::Disabled, QPalette::WindowText, Qt::white ); // windowText/foreground
212  p.setColor( QPalette::Disabled, QPalette::Window, Qt::darkCyan ); // background
213  p.setColor( QPalette::Disabled, QPalette::Light, Qt::lightGray); // border
214  p.setColor( QPalette::Disabled, QPalette::Dark, Qt::darkGray ); // border
215  p.setColor( QPalette::Disabled, QPalette::Mid, Qt::cyan ); // Between light and dark
216  p.setColor( QPalette::Disabled, QPalette::Midlight, Qt::white ); //
217  p.setColor( QPalette::Disabled, QPalette::Base, Qt::darkGray ); // bg for text entry
218 
219  p.setColor( QPalette::Inactive, QPalette::WindowText, Qt::white ); // windowText/foreground
220  p.setColor( QPalette::Inactive, QPalette::Window, Qt::darkCyan ); // background
221  p.setColor( QPalette::Inactive, QPalette::Light, Qt::lightGray); // border
222  p.setColor( QPalette::Inactive, QPalette::Dark, Qt::darkGray ); // border
223  p.setColor( QPalette::Inactive, QPalette::Mid, Qt::cyan ); // Between light and dark
224  p.setColor( QPalette::Inactive, QPalette::Midlight, Qt::white ); //
225  p.setColor( QPalette::Inactive, QPalette::Base, Qt::darkGray ); // bg for text entry
226 
227  return p;
228 }
229 
230 void US_GuiSettings::set_frameColor( const QPalette& palette )
231 {
232  QSettings settings( US3, "UltraScan" );
233  settings.setValue( "palettes/frameColor", palette );
234 }
235 
236 // Pushbutton
237 
239 {
240  QSettings settings( US3, "UltraScan" );
241  if ( settings.contains( "palettes/pushbColor" ) )
242  return settings.value( "palettes/pushbColor" ).value<QPalette>();
243  return pushbColorDefault();
244 }
245 
246 #define bluegreen QColor( 0x00, 0xe0, 0xe0 )
247 
249 {
250  QPalette p;
251  p.setColor( QPalette::Active, QPalette::ButtonText, Qt::black ); // windowText/foreground
252  p.setColor( QPalette::Active, QPalette::Button, bluegreen ); // background
253  p.setColor( QPalette::Active, QPalette::Light, Qt::white ); // border
254  p.setColor( QPalette::Active, QPalette::Dark, Qt::darkGray ); // border
255  p.setColor( QPalette::Active, QPalette::Shadow, Qt::black ); // Between light and dark
256 
257  p.setColor( QPalette::Disabled, QPalette::ButtonText, Qt::white ); // windowText/foreground
258  p.setColor( QPalette::Disabled, QPalette::Button, bluegreen ); // background
259  p.setColor( QPalette::Disabled, QPalette::Light, Qt::white ); // border
260  p.setColor( QPalette::Disabled, QPalette::Dark, Qt::darkGray ); // border
261  p.setColor( QPalette::Disabled, QPalette::Shadow, Qt::black ); // Between light and dark
262 
263  p.setColor( QPalette::Inactive, QPalette::ButtonText, Qt::black ); // windowText/foreground
264  p.setColor( QPalette::Inactive, QPalette::Button, bluegreen ); // background
265  p.setColor( QPalette::Inactive, QPalette::Light, Qt::white ); // border
266  p.setColor( QPalette::Inactive, QPalette::Dark, Qt::darkGray ); // border
267  p.setColor( QPalette::Inactive, QPalette::Shadow, Qt::black ); // Between light and dark
268 
269  return p;
270 }
271 
272 void US_GuiSettings::set_pushbColor( const QPalette& palette )
273 {
274  QSettings settings( US3, "UltraScan" );
275  settings.setValue( "palettes/pushbColor", palette );
276 }
277 
278 // Normal
279 
281 {
282  QSettings settings( US3, "UltraScan" );
283  if ( settings.contains( "palettes/normalColor" ) )
284  return settings.value( "palettes/normalColor" ).value<QPalette>();
285  return normalColorDefault();
286 }
287 
289 {
290  QPalette p;
291  p.setColor( QPalette::Active, QPalette::WindowText, Qt::black ); // windowText/foreground
292  p.setColor( QPalette::Active, QPalette::Window, Qt::lightGray ); // background
293  p.setColor( QPalette::Active, QPalette::Light, Qt::white ); // border
294  p.setColor( QPalette::Active, QPalette::Dark, Qt::darkGray ); // border
295  p.setColor( QPalette::Active, QPalette::Mid, Qt::lightGray );
296  p.setColor( QPalette::Active, QPalette::Text, Qt::black );
297  p.setColor( QPalette::Active, QPalette::Base, Qt::white );
298  p.setColor( QPalette::Active, QPalette::HighlightedText, Qt::white );
299  p.setColor( QPalette::Active, QPalette::Highlight, Qt::darkBlue );
300  p.setColor( QPalette::Active, QPalette::Button, Qt::lightGray );
301  p.setColor( QPalette::Active, QPalette::Midlight, Qt::lightGray );
302  p.setColor( QPalette::Active, QPalette::BrightText, Qt::red );
303  p.setColor( QPalette::Active, QPalette::ButtonText, Qt::black );
304  p.setColor( QPalette::Active, QPalette::Shadow, Qt::black ); // Between light and dark
305 
306  p.setColor( QPalette::Disabled, QPalette::WindowText, Qt::black ); // windowText/foreground
307  p.setColor( QPalette::Disabled, QPalette::Window, Qt::lightGray ); // background
308  p.setColor( QPalette::Disabled, QPalette::Light, Qt::white ); // border
309  p.setColor( QPalette::Disabled, QPalette::Dark, Qt::darkGray ); // border
310  p.setColor( QPalette::Disabled, QPalette::Mid, Qt::lightGray );
311  p.setColor( QPalette::Disabled, QPalette::Text, Qt::black );
312  p.setColor( QPalette::Disabled, QPalette::Base, Qt::lightGray );
313  p.setColor( QPalette::Disabled, QPalette::HighlightedText, Qt::white );
314  p.setColor( QPalette::Disabled, QPalette::Highlight, Qt::darkBlue );
315  p.setColor( QPalette::Disabled, QPalette::Button, Qt::lightGray );
316  p.setColor( QPalette::Disabled, QPalette::Midlight, Qt::lightGray );
317  p.setColor( QPalette::Disabled, QPalette::BrightText, Qt::red );
318  p.setColor( QPalette::Disabled, QPalette::ButtonText, Qt::black );
319  p.setColor( QPalette::Disabled, QPalette::Shadow, Qt::black ); // Between light and dark
320 
321  p.setColor( QPalette::Inactive, QPalette::WindowText, Qt::black ); // windowText/foreground
322  p.setColor( QPalette::Inactive, QPalette::Window, Qt::lightGray ); // background
323  p.setColor( QPalette::Inactive, QPalette::Light, Qt::white ); // border
324  p.setColor( QPalette::Inactive, QPalette::Dark, Qt::darkGray ); // border
325  p.setColor( QPalette::Inactive, QPalette::Mid, Qt::lightGray );
326  p.setColor( QPalette::Inactive, QPalette::Text, Qt::black );
327  p.setColor( QPalette::Inactive, QPalette::Base, Qt::white );
328  p.setColor( QPalette::Inactive, QPalette::HighlightedText, Qt::white );
329  p.setColor( QPalette::Inactive, QPalette::Highlight, Qt::darkBlue );
330  p.setColor( QPalette::Inactive, QPalette::Button, Qt::lightGray );
331  p.setColor( QPalette::Inactive, QPalette::Midlight, Qt::lightGray );
332  p.setColor( QPalette::Inactive, QPalette::BrightText, Qt::red );
333  p.setColor( QPalette::Inactive, QPalette::ButtonText, Qt::black );
334  p.setColor( QPalette::Inactive, QPalette::Shadow, Qt::black ); // Between light and dark
335 
336  return p;
337 }
338 
339 void US_GuiSettings::set_normalColor( const QPalette& palette )
340 {
341  QSettings settings( US3, "UltraScan" );
342  settings.setValue( "palettes/normalColor", palette );
343 }
344 
345 // LCD
346 QPalette US_GuiSettings::lcdColor( void )
347 {
348  QSettings settings( US3, "UltraScan" );
349  if ( settings.contains( "palettes/lcdColor" ) )
350  return settings.value( "palettes/lcdColor" ).value<QPalette>();
351  return lcdColorDefault();
352 }
353 
355 {
356  QPalette p;
357  p.setColor( QPalette::Active, QPalette::WindowText, Qt::green ); // foreground
358  p.setColor( QPalette::Active, QPalette::Window, Qt::black ); // background
359  p.setColor( QPalette::Active, QPalette::Light, Qt::green ); // highlight1
360  p.setColor( QPalette::Active, QPalette::Shadow, Qt::darkCyan ); // highlight2
361 
362  p.setColor( QPalette::Inactive, QPalette::WindowText, Qt::green ); // foreground
363  p.setColor( QPalette::Inactive, QPalette::Window, Qt::black ); // background
364  p.setColor( QPalette::Inactive, QPalette::Light, Qt::green ); // highlight1
365  p.setColor( QPalette::Inactive, QPalette::Shadow, Qt::darkCyan ); // highlight2
366 
367  return p;
368 }
369 
370 void US_GuiSettings::set_lcdColor( const QPalette& palette )
371 {
372  QSettings settings( US3, "UltraScan" );
373  settings.setValue( "palettes/lcdColor", palette );
374 }
375 
376 // Plot frame
378 {
379  QSettings settings( US3, "UltraScan" );
380  if ( settings.contains( "palettes/plotColor" ) )
381  return settings.value( "palettes/plotColor" ).value<QPalette>();
382  return plotColorDefault();
383 }
384 
386 {
387  QPalette p;
388  p.setColor( QPalette::Active, QPalette::WindowText, Qt::black ); // foreground
389  p.setColor( QPalette::Active, QPalette::Window, Qt::lightGray ); // background
390  p.setColor( QPalette::Active, QPalette::Shadow, Qt::black ); // highlights
391 
392  p.setColor( QPalette::Inactive, QPalette::WindowText, Qt::black ); // foreground
393  p.setColor( QPalette::Inactive, QPalette::Window, Qt::lightGray ); // background
394  p.setColor( QPalette::Inactive, QPalette::Shadow, Qt::black ); // highlights
395 
396  return p;
397 }
398 
399 void US_GuiSettings::set_plotColor( const QPalette& palette )
400 {
401  QSettings settings( US3, "UltraScan" );
402  settings.setValue( "palettes/plotColor", palette );
403 }
404 
405 
406 // Plot curve color
408 {
409  QSettings settings( US3, "UltraScan" );
410  return settings.value( "palettes/plotCurve", Qt::yellow ).value<QColor>();
411 }
412 
413 void US_GuiSettings::set_plotCurve( const QColor& color )
414 {
415  QSettings settings( US3, "UltraScan" );
416  if ( color == Qt::yellow )
417  settings.remove( "palettes/plotCurve" );
418  else
419  settings.setValue( "palettes/plotCurve", color );
420 }
421 
422 // Canvas background
424 {
425  QSettings settings( US3, "UltraScan" );
426  return settings.value( "palettes/normalColor", Qt::darkBlue ).value<QColor>();
427 }
428 
429 void US_GuiSettings::set_plotCanvasBG( const QColor& color )
430 {
431  QSettings settings( US3, "UltraScan" );
432  if ( color == Qt::darkBlue )
433  settings.remove( "palettes/plotCanvasBG" );
434  else
435  settings.setValue( "palettes/plotCanvasBG", color );
436 }
437 
438 // Canvas major gridlines
440 {
441  QSettings settings( US3, "UltraScan" );
442  return settings.value( "palettes/plotMajGrid", Qt::white ).value<QColor>();
443 }
444 
445 void US_GuiSettings::set_plotMajGrid( const QColor& color )
446 {
447  QSettings settings( US3, "UltraScan" );
448  if ( color == Qt::white )
449  settings.remove( "palettes/plotMajGrid" );
450  else
451  settings.setValue( "palettes/plotMajGrid", color );
452 }
453 
454 // Canvas minor gridlines
456 {
457  QSettings settings( US3, "UltraScan" );
458  return settings.value( "palettes/plotMinGrid", Qt::lightGray ).value<QColor>();
459 }
460 
461 void US_GuiSettings::set_plotMinGrid( const QColor& color )
462 {
463  QSettings settings( US3, "UltraScan" );
464  if ( color == Qt::lightGray )
465  settings.remove( "palettes/plotMinGrid" );
466  else
467  settings.setValue( "palettes/plotMinGrid", color );
468 }
469 
470 // Plot Picker rubber band pen and Tracker pen color
472 {
473  QSettings settings( US3, "UltraScan" );
474  return settings.value( "palettes/plotPicker", Qt::white ).value<QColor>();
475 }
476 
477 void US_GuiSettings::set_plotPicker( const QColor& color )
478 {
479  QSettings settings( US3, "UltraScan" );
480  if ( color == Qt::white )
481  settings.remove( "palettes/plotPicker" );
482  else
483  settings.setValue( "palettes/plotPicker", color );
484 }
485