Remove ui/special_buttons module.

This commit is contained in:
John Preston 2022-12-19 15:48:24 +04:00
parent 14f113266f
commit faf6c48f25
54 changed files with 737 additions and 588 deletions

View File

@ -1260,6 +1260,10 @@ PRIVATE
ui/chat/choose_send_as.h
ui/chat/choose_theme_controller.cpp
ui/chat/choose_theme_controller.h
ui/controls/silent_toggle.cpp
ui/controls/silent_toggle.h
ui/controls/userpic_button.cpp
ui/controls/userpic_button.h
ui/effects/emoji_fly_animation.cpp
ui/effects/emoji_fly_animation.h
ui/effects/message_sending_animation_common.h
@ -1288,8 +1292,6 @@ PRIVATE
ui/resize_area.h
ui/search_field_controller.cpp
ui/search_field_controller.h
ui/special_buttons.cpp
ui/special_buttons.h
ui/text/format_song_document_name.cpp
ui/text/format_song_document_name.h
ui/unread_badge.cpp

View File

@ -393,8 +393,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_settings_save" = "Save";
"lng_settings_upload" = "Set Profile Photo";
"lng_settings_crop_profile" = "Select an area for your profile photo";
"lng_settings_uploading_photo" = "Uploading photo...";
"lng_settings_edit" = "Edit";
"lng_settings_drop_area_subtitle" = "to set it as your photo";
@ -1202,9 +1200,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_profile_send_message" = "Send Message";
"lng_info_add_as_contact" = "Add to contacts";
"lng_profile_shared_media" = "Shared media";
"lng_profile_suggest_photo" = "Suggest Photo for {user}";
"lng_profile_set_photo_for" = "Set Photo for {user}";
"lng_profile_photo_reset" = "Reset to Original Photo";
"lng_profile_suggest_photo" = "Suggest Profile Photo";
"lng_profile_set_photo_for" = "Set Profile Photo";
"lng_profile_photo_reset" = "Reset to Original";
"lng_media_type_photos" = "Photos";
"lng_media_type_gifs" = "GIFs";
"lng_media_type_videos" = "Videos";
@ -1438,9 +1436,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_create_channel_link_pending" = "Checking name...";
"lng_create_channel_link_copied" = "Link copied to clipboard";
"lng_create_group_crop" = "Select an area for group photo";
"lng_create_channel_crop" = "Select an area for channel photo";
"lng_failed_add_participant" = "Could not add user. Please try again later.";
"lng_failed_add_not_mutual" = "Sorry, if a person leaves a group, only a mutual contact can bring them back (they need to have your phone number, and you need theirs).";
"lng_failed_add_not_mutual_channel" = "Sorry, if a person leaves a channel, only a mutual contact can bring them back (they need to have your phone number, and you need theirs).";

View File

@ -363,4 +363,21 @@ void PeerPhoto::requestUserPhotos(
_userPhotosRequests.emplace(user, requestId);
}
// Non-personal photo in case a personal photo is set.
void PeerPhoto::registerNonPersonalPhoto(
not_null<UserData*> user,
not_null<PhotoData*> photo) {
_nonPersonalPhotos.emplace_or_assign(user, photo);
}
void PeerPhoto::unregisterNonPersonalPhoto(not_null<UserData*> user) {
_nonPersonalPhotos.erase(user);
}
PhotoData *PeerPhoto::nonPersonalPhoto(
not_null<UserData*> user) const {
const auto i = _nonPersonalPhotos.find(user);
return (i != end(_nonPersonalPhotos)) ? i->second.get() : nullptr;
}
} // namespace Api

View File

@ -33,6 +33,14 @@ public:
void requestUserPhotos(not_null<UserData*> user, UserPhotoId afterId);
// Non-personal photo in case a personal photo is set.
void registerNonPersonalPhoto(
not_null<UserData*> user,
not_null<PhotoData*> photo);
void unregisterNonPersonalPhoto(not_null<UserData*> user);
[[nodiscard]] PhotoData *nonPersonalPhoto(
not_null<UserData*> user) const;
private:
void ready(const FullMsgId &msgId, const MTPInputFile &file);
void upload(not_null<PeerData*> peer, QImage &&image, bool suggestion);
@ -45,6 +53,10 @@ private:
base::flat_map<not_null<UserData*>, mtpRequestId> _userPhotosRequests;
base::flat_map<
not_null<UserData*>,
not_null<PhotoData*>> _nonPersonalPhotos;
};
} // namespace Api

View File

@ -22,11 +22,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "countries/countries_instance.h" // Countries::ExtractPhoneCode.
#include "window/window_session_controller.h"
#include "menu/menu_ttl.h"
#include "ui/controls/userpic_button.h"
#include "ui/widgets/checkbox.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h"
#include "ui/toast/toast.h"
#include "ui/special_buttons.h"
#include "ui/widgets/fields/special_fields.h"
#include "ui/widgets/popup_menu.h"
#include "ui/text/format_values.h"
@ -465,9 +465,6 @@ void GroupInfoBox::prepare() {
_photo.create(
this,
&_navigation->parentController()->window(),
((_type == Type::Channel)
? tr::lng_create_channel_crop
: tr::lng_create_group_crop)(tr::now),
Ui::UserpicButton::Role::ChangePhoto,
st::defaultUserpicButton);
_title.create(

View File

@ -62,6 +62,14 @@ defaultUserpicButton: UserpicButton {
uploadIcon: defaultUploadUserpicIcon;
uploadIconPosition: point(-1px, 1px);
}
uploadUserpicSize: 32px;
uploadUserpicButton: UserpicButton(defaultUserpicButton) {
size: size(uploadUserpicSize, uploadUserpicSize);
photoSize: uploadUserpicSize;
changeIcon: icon {{ "settings/photo", activeButtonFg }};
changeIconPosition: point(4px, 4px);
}
uploadUserpicButtonBorder: 2px;
confirmInviteTitle: FlatLabel(defaultFlatLabel) {
align: align(center);

View File

@ -19,10 +19,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "settings/settings_premium.h"
#include "ui/basic_click_handlers.h" // UrlClickHandler::Open.
#include "ui/controls/userpic_button.h"
#include "ui/effects/premium_graphics.h"
#include "ui/effects/premium_stars_colored.h"
#include "ui/layers/generic_box.h"
#include "ui/special_buttons.h"
#include "ui/text/format_values.h"
#include "ui/text/text_utilities.h"
#include "ui/widgets/checkbox.h"

View File

@ -136,15 +136,16 @@ void Controller::setupContent() {
}
void Controller::setupCover() {
_box->addRow(
const auto cover = _box->addRow(
object_ptr<Info::Profile::Cover>(
_box,
_user,
_window,
_user,
Info::Profile::Cover::Role::EditContact,
(_phone.isEmpty()
? tr::lng_contact_mobile_hidden()
: rpl::single(Ui::FormatPhone(_phone)))),
style::margins())->setAttribute(Qt::WA_TransparentForMouseEvents);
style::margins());
}
void Controller::setupNameFields() {

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/peers/edit_participant_box.h"
#include "lang/lang_keys.h"
#include "ui/controls/userpic_button.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/wrap/padding_wrap.h"
#include "ui/wrap/slide_wrap.h"
@ -20,7 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/toast/toast.h"
#include "ui/text/text_utilities.h"
#include "ui/text/text_options.h"
#include "ui/special_buttons.h"
#include "ui/painter.h"
#include "chat_helpers/emoji_suggestions_widget.h"
#include "settings/settings_privacy_security.h"

View File

@ -43,8 +43,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_account.h"
#include "main/main_app_config.h"
#include "settings/settings_common.h"
#include "ui/controls/userpic_button.h"
#include "ui/rp_widget.h"
#include "ui/special_buttons.h"
#include "ui/toast/toast.h"
#include "ui/toasts/common_toasts.h"
#include "ui/text/text_utilities.h"

View File

@ -29,7 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "mtproto/sender.h"
#include "ui/rp_widget.h"
#include "ui/special_buttons.h"
#include "ui/controls/userpic_button.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/checkbox.h"
#include "ui/widgets/input_fields.h"

View File

@ -21,7 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/sticker_set_box.h"
#include "apiwrap.h"
#include "storage/storage_account.h"
#include "dialogs/ui/dialogs_layout.h"
#include "lottie/lottie_single_player.h"
#include "chat_helpers/stickers_lottie.h"
#include "ui/widgets/buttons.h"
@ -35,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/image/image.h"
#include "ui/cached_round_corners.h"
#include "ui/painter.h"
#include "ui/unread_badge_paint.h"
#include "window/window_session_controller.h"
#include "media/clip/media_clip_reader.h"
#include "main/main_session.h"
@ -66,7 +66,7 @@ private:
void setCounter(int counter);
QString _text;
Dialogs::Ui::UnreadBadgeStyle _st;
Ui::UnreadBadgeStyle _st;
};
@ -335,7 +335,7 @@ void StickersBox::CounterWidget::setCounter(int counter) {
auto dummy = QImage(1, 1, QImage::Format_ARGB32_Premultiplied);
auto p = QPainter(&dummy);
const auto badge = Dialogs::Ui::PaintUnreadBadge(p, _text, 0, 0, _st);
const auto badge = Ui::PaintUnreadBadge(p, _text, 0, 0, _st);
resize(badge.width(), st::stickersFeaturedBadgeSize);
}
@ -346,7 +346,7 @@ void StickersBox::CounterWidget::paintEvent(QPaintEvent *e) {
if (!_text.isEmpty()) {
const auto unreadRight = rtl() ? 0 : width();
const auto unreadTop = 0;
Dialogs::Ui::PaintUnreadBadge(p, _text, unreadRight, unreadTop, _st);
Ui::PaintUnreadBadge(p, _text, unreadRight, unreadTop, _st);
}
}

View File

@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/tooltip.h"
#include "ui/widgets/rp_window.h"
#include "ui/chat/group_call_bar.h"
#include "ui/controls/userpic_button.h"
#include "ui/layers/layer_manager.h"
#include "ui/layers/generic_box.h"
#include "ui/text/text_utilities.h"
@ -35,7 +36,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/image/image_prepare.h"
#include "ui/painter.h"
#include "ui/round_rect.h"
#include "ui/special_buttons.h"
#include "info/profile/info_profile_values.h" // Info::Profile::Value.
#include "core/application.h"
#include "core/core_settings.h"

View File

@ -30,7 +30,7 @@ public:
private:
std::vector<QString> _usernames;
short _indexEditableUsername = -1;
int _indexEditableUsername = -1;
};

View File

@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/chat/requests_bar.h"
#include "ui/chat/group_call_bar.h"
#include "ui/controls/download_bar.h"
#include "ui/controls/jump_down_button.h"
#include "ui/painter.h"
#include "ui/ui_utility.h"
#include "lang/lang_keys.h"

View File

@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/section_widget.h"
#include "ui/effects/animations.h"
#include "ui/widgets/scroll_area.h"
#include "ui/special_buttons.h"
#include "mtproto/sender.h"
#include "api/api_single_message_search.h"
@ -44,6 +43,7 @@ class PlainShadow;
class DownloadBar;
class GroupCallBar;
class RequestsBar;
class JumpDownButton;
template <typename Widget>
class FadeWrapScaled;
} // namespace Ui
@ -247,7 +247,7 @@ private:
rpl::variable<float64> _shownProgressValue;
Ui::Animations::Simple _scrollToTopShown;
object_ptr<Ui::HistoryDownButton> _scrollToTop;
object_ptr<Ui::JumpDownButton> _scrollToTop;
bool _scrollToTopIsShown = false;
bool _forumSearchRequested = false;

View File

@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "dialogs/ui/dialogs_layout.h"
#include "data/data_abstract_structure.h"
#include "data/data_drafts.h"
#include "data/data_forum_topic.h"
#include "data/data_session.h"
@ -20,8 +19,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_options.h"
#include "ui/text/text_utilities.h"
#include "ui/unread_badge.h"
#include "ui/unread_badge_paint.h"
#include "ui/painter.h"
#include "ui/ui_utility.h"
#include "core/ui_integration.h"
#include "lang/lang_keys.h"
#include "support/support_helper.h"
@ -694,105 +693,6 @@ void PaintRow(
}
}
struct UnreadBadgeSizeData {
QImage circle;
QPixmap left[6], right[6];
};
class UnreadBadgeStyleData : public Data::AbstractStructure {
public:
UnreadBadgeStyleData();
UnreadBadgeSizeData sizes[static_cast<int>(UnreadBadgeSize::kCount)];
style::color bg[6] = {
st::dialogsUnreadBg,
st::dialogsUnreadBgOver,
st::dialogsUnreadBgActive,
st::dialogsUnreadBgMuted,
st::dialogsUnreadBgMutedOver,
st::dialogsUnreadBgMutedActive
};
style::color reactionBg[6] = {
st::dialogsDraftFg,
st::dialogsDraftFgOver,
st::dialogsDraftFgActive,
st::dialogsUnreadBgMuted,
st::dialogsUnreadBgMutedOver,
st::dialogsUnreadBgMutedActive
};
rpl::lifetime lifetime;
};
Data::GlobalStructurePointer<UnreadBadgeStyleData> unreadBadgeStyle;
UnreadBadgeStyleData::UnreadBadgeStyleData() {
style::PaletteChanged(
) | rpl::start_with_next([=] {
for (auto &data : sizes) {
for (auto &left : data.left) {
left = QPixmap();
}
for (auto &right : data.right) {
right = QPixmap();
}
}
}, lifetime);
}
void createCircleMask(UnreadBadgeSizeData *data, int size) {
if (!data->circle.isNull()) return;
data->circle = style::createCircleMask(size);
}
QImage colorizeCircleHalf(UnreadBadgeSizeData *data, int size, int half, int xoffset, style::color color) {
auto result = style::colorizeImage(data->circle, color, QRect(xoffset, 0, half, size));
result.setDevicePixelRatio(cRetinaFactor());
return result;
}
void PaintUnreadBadge(QPainter &p, const QRect &rect, const UnreadBadgeStyle &st) {
Assert(rect.height() == st.size);
int index = (st.muted ? 0x03 : 0x00) + (st.active ? 0x02 : (st.selected ? 0x01 : 0x00));
int size = st.size, sizehalf = size / 2;
unreadBadgeStyle.createIfNull();
auto badgeData = unreadBadgeStyle->sizes;
if (st.sizeId > UnreadBadgeSize()) {
Assert(st.sizeId < UnreadBadgeSize::kCount);
badgeData = &unreadBadgeStyle->sizes[static_cast<int>(st.sizeId)];
}
const auto bg = (st.sizeId == UnreadBadgeSize::ReactionInDialogs)
? unreadBadgeStyle->reactionBg[index]
: unreadBadgeStyle->bg[index];
if (badgeData->left[index].isNull()) {
int imgsize = size * cIntRetinaFactor(), imgsizehalf = sizehalf * cIntRetinaFactor();
createCircleMask(badgeData, size);
badgeData->left[index] = PixmapFromImage(
colorizeCircleHalf(badgeData, imgsize, imgsizehalf, 0, bg));
badgeData->right[index] = PixmapFromImage(colorizeCircleHalf(
badgeData,
imgsize,
imgsizehalf,
imgsize - imgsizehalf,
bg));
}
int bar = rect.width() - 2 * sizehalf;
p.drawPixmap(rect.x(), rect.y(), badgeData->left[index]);
if (bar) {
p.fillRect(rect.x() + sizehalf, rect.y(), bar, rect.height(), bg);
}
p.drawPixmap(rect.x() + sizehalf + bar, rect.y(), badgeData->right[index]);
}
[[nodiscard]] QString ComputeUnreadBadgeText(
const QString &unreadCount,
int allowDigits) {
return (allowDigits > 0) && (unreadCount.size() > allowDigits + 1)
? u".."_q + unreadCount.mid(unreadCount.size() - allowDigits)
: unreadCount;
}
} // namespace
const style::icon *ChatTypeIcon(not_null<PeerData*> peer) {
@ -835,61 +735,6 @@ const style::icon *ChatTypeIcon(
return nullptr;
}
UnreadBadgeStyle::UnreadBadgeStyle()
: size(st::dialogsUnreadHeight)
, padding(st::dialogsUnreadPadding)
, font(st::dialogsUnreadFont) {
}
QSize CountUnreadBadgeSize(
const QString &unreadCount,
const UnreadBadgeStyle &st,
int allowDigits) {
const auto text = ComputeUnreadBadgeText(unreadCount, allowDigits);
const auto unreadRectHeight = st.size;
const auto unreadWidth = st.font->width(text);
return {
std::max(unreadWidth + 2 * st.padding, unreadRectHeight),
unreadRectHeight,
};
}
QRect PaintUnreadBadge(
QPainter &p,
const QString &unreadCount,
int x,
int y,
const UnreadBadgeStyle &st,
int allowDigits) {
const auto text = ComputeUnreadBadgeText(unreadCount, allowDigits);
const auto unreadRectHeight = st.size;
const auto unreadWidth = st.font->width(text);
const auto unreadRectWidth = std::max(
unreadWidth + 2 * st.padding,
unreadRectHeight);
const auto unreadRectLeft = ((st.align & Qt::AlignHorizontal_Mask) & style::al_center)
? (x - unreadRectWidth) / 2
: ((st.align & Qt::AlignHorizontal_Mask) & style::al_right)
? (x - unreadRectWidth)
: x;
const auto unreadRectTop = y;
const auto badge = QRect(unreadRectLeft, unreadRectTop, unreadRectWidth, unreadRectHeight);
PaintUnreadBadge(p, badge, st);
const auto textTop = st.textTop ? st.textTop : (unreadRectHeight - st.font->height) / 2;
p.setFont(st.font);
p.setPen(st.active
? st::dialogsUnreadFgActive
: st.selected
? st::dialogsUnreadFgOver
: st::dialogsUnreadFg);
p.drawText(unreadRectLeft + (unreadRectWidth - unreadWidth) / 2, unreadRectTop + textTop + st.font->ascent, text);
return badge;
}
void RowPainter::Paint(
Painter &p,
not_null<const Row*> row,

View File

@ -104,42 +104,4 @@ void PaintCollapsedRow(
int unread,
const PaintContext &context);
enum class UnreadBadgeSize {
Dialogs,
MainMenu,
HistoryToDown,
StickersPanel,
StickersBox,
TouchBar,
ReactionInDialogs,
kCount,
};
struct UnreadBadgeStyle {
UnreadBadgeStyle();
style::align align = style::al_right;
bool active = false;
bool selected = false;
bool muted = false;
int textTop = 0;
int size = 0;
int padding = 0;
UnreadBadgeSize sizeId = UnreadBadgeSize::Dialogs;
style::font font;
};
[[nodiscard]] QSize CountUnreadBadgeSize(
const QString &unreadCount,
const UnreadBadgeStyle &st,
int allowDigits = 0);
QRect PaintUnreadBadge(
QPainter &p,
const QString &t,
int x,
int y,
const UnreadBadgeStyle &st,
int allowDigits = 0);
} // namespace Dialogs::Ui

View File

@ -490,6 +490,8 @@ void ApiWrap::requestSplitRanges() {
_splits.push_back(MTP_messageRange(
MTP_int(1),
MTP_int(std::numeric_limits<int>::max())));
//} else {
// ranges::reverse(_splits);
}
_startProcess->splitIndex = useOnlyLastSplit()
? (_splits.size() - 1)

View File

@ -26,7 +26,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/file_utilities.h"
#include "ui/toast/toast.h"
#include "ui/toasts/common_toasts.h"
#include "ui/special_buttons.h"
#include "ui/emoji_config.h"
#include "ui/chat/attach/attach_prepare.h"
#include "ui/chat/choose_theme_controller.h"
@ -45,10 +44,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/chat/choose_send_as.h"
#include "ui/image/image.h"
#include "ui/painter.h"
#include "ui/special_buttons.h"
#include "ui/controls/emoji_button.h"
#include "ui/controls/send_button.h"
#include "ui/controls/send_as_button.h"
#include "ui/controls/silent_toggle.h"
#include "inline_bots/inline_bot_result.h"
#include "base/event_filter.h"
#include "base/qt_signal_producer.h"

View File

@ -61,8 +61,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/controls/emoji_button.h"
#include "ui/controls/send_button.h"
#include "ui/controls/send_as_button.h"
#include "ui/controls/silent_toggle.h"
#include "ui/chat/choose_send_as.h"
#include "ui/special_buttons.h"
#include "window/window_adaptive.h"
#include "window/window_session_controller.h"
#include "mainwindow.h"

View File

@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/scroll_area.h"
#include "ui/chat/chat_style.h"
#include "ui/special_buttons.h"
#include "ui/controls/jump_down_button.h"
#include "base/qt/qt_key_modifiers.h"
#include "history/history.h"
#include "history/history_item.h"

View File

@ -17,7 +17,7 @@ struct FullMsgId;
namespace Ui {
class ChatStyle;
class ScrollArea;
class HistoryDownButton;
class JumpDownButton;
} // namespace Ui
namespace Data {
@ -32,7 +32,7 @@ struct CornerButton {
CornerButton(Args &&...args) : widget(std::forward<Args>(args)...) {
}
object_ptr<Ui::HistoryDownButton> widget;
object_ptr<Ui::JumpDownButton> widget;
Ui::Animations::Simple animation;
bool shown = false;
};

View File

@ -15,13 +15,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/boxes/confirm_box.h"
#include "ui/widgets/scroll_area.h"
#include "ui/widgets/shadow.h"
#include "ui/widgets/buttons.h"
#include "ui/layers/generic_box.h"
#include "ui/item_text_options.h"
#include "ui/chat/chat_style.h"
#include "ui/toast/toast.h"
#include "ui/text/format_values.h"
#include "ui/text/text_utilities.h"
#include "ui/special_buttons.h"
#include "ui/ui_utility.h"
#include "ui/toasts/common_toasts.h"
#include "base/timer_rpl.h"

View File

@ -21,7 +21,6 @@ namespace Ui {
class ScrollArea;
class PlainShadow;
class FlatButton;
class HistoryDownButton;
} // namespace Ui
namespace Profile {

View File

@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/chat/attach/attach_send_files_way.h"
#include "ui/chat/pinned_bar.h"
#include "ui/chat/chat_style.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/scroll_area.h"
#include "ui/widgets/shadow.h"
#include "ui/widgets/popup_menu.h"
@ -37,7 +38,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/format_values.h"
#include "ui/text/text_utilities.h"
#include "ui/effects/message_sending_animation_controller.h"
#include "ui/special_buttons.h"
#include "ui/ui_utility.h"
#include "ui/toasts/common_toasts.h"
#include "base/timer_rpl.h"

View File

@ -34,7 +34,6 @@ namespace Ui {
class ScrollArea;
class PlainShadow;
class FlatButton;
class HistoryDownButton;
class PinnedBar;
struct PreparedList;
class SendFilesWay;

View File

@ -25,7 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/chat/chat_style.h"
#include "ui/chat/attach/attach_prepare.h"
#include "ui/chat/attach/attach_send_files_way.h"
#include "ui/special_buttons.h"
#include "ui/ui_utility.h"
#include "ui/text/text_utilities.h"
#include "ui/toasts/common_toasts.h"

View File

@ -30,8 +30,7 @@ namespace Ui {
class ScrollArea;
class PlainShadow;
class FlatButton;
class HistoryDownButton;
struct PreparedList;
class PreparedList;
class SendFilesWay;
} // namespace Ui

View File

@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/shortcuts.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "ui/controls/userpic_button.h"
#include "ui/wrap/fade_wrap.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h"
@ -35,7 +36,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text.h"
#include "ui/text/text_options.h"
#include "ui/painter.h"
#include "ui/special_buttons.h"
#include "ui/unread_badge.h"
#include "ui/ui_utility.h"
#include "window/window_adaptive.h"

View File

@ -325,6 +325,10 @@ infoTopicCover: InfoProfileCover(infoProfileMegagroupCover) {
statusLeft: 79px;
statusTop: 38px;
}
infoEditContactCover: InfoProfileCover(infoProfileCover) {
nameTop: 33px;
statusTop: 57px;
}
infoProfileInaccessibleUserpic: icon {{ "info/inaccessible_userpic", historyPeerUserpicFg }};

View File

@ -25,9 +25,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/peers/edit_forum_topic_box.h"
#include "history/view/media/history_view_sticker_player.h"
#include "lang/lang_keys.h"
#include "ui/controls/userpic_button.h"
#include "ui/widgets/labels.h"
#include "ui/text/text_utilities.h"
#include "ui/special_buttons.h"
#include "base/unixtime.h"
#include "window/window_session_controller.h"
#include "main/main_session.h"
@ -74,50 +74,21 @@ auto ChatStatusText(int fullCount, int onlineCount, bool isGroup) {
: tr::lng_channel_status(tr::now);
};
} // namespace
Cover::Cover(
QWidget *parent,
not_null<PeerData*> peer,
not_null<Window::SessionController*> controller)
: Cover(parent, peer, controller, NameValue(peer)) {
}
Cover::Cover(
QWidget *parent,
not_null<Data::ForumTopic*> topic,
not_null<Window::SessionController*> controller)
: Cover(
parent,
topic->channel(),
topic,
controller,
TitleValue(topic)) {
}
Cover::Cover(
QWidget *parent,
not_null<PeerData*> peer,
not_null<Window::SessionController*> controller,
rpl::producer<QString> title)
: Cover(
parent,
peer,
nullptr,
controller,
std::move(title)) {
}
[[nodiscard]] const style::InfoProfileCover &CoverStyle(
not_null<PeerData*> peer,
Data::ForumTopic *topic) {
return topic
Data::ForumTopic *topic,
Cover::Role role) {
return (role == Cover::Role::EditContact)
? st::infoEditContactCover
: topic
? st::infoTopicCover
: peer->isMegagroup()
? st::infoProfileMegagroupCover
: st::infoProfileCover;
}
} // namespace
TopicIconView::TopicIconView(
not_null<Data::ForumTopic*> topic,
Fn<bool()> paused,
@ -273,12 +244,49 @@ TopicIconButton::TopicIconButton(
Cover::Cover(
QWidget *parent,
not_null<Window::SessionController*> controller,
not_null<PeerData*> peer)
: Cover(parent, controller, peer, Role::Info, NameValue(peer)) {
}
Cover::Cover(
QWidget *parent,
not_null<Window::SessionController*> controller,
not_null<Data::ForumTopic*> topic)
: Cover(
parent,
controller,
topic->channel(),
topic,
Role::Info,
TitleValue(topic)) {
}
Cover::Cover(
QWidget *parent,
not_null<Window::SessionController*> controller,
not_null<PeerData*> peer,
Role role,
rpl::producer<QString> title)
: Cover(
parent,
controller,
peer,
nullptr,
role,
std::move(title)) {
}
Cover::Cover(
QWidget *parent,
not_null<Window::SessionController*> controller,
not_null<PeerData*> peer,
Data::ForumTopic *topic,
not_null<Window::SessionController*> controller,
Role role,
rpl::producer<QString> title)
: FixedHeightWidget(parent, CoverStyle(peer, topic).height)
, _st(CoverStyle(peer, topic))
: FixedHeightWidget(parent, CoverStyle(peer, topic, role).height)
, _st(CoverStyle(peer, topic, role))
, _role(role)
, _controller(controller)
, _peer(peer)
, _emojiStatusPanel(peer->isSelf()
@ -300,7 +308,9 @@ Cover::Cover(
this,
controller,
_peer,
Ui::UserpicButton::Role::OpenPhoto,
(role == Role::Info
? Ui::UserpicButton::Role::OpenPhoto
: Ui::UserpicButton::Role::Custom),
_st.photo))
, _iconButton(topic
? object_ptr<TopicIconButton>(this, controller, topic)
@ -390,7 +400,7 @@ void Cover::initViewers(rpl::producer<QString> title) {
}
void Cover::refreshUploadPhotoOverlay() {
if (!_userpic) {
if (!_userpic || _role == Role::EditContact) {
return;
}

View File

@ -89,18 +89,24 @@ private:
class Cover final : public Ui::FixedHeightWidget {
public:
enum class Role {
Info,
EditContact,
};
Cover(
QWidget *parent,
not_null<PeerData*> peer,
not_null<Window::SessionController*> controller);
Cover(
QWidget *parent,
not_null<Data::ForumTopic*> topic,
not_null<Window::SessionController*> controller);
Cover(
QWidget *parent,
not_null<PeerData*> peer,
not_null<Window::SessionController*> controller,
not_null<PeerData*> peer);
Cover(
QWidget *parent,
not_null<Window::SessionController*> controller,
not_null<Data::ForumTopic*> topic);
Cover(
QWidget *parent,
not_null<Window::SessionController*> controller,
not_null<PeerData*> peer,
Role role,
rpl::producer<QString> title);
~Cover();
@ -113,9 +119,10 @@ public:
private:
Cover(
QWidget *parent,
not_null<Window::SessionController*> controller,
not_null<PeerData*> peer,
Data::ForumTopic *topic,
not_null<Window::SessionController*> controller,
Role role,
rpl::producer<QString> title);
void setupChildGeometry();
@ -127,6 +134,7 @@ private:
const style::InfoProfileCover &_st;
const Role _role = Role::Info;
const not_null<Window::SessionController*> _controller;
const not_null<PeerData*> _peer;
const std::unique_ptr<EmojiStatusPanel> _emojiStatusPanel;

View File

@ -67,12 +67,12 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
_cover = _topic
? result->add(object_ptr<Cover>(
result,
_topic,
_controller->parentController()))
_controller->parentController(),
_topic))
: result->add(object_ptr<Cover>(
result,
_peer,
_controller->parentController()));
_controller->parentController(),
_peer));
_cover->showSection(
) | rpl::start_with_next([=](Section section) {
_controller->showSection(_topic

View File

@ -11,10 +11,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/file_utilities.h"
#include "ui/boxes/confirm_box.h"
#include "lang/lang_keys.h"
#include "ui/controls/userpic_button.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h"
#include "ui/widgets/labels.h"
#include "ui/special_buttons.h"
#include "styles/style_intro.h"
#include "styles/style_boxes.h"
@ -29,7 +29,6 @@ SignupWidget::SignupWidget(
, _photo(
this,
data->controller,
tr::lng_settings_crop_profile(tr::now),
Ui::UserpicButton::Role::ChangePhoto,
st::defaultUserpicButton)
, _first(this, st::introName, tr::lng_signup_firstname())

View File

@ -31,7 +31,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_histories.h"
#include "data/stickers/data_stickers.h"
#include "ui/chat/chat_theme.h"
#include "ui/special_buttons.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/shadow.h"
#include "ui/toasts/common_toasts.h"
@ -113,6 +112,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_dialogs.h"
#include "styles/style_chat.h"
#include "styles/style_boxes.h"
#include "styles/style_window.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QMimeData>

View File

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/abstract_box.h"
#include "core/click_handler_types.h"
#include "data/data_user.h"
#include "ui/controls/userpic_button.h"
#include "ui/effects/animations.h"
#include "ui/effects/scroll_content_shadow.h"
#include "ui/widgets/buttons.h"
@ -23,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/padding_wrap.h"
#include "ui/text/text_utilities.h"
#include "ui/text/text_options.h"
#include "ui/special_buttons.h"
#include "styles/style_passport.h"
#include "styles/style_layers.h"
#include "styles/style_boxes.h"

View File

@ -8,12 +8,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "passport/passport_panel_password.h"
#include "passport/passport_panel_controller.h"
#include "ui/controls/userpic_button.h"
#include "ui/widgets/labels.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/wrap/padding_wrap.h"
#include "ui/special_buttons.h"
#include "boxes/passcode_box.h"
#include "data/data_user.h"
#include "lang/lang_keys.h"

View File

@ -20,7 +20,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_peer_values.h"
#include "data/data_session.h"
#include "data/data_user.h"
#include "dialogs/ui/dialogs_layout.h"
#include "history/history.h"
#include "main/main_session.h"
#include "mainwidget.h"
@ -29,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/animations.h"
#include "ui/empty_userpic.h"
#include "ui/userpic_view.h"
#include "ui/unread_badge_paint.h"
#include "ui/painter.h"
#include "window/window_controller.h"
#include "window/window_session_controller.h"
@ -98,8 +98,8 @@ QImage UnreadBadge(not_null<PeerData*> peer) {
const auto counter = (state.unreadCounter > 0)
? QString::number(state.unreadCounter)
: QString();
Dialogs::Ui::UnreadBadgeStyle unreadSt;
unreadSt.sizeId = Dialogs::Ui::UnreadBadgeSize::TouchBar;
Ui::UnreadBadgeStyle unreadSt;
unreadSt.sizeId = Ui::UnreadBadgeSize::TouchBar;
unreadSt.muted = state.unreadMuted;
// Use constant values to draw badge regardless of cConfigScale().
unreadSt.size = kUnreadBadgeSize * cRetinaFactor();
@ -115,7 +115,7 @@ QImage UnreadBadge(not_null<PeerData*> peer) {
result.fill(Qt::transparent);
Painter p(&result);
Dialogs::Ui::PaintUnreadBadge(
Ui::PaintUnreadBadge(
p,
counter,
result.width(),

View File

@ -178,14 +178,6 @@ settingsInfoPhoto: UserpicButton(defaultUserpicButton) {
size: size(settingsInfoPhotoSize, settingsInfoPhotoSize);
photoSize: settingsInfoPhotoSize;
}
settingsInfoUploadSize: 32px;
settingsInfoUpload: UserpicButton(defaultUserpicButton) {
size: size(settingsInfoUploadSize, settingsInfoUploadSize);
photoSize: settingsInfoUploadSize;
changeIcon: icon {{ "settings/photo", activeButtonFg }};
changeIconPosition: point(4px, 4px);
}
settingsInfoUploadBorder: 2px;
settingsInfoPhotoTop: 0px;
settingsInfoPhotoSkip: 7px;
settingsInfoNameSkip: -1px;

View File

@ -20,9 +20,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/box_content_divider.h"
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
#include "ui/boxes/confirm_box.h"
#include "ui/controls/userpic_button.h"
#include "ui/text/text_utilities.h"
#include "ui/painter.h"
#include "ui/special_buttons.h"
#include "ui/unread_badge_paint.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "chat_helpers/emoji_suggestions_widget.h"
@ -35,7 +36,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_peer_values.h"
#include "data/data_changes.h"
#include "data/data_premium_limits.h"
#include "dialogs/ui/dialogs_layout.h"
#include "info/profile/info_profile_values.h"
#include "info/profile/info_profile_badge.h"
#include "lang/lang_keys.h"
@ -57,6 +57,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "styles/style_layers.h"
#include "styles/style_settings.h"
#include "styles/style_menu_icons.h"
#include "styles/style_window.h"
#include <QtGui/QGuiApplication>
#include <QtGui/QClipboard>
@ -232,40 +233,6 @@ private:
};
}
[[nodiscard]] not_null<Ui::UserpicButton*> CreateUploadButton(
not_null<Ui::RpWidget*> parent,
not_null<Window::SessionController*> controller) {
const auto background = Ui::CreateChild<Ui::RpWidget>(parent.get());
const auto upload = Ui::CreateChild<Ui::UserpicButton>(
parent.get(),
&controller->window(),
tr::lng_settings_crop_profile(tr::now),
Ui::UserpicButton::Role::ChoosePhoto,
st::settingsInfoUpload);
const auto border = st::settingsInfoUploadBorder;
const auto size = upload->rect().marginsAdded(
{ border, border, border, border }
).size();
background->resize(size);
background->paintRequest(
) | rpl::start_with_next([=] {
auto p = QPainter(background);
auto hq = PainterHighQualityEnabler(p);
p.setBrush(st::boxBg);
p.setPen(Qt::NoPen);
p.drawEllipse(background->rect());
}, background->lifetime());
upload->positionValue(
) | rpl::start_with_next([=](QPoint position) {
background->move(position - QPoint(border, border));
}, background->lifetime());
return upload;
}
void SetupPhoto(
not_null<Ui::VerticalLayout*> container,
not_null<Window::SessionController*> controller,
@ -279,7 +246,7 @@ void SetupPhoto(
self,
Ui::UserpicButton::Role::OpenPhoto,
st::settingsInfoPhoto);
const auto upload = CreateUploadButton(wrap, controller);
const auto upload = CreateUploadSubButton(wrap, controller);
upload->chosenImages(
) | rpl::start_with_next([=](Ui::UserpicButton::ChosenImage &&chosen) {
@ -979,11 +946,11 @@ void UpdatePhotoLocally(not_null<UserData*> user, const QImage &image) {
namespace Badge {
Dialogs::Ui::UnreadBadgeStyle Style() {
auto result = Dialogs::Ui::UnreadBadgeStyle();
Ui::UnreadBadgeStyle Style() {
auto result = Ui::UnreadBadgeStyle();
result.font = st::mainMenuBadgeFont;
result.size = st::mainMenuBadgeSize;
result.sizeId = Dialogs::Ui::UnreadBadgeSize::MainMenu;
result.sizeId = Ui::UnreadBadgeSize::MainMenu;
return result;
}
@ -1020,7 +987,7 @@ not_null<Ui::RpWidget*> CreateUnread(
}
Ui::RpWidget widget;
Dialogs::Ui::UnreadBadgeStyle st = Style();
Ui::UnreadBadgeStyle st = Style();
int count = 0;
QString string;
};
@ -1036,7 +1003,7 @@ not_null<Ui::RpWidget*> CreateUnread(
return;
}
state->string = Lang::FormatCountToShort(state->count).string;
state->widget.resize(CountUnreadBadgeSize(state->string, state->st));
state->widget.resize(Ui::CountUnreadBadgeSize(state->string, state->st));
if (state->widget.isHidden()) {
state->widget.show();
}
@ -1045,7 +1012,7 @@ not_null<Ui::RpWidget*> CreateUnread(
state->widget.paintRequest(
) | rpl::start_with_next([=] {
auto p = Painter(&state->widget);
Dialogs::Ui::PaintUnreadBadge(
Ui::PaintUnreadBadge(
p,
state->string,
state->widget.width(),

View File

@ -9,10 +9,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_common.h"
namespace Dialogs::Ui {
using namespace ::Ui;
namespace Ui {
struct UnreadBadgeStyle;
} // namespace Dialogs::Ui
} // namespace Ui
namespace Main {
class Account;
@ -44,7 +43,7 @@ void UpdatePhotoLocally(not_null<UserData*> user, const QImage &image);
namespace Badge {
[[nodiscard]] Dialogs::Ui::UnreadBadgeStyle Style();
[[nodiscard]] Ui::UnreadBadgeStyle Style();
struct UnreadBadge {
int count = 0;

View File

@ -19,9 +19,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_premium.h"
#include "boxes/language_box.h"
#include "boxes/username_box.h"
#include "ui/boxes/confirm_box.h"
#include "boxes/about_box.h"
#include "ui/basic_click_handlers.h"
#include "ui/boxes/confirm_box.h"
#include "ui/controls/userpic_button.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/wrap/slide_wrap.h"
#include "ui/wrap/padding_wrap.h"
@ -30,7 +31,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/buttons.h"
#include "ui/text/text_utilities.h"
#include "ui/toast/toast.h"
#include "ui/special_buttons.h"
#include "info/profile/info_profile_badge.h"
#include "info/profile/info_profile_emoji_status_panel.h"
#include "data/data_user.h"

View File

@ -0,0 +1,67 @@
/*
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 "ui/controls/jump_down_button.h"
#include "ui/effects/ripple_animation.h"
#include "ui/unread_badge_paint.h"
#include "styles/style_chat.h"
namespace Ui {
JumpDownButton::JumpDownButton(
QWidget *parent,
const style::TwoIconButton &st)
: RippleButton(parent, st.ripple)
, _st(st) {
resize(_st.width, _st.height);
setCursor(style::cur_pointer);
hide();
}
QImage JumpDownButton::prepareRippleMask() const {
return Ui::RippleAnimation::EllipseMask(
QSize(_st.rippleAreaSize, _st.rippleAreaSize));
}
QPoint JumpDownButton::prepareRippleStartPosition() const {
return mapFromGlobal(QCursor::pos()) - _st.rippleAreaPosition;
}
void JumpDownButton::paintEvent(QPaintEvent *e) {
auto p = QPainter(this);
const auto over = isOver();
const auto down = isDown();
((over || down)
? _st.iconBelowOver
: _st.iconBelow).paint(p, _st.iconPosition, width());
paintRipple(p, _st.rippleAreaPosition.x(), _st.rippleAreaPosition.y());
((over || down)
? _st.iconAboveOver
: _st.iconAbove).paint(p, _st.iconPosition, width());
if (_unreadCount > 0) {
auto unreadString = QString::number(_unreadCount);
Ui::UnreadBadgeStyle st;
st.align = style::al_center;
st.font = st::historyToDownBadgeFont;
st.size = st::historyToDownBadgeSize;
st.sizeId = Ui::UnreadBadgeSize::HistoryToDown;
Ui::PaintUnreadBadge(p, unreadString, width(), 0, st, 4);
}
}
void JumpDownButton::setUnreadCount(int unreadCount) {
if (_unreadCount != unreadCount) {
_unreadCount = unreadCount;
update();
}
}
} // namespace Ui

View File

@ -0,0 +1,36 @@
/*
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/buttons.h"
namespace Ui {
class JumpDownButton final : public RippleButton {
public:
JumpDownButton(QWidget *parent, const style::TwoIconButton &st);
void setUnreadCount(int unreadCount);
[[nodiscard]] int unreadCount() const {
return _unreadCount;
}
protected:
void paintEvent(QPaintEvent *e) override;
QImage prepareRippleMask() const override;
QPoint prepareRippleStartPosition() const override;
private:
const style::TwoIconButton &_st;
int _unreadCount = 0;
};
} // namespace Ui

View File

@ -0,0 +1,112 @@
/*
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 "ui/controls/silent_toggle.h"
#include "ui/effects/ripple_animation.h"
#include "data/notify/data_notify_settings.h"
#include "data/data_session.h"
#include "data/data_channel.h"
#include "lang/lang_keys.h"
#include "styles/style_chat.h"
namespace Ui {
namespace {
constexpr auto kAnimationDuration = crl::time(120);
} // namespace
SilentToggle::SilentToggle(QWidget *parent, not_null<ChannelData*> channel)
: RippleButton(parent, st::historySilentToggle.ripple)
, _st(st::historySilentToggle)
, _channel(channel)
, _checked(channel->owner().notifySettings().silentPosts(_channel)) {
Expects(!channel->owner().notifySettings().silentPostsUnknown(_channel));
resize(_st.width, _st.height);
paintRequest(
) | rpl::start_with_next([=](const QRect &clip) {
auto p = QPainter(this);
paintRipple(p, _st.rippleAreaPosition, nullptr);
//const auto checked = _crossLineAnimation.value(_checked ? 1. : 0.);
const auto over = isOver();
(_checked
? (over
? st::historySilentToggleOnOver
: st::historySilentToggleOn)
: (over
? st::historySilentToggle.iconOver
: st::historySilentToggle.icon)).paintInCenter(p, rect());
}, lifetime());
setMouseTracking(true);
}
void SilentToggle::mouseMoveEvent(QMouseEvent *e) {
RippleButton::mouseMoveEvent(e);
if (rect().contains(e->pos())) {
Ui::Tooltip::Show(1000, this);
} else {
Ui::Tooltip::Hide();
}
}
void SilentToggle::setChecked(bool checked) {
if (_checked != checked) {
_checked = checked;
_crossLineAnimation.start(
[=] { update(); },
_checked ? 0. : 1.,
_checked ? 1. : 0.,
kAnimationDuration);
}
}
void SilentToggle::leaveEventHook(QEvent *e) {
RippleButton::leaveEventHook(e);
Ui::Tooltip::Hide();
}
void SilentToggle::mouseReleaseEvent(QMouseEvent *e) {
setChecked(!_checked);
RippleButton::mouseReleaseEvent(e);
Ui::Tooltip::Show(0, this);
_channel->owner().notifySettings().update(_channel, {}, _checked);
}
QString SilentToggle::tooltipText() const {
return _checked
? tr::lng_wont_be_notified(tr::now)
: tr::lng_will_be_notified(tr::now);
}
QPoint SilentToggle::tooltipPos() const {
return QCursor::pos();
}
bool SilentToggle::tooltipWindowActive() const {
return Ui::AppInFocus() && InFocusChain(window());
}
QPoint SilentToggle::prepareRippleStartPosition() const {
const auto result = mapFromGlobal(QCursor::pos())
- _st.rippleAreaPosition;
const auto rect = QRect(0, 0, _st.rippleAreaSize, _st.rippleAreaSize);
return rect.contains(result)
? result
: DisabledRippleStartPosition();
}
QImage SilentToggle::prepareRippleMask() const {
return RippleAnimation::EllipseMask(
QSize(_st.rippleAreaSize, _st.rippleAreaSize));
}
} // namespace Ui

View File

@ -0,0 +1,49 @@
/*
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/buttons.h"
#include "ui/widgets/tooltip.h"
namespace Ui {
class SilentToggle final
: public RippleButton
, public AbstractTooltipShower {
public:
SilentToggle(QWidget *parent, not_null<ChannelData*> channel);
void setChecked(bool checked);
bool checked() const {
return _checked;
}
// AbstractTooltipShower interface
QString tooltipText() const override;
QPoint tooltipPos() const override;
bool tooltipWindowActive() const override;
protected:
void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void leaveEventHook(QEvent *e) override;
QImage prepareRippleMask() const override;
QPoint prepareRippleStartPosition() const override;
private:
const style::IconButton &_st;
not_null<ChannelData*> _channel;
bool _checked = false;
Animations::Simple _crossLineAnimation;
};
} // namespace Ui

View File

@ -5,36 +5,26 @@ 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 "ui/special_buttons.h"
#include "ui/controls/userpic_button.h"
#include "base/call_delayed.h"
#include "dialogs/ui/dialogs_layout.h"
#include "ui/effects/ripple_animation.h"
#include "ui/effects/radial_animation.h"
#include "ui/image/image_prepare.h"
#include "ui/empty_userpic.h"
#include "ui/ui_utility.h"
#include "data/notify/data_notify_settings.h"
#include "data/data_photo.h"
#include "data/data_session.h"
#include "data/data_folder.h"
#include "data/data_channel.h"
#include "data/data_cloud_file.h"
#include "data/data_changes.h"
#include "data/data_user.h"
#include "data/data_streaming.h"
#include "data/data_file_origin.h"
#include "history/history.h"
#include "core/file_utilities.h"
#include "calls/calls_instance.h"
#include "core/application.h"
#include "ui/boxes/confirm_box.h"
#include "ui/layers/generic_box.h"
#include "ui/painter.h"
#include "editor/photo_editor_layer_widget.h"
#include "media/streaming/media_streaming_instance.h"
#include "media/streaming/media_streaming_player.h"
#include "media/streaming/media_streaming_document.h"
#include "settings/settings_calls.h" // Calls::AddCameraSubsection.
#include "calls/calls_instance.h"
#include "webrtc/webrtc_media_devices.h" // Webrtc::GetVideoInputList.
#include "webrtc/webrtc_video_track.h"
#include "ui/widgets/popup_menu.h"
@ -45,15 +35,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h"
#include "api/api_peer_photo.h"
#include "styles/style_boxes.h"
#include "styles/style_chat.h"
#include "styles/style_menu_icons.h"
namespace Ui {
namespace {
constexpr auto kAnimationDuration = crl::time(120);
bool IsCameraAvailable() {
[[nodiscard]] bool IsCameraAvailable() {
return (Core::App().calls().currentCall() == nullptr)
&& !Webrtc::GetVideoInputList().empty();
}
@ -99,16 +86,6 @@ void CameraBox(
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
}
QString CropTitle(not_null<PeerData*> peer) {
if (peer->isChat() || peer->isMegagroup()) {
return tr::lng_create_group_crop(tr::now);
} else if (peer->isChannel()) {
return tr::lng_create_channel_crop(tr::now);
} else {
return tr::lng_settings_crop_profile(tr::now);
}
}
template <typename Callback>
QPixmap CreateSquarePixmap(int width, Callback &&paintCallback) {
auto size = QSize(width, width) * cIntRetinaFactor();
@ -124,49 +101,6 @@ QPixmap CreateSquarePixmap(int width, Callback &&paintCallback) {
} // namespace
HistoryDownButton::HistoryDownButton(QWidget *parent, const style::TwoIconButton &st) : RippleButton(parent, st.ripple)
, _st(st) {
resize(_st.width, _st.height);
setCursor(style::cur_pointer);
hide();
}
QImage HistoryDownButton::prepareRippleMask() const {
return Ui::RippleAnimation::EllipseMask(QSize(_st.rippleAreaSize, _st.rippleAreaSize));
}
QPoint HistoryDownButton::prepareRippleStartPosition() const {
return mapFromGlobal(QCursor::pos()) - _st.rippleAreaPosition;
}
void HistoryDownButton::paintEvent(QPaintEvent *e) {
auto p = QPainter(this);
const auto over = isOver();
const auto down = isDown();
((over || down) ? _st.iconBelowOver : _st.iconBelow).paint(p, _st.iconPosition, width());
paintRipple(p, _st.rippleAreaPosition.x(), _st.rippleAreaPosition.y());
((over || down) ? _st.iconAboveOver : _st.iconAbove).paint(p, _st.iconPosition, width());
if (_unreadCount > 0) {
auto unreadString = QString::number(_unreadCount);
Dialogs::Ui::UnreadBadgeStyle st;
st.align = style::al_center;
st.font = st::historyToDownBadgeFont;
st.size = st::historyToDownBadgeSize;
st.sizeId = Dialogs::Ui::UnreadBadgeSize::HistoryToDown;
Dialogs::Ui::PaintUnreadBadge(p, unreadString, width(), 0, st, 4);
}
}
void HistoryDownButton::setUnreadCount(int unreadCount) {
if (_unreadCount != unreadCount) {
_unreadCount = unreadCount;
update();
}
}
UserpicButton::UserpicButton(
QWidget *parent,
not_null<Window::Controller*> window,
@ -178,7 +112,6 @@ UserpicButton::UserpicButton(
, _controller(window->sessionController())
, _window(window)
, _peer(peer)
, _cropTitle(CropTitle(peer))
, _role(role) {
Expects(_role == Role::ChangePhoto);
@ -189,14 +122,12 @@ UserpicButton::UserpicButton(
UserpicButton::UserpicButton(
QWidget *parent,
not_null<Window::Controller*> window,
const QString &cropTitle,
Role role,
const style::UserpicButton &st)
: RippleButton(parent, st.changeButton.ripple)
, _st(st)
, _controller(window->sessionController())
, _window(window)
, _cropTitle(cropTitle)
, _role(role) {
Expects(_role == Role::ChangePhoto || _role == Role::ChoosePhoto);
@ -215,7 +146,6 @@ UserpicButton::UserpicButton(
, _controller(controller)
, _window(&controller->window())
, _peer(peer)
, _cropTitle(CropTitle(_peer))
, _role(role) {
processPeerPhoto();
prepare();
@ -230,7 +160,6 @@ UserpicButton::UserpicButton(
: RippleButton(parent, st.changeButton.ripple)
, _st(st)
, _peer(peer)
, _cropTitle(CropTitle(_peer))
, _role(role) {
Expects(_role != Role::OpenProfile && _role != Role::OpenPhoto);
@ -240,6 +169,8 @@ UserpicButton::UserpicButton(
setupPeerViewers();
}
UserpicButton::~UserpicButton() = default;
void UserpicButton::prepare() {
resize(_st.size);
_notShownYet = _waiting;
@ -311,15 +242,12 @@ void UserpicButton::choosePhotoLocally() {
st::popupMenuWithIcons);
const auto user = _peer ? _peer->asUser() : nullptr;
if (user && !user->isSelf()) {
const auto name = user->firstName.isEmpty()
? user->name()
: user->firstName;
_menu->addAction(
tr::lng_profile_set_photo_for(tr::now, lt_user, name),
tr::lng_profile_set_photo_for(tr::now),
[=] { chooseFile(); },
&st::menuIconPhotoSet);
_menu->addAction(
tr::lng_profile_suggest_photo(tr::now, lt_user, name),
tr::lng_profile_suggest_photo(tr::now),
[=] { chooseFile(ChosenType::Suggest); },
&st::menuIconPhotoSuggest);
if (user->hasPersonalPhoto()) {
@ -858,92 +786,45 @@ void UserpicButton::prepareUserpicPixmap() {
: InMemoryKey();
}
SilentToggle::SilentToggle(QWidget *parent, not_null<ChannelData*> channel)
: RippleButton(parent, st::historySilentToggle.ripple)
, _st(st::historySilentToggle)
, _channel(channel)
, _checked(channel->owner().notifySettings().silentPosts(_channel)) {
Expects(!channel->owner().notifySettings().silentPostsUnknown(_channel));
not_null<Ui::UserpicButton*> CreateUploadSubButton(
not_null<Ui::RpWidget*> parent,
not_null<Window::SessionController*> controller) {
const auto background = Ui::CreateChild<Ui::RpWidget>(parent.get());
const auto upload = Ui::CreateChild<Ui::UserpicButton>(
parent.get(),
&controller->window(),
Ui::UserpicButton::Role::ChoosePhoto,
st::uploadUserpicButton);
resize(_st.width, _st.height);
const auto border = st::uploadUserpicButtonBorder;
const auto size = upload->rect().marginsAdded(
{ border, border, border, border }
).size();
paintRequest(
) | rpl::start_with_next([=](const QRect &clip) {
auto p = QPainter(this);
paintRipple(p, _st.rippleAreaPosition, nullptr);
background->resize(size);
background->paintRequest(
) | rpl::start_with_next([=] {
auto p = QPainter(background);
auto hq = PainterHighQualityEnabler(p);
p.setBrush(st::boxBg);
p.setPen(Qt::NoPen);
p.drawEllipse(background->rect());
}, background->lifetime());
//const auto checked = _crossLineAnimation.value(_checked ? 1. : 0.);
const auto over = isOver();
(_checked
? (over
? st::historySilentToggleOnOver
: st::historySilentToggleOn)
: (over
? st::historySilentToggle.iconOver
: st::historySilentToggle.icon)).paintInCenter(p, rect());
}, lifetime());
upload->positionValue(
) | rpl::start_with_next([=](QPoint position) {
background->move(position - QPoint(border, border));
}, background->lifetime());
setMouseTracking(true);
return upload;
}
void SilentToggle::mouseMoveEvent(QMouseEvent *e) {
RippleButton::mouseMoveEvent(e);
if (rect().contains(e->pos())) {
Ui::Tooltip::Show(1000, this);
} else {
Ui::Tooltip::Hide();
}
}
void SilentToggle::setChecked(bool checked) {
if (_checked != checked) {
_checked = checked;
_crossLineAnimation.start(
[=] { update(); },
_checked ? 0. : 1.,
_checked ? 1. : 0.,
kAnimationDuration);
}
}
void SilentToggle::leaveEventHook(QEvent *e) {
RippleButton::leaveEventHook(e);
Ui::Tooltip::Hide();
}
void SilentToggle::mouseReleaseEvent(QMouseEvent *e) {
setChecked(!_checked);
RippleButton::mouseReleaseEvent(e);
Ui::Tooltip::Show(0, this);
_channel->owner().notifySettings().update(_channel, {}, _checked);
}
QString SilentToggle::tooltipText() const {
return _checked
? tr::lng_wont_be_notified(tr::now)
: tr::lng_will_be_notified(tr::now);
}
QPoint SilentToggle::tooltipPos() const {
return QCursor::pos();
}
bool SilentToggle::tooltipWindowActive() const {
return Ui::AppInFocus() && InFocusChain(window());
}
QPoint SilentToggle::prepareRippleStartPosition() const {
const auto result = mapFromGlobal(QCursor::pos())
- _st.rippleAreaPosition;
const auto rect = QRect(0, 0, _st.rippleAreaSize, _st.rippleAreaSize);
return rect.contains(result)
? result
: DisabledRippleStartPosition();
}
QImage SilentToggle::prepareRippleMask() const {
return RippleAnimation::EllipseMask(
QSize(_st.rippleAreaSize, _st.rippleAreaSize));
not_null<Ui::UserpicButton*> CreateUploadSubButton(
not_null<Ui::RpWidget*> parent,
not_null<UserData*> contact,
not_null<Window::SessionController*> controller) {
const auto result = CreateUploadSubButton(parent, controller);
return result;
}
} // namespace Ui

View File

@ -8,12 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "ui/widgets/buttons.h"
#include "ui/widgets/tooltip.h"
#include "ui/effects/animations.h"
#include "ui/effects/cross_line.h"
#include "ui/userpic_view.h"
#include "styles/style_window.h"
#include "styles/style_widgets.h"
class PeerData;
@ -31,33 +26,15 @@ struct Information;
} // namespace Streaming
} // namespace Media
namespace style {
struct UserpicButton;
} // namespace style
namespace Ui {
class PopupMenu;
class HistoryDownButton : public RippleButton {
public:
HistoryDownButton(QWidget *parent, const style::TwoIconButton &st);
void setUnreadCount(int unreadCount);
int unreadCount() const {
return _unreadCount;
}
protected:
void paintEvent(QPaintEvent *e) override;
QImage prepareRippleMask() const override;
QPoint prepareRippleStartPosition() const override;
private:
const style::TwoIconButton &_st;
int _unreadCount = 0;
};
class UserpicButton : public RippleButton {
class UserpicButton final : public RippleButton {
public:
enum class Role {
ChoosePhoto,
@ -76,7 +53,6 @@ public:
UserpicButton(
QWidget *parent,
not_null<::Window::Controller*> window,
const QString &cropTitle,
Role role,
const style::UserpicButton &st);
UserpicButton(
@ -90,6 +66,7 @@ public:
not_null<PeerData*> peer,
Role role,
const style::UserpicButton &st);
~UserpicButton();
enum class ChosenType {
Set,
@ -163,7 +140,6 @@ private:
::Window::Controller *_window = nullptr;
PeerData *_peer = nullptr;
PeerUserpicView _userpicView;
QString _cropTitle;
Role _role = Role::ChangePhoto;
bool _notShownYet = true;
bool _waiting = false;
@ -190,38 +166,13 @@ private:
};
class SilentToggle final
: public RippleButton
, public AbstractTooltipShower {
public:
SilentToggle(QWidget *parent, not_null<ChannelData*> channel);
[[nodiscard]] not_null<Ui::UserpicButton*> CreateUploadSubButton(
not_null<Ui::RpWidget*> parent,
not_null<Window::SessionController*> controller);
void setChecked(bool checked);
bool checked() const {
return _checked;
}
// AbstractTooltipShower interface
QString tooltipText() const override;
QPoint tooltipPos() const override;
bool tooltipWindowActive() const override;
protected:
void mouseMoveEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void leaveEventHook(QEvent *e) override;
QImage prepareRippleMask() const override;
QPoint prepareRippleStartPosition() const override;
private:
const style::IconButton &_st;
not_null<ChannelData*> _channel;
bool _checked = false;
Animations::Simple _crossLineAnimation;
};
[[nodiscard]] not_null<Ui::UserpicButton*> CreateUploadSubButton(
not_null<Ui::RpWidget*> parent,
not_null<UserData*> contact,
not_null<Window::SessionController*> controller);
} // namespace Ui

View File

@ -12,9 +12,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h"
#include "data/stickers/data_custom_emoji.h"
#include "main/main_session.h"
#include "dialogs/ui/dialogs_layout.h"
#include "lang/lang_keys.h"
#include "ui/painter.h"
#include "ui/unread_badge_paint.h"
#include "styles/style_dialogs.h"
namespace Ui {
@ -46,11 +46,11 @@ void UnreadBadge::paintEvent(QPaintEvent *e) {
auto p = QPainter(this);
Dialogs::Ui::UnreadBadgeStyle unreadSt;
UnreadBadgeStyle unreadSt;
unreadSt.muted = !_active;
auto unreadRight = width();
auto unreadTop = 0;
Dialogs::Ui::PaintUnreadBadge(
PaintUnreadBadge(
p,
_text,
unreadRight,

View File

@ -0,0 +1,183 @@
/*
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 "ui/unread_badge_paint.h"
#include "ui/ui_utility.h"
#include "styles/style_dialogs.h"
namespace Ui {
namespace {
struct UnreadBadgeSizeData {
QImage circle;
QPixmap left[6], right[6];
};
class UnreadBadgeStyleData {
public:
UnreadBadgeStyleData();
UnreadBadgeSizeData sizes[static_cast<int>(UnreadBadgeSize::kCount)];
style::color bg[6] = {
st::dialogsUnreadBg,
st::dialogsUnreadBgOver,
st::dialogsUnreadBgActive,
st::dialogsUnreadBgMuted,
st::dialogsUnreadBgMutedOver,
st::dialogsUnreadBgMutedActive
};
style::color reactionBg[6] = {
st::dialogsDraftFg,
st::dialogsDraftFgOver,
st::dialogsDraftFgActive,
st::dialogsUnreadBgMuted,
st::dialogsUnreadBgMutedOver,
st::dialogsUnreadBgMutedActive
};
rpl::lifetime lifetime;
};
UnreadBadgeStyleData::UnreadBadgeStyleData() {
style::PaletteChanged(
) | rpl::start_with_next([=] {
for (auto &data : sizes) {
for (auto &left : data.left) {
left = QPixmap();
}
for (auto &right : data.right) {
right = QPixmap();
}
}
}, lifetime);
}
UnreadBadgeStyleData &UnreadBadgeStyles() {
static auto result = UnreadBadgeStyleData();
return result;
}
void CreateCircleMask(UnreadBadgeSizeData *data, int size) {
if (!data->circle.isNull()) {
return;
}
data->circle = style::createCircleMask(size);
}
[[nodiscard]] QImage ColorizeCircleHalf(
UnreadBadgeSizeData *data,
int size,
int half,
int xoffset,
style::color color) {
auto result = style::colorizeImage(data->circle, color, QRect(xoffset, 0, half, size));
result.setDevicePixelRatio(style::DevicePixelRatio());
return result;
}
[[nodiscard]] QString ComputeUnreadBadgeText(
const QString &unreadCount,
int allowDigits) {
return (allowDigits > 0) && (unreadCount.size() > allowDigits + 1)
? u".."_q + unreadCount.mid(unreadCount.size() - allowDigits)
: unreadCount;
}
void PaintUnreadBadge(QPainter &p, const QRect &rect, const UnreadBadgeStyle &st) {
Assert(rect.height() == st.size);
int index = (st.muted ? 0x03 : 0x00) + (st.active ? 0x02 : (st.selected ? 0x01 : 0x00));
int size = st.size, sizehalf = size / 2;
auto &styles = UnreadBadgeStyles();
auto badgeData = styles.sizes;
if (st.sizeId > UnreadBadgeSize()) {
Assert(st.sizeId < UnreadBadgeSize::kCount);
badgeData = &styles.sizes[static_cast<int>(st.sizeId)];
}
const auto bg = (st.sizeId == UnreadBadgeSize::ReactionInDialogs)
? styles.reactionBg[index]
: styles.bg[index];
if (badgeData->left[index].isNull()) {
const auto ratio = style::DevicePixelRatio();
int imgsize = size * ratio, imgsizehalf = sizehalf * ratio;
CreateCircleMask(badgeData, size);
badgeData->left[index] = PixmapFromImage(
ColorizeCircleHalf(badgeData, imgsize, imgsizehalf, 0, bg));
badgeData->right[index] = PixmapFromImage(ColorizeCircleHalf(
badgeData,
imgsize,
imgsizehalf,
imgsize - imgsizehalf,
bg));
}
int bar = rect.width() - 2 * sizehalf;
p.drawPixmap(rect.x(), rect.y(), badgeData->left[index]);
if (bar) {
p.fillRect(rect.x() + sizehalf, rect.y(), bar, rect.height(), bg);
}
p.drawPixmap(rect.x() + sizehalf + bar, rect.y(), badgeData->right[index]);
}
} // namespace
UnreadBadgeStyle::UnreadBadgeStyle()
: size(st::dialogsUnreadHeight)
, padding(st::dialogsUnreadPadding)
, font(st::dialogsUnreadFont) {
}
QSize CountUnreadBadgeSize(
const QString &unreadCount,
const UnreadBadgeStyle &st,
int allowDigits) {
const auto text = ComputeUnreadBadgeText(unreadCount, allowDigits);
const auto unreadRectHeight = st.size;
const auto unreadWidth = st.font->width(text);
return {
std::max(unreadWidth + 2 * st.padding, unreadRectHeight),
unreadRectHeight,
};
}
QRect PaintUnreadBadge(
QPainter &p,
const QString &unreadCount,
int x,
int y,
const UnreadBadgeStyle &st,
int allowDigits) {
const auto text = ComputeUnreadBadgeText(unreadCount, allowDigits);
const auto unreadRectHeight = st.size;
const auto unreadWidth = st.font->width(text);
const auto unreadRectWidth = std::max(
unreadWidth + 2 * st.padding,
unreadRectHeight);
const auto unreadRectLeft = ((st.align & Qt::AlignHorizontal_Mask) & style::al_center)
? (x - unreadRectWidth) / 2
: ((st.align & Qt::AlignHorizontal_Mask) & style::al_right)
? (x - unreadRectWidth)
: x;
const auto unreadRectTop = y;
const auto badge = QRect(unreadRectLeft, unreadRectTop, unreadRectWidth, unreadRectHeight);
PaintUnreadBadge(p, badge, st);
const auto textTop = st.textTop ? st.textTop : (unreadRectHeight - st.font->height) / 2;
p.setFont(st.font);
p.setPen(st.active
? st::dialogsUnreadFgActive
: st.selected
? st::dialogsUnreadFgOver
: st::dialogsUnreadFg);
p.drawText(unreadRectLeft + (unreadRectWidth - unreadWidth) / 2, unreadRectTop + textTop + st.font->ascent, text);
return badge;
}
} // namespace Ui

View File

@ -0,0 +1,50 @@
/*
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
namespace Ui {
enum class UnreadBadgeSize {
Dialogs,
MainMenu,
HistoryToDown,
StickersPanel,
StickersBox,
TouchBar,
ReactionInDialogs,
kCount,
};
struct UnreadBadgeStyle {
UnreadBadgeStyle();
style::align align = style::al_right;
bool active = false;
bool selected = false;
bool muted = false;
int textTop = 0;
int size = 0;
int padding = 0;
UnreadBadgeSize sizeId = UnreadBadgeSize::Dialogs;
style::font font;
};
[[nodiscard]] QSize CountUnreadBadgeSize(
const QString &unreadCount,
const UnreadBadgeStyle &st,
int allowDigits = 0);
QRect PaintUnreadBadge(
QPainter &p,
const QString &t,
int x,
int y,
const UnreadBadgeStyle &st,
int allowDigits = 0);
} // namespace Ui

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_session_controller.h"
#include "window/window_controller.h"
#include "ui/chat/chat_theme.h"
#include "ui/controls/userpic_button.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h"
#include "ui/widgets/popup_menu.h"
@ -24,9 +25,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_utilities.h"
#include "ui/text/text_options.h"
#include "ui/painter.h"
#include "ui/special_buttons.h"
#include "ui/empty_userpic.h"
#include "dialogs/ui/dialogs_layout.h"
#include "ui/unread_badge_paint.h"
#include "base/call_delayed.h"
#include "mainwindow.h"
#include "storage/localstorage.h"
@ -271,7 +271,7 @@ void MainMenu::ToggleAccountsButton::paintUnreadBadge(Painter &p) {
- st::mainMenuTogglePosition.y()
- st::mainMenuBadgeSize / 2;
p.setOpacity(progress);
Dialogs::Ui::PaintUnreadBadge(p, _unreadBadge, right, top, st);
Ui::PaintUnreadBadge(p, _unreadBadge, right, top, st);
}
void MainMenu::ToggleAccountsButton::validateUnreadBadge() {
@ -289,7 +289,7 @@ void MainMenu::ToggleAccountsButton::validateUnreadBadge() {
if (!_unreadBadge.isEmpty()) {
const auto st = Settings::Badge::Style();
skip += 2 * st::mainMenuToggleSize
+ Dialogs::Ui::CountUnreadBadgeSize(_unreadBadge, st).width();
+ Ui::CountUnreadBadgeSize(_unreadBadge, st).width();
}
_rightSkip = skip;
}

View File

@ -218,6 +218,8 @@ PRIVATE
ui/controls/download_bar.h
ui/controls/emoji_button.cpp
ui/controls/emoji_button.h
ui/controls/jump_down_button.cpp
ui/controls/jump_down_button.h
ui/controls/invite_link_buttons.cpp
ui/controls/invite_link_buttons.h
ui/controls/invite_link_label.cpp
@ -278,6 +280,8 @@ PRIVATE
ui/empty_userpic.h
ui/grouped_layout.cpp
ui/grouped_layout.h
ui/unread_badge_paint.cpp
ui/unread_badge_paint.h
ui/userpic_view.cpp
ui/userpic_view.h
ui/widgets/fields/special_fields.cpp