mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Changed row in usernames list for editable one.
This commit is contained in:
parent
ad70942d0e
commit
bdd79aa2f2
5 changed files with 39 additions and 16 deletions
|
@ -407,6 +407,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_username_link" = "This link opens a chat with you:";
|
"lng_username_link" = "This link opens a chat with you:";
|
||||||
"lng_username_copied" = "Link copied to clipboard.";
|
"lng_username_copied" = "Link copied to clipboard.";
|
||||||
|
|
||||||
|
"lng_usernames_edit" = "click to edit";
|
||||||
"lng_usernames_active" = "active";
|
"lng_usernames_active" = "active";
|
||||||
"lng_usernames_non_active" = "non active";
|
"lng_usernames_non_active" = "non active";
|
||||||
"lng_usernames_subtitle" = "Usernames order";
|
"lng_usernames_subtitle" = "Usernames order";
|
||||||
|
@ -415,7 +416,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_channel_usernames_subtitle" = "Links order";
|
"lng_channel_usernames_subtitle" = "Links order";
|
||||||
"lng_usernames_deactivate_description" = "Do you want to hide this username from your info page?";
|
"lng_usernames_deactivate_description" = "Do you want to hide this username from your info page?";
|
||||||
"lng_usernames_deactivate_confirm" = "Hide";
|
"lng_usernames_deactivate_confirm" = "Hide";
|
||||||
"lng_usernames_deactivate_error" = "Sorry, you can't deactivate this username from your info page. ";
|
|
||||||
"lng_usernames_description" = "Drag and drop links to change the order in which they will be displayed on your info page.";
|
"lng_usernames_description" = "Drag and drop links to change the order in which they will be displayed on your info page.";
|
||||||
|
|
||||||
"lng_channel_usernames_activate_description" = "Do you want to show this link on the channel info page?";
|
"lng_channel_usernames_activate_description" = "Do you want to show this link on the channel info page?";
|
||||||
|
|
|
@ -88,6 +88,10 @@ public:
|
||||||
return _controls.requestToJoin && _controls.requestToJoin->toggled();
|
return _controls.requestToJoin && _controls.requestToJoin->toggled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] rpl::producer<int> scrollToRequests() const {
|
||||||
|
return _scrollToRequests.events();
|
||||||
|
}
|
||||||
|
|
||||||
void showError(rpl::producer<QString> text) {
|
void showError(rpl::producer<QString> text) {
|
||||||
_controls.usernameInput->showError();
|
_controls.usernameInput->showError();
|
||||||
showUsernameError(std::move(text));
|
showUsernameError(std::move(text));
|
||||||
|
@ -155,6 +159,8 @@ private:
|
||||||
UsernameState _usernameState = UsernameState::Normal;
|
UsernameState _usernameState = UsernameState::Normal;
|
||||||
rpl::event_stream<rpl::producer<QString>> _usernameResultTexts;
|
rpl::event_stream<rpl::producer<QString>> _usernameResultTexts;
|
||||||
|
|
||||||
|
rpl::event_stream<int> _scrollToRequests;
|
||||||
|
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -446,8 +452,12 @@ object_ptr<Ui::RpWidget> Controller::createUsernameEdit() {
|
||||||
container,
|
container,
|
||||||
tr::lng_create_channel_link_about());
|
tr::lng_create_channel_link_about());
|
||||||
|
|
||||||
|
const auto focusCallback = [=] {
|
||||||
|
_scrollToRequests.fire(container->y());
|
||||||
|
_controls.usernameInput->setFocusFast();
|
||||||
|
};
|
||||||
_controls.usernamesList = container->add(
|
_controls.usernamesList = container->add(
|
||||||
object_ptr<UsernamesList>(container, channel, _show));
|
object_ptr<UsernamesList>(container, channel, _show, focusCallback));
|
||||||
|
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
_controls.usernameInput,
|
_controls.usernameInput,
|
||||||
|
@ -715,6 +725,10 @@ void EditPeerTypeBox::prepare() {
|
||||||
_peer,
|
_peer,
|
||||||
_useLocationPhrases,
|
_useLocationPhrases,
|
||||||
_dataSavedValue);
|
_dataSavedValue);
|
||||||
|
controller->scrollToRequests(
|
||||||
|
) | rpl::start_with_next([=, raw = content.data()](int y) {
|
||||||
|
scrollToY(raw->y() + y);
|
||||||
|
}, lifetime());
|
||||||
_focusRequests.events(
|
_focusRequests.events(
|
||||||
) | rpl::start_with_next(
|
) | rpl::start_with_next(
|
||||||
[=] {
|
[=] {
|
||||||
|
|
|
@ -93,7 +93,9 @@ UsernamesList::Row::Row(
|
||||||
: Ui::SettingsButton(parent, rpl::never<QString>())
|
: Ui::SettingsButton(parent, rpl::never<QString>())
|
||||||
, _st(st::inviteLinkListItem)
|
, _st(st::inviteLinkListItem)
|
||||||
, _data(data)
|
, _data(data)
|
||||||
, _status(data.active
|
, _status(data.editable
|
||||||
|
? tr::lng_usernames_edit(tr::now)
|
||||||
|
: data.active
|
||||||
? tr::lng_usernames_active(tr::now)
|
? tr::lng_usernames_active(tr::now)
|
||||||
: tr::lng_usernames_non_active(tr::now))
|
: tr::lng_usernames_non_active(tr::now))
|
||||||
, _rightAction(Ui::CreateChild<RightAction>(this))
|
, _rightAction(Ui::CreateChild<RightAction>(this))
|
||||||
|
@ -152,14 +154,16 @@ void UsernamesList::Row::paintEvent(QPaintEvent *e) {
|
||||||
Ui::SettingsButton::paintBg(p, e->rect(), paintOver);
|
Ui::SettingsButton::paintBg(p, e->rect(), paintOver);
|
||||||
Ui::SettingsButton::paintRipple(p, 0, 0);
|
Ui::SettingsButton::paintRipple(p, 0, 0);
|
||||||
|
|
||||||
const auto &color = _data.active ? st::msgFile1Bg : st::windowSubTextFg;
|
const auto active = _data.active;
|
||||||
|
|
||||||
|
const auto &color = active ? st::msgFile1Bg : st::windowSubTextFg;
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
p.setBrush(color);
|
p.setBrush(color);
|
||||||
{
|
{
|
||||||
auto hq = PainterHighQualityEnabler(p);
|
auto hq = PainterHighQualityEnabler(p);
|
||||||
p.drawEllipse(_iconRect);
|
p.drawEllipse(_iconRect);
|
||||||
}
|
}
|
||||||
(!_data.active
|
(!active
|
||||||
? st::inviteLinkRevokedIcon
|
? st::inviteLinkRevokedIcon
|
||||||
: st::inviteLinkIcon).paintInCenter(p, _iconRect);
|
: st::inviteLinkIcon).paintInCenter(p, _iconRect);
|
||||||
|
|
||||||
|
@ -171,7 +175,7 @@ void UsernamesList::Row::paintEvent(QPaintEvent *e) {
|
||||||
width(),
|
width(),
|
||||||
width() - _st.namePosition.x());
|
width() - _st.namePosition.x());
|
||||||
|
|
||||||
p.setPen(_data.active
|
p.setPen(active
|
||||||
? _st.statusFgActive
|
? _st.statusFgActive
|
||||||
: paintOver
|
: paintOver
|
||||||
? _st.statusFgOver
|
? _st.statusFgOver
|
||||||
|
@ -187,10 +191,12 @@ void UsernamesList::Row::paintEvent(QPaintEvent *e) {
|
||||||
UsernamesList::UsernamesList(
|
UsernamesList::UsernamesList(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
std::shared_ptr<Ui::Show> show)
|
std::shared_ptr<Ui::Show> show,
|
||||||
|
Fn<void()> focusCallback)
|
||||||
: RpWidget(parent)
|
: RpWidget(parent)
|
||||||
, _show(show)
|
, _show(show)
|
||||||
, _peer(peer) {
|
, _peer(peer)
|
||||||
|
, _focusCallback(std::move(focusCallback)) {
|
||||||
{
|
{
|
||||||
auto &api = _peer->session().api();
|
auto &api = _peer->session().api();
|
||||||
const auto usernames = api.usernames().cacheFor(_peer->id);
|
const auto usernames = api.usernames().cacheFor(_peer->id);
|
||||||
|
@ -247,12 +253,8 @@ void UsernamesList::rebuild(const Data::Usernames &usernames) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (username.username == _peer->userName()) {
|
if (username.editable) {
|
||||||
_show->showBox(
|
_focusCallback();
|
||||||
Ui::MakeInformBox(_peer->isSelf()
|
|
||||||
? tr::lng_usernames_deactivate_error()
|
|
||||||
: tr::lng_channel_usernames_deactivate_error()),
|
|
||||||
Ui::LayerOption::KeepOther);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,8 @@ public:
|
||||||
UsernamesList(
|
UsernamesList(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
std::shared_ptr<Ui::Show> show);
|
std::shared_ptr<Ui::Show> show,
|
||||||
|
Fn<void()> focusCallback);
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<> save();
|
[[nodiscard]] rpl::producer<> save();
|
||||||
[[nodiscard]] std::vector<QString> order() const;
|
[[nodiscard]] std::vector<QString> order() const;
|
||||||
|
@ -40,6 +41,7 @@ private:
|
||||||
|
|
||||||
const std::shared_ptr<Ui::Show> _show;
|
const std::shared_ptr<Ui::Show> _show;
|
||||||
const not_null<PeerData*> _peer;
|
const not_null<PeerData*> _peer;
|
||||||
|
Fn<void()> _focusCallback;
|
||||||
|
|
||||||
base::unique_qptr<Ui::VerticalLayout> _container;
|
base::unique_qptr<Ui::VerticalLayout> _container;
|
||||||
std::unique_ptr<Ui::VerticalLayoutReorder> _reorder;
|
std::unique_ptr<Ui::VerticalLayoutReorder> _reorder;
|
||||||
|
|
|
@ -294,6 +294,7 @@ void UsernamesBox(
|
||||||
const auto editor = box->addRow(
|
const auto editor = box->addRow(
|
||||||
object_ptr<UsernameEditor>(box, session),
|
object_ptr<UsernameEditor>(box, session),
|
||||||
{});
|
{});
|
||||||
|
box->setFocusCallback([=] { editor->setInnerFocus(); });
|
||||||
|
|
||||||
container->add(object_ptr<Ui::DividerLabel>(
|
container->add(object_ptr<Ui::DividerLabel>(
|
||||||
container,
|
container,
|
||||||
|
@ -307,7 +308,11 @@ void UsernamesBox(
|
||||||
object_ptr<UsernamesList>(
|
object_ptr<UsernamesList>(
|
||||||
box,
|
box,
|
||||||
session->user(),
|
session->user(),
|
||||||
std::make_shared<Ui::BoxShow>(box)),
|
std::make_shared<Ui::BoxShow>(box),
|
||||||
|
[=] {
|
||||||
|
box->scrollToY(0);
|
||||||
|
editor->setInnerFocus();
|
||||||
|
}),
|
||||||
{});
|
{});
|
||||||
|
|
||||||
const auto finish = [=] {
|
const auto finish = [=] {
|
||||||
|
|
Loading…
Add table
Reference in a new issue