WarningMessagesDialog.cxx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. QObject::connect(this->buttonBox, &QDialogButtonBox::accepted, this,
  26. &WarningMessagesDialog::doAccept);
  27. QObject::connect(this->suppressDeveloperWarnings, &QCheckBox::stateChanged,
  28. this,
  29. &WarningMessagesDialog::doSuppressDeveloperWarningsChanged);
  30. QObject::connect(
  31. this->suppressDeprecatedWarnings, &QCheckBox::stateChanged, this,
  32. &WarningMessagesDialog::doSuppressDeprecatedWarningsChanged);
  33. QObject::connect(this->developerWarningsAsErrors, &QCheckBox::stateChanged,
  34. this,
  35. &WarningMessagesDialog::doDeveloperWarningsAsErrorsChanged);
  36. QObject::connect(
  37. this->deprecatedWarningsAsErrors, &QCheckBox::stateChanged, this,
  38. &WarningMessagesDialog::doDeprecatedWarningsAsErrorsChanged);
  39. }
  40. void WarningMessagesDialog::doAccept()
  41. {
  42. this->cmakeInstance->setSuppressDevWarnings(
  43. this->suppressDeveloperWarnings->isChecked());
  44. this->cmakeInstance->setSuppressDeprecatedWarnings(
  45. this->suppressDeprecatedWarnings->isChecked());
  46. this->cmakeInstance->setDevWarningsAsErrors(
  47. this->developerWarningsAsErrors->isChecked());
  48. this->cmakeInstance->setDeprecatedWarningsAsErrors(
  49. this->deprecatedWarningsAsErrors->isChecked());
  50. }
  51. void WarningMessagesDialog::doSuppressDeveloperWarningsChanged(int state)
  52. {
  53. // no warnings implies no errors either
  54. if (state) {
  55. this->developerWarningsAsErrors->setChecked(false);
  56. }
  57. }
  58. void WarningMessagesDialog::doSuppressDeprecatedWarningsChanged(int state)
  59. {
  60. // no warnings implies no errors either
  61. if (state) {
  62. this->deprecatedWarningsAsErrors->setChecked(false);
  63. }
  64. }
  65. void WarningMessagesDialog::doDeveloperWarningsAsErrorsChanged(int state)
  66. {
  67. // warnings as errors implies warnings are not suppressed
  68. if (state) {
  69. this->suppressDeveloperWarnings->setChecked(false);
  70. }
  71. }
  72. void WarningMessagesDialog::doDeprecatedWarningsAsErrorsChanged(int state)
  73. {
  74. // warnings as errors implies warnings are not suppressed
  75. if (state) {
  76. this->suppressDeprecatedWarnings->setChecked(false);
  77. }
  78. }