mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-26 07:23:02 +02:00
Show star in channel direct messages settings.
This commit is contained in:
parent
a08436ecd2
commit
11986ac698
4 changed files with 72 additions and 35 deletions
|
@ -82,6 +82,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "api/api_invite_links.h"
|
#include "api/api_invite_links.h"
|
||||||
#include "styles/style_chat_helpers.h"
|
#include "styles/style_chat_helpers.h"
|
||||||
|
#include "styles/style_credits.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
#include "styles/style_menu_icons.h"
|
#include "styles/style_menu_icons.h"
|
||||||
#include "styles/style_settings.h"
|
#include "styles/style_settings.h"
|
||||||
|
@ -133,7 +134,7 @@ void AddButtonWithCount(
|
||||||
not_null<Ui::SettingsButton*> AddButtonWithText(
|
not_null<Ui::SettingsButton*> AddButtonWithText(
|
||||||
not_null<Ui::VerticalLayout*> parent,
|
not_null<Ui::VerticalLayout*> parent,
|
||||||
rpl::producer<QString> &&text,
|
rpl::producer<QString> &&text,
|
||||||
rpl::producer<QString> &&label,
|
rpl::producer<TextWithEntities> &&label,
|
||||||
Fn<void()> callback,
|
Fn<void()> callback,
|
||||||
Settings::IconDescriptor &&descriptor) {
|
Settings::IconDescriptor &&descriptor) {
|
||||||
return parent->add(EditPeerInfoBox::CreateButton(
|
return parent->add(EditPeerInfoBox::CreateButton(
|
||||||
|
@ -145,6 +146,20 @@ not_null<Ui::SettingsButton*> AddButtonWithText(
|
||||||
std::move(descriptor)));
|
std::move(descriptor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
not_null<Ui::SettingsButton*> AddButtonWithText(
|
||||||
|
not_null<Ui::VerticalLayout*> parent,
|
||||||
|
rpl::producer<QString> &&text,
|
||||||
|
rpl::producer<QString> &&label,
|
||||||
|
Fn<void()> callback,
|
||||||
|
Settings::IconDescriptor &&descriptor) {
|
||||||
|
return AddButtonWithText(
|
||||||
|
parent,
|
||||||
|
std::move(text),
|
||||||
|
std::move(label) | Ui::Text::ToWithEntities(),
|
||||||
|
std::move(callback),
|
||||||
|
std::move(descriptor));
|
||||||
|
}
|
||||||
|
|
||||||
void AddButtonDelete(
|
void AddButtonDelete(
|
||||||
not_null<Ui::VerticalLayout*> parent,
|
not_null<Ui::VerticalLayout*> parent,
|
||||||
rpl::producer<QString> &&text,
|
rpl::producer<QString> &&text,
|
||||||
|
@ -1077,10 +1092,14 @@ void Controller::fillDirectMessagesButton() {
|
||||||
auto label = _starsPerDirectMessageSavedValue->value(
|
auto label = _starsPerDirectMessageSavedValue->value(
|
||||||
) | rpl::map([](int starsPerMessage) {
|
) | rpl::map([](int starsPerMessage) {
|
||||||
return (starsPerMessage < 0)
|
return (starsPerMessage < 0)
|
||||||
? tr::lng_manage_monoforum_off()
|
? tr::lng_manage_monoforum_off(Ui::Text::WithEntities)
|
||||||
: !starsPerMessage
|
: !starsPerMessage
|
||||||
? tr::lng_manage_monoforum_free()
|
? tr::lng_manage_monoforum_free(Ui::Text::WithEntities)
|
||||||
: rpl::single(Lang::FormatCountDecimal(starsPerMessage));
|
: rpl::single(Ui::Text::IconEmoji(
|
||||||
|
&st::starIconEmojiColored
|
||||||
|
).append(' ').append(
|
||||||
|
Lang::FormatStarsAmountDecimal(
|
||||||
|
StarsAmount{ starsPerMessage })));
|
||||||
}) | rpl::flatten_latest();
|
}) | rpl::flatten_latest();
|
||||||
AddButtonWithText(
|
AddButtonWithText(
|
||||||
_controls.buttonsLayout,
|
_controls.buttonsLayout,
|
||||||
|
@ -2866,6 +2885,22 @@ object_ptr<Ui::SettingsButton> EditPeerInfoBox::CreateButton(
|
||||||
Fn<void()> callback,
|
Fn<void()> callback,
|
||||||
const style::SettingsCountButton &st,
|
const style::SettingsCountButton &st,
|
||||||
Settings::IconDescriptor &&descriptor) {
|
Settings::IconDescriptor &&descriptor) {
|
||||||
|
return CreateButton(
|
||||||
|
parent,
|
||||||
|
std::move(text),
|
||||||
|
std::move(count) | Ui::Text::ToWithEntities(),
|
||||||
|
std::move(callback),
|
||||||
|
st,
|
||||||
|
std::move(descriptor));
|
||||||
|
}
|
||||||
|
|
||||||
|
object_ptr<Ui::SettingsButton> EditPeerInfoBox::CreateButton(
|
||||||
|
not_null<QWidget*> parent,
|
||||||
|
rpl::producer<QString> &&text,
|
||||||
|
rpl::producer<TextWithEntities> &&labelText,
|
||||||
|
Fn<void()> callback,
|
||||||
|
const style::SettingsCountButton &st,
|
||||||
|
Settings::IconDescriptor &&descriptor) {
|
||||||
auto result = object_ptr<Ui::SettingsButton>(
|
auto result = object_ptr<Ui::SettingsButton>(
|
||||||
parent,
|
parent,
|
||||||
rpl::duplicate(text),
|
rpl::duplicate(text),
|
||||||
|
@ -2886,37 +2921,49 @@ object_ptr<Ui::SettingsButton> EditPeerInfoBox::CreateButton(
|
||||||
std::move(descriptor));
|
std::move(descriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto labelText = rpl::combine(
|
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
|
button,
|
||||||
|
rpl::duplicate(labelText),
|
||||||
|
st.label);
|
||||||
|
label->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
label->show();
|
||||||
|
|
||||||
|
rpl::combine(
|
||||||
rpl::duplicate(text),
|
rpl::duplicate(text),
|
||||||
std::move(count),
|
std::move(labelText),
|
||||||
button->widthValue()
|
button->widthValue()
|
||||||
) | rpl::map([&st](const QString &text, const QString &count, int width) {
|
) | rpl::start_with_next([&st, label](
|
||||||
|
const QString &text,
|
||||||
|
const TextWithEntities &labelText,
|
||||||
|
int width) {
|
||||||
const auto available = width
|
const auto available = width
|
||||||
- st.button.padding.left()
|
- st.button.padding.left()
|
||||||
- (st.button.style.font->spacew * 2)
|
- (st.button.style.font->spacew * 2)
|
||||||
- st.button.style.font->width(text)
|
- st.button.style.font->width(text)
|
||||||
- st.labelPosition.x();
|
- st.labelPosition.x();
|
||||||
const auto required = st.label.style.font->width(count);
|
const auto required = label->textMaxWidth();
|
||||||
return (required > available)
|
label->resizeToWidth(std::min(required, available));
|
||||||
? st.label.style.font->elided(count, std::max(available, 0))
|
label->moveToRight(
|
||||||
: count;
|
st.labelPosition.x(),
|
||||||
});
|
st.labelPosition.y(),
|
||||||
|
width);
|
||||||
|
}, label->lifetime());
|
||||||
|
|
||||||
if (badge) {
|
if (badge) {
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
std::move(text),
|
std::move(text),
|
||||||
rpl::duplicate(labelText),
|
label->widthValue(),
|
||||||
button->widthValue()
|
button->widthValue()
|
||||||
) | rpl::start_with_next([=](
|
) | rpl::start_with_next([=](
|
||||||
const QString &text,
|
const QString &text,
|
||||||
const QString &label,
|
int labelWidth,
|
||||||
int width) {
|
int width) {
|
||||||
const auto space = st.button.style.font->spacew;
|
const auto space = st.button.style.font->spacew;
|
||||||
const auto left = st.button.padding.left()
|
const auto left = st.button.padding.left()
|
||||||
+ st.button.style.font->width(text)
|
+ st.button.style.font->width(text)
|
||||||
+ space;
|
+ space;
|
||||||
const auto right = st.labelPosition.x()
|
const auto right = st.labelPosition.x()
|
||||||
+ st.label.style.font->width(label)
|
+ labelWidth
|
||||||
+ (space * 2);
|
+ (space * 2);
|
||||||
const auto available = width - left - right;
|
const auto available = width - left - right;
|
||||||
badge->setVisible(available >= badge->width());
|
badge->setVisible(available >= badge->width());
|
||||||
|
@ -2930,23 +2977,6 @@ object_ptr<Ui::SettingsButton> EditPeerInfoBox::CreateButton(
|
||||||
}, badge->lifetime());
|
}, badge->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto label = Ui::CreateChild<Ui::FlatLabel>(
|
|
||||||
button,
|
|
||||||
std::move(labelText),
|
|
||||||
st.label);
|
|
||||||
label->setAttribute(Qt::WA_TransparentForMouseEvents);
|
|
||||||
label->show();
|
|
||||||
|
|
||||||
rpl::combine(
|
|
||||||
button->widthValue(),
|
|
||||||
label->widthValue()
|
|
||||||
) | rpl::start_with_next([=, &st](int outerWidth, int width) {
|
|
||||||
label->moveToRight(
|
|
||||||
st.labelPosition.x(),
|
|
||||||
st.labelPosition.y(),
|
|
||||||
outerWidth);
|
|
||||||
}, label->lifetime());
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,13 @@ public:
|
||||||
Fn<void()> callback,
|
Fn<void()> callback,
|
||||||
const style::SettingsCountButton &st,
|
const style::SettingsCountButton &st,
|
||||||
Settings::IconDescriptor &&descriptor);
|
Settings::IconDescriptor &&descriptor);
|
||||||
|
[[nodiscard]] static object_ptr<Ui::SettingsButton> CreateButton(
|
||||||
|
not_null<QWidget*> parent,
|
||||||
|
rpl::producer<QString> &&text,
|
||||||
|
rpl::producer<TextWithEntities> &&labelText,
|
||||||
|
Fn<void()> callback,
|
||||||
|
const style::SettingsCountButton &st,
|
||||||
|
Settings::IconDescriptor &&descriptor);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
|
|
@ -1250,7 +1250,7 @@ void CreateGiveawayBox(
|
||||||
rpl::duplicate(creditsValueType),
|
rpl::duplicate(creditsValueType),
|
||||||
tr::lng_giveaway_additional_credits_about(),
|
tr::lng_giveaway_additional_credits_about(),
|
||||||
tr::lng_giveaway_additional_about()
|
tr::lng_giveaway_additional_about()
|
||||||
) | rpl::map(Ui::Text::WithEntities)));
|
) | Ui::Text::ToWithEntities()));
|
||||||
Ui::AddSkip(additionalWrap);
|
Ui::AddSkip(additionalWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,8 +151,8 @@ void AddExpandablePeerList(
|
||||||
|
|
||||||
using namespace Info::Profile;
|
using namespace Info::Profile;
|
||||||
auto name = controller->data.bold
|
auto name = controller->data.bold
|
||||||
? NameValue(peer) | rpl::map(Ui::Text::Bold)
|
? NameValue(peer) | Ui::Text::ToBold()
|
||||||
: NameValue(peer) | rpl::map(Ui::Text::WithEntities);
|
: NameValue(peer) | Ui::Text::ToWithEntities();
|
||||||
const auto userpic
|
const auto userpic
|
||||||
= Ui::CreateChild<Ui::UserpicButton>(line, peer, st);
|
= Ui::CreateChild<Ui::UserpicButton>(line, peer, st);
|
||||||
const auto checkbox = Ui::CreateChild<Ui::Checkbox>(
|
const auto checkbox = Ui::CreateChild<Ui::Checkbox>(
|
||||||
|
|
Loading…
Add table
Reference in a new issue