2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 22:55:11 +00:00

Moved menu item with check to td_ui.

This commit is contained in:
23rd
2022-03-27 15:46:27 +03:00
parent 2846aa2f77
commit 51cb234b37
5 changed files with 75 additions and 40 deletions

View File

@@ -0,0 +1,39 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "menu/menu_check_item.h"
#include "ui/widgets/checkbox.h"
#include "styles/style_media_player.h"
namespace Menu {
void ItemWithCheck::init(bool checked) {
enableMouseSelecting();
AbstractButton::setDisabled(true);
_checkView = std::make_unique<Ui::CheckView>(st::defaultCheck, false);
_checkView->checkedChanges(
) | rpl::start_with_next([=](bool checked) {
setIcon(checked ? &st::mediaPlayerMenuCheck : nullptr);
}, lifetime());
_checkView->setChecked(checked, anim::type::normal);
AbstractButton::clicks(
) | rpl::start_with_next([=] {
_checkView->setChecked(
!_checkView->checked(),
anim::type::normal);
}, lifetime());
}
not_null<Ui::CheckView*> ItemWithCheck::checkView() const {
return _checkView.get();
}
} // namespace Menu

View File

@@ -0,0 +1,30 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "ui/widgets/menu/menu_action.h"
namespace Ui {
class CheckView;
} // namespace Ui
namespace Menu {
class ItemWithCheck final : public Ui::Menu::Action {
public:
using Ui::Menu::Action::Action;
void init(bool checked);
not_null<Ui::CheckView*> checkView() const;
private:
std::unique_ptr<Ui::CheckView> _checkView;
};
} // namespace Menu