menu_check_item.cpp 1010 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "menu/menu_check_item.h"
  8. #include "ui/widgets/checkbox.h"
  9. #include "styles/style_media_player.h"
  10. namespace Menu {
  11. void ItemWithCheck::init(bool checked) {
  12. enableMouseSelecting();
  13. AbstractButton::setDisabled(true);
  14. _checkView = std::make_unique<Ui::CheckView>(st::defaultCheck, false);
  15. _checkView->checkedChanges(
  16. ) | rpl::start_with_next([=](bool checked) {
  17. setIcon(checked ? &st::mediaPlayerMenuCheck : nullptr);
  18. }, lifetime());
  19. _checkView->setChecked(checked, anim::type::normal);
  20. AbstractButton::clicks(
  21. ) | rpl::start_with_next([=] {
  22. _checkView->setChecked(
  23. !_checkView->checked(),
  24. anim::type::normal);
  25. }, lifetime());
  26. }
  27. not_null<Ui::CheckView*> ItemWithCheck::checkView() const {
  28. return _checkView.get();
  29. }
  30. } // namespace Menu