mute-checkbox.hpp 511 B

12345678910111213141516171819202122232425
  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. setProperty("class", "indicator-mute");
  10. }
  11. protected:
  12. /* While we need it to be tristate internally, we don't want a user being
  13. * able to manually get into the partial state. */
  14. void nextCheckState() override
  15. {
  16. if (checkState() != Qt::Checked)
  17. setCheckState(Qt::Checked);
  18. else
  19. setCheckState(Qt::Unchecked);
  20. }
  21. };