mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Remove ui/special_buttons module.
This commit is contained in:
parent
14f113266f
commit
faf6c48f25
54 changed files with 737 additions and 588 deletions
|
@ -1260,6 +1260,10 @@ PRIVATE
|
||||||
ui/chat/choose_send_as.h
|
ui/chat/choose_send_as.h
|
||||||
ui/chat/choose_theme_controller.cpp
|
ui/chat/choose_theme_controller.cpp
|
||||||
ui/chat/choose_theme_controller.h
|
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.cpp
|
||||||
ui/effects/emoji_fly_animation.h
|
ui/effects/emoji_fly_animation.h
|
||||||
ui/effects/message_sending_animation_common.h
|
ui/effects/message_sending_animation_common.h
|
||||||
|
@ -1288,8 +1292,6 @@ PRIVATE
|
||||||
ui/resize_area.h
|
ui/resize_area.h
|
||||||
ui/search_field_controller.cpp
|
ui/search_field_controller.cpp
|
||||||
ui/search_field_controller.h
|
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.cpp
|
||||||
ui/text/format_song_document_name.h
|
ui/text/format_song_document_name.h
|
||||||
ui/unread_badge.cpp
|
ui/unread_badge.cpp
|
||||||
|
|
|
@ -393,8 +393,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
"lng_settings_save" = "Save";
|
"lng_settings_save" = "Save";
|
||||||
"lng_settings_upload" = "Set Profile Photo";
|
"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_edit" = "Edit";
|
||||||
"lng_settings_drop_area_subtitle" = "to set it as your photo";
|
"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_profile_send_message" = "Send Message";
|
||||||
"lng_info_add_as_contact" = "Add to contacts";
|
"lng_info_add_as_contact" = "Add to contacts";
|
||||||
"lng_profile_shared_media" = "Shared media";
|
"lng_profile_shared_media" = "Shared media";
|
||||||
"lng_profile_suggest_photo" = "Suggest Photo for {user}";
|
"lng_profile_suggest_photo" = "Suggest Profile Photo";
|
||||||
"lng_profile_set_photo_for" = "Set Photo for {user}";
|
"lng_profile_set_photo_for" = "Set Profile Photo";
|
||||||
"lng_profile_photo_reset" = "Reset to Original Photo";
|
"lng_profile_photo_reset" = "Reset to Original";
|
||||||
"lng_media_type_photos" = "Photos";
|
"lng_media_type_photos" = "Photos";
|
||||||
"lng_media_type_gifs" = "GIFs";
|
"lng_media_type_gifs" = "GIFs";
|
||||||
"lng_media_type_videos" = "Videos";
|
"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_pending" = "Checking name...";
|
||||||
"lng_create_channel_link_copied" = "Link copied to clipboard";
|
"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_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" = "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).";
|
"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).";
|
||||||
|
|
|
@ -363,4 +363,21 @@ void PeerPhoto::requestUserPhotos(
|
||||||
_userPhotosRequests.emplace(user, requestId);
|
_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
|
} // namespace Api
|
||||||
|
|
|
@ -33,6 +33,14 @@ public:
|
||||||
|
|
||||||
void requestUserPhotos(not_null<UserData*> user, UserPhotoId afterId);
|
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:
|
private:
|
||||||
void ready(const FullMsgId &msgId, const MTPInputFile &file);
|
void ready(const FullMsgId &msgId, const MTPInputFile &file);
|
||||||
void upload(not_null<PeerData*> peer, QImage &&image, bool suggestion);
|
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*>, mtpRequestId> _userPhotosRequests;
|
||||||
|
|
||||||
|
base::flat_map<
|
||||||
|
not_null<UserData*>,
|
||||||
|
not_null<PhotoData*>> _nonPersonalPhotos;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Api
|
} // namespace Api
|
||||||
|
|
|
@ -22,11 +22,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "countries/countries_instance.h" // Countries::ExtractPhoneCode.
|
#include "countries/countries_instance.h" // Countries::ExtractPhoneCode.
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "menu/menu_ttl.h"
|
#include "menu/menu_ttl.h"
|
||||||
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "ui/widgets/fields/special_fields.h"
|
#include "ui/widgets/fields/special_fields.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/text/format_values.h"
|
#include "ui/text/format_values.h"
|
||||||
|
@ -465,9 +465,6 @@ void GroupInfoBox::prepare() {
|
||||||
_photo.create(
|
_photo.create(
|
||||||
this,
|
this,
|
||||||
&_navigation->parentController()->window(),
|
&_navigation->parentController()->window(),
|
||||||
((_type == Type::Channel)
|
|
||||||
? tr::lng_create_channel_crop
|
|
||||||
: tr::lng_create_group_crop)(tr::now),
|
|
||||||
Ui::UserpicButton::Role::ChangePhoto,
|
Ui::UserpicButton::Role::ChangePhoto,
|
||||||
st::defaultUserpicButton);
|
st::defaultUserpicButton);
|
||||||
_title.create(
|
_title.create(
|
||||||
|
|
|
@ -62,6 +62,14 @@ defaultUserpicButton: UserpicButton {
|
||||||
uploadIcon: defaultUploadUserpicIcon;
|
uploadIcon: defaultUploadUserpicIcon;
|
||||||
uploadIconPosition: point(-1px, 1px);
|
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) {
|
confirmInviteTitle: FlatLabel(defaultFlatLabel) {
|
||||||
align: align(center);
|
align: align(center);
|
||||||
|
|
|
@ -19,10 +19,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "settings/settings_premium.h"
|
#include "settings/settings_premium.h"
|
||||||
#include "ui/basic_click_handlers.h" // UrlClickHandler::Open.
|
#include "ui/basic_click_handlers.h" // UrlClickHandler::Open.
|
||||||
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/effects/premium_graphics.h"
|
#include "ui/effects/premium_graphics.h"
|
||||||
#include "ui/effects/premium_stars_colored.h"
|
#include "ui/effects/premium_stars_colored.h"
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "ui/text/format_values.h"
|
#include "ui/text/format_values.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
|
|
|
@ -136,15 +136,16 @@ void Controller::setupContent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::setupCover() {
|
void Controller::setupCover() {
|
||||||
_box->addRow(
|
const auto cover = _box->addRow(
|
||||||
object_ptr<Info::Profile::Cover>(
|
object_ptr<Info::Profile::Cover>(
|
||||||
_box,
|
_box,
|
||||||
_user,
|
|
||||||
_window,
|
_window,
|
||||||
|
_user,
|
||||||
|
Info::Profile::Cover::Role::EditContact,
|
||||||
(_phone.isEmpty()
|
(_phone.isEmpty()
|
||||||
? tr::lng_contact_mobile_hidden()
|
? tr::lng_contact_mobile_hidden()
|
||||||
: rpl::single(Ui::FormatPhone(_phone)))),
|
: rpl::single(Ui::FormatPhone(_phone)))),
|
||||||
style::margins())->setAttribute(Qt::WA_TransparentForMouseEvents);
|
style::margins());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::setupNameFields() {
|
void Controller::setupNameFields() {
|
||||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/peers/edit_participant_box.h"
|
#include "boxes/peers/edit_participant_box.h"
|
||||||
|
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
#include "ui/wrap/padding_wrap.h"
|
#include "ui/wrap/padding_wrap.h"
|
||||||
#include "ui/wrap/slide_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/toast/toast.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/text/text_options.h"
|
#include "ui/text/text_options.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||||
#include "settings/settings_privacy_security.h"
|
#include "settings/settings_privacy_security.h"
|
||||||
|
|
|
@ -43,8 +43,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
#include "main/main_app_config.h"
|
#include "main/main_app_config.h"
|
||||||
#include "settings/settings_common.h"
|
#include "settings/settings_common.h"
|
||||||
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/rp_widget.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "ui/toasts/common_toasts.h"
|
#include "ui/toasts/common_toasts.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
|
|
|
@ -29,7 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
#include "ui/rp_widget.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/buttons.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "ui/widgets/input_fields.h"
|
#include "ui/widgets/input_fields.h"
|
||||||
|
|
|
@ -21,7 +21,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/sticker_set_box.h"
|
#include "boxes/sticker_set_box.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "storage/storage_account.h"
|
#include "storage/storage_account.h"
|
||||||
#include "dialogs/ui/dialogs_layout.h"
|
|
||||||
#include "lottie/lottie_single_player.h"
|
#include "lottie/lottie_single_player.h"
|
||||||
#include "chat_helpers/stickers_lottie.h"
|
#include "chat_helpers/stickers_lottie.h"
|
||||||
#include "ui/widgets/buttons.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/image/image.h"
|
||||||
#include "ui/cached_round_corners.h"
|
#include "ui/cached_round_corners.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/unread_badge_paint.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "media/clip/media_clip_reader.h"
|
#include "media/clip/media_clip_reader.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
@ -66,7 +66,7 @@ private:
|
||||||
void setCounter(int counter);
|
void setCounter(int counter);
|
||||||
|
|
||||||
QString _text;
|
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 dummy = QImage(1, 1, QImage::Format_ARGB32_Premultiplied);
|
||||||
auto p = QPainter(&dummy);
|
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);
|
resize(badge.width(), st::stickersFeaturedBadgeSize);
|
||||||
}
|
}
|
||||||
|
@ -346,7 +346,7 @@ void StickersBox::CounterWidget::paintEvent(QPaintEvent *e) {
|
||||||
if (!_text.isEmpty()) {
|
if (!_text.isEmpty()) {
|
||||||
const auto unreadRight = rtl() ? 0 : width();
|
const auto unreadRight = rtl() ? 0 : width();
|
||||||
const auto unreadTop = 0;
|
const auto unreadTop = 0;
|
||||||
Dialogs::Ui::PaintUnreadBadge(p, _text, unreadRight, unreadTop, _st);
|
Ui::PaintUnreadBadge(p, _text, unreadRight, unreadTop, _st);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/tooltip.h"
|
#include "ui/widgets/tooltip.h"
|
||||||
#include "ui/widgets/rp_window.h"
|
#include "ui/widgets/rp_window.h"
|
||||||
#include "ui/chat/group_call_bar.h"
|
#include "ui/chat/group_call_bar.h"
|
||||||
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/layers/layer_manager.h"
|
#include "ui/layers/layer_manager.h"
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
#include "ui/text/text_utilities.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/image/image_prepare.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "ui/round_rect.h"
|
#include "ui/round_rect.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "info/profile/info_profile_values.h" // Info::Profile::Value.
|
#include "info/profile/info_profile_values.h" // Info::Profile::Value.
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<QString> _usernames;
|
std::vector<QString> _usernames;
|
||||||
short _indexEditableUsername = -1;
|
int _indexEditableUsername = -1;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/chat/requests_bar.h"
|
#include "ui/chat/requests_bar.h"
|
||||||
#include "ui/chat/group_call_bar.h"
|
#include "ui/chat/group_call_bar.h"
|
||||||
#include "ui/controls/download_bar.h"
|
#include "ui/controls/download_bar.h"
|
||||||
|
#include "ui/controls/jump_down_button.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
|
|
@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/section_widget.h"
|
#include "window/section_widget.h"
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
#include "api/api_single_message_search.h"
|
#include "api/api_single_message_search.h"
|
||||||
|
|
||||||
|
@ -44,6 +43,7 @@ class PlainShadow;
|
||||||
class DownloadBar;
|
class DownloadBar;
|
||||||
class GroupCallBar;
|
class GroupCallBar;
|
||||||
class RequestsBar;
|
class RequestsBar;
|
||||||
|
class JumpDownButton;
|
||||||
template <typename Widget>
|
template <typename Widget>
|
||||||
class FadeWrapScaled;
|
class FadeWrapScaled;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
@ -247,7 +247,7 @@ private:
|
||||||
rpl::variable<float64> _shownProgressValue;
|
rpl::variable<float64> _shownProgressValue;
|
||||||
|
|
||||||
Ui::Animations::Simple _scrollToTopShown;
|
Ui::Animations::Simple _scrollToTopShown;
|
||||||
object_ptr<Ui::HistoryDownButton> _scrollToTop;
|
object_ptr<Ui::JumpDownButton> _scrollToTop;
|
||||||
bool _scrollToTopIsShown = false;
|
bool _scrollToTopIsShown = false;
|
||||||
bool _forumSearchRequested = false;
|
bool _forumSearchRequested = false;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "dialogs/ui/dialogs_layout.h"
|
#include "dialogs/ui/dialogs_layout.h"
|
||||||
|
|
||||||
#include "data/data_abstract_structure.h"
|
|
||||||
#include "data/data_drafts.h"
|
#include "data/data_drafts.h"
|
||||||
#include "data/data_forum_topic.h"
|
#include "data/data_forum_topic.h"
|
||||||
#include "data/data_session.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_options.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/unread_badge.h"
|
#include "ui/unread_badge.h"
|
||||||
|
#include "ui/unread_badge_paint.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "ui/ui_utility.h"
|
|
||||||
#include "core/ui_integration.h"
|
#include "core/ui_integration.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "support/support_helper.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
|
} // namespace
|
||||||
|
|
||||||
const style::icon *ChatTypeIcon(not_null<PeerData*> peer) {
|
const style::icon *ChatTypeIcon(not_null<PeerData*> peer) {
|
||||||
|
@ -835,61 +735,6 @@ const style::icon *ChatTypeIcon(
|
||||||
return nullptr;
|
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(
|
void RowPainter::Paint(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
not_null<const Row*> row,
|
not_null<const Row*> row,
|
||||||
|
|
|
@ -104,42 +104,4 @@ void PaintCollapsedRow(
|
||||||
int unread,
|
int unread,
|
||||||
const PaintContext &context);
|
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
|
} // namespace Dialogs::Ui
|
||||||
|
|
|
@ -490,6 +490,8 @@ void ApiWrap::requestSplitRanges() {
|
||||||
_splits.push_back(MTP_messageRange(
|
_splits.push_back(MTP_messageRange(
|
||||||
MTP_int(1),
|
MTP_int(1),
|
||||||
MTP_int(std::numeric_limits<int>::max())));
|
MTP_int(std::numeric_limits<int>::max())));
|
||||||
|
//} else {
|
||||||
|
// ranges::reverse(_splits);
|
||||||
}
|
}
|
||||||
_startProcess->splitIndex = useOnlyLastSplit()
|
_startProcess->splitIndex = useOnlyLastSplit()
|
||||||
? (_splits.size() - 1)
|
? (_splits.size() - 1)
|
||||||
|
|
|
@ -26,7 +26,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/file_utilities.h"
|
#include "core/file_utilities.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "ui/toasts/common_toasts.h"
|
#include "ui/toasts/common_toasts.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "ui/emoji_config.h"
|
#include "ui/emoji_config.h"
|
||||||
#include "ui/chat/attach/attach_prepare.h"
|
#include "ui/chat/attach/attach_prepare.h"
|
||||||
#include "ui/chat/choose_theme_controller.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/chat/choose_send_as.h"
|
||||||
#include "ui/image/image.h"
|
#include "ui/image/image.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "ui/controls/emoji_button.h"
|
#include "ui/controls/emoji_button.h"
|
||||||
#include "ui/controls/send_button.h"
|
#include "ui/controls/send_button.h"
|
||||||
#include "ui/controls/send_as_button.h"
|
#include "ui/controls/send_as_button.h"
|
||||||
|
#include "ui/controls/silent_toggle.h"
|
||||||
#include "inline_bots/inline_bot_result.h"
|
#include "inline_bots/inline_bot_result.h"
|
||||||
#include "base/event_filter.h"
|
#include "base/event_filter.h"
|
||||||
#include "base/qt_signal_producer.h"
|
#include "base/qt_signal_producer.h"
|
||||||
|
|
|
@ -61,8 +61,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/controls/emoji_button.h"
|
#include "ui/controls/emoji_button.h"
|
||||||
#include "ui/controls/send_button.h"
|
#include "ui/controls/send_button.h"
|
||||||
#include "ui/controls/send_as_button.h"
|
#include "ui/controls/send_as_button.h"
|
||||||
|
#include "ui/controls/silent_toggle.h"
|
||||||
#include "ui/chat/choose_send_as.h"
|
#include "ui/chat/choose_send_as.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "window/window_adaptive.h"
|
#include "window/window_adaptive.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
|
@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
#include "ui/chat/chat_style.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 "base/qt/qt_key_modifiers.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "history/history_item.h"
|
#include "history/history_item.h"
|
||||||
|
|
|
@ -17,7 +17,7 @@ struct FullMsgId;
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ChatStyle;
|
class ChatStyle;
|
||||||
class ScrollArea;
|
class ScrollArea;
|
||||||
class HistoryDownButton;
|
class JumpDownButton;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
@ -32,7 +32,7 @@ struct CornerButton {
|
||||||
CornerButton(Args &&...args) : widget(std::forward<Args>(args)...) {
|
CornerButton(Args &&...args) : widget(std::forward<Args>(args)...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
object_ptr<Ui::HistoryDownButton> widget;
|
object_ptr<Ui::JumpDownButton> widget;
|
||||||
Ui::Animations::Simple animation;
|
Ui::Animations::Simple animation;
|
||||||
bool shown = false;
|
bool shown = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,13 +15,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
#include "ui/widgets/shadow.h"
|
#include "ui/widgets/shadow.h"
|
||||||
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
#include "ui/item_text_options.h"
|
#include "ui/item_text_options.h"
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "ui/text/format_values.h"
|
#include "ui/text/format_values.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "ui/toasts/common_toasts.h"
|
#include "ui/toasts/common_toasts.h"
|
||||||
#include "base/timer_rpl.h"
|
#include "base/timer_rpl.h"
|
||||||
|
|
|
@ -21,7 +21,6 @@ namespace Ui {
|
||||||
class ScrollArea;
|
class ScrollArea;
|
||||||
class PlainShadow;
|
class PlainShadow;
|
||||||
class FlatButton;
|
class FlatButton;
|
||||||
class HistoryDownButton;
|
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Profile {
|
namespace Profile {
|
||||||
|
|
|
@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/chat/attach/attach_send_files_way.h"
|
#include "ui/chat/attach/attach_send_files_way.h"
|
||||||
#include "ui/chat/pinned_bar.h"
|
#include "ui/chat/pinned_bar.h"
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
#include "ui/widgets/shadow.h"
|
#include "ui/widgets/shadow.h"
|
||||||
#include "ui/widgets/popup_menu.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/format_values.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/effects/message_sending_animation_controller.h"
|
#include "ui/effects/message_sending_animation_controller.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "ui/toasts/common_toasts.h"
|
#include "ui/toasts/common_toasts.h"
|
||||||
#include "base/timer_rpl.h"
|
#include "base/timer_rpl.h"
|
||||||
|
|
|
@ -34,7 +34,6 @@ namespace Ui {
|
||||||
class ScrollArea;
|
class ScrollArea;
|
||||||
class PlainShadow;
|
class PlainShadow;
|
||||||
class FlatButton;
|
class FlatButton;
|
||||||
class HistoryDownButton;
|
|
||||||
class PinnedBar;
|
class PinnedBar;
|
||||||
struct PreparedList;
|
struct PreparedList;
|
||||||
class SendFilesWay;
|
class SendFilesWay;
|
||||||
|
|
|
@ -25,7 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/chat/chat_style.h"
|
#include "ui/chat/chat_style.h"
|
||||||
#include "ui/chat/attach/attach_prepare.h"
|
#include "ui/chat/attach/attach_prepare.h"
|
||||||
#include "ui/chat/attach/attach_send_files_way.h"
|
#include "ui/chat/attach/attach_send_files_way.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/toasts/common_toasts.h"
|
#include "ui/toasts/common_toasts.h"
|
||||||
|
|
|
@ -30,8 +30,7 @@ namespace Ui {
|
||||||
class ScrollArea;
|
class ScrollArea;
|
||||||
class PlainShadow;
|
class PlainShadow;
|
||||||
class FlatButton;
|
class FlatButton;
|
||||||
class HistoryDownButton;
|
class PreparedList;
|
||||||
struct PreparedList;
|
|
||||||
class SendFilesWay;
|
class SendFilesWay;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/shortcuts.h"
|
#include "core/shortcuts.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/wrap/fade_wrap.h"
|
#include "ui/wrap/fade_wrap.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/input_fields.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.h"
|
||||||
#include "ui/text/text_options.h"
|
#include "ui/text/text_options.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "ui/unread_badge.h"
|
#include "ui/unread_badge.h"
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "window/window_adaptive.h"
|
#include "window/window_adaptive.h"
|
||||||
|
|
|
@ -325,6 +325,10 @@ infoTopicCover: InfoProfileCover(infoProfileMegagroupCover) {
|
||||||
statusLeft: 79px;
|
statusLeft: 79px;
|
||||||
statusTop: 38px;
|
statusTop: 38px;
|
||||||
}
|
}
|
||||||
|
infoEditContactCover: InfoProfileCover(infoProfileCover) {
|
||||||
|
nameTop: 33px;
|
||||||
|
statusTop: 57px;
|
||||||
|
}
|
||||||
|
|
||||||
infoProfileInaccessibleUserpic: icon {{ "info/inaccessible_userpic", historyPeerUserpicFg }};
|
infoProfileInaccessibleUserpic: icon {{ "info/inaccessible_userpic", historyPeerUserpicFg }};
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/peers/edit_forum_topic_box.h"
|
#include "boxes/peers/edit_forum_topic_box.h"
|
||||||
#include "history/view/media/history_view_sticker_player.h"
|
#include "history/view/media/history_view_sticker_player.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
@ -74,50 +74,21 @@ auto ChatStatusText(int fullCount, int onlineCount, bool isGroup) {
|
||||||
: tr::lng_channel_status(tr::now);
|
: 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(
|
[[nodiscard]] const style::InfoProfileCover &CoverStyle(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
Data::ForumTopic *topic) {
|
Data::ForumTopic *topic,
|
||||||
return topic
|
Cover::Role role) {
|
||||||
|
return (role == Cover::Role::EditContact)
|
||||||
|
? st::infoEditContactCover
|
||||||
|
: topic
|
||||||
? st::infoTopicCover
|
? st::infoTopicCover
|
||||||
: peer->isMegagroup()
|
: peer->isMegagroup()
|
||||||
? st::infoProfileMegagroupCover
|
? st::infoProfileMegagroupCover
|
||||||
: st::infoProfileCover;
|
: st::infoProfileCover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
TopicIconView::TopicIconView(
|
TopicIconView::TopicIconView(
|
||||||
not_null<Data::ForumTopic*> topic,
|
not_null<Data::ForumTopic*> topic,
|
||||||
Fn<bool()> paused,
|
Fn<bool()> paused,
|
||||||
|
@ -273,12 +244,49 @@ TopicIconButton::TopicIconButton(
|
||||||
|
|
||||||
Cover::Cover(
|
Cover::Cover(
|
||||||
QWidget *parent,
|
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,
|
not_null<PeerData*> peer,
|
||||||
Data::ForumTopic *topic,
|
Data::ForumTopic *topic,
|
||||||
not_null<Window::SessionController*> controller,
|
Role role,
|
||||||
rpl::producer<QString> title)
|
rpl::producer<QString> title)
|
||||||
: FixedHeightWidget(parent, CoverStyle(peer, topic).height)
|
: FixedHeightWidget(parent, CoverStyle(peer, topic, role).height)
|
||||||
, _st(CoverStyle(peer, topic))
|
, _st(CoverStyle(peer, topic, role))
|
||||||
|
, _role(role)
|
||||||
, _controller(controller)
|
, _controller(controller)
|
||||||
, _peer(peer)
|
, _peer(peer)
|
||||||
, _emojiStatusPanel(peer->isSelf()
|
, _emojiStatusPanel(peer->isSelf()
|
||||||
|
@ -300,7 +308,9 @@ Cover::Cover(
|
||||||
this,
|
this,
|
||||||
controller,
|
controller,
|
||||||
_peer,
|
_peer,
|
||||||
Ui::UserpicButton::Role::OpenPhoto,
|
(role == Role::Info
|
||||||
|
? Ui::UserpicButton::Role::OpenPhoto
|
||||||
|
: Ui::UserpicButton::Role::Custom),
|
||||||
_st.photo))
|
_st.photo))
|
||||||
, _iconButton(topic
|
, _iconButton(topic
|
||||||
? object_ptr<TopicIconButton>(this, controller, topic)
|
? object_ptr<TopicIconButton>(this, controller, topic)
|
||||||
|
@ -390,7 +400,7 @@ void Cover::initViewers(rpl::producer<QString> title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cover::refreshUploadPhotoOverlay() {
|
void Cover::refreshUploadPhotoOverlay() {
|
||||||
if (!_userpic) {
|
if (!_userpic || _role == Role::EditContact) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,18 +89,24 @@ private:
|
||||||
|
|
||||||
class Cover final : public Ui::FixedHeightWidget {
|
class Cover final : public Ui::FixedHeightWidget {
|
||||||
public:
|
public:
|
||||||
|
enum class Role {
|
||||||
|
Info,
|
||||||
|
EditContact,
|
||||||
|
};
|
||||||
|
|
||||||
Cover(
|
Cover(
|
||||||
QWidget *parent,
|
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<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);
|
rpl::producer<QString> title);
|
||||||
~Cover();
|
~Cover();
|
||||||
|
|
||||||
|
@ -113,9 +119,10 @@ public:
|
||||||
private:
|
private:
|
||||||
Cover(
|
Cover(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
Data::ForumTopic *topic,
|
Data::ForumTopic *topic,
|
||||||
not_null<Window::SessionController*> controller,
|
Role role,
|
||||||
rpl::producer<QString> title);
|
rpl::producer<QString> title);
|
||||||
|
|
||||||
void setupChildGeometry();
|
void setupChildGeometry();
|
||||||
|
@ -127,6 +134,7 @@ private:
|
||||||
|
|
||||||
const style::InfoProfileCover &_st;
|
const style::InfoProfileCover &_st;
|
||||||
|
|
||||||
|
const Role _role = Role::Info;
|
||||||
const not_null<Window::SessionController*> _controller;
|
const not_null<Window::SessionController*> _controller;
|
||||||
const not_null<PeerData*> _peer;
|
const not_null<PeerData*> _peer;
|
||||||
const std::unique_ptr<EmojiStatusPanel> _emojiStatusPanel;
|
const std::unique_ptr<EmojiStatusPanel> _emojiStatusPanel;
|
||||||
|
|
|
@ -67,12 +67,12 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
|
||||||
_cover = _topic
|
_cover = _topic
|
||||||
? result->add(object_ptr<Cover>(
|
? result->add(object_ptr<Cover>(
|
||||||
result,
|
result,
|
||||||
_topic,
|
_controller->parentController(),
|
||||||
_controller->parentController()))
|
_topic))
|
||||||
: result->add(object_ptr<Cover>(
|
: result->add(object_ptr<Cover>(
|
||||||
result,
|
result,
|
||||||
_peer,
|
_controller->parentController(),
|
||||||
_controller->parentController()));
|
_peer));
|
||||||
_cover->showSection(
|
_cover->showSection(
|
||||||
) | rpl::start_with_next([=](Section section) {
|
) | rpl::start_with_next([=](Section section) {
|
||||||
_controller->showSection(_topic
|
_controller->showSection(_topic
|
||||||
|
|
|
@ -11,10 +11,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/file_utilities.h"
|
#include "core/file_utilities.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/input_fields.h"
|
#include "ui/widgets/input_fields.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "styles/style_intro.h"
|
#include "styles/style_intro.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ SignupWidget::SignupWidget(
|
||||||
, _photo(
|
, _photo(
|
||||||
this,
|
this,
|
||||||
data->controller,
|
data->controller,
|
||||||
tr::lng_settings_crop_profile(tr::now),
|
|
||||||
Ui::UserpicButton::Role::ChangePhoto,
|
Ui::UserpicButton::Role::ChangePhoto,
|
||||||
st::defaultUserpicButton)
|
st::defaultUserpicButton)
|
||||||
, _first(this, st::introName, tr::lng_signup_firstname())
|
, _first(this, st::introName, tr::lng_signup_firstname())
|
||||||
|
|
|
@ -31,7 +31,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_histories.h"
|
#include "data/data_histories.h"
|
||||||
#include "data/stickers/data_stickers.h"
|
#include "data/stickers/data_stickers.h"
|
||||||
#include "ui/chat/chat_theme.h"
|
#include "ui/chat/chat_theme.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/shadow.h"
|
#include "ui/widgets/shadow.h"
|
||||||
#include "ui/toasts/common_toasts.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_dialogs.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
#include "styles/style_window.h"
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
#include <QtCore/QMimeData>
|
#include <QtCore/QMimeData>
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
#include "ui/effects/scroll_content_shadow.h"
|
#include "ui/effects/scroll_content_shadow.h"
|
||||||
#include "ui/widgets/buttons.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/wrap/padding_wrap.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/text/text_options.h"
|
#include "ui/text/text_options.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "styles/style_passport.h"
|
#include "styles/style_passport.h"
|
||||||
#include "styles/style_layers.h"
|
#include "styles/style_layers.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
|
|
@ -8,12 +8,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "passport/passport_panel_password.h"
|
#include "passport/passport_panel_password.h"
|
||||||
|
|
||||||
#include "passport/passport_panel_controller.h"
|
#include "passport/passport_panel_controller.h"
|
||||||
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/input_fields.h"
|
#include "ui/widgets/input_fields.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
#include "ui/wrap/padding_wrap.h"
|
#include "ui/wrap/padding_wrap.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "boxes/passcode_box.h"
|
#include "boxes/passcode_box.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
|
|
@ -20,7 +20,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "dialogs/ui/dialogs_layout.h"
|
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
@ -29,6 +28,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
#include "ui/empty_userpic.h"
|
#include "ui/empty_userpic.h"
|
||||||
#include "ui/userpic_view.h"
|
#include "ui/userpic_view.h"
|
||||||
|
#include "ui/unread_badge_paint.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
@ -98,8 +98,8 @@ QImage UnreadBadge(not_null<PeerData*> peer) {
|
||||||
const auto counter = (state.unreadCounter > 0)
|
const auto counter = (state.unreadCounter > 0)
|
||||||
? QString::number(state.unreadCounter)
|
? QString::number(state.unreadCounter)
|
||||||
: QString();
|
: QString();
|
||||||
Dialogs::Ui::UnreadBadgeStyle unreadSt;
|
Ui::UnreadBadgeStyle unreadSt;
|
||||||
unreadSt.sizeId = Dialogs::Ui::UnreadBadgeSize::TouchBar;
|
unreadSt.sizeId = Ui::UnreadBadgeSize::TouchBar;
|
||||||
unreadSt.muted = state.unreadMuted;
|
unreadSt.muted = state.unreadMuted;
|
||||||
// Use constant values to draw badge regardless of cConfigScale().
|
// Use constant values to draw badge regardless of cConfigScale().
|
||||||
unreadSt.size = kUnreadBadgeSize * cRetinaFactor();
|
unreadSt.size = kUnreadBadgeSize * cRetinaFactor();
|
||||||
|
@ -115,7 +115,7 @@ QImage UnreadBadge(not_null<PeerData*> peer) {
|
||||||
result.fill(Qt::transparent);
|
result.fill(Qt::transparent);
|
||||||
Painter p(&result);
|
Painter p(&result);
|
||||||
|
|
||||||
Dialogs::Ui::PaintUnreadBadge(
|
Ui::PaintUnreadBadge(
|
||||||
p,
|
p,
|
||||||
counter,
|
counter,
|
||||||
result.width(),
|
result.width(),
|
||||||
|
|
|
@ -178,14 +178,6 @@ settingsInfoPhoto: UserpicButton(defaultUserpicButton) {
|
||||||
size: size(settingsInfoPhotoSize, settingsInfoPhotoSize);
|
size: size(settingsInfoPhotoSize, settingsInfoPhotoSize);
|
||||||
photoSize: 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;
|
settingsInfoPhotoTop: 0px;
|
||||||
settingsInfoPhotoSkip: 7px;
|
settingsInfoPhotoSkip: 7px;
|
||||||
settingsInfoNameSkip: -1px;
|
settingsInfoNameSkip: -1px;
|
||||||
|
|
|
@ -20,9 +20,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/box_content_divider.h"
|
#include "ui/widgets/box_content_divider.h"
|
||||||
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
|
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "ui/special_buttons.h"
|
#include "ui/unread_badge_paint.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "core/core_settings.h"
|
#include "core/core_settings.h"
|
||||||
#include "chat_helpers/emoji_suggestions_widget.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_peer_values.h"
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
#include "data/data_premium_limits.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_values.h"
|
||||||
#include "info/profile/info_profile_badge.h"
|
#include "info/profile/info_profile_badge.h"
|
||||||
#include "lang/lang_keys.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_layers.h"
|
||||||
#include "styles/style_settings.h"
|
#include "styles/style_settings.h"
|
||||||
#include "styles/style_menu_icons.h"
|
#include "styles/style_menu_icons.h"
|
||||||
|
#include "styles/style_window.h"
|
||||||
|
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
#include <QtGui/QClipboard>
|
#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(
|
void SetupPhoto(
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
|
@ -279,7 +246,7 @@ void SetupPhoto(
|
||||||
self,
|
self,
|
||||||
Ui::UserpicButton::Role::OpenPhoto,
|
Ui::UserpicButton::Role::OpenPhoto,
|
||||||
st::settingsInfoPhoto);
|
st::settingsInfoPhoto);
|
||||||
const auto upload = CreateUploadButton(wrap, controller);
|
const auto upload = CreateUploadSubButton(wrap, controller);
|
||||||
|
|
||||||
upload->chosenImages(
|
upload->chosenImages(
|
||||||
) | rpl::start_with_next([=](Ui::UserpicButton::ChosenImage &&chosen) {
|
) | rpl::start_with_next([=](Ui::UserpicButton::ChosenImage &&chosen) {
|
||||||
|
@ -979,11 +946,11 @@ void UpdatePhotoLocally(not_null<UserData*> user, const QImage &image) {
|
||||||
|
|
||||||
namespace Badge {
|
namespace Badge {
|
||||||
|
|
||||||
Dialogs::Ui::UnreadBadgeStyle Style() {
|
Ui::UnreadBadgeStyle Style() {
|
||||||
auto result = Dialogs::Ui::UnreadBadgeStyle();
|
auto result = Ui::UnreadBadgeStyle();
|
||||||
result.font = st::mainMenuBadgeFont;
|
result.font = st::mainMenuBadgeFont;
|
||||||
result.size = st::mainMenuBadgeSize;
|
result.size = st::mainMenuBadgeSize;
|
||||||
result.sizeId = Dialogs::Ui::UnreadBadgeSize::MainMenu;
|
result.sizeId = Ui::UnreadBadgeSize::MainMenu;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1020,7 +987,7 @@ not_null<Ui::RpWidget*> CreateUnread(
|
||||||
}
|
}
|
||||||
|
|
||||||
Ui::RpWidget widget;
|
Ui::RpWidget widget;
|
||||||
Dialogs::Ui::UnreadBadgeStyle st = Style();
|
Ui::UnreadBadgeStyle st = Style();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
QString string;
|
QString string;
|
||||||
};
|
};
|
||||||
|
@ -1036,7 +1003,7 @@ not_null<Ui::RpWidget*> CreateUnread(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state->string = Lang::FormatCountToShort(state->count).string;
|
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()) {
|
if (state->widget.isHidden()) {
|
||||||
state->widget.show();
|
state->widget.show();
|
||||||
}
|
}
|
||||||
|
@ -1045,7 +1012,7 @@ not_null<Ui::RpWidget*> CreateUnread(
|
||||||
state->widget.paintRequest(
|
state->widget.paintRequest(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
auto p = Painter(&state->widget);
|
auto p = Painter(&state->widget);
|
||||||
Dialogs::Ui::PaintUnreadBadge(
|
Ui::PaintUnreadBadge(
|
||||||
p,
|
p,
|
||||||
state->string,
|
state->string,
|
||||||
state->widget.width(),
|
state->widget.width(),
|
||||||
|
|
|
@ -9,10 +9,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "settings/settings_common.h"
|
#include "settings/settings_common.h"
|
||||||
|
|
||||||
namespace Dialogs::Ui {
|
namespace Ui {
|
||||||
using namespace ::Ui;
|
|
||||||
struct UnreadBadgeStyle;
|
struct UnreadBadgeStyle;
|
||||||
} // namespace Dialogs::Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Main {
|
namespace Main {
|
||||||
class Account;
|
class Account;
|
||||||
|
@ -44,7 +43,7 @@ void UpdatePhotoLocally(not_null<UserData*> user, const QImage &image);
|
||||||
|
|
||||||
namespace Badge {
|
namespace Badge {
|
||||||
|
|
||||||
[[nodiscard]] Dialogs::Ui::UnreadBadgeStyle Style();
|
[[nodiscard]] Ui::UnreadBadgeStyle Style();
|
||||||
|
|
||||||
struct UnreadBadge {
|
struct UnreadBadge {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
|
@ -19,9 +19,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "settings/settings_premium.h"
|
#include "settings/settings_premium.h"
|
||||||
#include "boxes/language_box.h"
|
#include "boxes/language_box.h"
|
||||||
#include "boxes/username_box.h"
|
#include "boxes/username_box.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
|
||||||
#include "boxes/about_box.h"
|
#include "boxes/about_box.h"
|
||||||
#include "ui/basic_click_handlers.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/vertical_layout.h"
|
||||||
#include "ui/wrap/slide_wrap.h"
|
#include "ui/wrap/slide_wrap.h"
|
||||||
#include "ui/wrap/padding_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/widgets/buttons.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "info/profile/info_profile_badge.h"
|
#include "info/profile/info_profile_badge.h"
|
||||||
#include "info/profile/info_profile_emoji_status_panel.h"
|
#include "info/profile/info_profile_emoji_status_panel.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
|
67
Telegram/SourceFiles/ui/controls/jump_down_button.cpp
Normal file
67
Telegram/SourceFiles/ui/controls/jump_down_button.cpp
Normal 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
|
36
Telegram/SourceFiles/ui/controls/jump_down_button.h
Normal file
36
Telegram/SourceFiles/ui/controls/jump_down_button.h
Normal 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
|
112
Telegram/SourceFiles/ui/controls/silent_toggle.cpp
Normal file
112
Telegram/SourceFiles/ui/controls/silent_toggle.cpp
Normal 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
|
49
Telegram/SourceFiles/ui/controls/silent_toggle.h
Normal file
49
Telegram/SourceFiles/ui/controls/silent_toggle.h
Normal 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
|
|
@ -5,36 +5,26 @@ the official desktop application for the Telegram messaging service.
|
||||||
For license and copyright information please follow this link:
|
For license and copyright information please follow this link:
|
||||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
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 "base/call_delayed.h"
|
||||||
#include "dialogs/ui/dialogs_layout.h"
|
|
||||||
#include "ui/effects/ripple_animation.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/empty_userpic.h"
|
||||||
#include "ui/ui_utility.h"
|
|
||||||
#include "data/notify/data_notify_settings.h"
|
|
||||||
#include "data/data_photo.h"
|
#include "data/data_photo.h"
|
||||||
#include "data/data_session.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_changes.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_streaming.h"
|
#include "data/data_streaming.h"
|
||||||
#include "data/data_file_origin.h"
|
#include "data/data_file_origin.h"
|
||||||
#include "history/history.h"
|
#include "calls/calls_instance.h"
|
||||||
#include "core/file_utilities.h"
|
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "editor/photo_editor_layer_widget.h"
|
#include "editor/photo_editor_layer_widget.h"
|
||||||
#include "media/streaming/media_streaming_instance.h"
|
#include "media/streaming/media_streaming_instance.h"
|
||||||
#include "media/streaming/media_streaming_player.h"
|
#include "media/streaming/media_streaming_player.h"
|
||||||
#include "media/streaming/media_streaming_document.h"
|
#include "media/streaming/media_streaming_document.h"
|
||||||
#include "settings/settings_calls.h" // Calls::AddCameraSubsection.
|
#include "settings/settings_calls.h" // Calls::AddCameraSubsection.
|
||||||
#include "calls/calls_instance.h"
|
|
||||||
#include "webrtc/webrtc_media_devices.h" // Webrtc::GetVideoInputList.
|
#include "webrtc/webrtc_media_devices.h" // Webrtc::GetVideoInputList.
|
||||||
#include "webrtc/webrtc_video_track.h"
|
#include "webrtc/webrtc_video_track.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
|
@ -45,15 +35,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "api/api_peer_photo.h"
|
#include "api/api_peer_photo.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
#include "styles/style_chat.h"
|
|
||||||
#include "styles/style_menu_icons.h"
|
#include "styles/style_menu_icons.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kAnimationDuration = crl::time(120);
|
[[nodiscard]] bool IsCameraAvailable() {
|
||||||
|
|
||||||
bool IsCameraAvailable() {
|
|
||||||
return (Core::App().calls().currentCall() == nullptr)
|
return (Core::App().calls().currentCall() == nullptr)
|
||||||
&& !Webrtc::GetVideoInputList().empty();
|
&& !Webrtc::GetVideoInputList().empty();
|
||||||
}
|
}
|
||||||
|
@ -99,16 +86,6 @@ void CameraBox(
|
||||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
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>
|
template <typename Callback>
|
||||||
QPixmap CreateSquarePixmap(int width, Callback &&paintCallback) {
|
QPixmap CreateSquarePixmap(int width, Callback &&paintCallback) {
|
||||||
auto size = QSize(width, width) * cIntRetinaFactor();
|
auto size = QSize(width, width) * cIntRetinaFactor();
|
||||||
|
@ -124,49 +101,6 @@ QPixmap CreateSquarePixmap(int width, Callback &&paintCallback) {
|
||||||
|
|
||||||
} // namespace
|
} // 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(
|
UserpicButton::UserpicButton(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<Window::Controller*> window,
|
not_null<Window::Controller*> window,
|
||||||
|
@ -178,7 +112,6 @@ UserpicButton::UserpicButton(
|
||||||
, _controller(window->sessionController())
|
, _controller(window->sessionController())
|
||||||
, _window(window)
|
, _window(window)
|
||||||
, _peer(peer)
|
, _peer(peer)
|
||||||
, _cropTitle(CropTitle(peer))
|
|
||||||
, _role(role) {
|
, _role(role) {
|
||||||
Expects(_role == Role::ChangePhoto);
|
Expects(_role == Role::ChangePhoto);
|
||||||
|
|
||||||
|
@ -189,14 +122,12 @@ UserpicButton::UserpicButton(
|
||||||
UserpicButton::UserpicButton(
|
UserpicButton::UserpicButton(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<Window::Controller*> window,
|
not_null<Window::Controller*> window,
|
||||||
const QString &cropTitle,
|
|
||||||
Role role,
|
Role role,
|
||||||
const style::UserpicButton &st)
|
const style::UserpicButton &st)
|
||||||
: RippleButton(parent, st.changeButton.ripple)
|
: RippleButton(parent, st.changeButton.ripple)
|
||||||
, _st(st)
|
, _st(st)
|
||||||
, _controller(window->sessionController())
|
, _controller(window->sessionController())
|
||||||
, _window(window)
|
, _window(window)
|
||||||
, _cropTitle(cropTitle)
|
|
||||||
, _role(role) {
|
, _role(role) {
|
||||||
Expects(_role == Role::ChangePhoto || _role == Role::ChoosePhoto);
|
Expects(_role == Role::ChangePhoto || _role == Role::ChoosePhoto);
|
||||||
|
|
||||||
|
@ -215,7 +146,6 @@ UserpicButton::UserpicButton(
|
||||||
, _controller(controller)
|
, _controller(controller)
|
||||||
, _window(&controller->window())
|
, _window(&controller->window())
|
||||||
, _peer(peer)
|
, _peer(peer)
|
||||||
, _cropTitle(CropTitle(_peer))
|
|
||||||
, _role(role) {
|
, _role(role) {
|
||||||
processPeerPhoto();
|
processPeerPhoto();
|
||||||
prepare();
|
prepare();
|
||||||
|
@ -230,7 +160,6 @@ UserpicButton::UserpicButton(
|
||||||
: RippleButton(parent, st.changeButton.ripple)
|
: RippleButton(parent, st.changeButton.ripple)
|
||||||
, _st(st)
|
, _st(st)
|
||||||
, _peer(peer)
|
, _peer(peer)
|
||||||
, _cropTitle(CropTitle(_peer))
|
|
||||||
, _role(role) {
|
, _role(role) {
|
||||||
Expects(_role != Role::OpenProfile && _role != Role::OpenPhoto);
|
Expects(_role != Role::OpenProfile && _role != Role::OpenPhoto);
|
||||||
|
|
||||||
|
@ -240,6 +169,8 @@ UserpicButton::UserpicButton(
|
||||||
setupPeerViewers();
|
setupPeerViewers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UserpicButton::~UserpicButton() = default;
|
||||||
|
|
||||||
void UserpicButton::prepare() {
|
void UserpicButton::prepare() {
|
||||||
resize(_st.size);
|
resize(_st.size);
|
||||||
_notShownYet = _waiting;
|
_notShownYet = _waiting;
|
||||||
|
@ -311,15 +242,12 @@ void UserpicButton::choosePhotoLocally() {
|
||||||
st::popupMenuWithIcons);
|
st::popupMenuWithIcons);
|
||||||
const auto user = _peer ? _peer->asUser() : nullptr;
|
const auto user = _peer ? _peer->asUser() : nullptr;
|
||||||
if (user && !user->isSelf()) {
|
if (user && !user->isSelf()) {
|
||||||
const auto name = user->firstName.isEmpty()
|
|
||||||
? user->name()
|
|
||||||
: user->firstName;
|
|
||||||
_menu->addAction(
|
_menu->addAction(
|
||||||
tr::lng_profile_set_photo_for(tr::now, lt_user, name),
|
tr::lng_profile_set_photo_for(tr::now),
|
||||||
[=] { chooseFile(); },
|
[=] { chooseFile(); },
|
||||||
&st::menuIconPhotoSet);
|
&st::menuIconPhotoSet);
|
||||||
_menu->addAction(
|
_menu->addAction(
|
||||||
tr::lng_profile_suggest_photo(tr::now, lt_user, name),
|
tr::lng_profile_suggest_photo(tr::now),
|
||||||
[=] { chooseFile(ChosenType::Suggest); },
|
[=] { chooseFile(ChosenType::Suggest); },
|
||||||
&st::menuIconPhotoSuggest);
|
&st::menuIconPhotoSuggest);
|
||||||
if (user->hasPersonalPhoto()) {
|
if (user->hasPersonalPhoto()) {
|
||||||
|
@ -858,92 +786,45 @@ void UserpicButton::prepareUserpicPixmap() {
|
||||||
: InMemoryKey();
|
: InMemoryKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
SilentToggle::SilentToggle(QWidget *parent, not_null<ChannelData*> channel)
|
not_null<Ui::UserpicButton*> CreateUploadSubButton(
|
||||||
: RippleButton(parent, st::historySilentToggle.ripple)
|
not_null<Ui::RpWidget*> parent,
|
||||||
, _st(st::historySilentToggle)
|
not_null<Window::SessionController*> controller) {
|
||||||
, _channel(channel)
|
const auto background = Ui::CreateChild<Ui::RpWidget>(parent.get());
|
||||||
, _checked(channel->owner().notifySettings().silentPosts(_channel)) {
|
const auto upload = Ui::CreateChild<Ui::UserpicButton>(
|
||||||
Expects(!channel->owner().notifySettings().silentPostsUnknown(_channel));
|
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(
|
background->resize(size);
|
||||||
) | rpl::start_with_next([=](const QRect &clip) {
|
background->paintRequest(
|
||||||
auto p = QPainter(this);
|
) | rpl::start_with_next([=] {
|
||||||
paintRipple(p, _st.rippleAreaPosition, nullptr);
|
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.);
|
upload->positionValue(
|
||||||
const auto over = isOver();
|
) | rpl::start_with_next([=](QPoint position) {
|
||||||
(_checked
|
background->move(position - QPoint(border, border));
|
||||||
? (over
|
}, background->lifetime());
|
||||||
? st::historySilentToggleOnOver
|
|
||||||
: st::historySilentToggleOn)
|
|
||||||
: (over
|
|
||||||
? st::historySilentToggle.iconOver
|
|
||||||
: st::historySilentToggle.icon)).paintInCenter(p, rect());
|
|
||||||
}, lifetime());
|
|
||||||
|
|
||||||
setMouseTracking(true);
|
return upload;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SilentToggle::mouseMoveEvent(QMouseEvent *e) {
|
not_null<Ui::UserpicButton*> CreateUploadSubButton(
|
||||||
RippleButton::mouseMoveEvent(e);
|
not_null<Ui::RpWidget*> parent,
|
||||||
if (rect().contains(e->pos())) {
|
not_null<UserData*> contact,
|
||||||
Ui::Tooltip::Show(1000, this);
|
not_null<Window::SessionController*> controller) {
|
||||||
} else {
|
const auto result = CreateUploadSubButton(parent, controller);
|
||||||
Ui::Tooltip::Hide();
|
return result;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
} // namespace Ui
|
|
@ -8,12 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ui/widgets/buttons.h"
|
#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 "ui/userpic_view.h"
|
||||||
#include "styles/style_window.h"
|
|
||||||
#include "styles/style_widgets.h"
|
|
||||||
|
|
||||||
class PeerData;
|
class PeerData;
|
||||||
|
|
||||||
|
@ -31,33 +26,15 @@ struct Information;
|
||||||
} // namespace Streaming
|
} // namespace Streaming
|
||||||
} // namespace Media
|
} // namespace Media
|
||||||
|
|
||||||
|
namespace style {
|
||||||
|
struct UserpicButton;
|
||||||
|
} // namespace style
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
class PopupMenu;
|
class PopupMenu;
|
||||||
|
|
||||||
class HistoryDownButton : public RippleButton {
|
class UserpicButton final : 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 {
|
|
||||||
public:
|
public:
|
||||||
enum class Role {
|
enum class Role {
|
||||||
ChoosePhoto,
|
ChoosePhoto,
|
||||||
|
@ -76,7 +53,6 @@ public:
|
||||||
UserpicButton(
|
UserpicButton(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<::Window::Controller*> window,
|
not_null<::Window::Controller*> window,
|
||||||
const QString &cropTitle,
|
|
||||||
Role role,
|
Role role,
|
||||||
const style::UserpicButton &st);
|
const style::UserpicButton &st);
|
||||||
UserpicButton(
|
UserpicButton(
|
||||||
|
@ -90,6 +66,7 @@ public:
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
Role role,
|
Role role,
|
||||||
const style::UserpicButton &st);
|
const style::UserpicButton &st);
|
||||||
|
~UserpicButton();
|
||||||
|
|
||||||
enum class ChosenType {
|
enum class ChosenType {
|
||||||
Set,
|
Set,
|
||||||
|
@ -163,7 +140,6 @@ private:
|
||||||
::Window::Controller *_window = nullptr;
|
::Window::Controller *_window = nullptr;
|
||||||
PeerData *_peer = nullptr;
|
PeerData *_peer = nullptr;
|
||||||
PeerUserpicView _userpicView;
|
PeerUserpicView _userpicView;
|
||||||
QString _cropTitle;
|
|
||||||
Role _role = Role::ChangePhoto;
|
Role _role = Role::ChangePhoto;
|
||||||
bool _notShownYet = true;
|
bool _notShownYet = true;
|
||||||
bool _waiting = false;
|
bool _waiting = false;
|
||||||
|
@ -190,38 +166,13 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SilentToggle final
|
[[nodiscard]] not_null<Ui::UserpicButton*> CreateUploadSubButton(
|
||||||
: public RippleButton
|
not_null<Ui::RpWidget*> parent,
|
||||||
, public AbstractTooltipShower {
|
not_null<Window::SessionController*> controller);
|
||||||
public:
|
|
||||||
SilentToggle(QWidget *parent, not_null<ChannelData*> channel);
|
|
||||||
|
|
||||||
void setChecked(bool checked);
|
[[nodiscard]] not_null<Ui::UserpicButton*> CreateUploadSubButton(
|
||||||
bool checked() const {
|
not_null<Ui::RpWidget*> parent,
|
||||||
return _checked;
|
not_null<UserData*> contact,
|
||||||
}
|
not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
// 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
|
} // namespace Ui
|
|
@ -12,9 +12,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/stickers/data_custom_emoji.h"
|
#include "data/stickers/data_custom_emoji.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "dialogs/ui/dialogs_layout.h"
|
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/unread_badge_paint.h"
|
||||||
#include "styles/style_dialogs.h"
|
#include "styles/style_dialogs.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -46,11 +46,11 @@ void UnreadBadge::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
auto p = QPainter(this);
|
auto p = QPainter(this);
|
||||||
|
|
||||||
Dialogs::Ui::UnreadBadgeStyle unreadSt;
|
UnreadBadgeStyle unreadSt;
|
||||||
unreadSt.muted = !_active;
|
unreadSt.muted = !_active;
|
||||||
auto unreadRight = width();
|
auto unreadRight = width();
|
||||||
auto unreadTop = 0;
|
auto unreadTop = 0;
|
||||||
Dialogs::Ui::PaintUnreadBadge(
|
PaintUnreadBadge(
|
||||||
p,
|
p,
|
||||||
_text,
|
_text,
|
||||||
unreadRight,
|
unreadRight,
|
||||||
|
|
183
Telegram/SourceFiles/ui/unread_badge_paint.cpp
Normal file
183
Telegram/SourceFiles/ui/unread_badge_paint.cpp
Normal 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
|
50
Telegram/SourceFiles/ui/unread_badge_paint.h
Normal file
50
Telegram/SourceFiles/ui/unread_badge_paint.h
Normal 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
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "ui/chat/chat_theme.h"
|
#include "ui/chat/chat_theme.h"
|
||||||
|
#include "ui/controls/userpic_button.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/widgets/popup_menu.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_utilities.h"
|
||||||
#include "ui/text/text_options.h"
|
#include "ui/text/text_options.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
#include "ui/special_buttons.h"
|
|
||||||
#include "ui/empty_userpic.h"
|
#include "ui/empty_userpic.h"
|
||||||
#include "dialogs/ui/dialogs_layout.h"
|
#include "ui/unread_badge_paint.h"
|
||||||
#include "base/call_delayed.h"
|
#include "base/call_delayed.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
|
@ -271,7 +271,7 @@ void MainMenu::ToggleAccountsButton::paintUnreadBadge(Painter &p) {
|
||||||
- st::mainMenuTogglePosition.y()
|
- st::mainMenuTogglePosition.y()
|
||||||
- st::mainMenuBadgeSize / 2;
|
- st::mainMenuBadgeSize / 2;
|
||||||
p.setOpacity(progress);
|
p.setOpacity(progress);
|
||||||
Dialogs::Ui::PaintUnreadBadge(p, _unreadBadge, right, top, st);
|
Ui::PaintUnreadBadge(p, _unreadBadge, right, top, st);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainMenu::ToggleAccountsButton::validateUnreadBadge() {
|
void MainMenu::ToggleAccountsButton::validateUnreadBadge() {
|
||||||
|
@ -289,7 +289,7 @@ void MainMenu::ToggleAccountsButton::validateUnreadBadge() {
|
||||||
if (!_unreadBadge.isEmpty()) {
|
if (!_unreadBadge.isEmpty()) {
|
||||||
const auto st = Settings::Badge::Style();
|
const auto st = Settings::Badge::Style();
|
||||||
skip += 2 * st::mainMenuToggleSize
|
skip += 2 * st::mainMenuToggleSize
|
||||||
+ Dialogs::Ui::CountUnreadBadgeSize(_unreadBadge, st).width();
|
+ Ui::CountUnreadBadgeSize(_unreadBadge, st).width();
|
||||||
}
|
}
|
||||||
_rightSkip = skip;
|
_rightSkip = skip;
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,6 +218,8 @@ PRIVATE
|
||||||
ui/controls/download_bar.h
|
ui/controls/download_bar.h
|
||||||
ui/controls/emoji_button.cpp
|
ui/controls/emoji_button.cpp
|
||||||
ui/controls/emoji_button.h
|
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.cpp
|
||||||
ui/controls/invite_link_buttons.h
|
ui/controls/invite_link_buttons.h
|
||||||
ui/controls/invite_link_label.cpp
|
ui/controls/invite_link_label.cpp
|
||||||
|
@ -278,6 +280,8 @@ PRIVATE
|
||||||
ui/empty_userpic.h
|
ui/empty_userpic.h
|
||||||
ui/grouped_layout.cpp
|
ui/grouped_layout.cpp
|
||||||
ui/grouped_layout.h
|
ui/grouped_layout.h
|
||||||
|
ui/unread_badge_paint.cpp
|
||||||
|
ui/unread_badge_paint.h
|
||||||
ui/userpic_view.cpp
|
ui/userpic_view.cpp
|
||||||
ui/userpic_view.h
|
ui/userpic_view.h
|
||||||
ui/widgets/fields/special_fields.cpp
|
ui/widgets/fields/special_fields.cpp
|
||||||
|
|
Loading…
Add table
Reference in a new issue