2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +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

@@ -21,12 +21,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/buttons.h"
#include "ui/widgets/scroll_area.h"
#include "ui/widgets/input_fields.h"
#include "ui/widgets/menu/menu_action.h"
#include "ui/widgets/popup_menu.h"
#include "ui/wrap/slide_wrap.h"
#include "ui/text/text_options.h"
#include "ui/text/text_utilities.h"
#include "chat_helpers/message_field.h"
#include "menu/menu_check_item.h"
#include "menu/menu_send.h"
#include "history/history.h"
#include "history/history_message.h"
@@ -49,47 +49,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_boxes.h"
#include "styles/style_chat.h"
#include "styles/style_menu_icons.h"
#include "styles/style_media_player.h"
#include <QtGui/QGuiApplication>
#include <QtGui/QClipboard>
namespace {
class ForwardOptionItem final : public Ui::Menu::Action {
public:
using Ui::Menu::Action::Action;
void 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*> checkView() const {
return _checkView.get();
}
private:
std::unique_ptr<Ui::CheckView> _checkView;
};
} // namespace
class ShareBox::Inner final : public Ui::RpWidget {
public:
Inner(QWidget *parent, const Descriptor &descriptor);
@@ -503,7 +466,7 @@ void ShareBox::showMenu(not_null<Ui::RpWidget*> parent) {
if (_descriptor.forwardOptions.show) {
auto createView = [&](rpl::producer<QString> &&text, bool checked) {
auto item = base::make_unique_q<ForwardOptionItem>(
auto item = base::make_unique_q<Menu::ItemWithCheck>(
_menu->menu(),
st::popupMenuWithIcons.menu,
new QAction(QString(), _menu->menu()),