diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_usernames_list.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_usernames_list.cpp index fe7db2e7a..96bd64211 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_usernames_list.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_usernames_list.cpp @@ -28,6 +28,35 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include +namespace { + +class RightAction final : public Ui::RpWidget { +public: + RightAction(not_null parent); + +protected: + void paintEvent(QPaintEvent *e) override; + void mousePressEvent(QMouseEvent *e) override; + +}; + +RightAction::RightAction(not_null parent) +: RpWidget(parent) { + setCursor(style::cur_sizeall); + const auto &st = st::inviteLinkThreeDots; + resize(st.width, st.height); +} + +void RightAction::paintEvent(QPaintEvent *e) { + auto p = Painter(this); + st::usernamesReorderIcon.paintInCenter(p, rect()); +} + +void RightAction::mousePressEvent(QMouseEvent *e) { +} + +} // namespace + class UsernamesList::Row final : public Ui::SettingsButton { public: Row( @@ -37,6 +66,7 @@ public: QString link); [[nodiscard]] const Data::Username &username() const; + [[nodiscard]] not_null rightAction() const; int resizeGetHeight(int newWidth) override; @@ -47,6 +77,7 @@ private: const style::PeerListItem &_st; const Data::Username _data; const QString _status; + const not_null _rightAction; const QRect _iconRect; std::shared_ptr _show; Ui::Text::String _title; @@ -65,6 +96,7 @@ UsernamesList::Row::Row( , _status(data.active ? tr::lng_usernames_active(tr::now) : tr::lng_usernames_non_active(tr::now)) +, _rightAction(Ui::CreateChild(this)) , _iconRect( _st.photoPosition.x() + st::inviteLinkIconSkip, _st.photoPosition.y() + st::inviteLinkIconSkip, @@ -91,12 +123,24 @@ UsernamesList::Row::Row( _menu->popup(QCursor::pos()); return base::EventFilterResult::Cancel; }); + + _rightAction->setVisible(data.active); + sizeValue( + ) | rpl::start_with_next([=](const QSize &s) { + _rightAction->moveToLeft( + s.width() - _rightAction->width() - st::inviteLinkThreeDotsSkip, + (s.height() - _rightAction->height()) / 2); + }, _rightAction->lifetime()); } const Data::Username &UsernamesList::Row::username() const { return _data; } +not_null UsernamesList::Row::rightAction() const { + return _rightAction; +} + int UsernamesList::Row::resizeGetHeight(int newWidth) { return _st.height; } @@ -252,6 +296,9 @@ void UsernamesList::rebuild(const Data::Usernames &usernames) { } _reorder = std::make_unique(content); + _reorder->setMouseEventProxy([=](int i) { + return _rows[i]->rightAction(); + }); { const auto it = ranges::find_if(usernames, [&]( @@ -262,6 +309,10 @@ void UsernamesList::rebuild(const Data::Usernames &usernames) { const auto from = std::distance(begin(usernames), it); const auto length = std::distance(it, end(usernames)); _reorder->addPinnedInterval(from, length); + if (from == 1) { + // Can't be reordered. + _rows[0]->rightAction()->hide(); + } } } _reorder->start(); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_usernames_list.h b/Telegram/SourceFiles/boxes/peers/edit_peer_usernames_list.h index b0a07c065..7ff074c4e 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_usernames_list.h +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_usernames_list.h @@ -38,10 +38,11 @@ private: class Row; + const std::shared_ptr _show; + const not_null _peer; + base::unique_qptr _container; std::unique_ptr _reorder; - std::shared_ptr _show; - const not_null _peer; std::vector _rows; int _reordering = 0; diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style index 309017a96..365b6b26c 100644 --- a/Telegram/SourceFiles/info/info.style +++ b/Telegram/SourceFiles/info/info.style @@ -853,6 +853,8 @@ inviteLinkQrSkip: 24px; inviteLinkQrMargin: margins(0px, 0px, 0px, 13px); inviteLinkQrValuePadding: margins(22px, 0px, 22px, 12px); +usernamesReorderIcon: icon {{ "stickers_reorder", dialogsMenuIconFg }}; + infoAboutGigagroup: FlatLabel(defaultFlatLabel) { minWidth: 274px; }