WarningMessagesDialog.cxx 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "WarningMessagesDialog.h"
  4. WarningMessagesDialog::WarningMessagesDialog(QWidget* prnt, QCMake* instance)
  5. : QDialog(prnt)
  6. , cmakeInstance(instance)
  7. {
  8. this->setupUi(this);
  9. this->setInitialValues();
  10. this->setupSignals();
  11. }
  12. void WarningMessagesDialog::setInitialValues()
  13. {
  14. this->suppressDeveloperWarnings->setChecked(
  15. this->cmakeInstance->getSuppressDevWarnings());
  16. this->suppressDeprecatedWarnings->setChecked(
  17. this->cmakeInstance->getSuppressDeprecatedWarnings());
  18. this->developerWarningsAsErrors->setChecked(
  19. this->cmakeInstance->getDevWarningsAsErrors());
  20. this->deprecatedWarningsAsErrors->setChecked(
  21. this->cmakeInstance->getDeprecatedWarningsAsErrors());
  22. }
  23. void WarningMessagesDialog::setupSignals()
  24. {
  25. #if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0))
  26. static auto const checkStateChanged = &QCheckBox::checkStateChanged;
  27. #else
  28. static auto const checkStateChanged = &QCheckBox::stateChanged;
  29. #endif
  30. QObject::connect(this->buttonBox, &QDialogButtonBox::accepted, this,
  31. &WarningMessagesDialog::doAccept);
  32. QObject::connect(this->suppressDeveloperWarnings, checkStateChanged, this,
  33. &WarningMessagesDialog::doSuppressDeveloperWarningsChanged);
  34. QObject::connect(
  35. this->suppressDeprecatedWarnings, checkStateChanged, this,
  36. &WarningMessagesDialog::doSuppressDeprecatedWarningsChanged);
  37. QObject::connect(this->developerWarningsAsErrors, checkStateChanged, this,
  38. &WarningMessagesDialog::doDeveloperWarningsAsErrorsChanged);
  39. QObject::connect(
  40. this->deprecatedWarningsAsErrors, checkStateChanged, this,
  41. &WarningMessagesDialog::doDeprecatedWarningsAsErrorsChanged);
  42. }
  43. void WarningMessagesDialog::doAccept()
  44. {
  45. this->cmakeInstance->setSuppressDevWarnings(
  46. this->suppressDeveloperWarnings->isChecked());
  47. this->cmakeInstance->setSuppressDeprecatedWarnings(
  48. this->suppressDeprecatedWarnings->isChecked());
  49. this->cmakeInstance->setDevWarningsAsErrors(
  50. this->developerWarningsAsErrors->isChecked());
  51. this->cmakeInstance->setDeprecatedWarningsAsErrors(
  52. this->deprecatedWarningsAsErrors->isChecked());
  53. }
  54. void WarningMessagesDialog::doSuppressDeveloperWarningsChanged(int state)
  55. {
  56. // no warnings implies no errors either
  57. if (state) {
  58. this->developerWarningsAsErrors->setChecked(false);
  59. }
  60. }
  61. void WarningMessagesDialog::doSuppressDeprecatedWarningsChanged(int state)
  62. {
  63. // no warnings implies no errors either
  64. if (state) {
  65. this->deprecatedWarningsAsErrors->setChecked(false);
  66. }
  67. }
  68. void WarningMessagesDialog::doDeveloperWarningsAsErrorsChanged(int state)
  69. {
  70. // warnings as errors implies warnings are not suppressed
  71. if (state) {
  72. this->suppressDeveloperWarnings->setChecked(false);
  73. }
  74. }
  75. void WarningMessagesDialog::doDeprecatedWarningsAsErrorsChanged(int state)
  76. {
  77. // warnings as errors implies warnings are not suppressed
  78. if (state) {
  79. this->suppressDeprecatedWarnings->setChecked(false);
  80. }
  81. }