Typica is a free program for professional coffee roasters. https://typica.us
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

advancedsettings.w 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. @* Advanced settings configuration.
  2. \noindent Sometimes a feature has a sensible default that should be used the
  3. vast majority of the time but sometimes requires some other setting to be
  4. available in a reasonably accessible way.
  5. @<Class declarations@>=
  6. class AdvancedSettingsWidget : public QWidget@/
  7. {@/
  8. @[Q_OBJECT@]@;
  9. public:@/
  10. AdvancedSettingsWidget();
  11. @[public slots:@]@/
  12. void enableDiagnosticLogging(bool enabled);
  13. };
  14. @ At present the advanced settings consist only of an option to redirect
  15. diagnostic output to a file. This should normally be disabled as it supresses
  16. console output and there is no mechanism within \pn{} for periodically removing
  17. the files generated. It is, however, useful for producing a diagnostic file
  18. that can be attached to an email if someone is encountering an issue that they
  19. are not able to resolve on their own. It is especially useful on Microsoft
  20. Windows where this output is not otherwise available unless Typica is run from
  21. software development tools most people do not have installed.
  22. @<AdvancedSettingsWidget implementation@>=
  23. AdvancedSettingsWidget::AdvancedSettingsWidget() : QWidget(NULL)
  24. {
  25. QSettings settings;
  26. QFormLayout *layout = new QFormLayout;
  27. QCheckBox *logDiagnostics = new QCheckBox;
  28. logDiagnostics->setCheckState(
  29. settings.value("settings/advanced/logging", false).toBool() ?
  30. Qt::Checked : Qt::Unchecked);
  31. connect(logDiagnostics, SIGNAL(toggled(bool)), this, SLOT(enableDiagnosticLogging(bool)));
  32. layout->addRow(tr("Enable diagnostic logging"), logDiagnostics);
  33. setLayout(layout);
  34. }
  35. @ Changes to this setting should take effect immediately. It should also be
  36. written to |QSettings| so the feature can be correctly enabled or not.
  37. @<AdvancedSettingsWidget implementation@>=
  38. void AdvancedSettingsWidget::enableDiagnosticLogging(bool enabled)
  39. {
  40. QSettings settings;
  41. settings.setValue("settings/advanced/logging", enabled);
  42. if(enabled)
  43. {
  44. qInstallMsgHandler(messageFileOutput);
  45. }
  46. else
  47. {
  48. qInstallMsgHandler(0);
  49. }
  50. }
  51. @ Currently the implementation is brought into typica.cpp.
  52. @<Class implementations@>=
  53. @<AdvancedSettingsWidget implementation@>