WarningMessagesDialog.cxx 2.8 KB

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