mute-checkbox.hpp 469 B

123456789101112131415161718192021222324
  1. #pragma once
  2. #include <QCheckBox>
  3. class MuteCheckBox : public QCheckBox {
  4. Q_OBJECT
  5. public:
  6. MuteCheckBox(QWidget *parent = nullptr) : QCheckBox(parent)
  7. {
  8. setTristate(true);
  9. }
  10. protected:
  11. /* While we need it to be tristate internally, we don't want a user being
  12. * able to manually get into the partial state. */
  13. void nextCheckState() override
  14. {
  15. if (checkState() != Qt::Checked)
  16. setCheckState(Qt::Checked);
  17. else
  18. setCheckState(Qt::Unchecked);
  19. }
  20. };