Remove twidget header.

This commit is contained in:
John Preston 2019-09-13 15:22:54 +03:00
parent e2f54eb3e9
commit c5845f17ae
188 changed files with 1070 additions and 907 deletions

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "data/data_types.h"
#include "ui/rect_part.h"
enum class ImageRoundRadius;
class MainWindow;

View File

@ -32,6 +32,17 @@ inline bool contains(const Container &container, const T &value) {
return std::find(std::begin(container), end, value) != end;
}
template <typename D, typename T>
inline constexpr D up_cast(T object) {
using DV = std::decay_t<decltype(*D())>;
using TV = std::decay_t<decltype(*T())>;
if constexpr (std::is_base_of_v<DV, TV>) {
return object;
} else {
return nullptr;
}
}
// We need a custom comparator for set<std::unique_ptr<T>>::find to work with pointers.
// thanks to http://stackoverflow.com/questions/18939882/raw-pointer-lookup-for-sets-of-unique-ptrs
template <typename T>

View File

@ -40,3 +40,23 @@ inline void InvokeQueued(const QObject *context, Lambda &&lambda) {
const_cast<QObject*>(context),
new base::InvokeQueuedEvent(std::forward<Lambda>(lambda)));
}
class SingleQueuedInvokation : public QObject {
public:
SingleQueuedInvokation(Fn<void()> callback) : _callback(callback) {
}
void call() {
if (_pending.testAndSetAcquire(0, 1)) {
InvokeQueued(this, [this] {
if (_pending.testAndSetRelease(1, 0)) {
_callback();
}
});
}
}
private:
Fn<void()> _callback;
QAtomicInt _pending = { 0 };
};

View File

@ -0,0 +1,119 @@
/*
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
// Smart pointer for QObject*, has move semantics, destroys object if it doesn't have a parent.
template <typename Object>
class object_ptr {
public:
object_ptr(std::nullptr_t) noexcept {
}
// No default constructor, but constructors with at least
// one argument are simply make functions.
template <typename Parent, typename... Args>
explicit object_ptr(Parent &&parent, Args&&... args)
: _object(new Object(std::forward<Parent>(parent), std::forward<Args>(args)...)) {
}
static object_ptr<Object> fromRaw(Object *value) noexcept {
object_ptr<Object> result = { nullptr };
result._object = value;
return result;
}
Object *release() noexcept {
return static_cast<Object*>(base::take(_object).data());
}
object_ptr(const object_ptr &other) = delete;
object_ptr &operator=(const object_ptr &other) = delete;
object_ptr(object_ptr &&other) noexcept : _object(base::take(other._object)) {
}
object_ptr &operator=(object_ptr &&other) noexcept {
auto temp = std::move(other);
destroy();
std::swap(_object, temp._object);
return *this;
}
template <
typename OtherObject,
typename = std::enable_if_t<
std::is_base_of_v<Object, OtherObject>>>
object_ptr(object_ptr<OtherObject> &&other) noexcept
: _object(base::take(other._object)) {
}
template <
typename OtherObject,
typename = std::enable_if_t<
std::is_base_of_v<Object, OtherObject>>>
object_ptr &operator=(object_ptr<OtherObject> &&other) noexcept {
_object = base::take(other._object);
return *this;
}
object_ptr &operator=(std::nullptr_t) noexcept {
_object = nullptr;
return *this;
}
// So we can pass this pointer to methods like connect().
Object *data() const noexcept {
return static_cast<Object*>(_object.data());
}
operator Object*() const noexcept {
return data();
}
explicit operator bool() const noexcept {
return _object != nullptr;
}
Object *operator->() const noexcept {
return data();
}
Object &operator*() const noexcept {
return *data();
}
// Use that instead "= new Object(parent, ...)"
template <typename Parent, typename... Args>
Object *create(Parent &&parent, Args&&... args) {
destroy();
_object = new Object(
std::forward<Parent>(parent),
std::forward<Args>(args)...);
return data();
}
void destroy() noexcept {
delete base::take(_object);
}
void destroyDelayed() {
if (_object) {
if (auto widget = base::up_cast<QWidget*>(data())) {
widget->hide();
}
base::take(_object)->deleteLater();
}
}
~object_ptr() noexcept {
if (auto pointer = _object) {
if (!pointer->parent()) {
destroy();
}
}
}
private:
template <typename OtherObject>
friend class object_ptr;
QPointer<QObject> _object;
};

View File

@ -225,7 +225,8 @@ protected:
template <typename Widget>
object_ptr<Widget> takeInnerWidget() {
return static_object_cast<Widget>(doTakeInnerWidget());
return object_ptr<Widget>::fromRaw(
static_cast<Widget*>(doTakeInnerWidget().release()));
}
void setInnerVisible(bool scrollAreaVisible);

View File

@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/special_buttons.h"
#include "ui/text_options.h"
#include "ui/unread_badge.h"
#include "ui/ui_utility.h"
#include "data/data_channel.h"
#include "data/data_chat.h"
#include "data/data_user.h"
@ -579,7 +580,7 @@ void GroupInfoBox::createGroup(
}).fail([=](const RPCError &error) {
_creationRequestId = 0;
if (error.type() == qstr("NO_CHAT_TITLE")) {
auto weak = make_weak(this);
auto weak = Ui::MakeWeak(this);
selectUsersBox->closeBox();
if (weak) {
_title->showError();
@ -618,7 +619,7 @@ void GroupInfoBox::submit() {
if (_type != Type::Group) {
createChannel(title, description);
} else {
auto initBox = [title, weak = make_weak(this)](
auto initBox = [title, weak = Ui::MakeWeak(this)](
not_null<PeerListBox*> box) {
auto create = [box, title, weak] {
if (weak) {
@ -1362,7 +1363,7 @@ void RevokePublicLinkBox::Inner::updateSelected() {
PeerData *selected = nullptr;
auto top = _rowsTop;
for (const auto &row : _rows) {
auto revokeLink = rtlrect(width() - st::contactsPadding.right() - st::contactsCheckPosition.x() - _revokeWidth, top + st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, _revokeWidth, st::normalFont->height, width());
auto revokeLink = style::rtlrect(width() - st::contactsPadding.right() - st::contactsCheckPosition.x() - _revokeWidth, top + st::contactsPadding.top() + (st::contactsPhotoSize - st::normalFont->height) / 2, _revokeWidth, st::normalFont->height, width());
if (revokeLink.contains(point)) {
selected = row.peer;
break;

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "ui/effects/round_checkbox.h"
#include "ui/image/image.h"
#include "ui/ui_utility.h"
#include "main/main_session.h"
#include "apiwrap.h"
#include "mtproto/sender.h"
@ -154,7 +155,7 @@ void BackgroundBox::prepare() {
void BackgroundBox::removePaper(const Data::WallPaper &paper) {
const auto box = std::make_shared<QPointer<BoxContent>>();
const auto session = _session;
const auto remove = [=, weak = make_weak(this)]{
const auto remove = [=, weak = Ui::MakeWeak(this)]{
if (*box) {
(*box)->closeBox();
}

View File

@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/toast/toast.h"
#include "ui/image/image.h"
#include "ui/widgets/checkbox.h"
#include "ui/ui_utility.h"
#include "history/history.h"
#include "history/history_message.h"
#include "history/view/history_view_message.h"

View File

@ -8,10 +8,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/calendar_box.h"
#include "ui/widgets/buttons.h"
#include "styles/style_boxes.h"
#include "styles/style_dialogs.h"
#include "lang/lang_keys.h"
#include "ui/effects/ripple_animation.h"
#include "ui/ui_utility.h"
#include "styles/style_boxes.h"
#include "styles/style_dialogs.h"
namespace {
@ -258,7 +259,7 @@ void CalendarBox::Inner::monthChanged(QDate month) {
_ripples.clear();
resizeToCurrent();
update();
sendSynteticMouseEvent(this, QEvent::MouseMove, Qt::NoButton);
Ui::SendSynteticMouseEvent(this, QEvent::MouseMove, Qt::NoButton);
}
void CalendarBox::Inner::resizeToCurrent() {

View File

@ -309,7 +309,7 @@ void ChangePhoneBox::EnterCode::submit() {
const auto session = _session;
const auto code = _code->getDigitsOnly();
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
_requestId = MTP::send(MTPaccount_ChangePhone(
MTP_string(_phone),
MTP_string(_hash),

View File

@ -415,7 +415,7 @@ void ProxyRow::paintCheck(Painter &p) {
pen.setCapStyle(Qt::RoundCap);
p.setPen(pen);
p.setBrush(_st->bg);
const auto rect = rtlrect(QRectF(left, top, _st->diameter, _st->diameter).marginsRemoved(QMarginsF(_st->thickness / 2., _st->thickness / 2., _st->thickness / 2., _st->thickness / 2.)), outerWidth);
const auto rect = style::rtlrect(QRectF(left, top, _st->diameter, _st->diameter).marginsRemoved(QMarginsF(_st->thickness / 2., _st->thickness / 2., _st->thickness / 2., _st->thickness / 2.)), outerWidth);
if (_progress && loading.shown > 0 && anim::Disabled()) {
anim::DrawStaticLoading(
p,
@ -434,7 +434,7 @@ void ProxyRow::paintCheck(Painter &p) {
p.setBrush(anim::brush(_st->untoggledFg, _st->toggledFg, toggled * set));
auto skip0 = _st->diameter / 2., skip1 = _st->skip / 10., checkSkip = skip0 * (1. - toggled) + skip1 * toggled;
p.drawEllipse(rtlrect(QRectF(left, top, _st->diameter, _st->diameter).marginsRemoved(QMarginsF(checkSkip, checkSkip, checkSkip, checkSkip)), outerWidth));
p.drawEllipse(style::rtlrect(QRectF(left, top, _st->diameter, _st->diameter).marginsRemoved(QMarginsF(checkSkip, checkSkip, checkSkip, checkSkip)), outerWidth));
}
}

View File

@ -812,10 +812,10 @@ void EditCaptionBox::paintEvent(QPaintEvent *e) {
// App::roundRect(p, x, y, w, h, st::msgInBg, MessageInCorners, &st::msgInShadow);
if (_thumbw) {
QRect rthumb(rtlrect(x + 0, y + 0, st::msgFileThumbSize, st::msgFileThumbSize, width()));
QRect rthumb(style::rtlrect(x + 0, y + 0, st::msgFileThumbSize, st::msgFileThumbSize, width()));
p.drawPixmap(rthumb.topLeft(), _thumb);
} else {
const QRect inner(rtlrect(x + 0, y + 0, st::msgFileSize, st::msgFileSize, width()));
const QRect inner(style::rtlrect(x + 0, y + 0, st::msgFileSize, st::msgFileSize, width()));
p.setPen(Qt::NoPen);
p.setBrush(st::msgFileInBg);

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "ui/widgets/shadow.h"
#include "ui/widgets/input_fields.h"
#include "ui/ui_utility.h"
#include "platform/platform_info.h"
#include "app.h"
#include "styles/style_boxes.h"
@ -874,7 +875,7 @@ void EditColorBox::fieldSubmitted() {
}
void EditColorBox::saveColor() {
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
_cancelCallback = nullptr;
if (_saveCallback) {
_saveCallback(_new.toRgb());

View File

@ -269,7 +269,7 @@ void PasscodeBox::setPasswordDone(const QByteArray &newPasswordBytes) {
}
_setRequest = 0;
_newPasswordSet.fire_copy(newPasswordBytes);
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
const auto text = _reenterPasscode->isHidden()
? tr::lng_cloud_password_removed(tr::now)
: _oldPasscode->isHidden()
@ -368,7 +368,7 @@ void PasscodeBox::validateEmail(
} else if (error.type() == qstr("CODE_INVALID")) {
errors->fire(tr::lng_signin_wrong_code(tr::now));
} else if (error.type() == qstr("EMAIL_HASH_EXPIRED")) {
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
_clearUnconfirmedPassword.fire({});
if (weak) {
auto box = Box<InformBox>(
@ -409,7 +409,7 @@ void PasscodeBox::validateEmail(
box->boxClosing(
) | rpl::filter([=] {
return !*set;
}) | start_with_next([=, weak = make_weak(this)] {
}) | start_with_next([=, weak = Ui::MakeWeak(this)] {
if (weak) {
weak->_clearUnconfirmedPassword.fire({});
}
@ -512,7 +512,7 @@ void PasscodeBox::save(bool force) {
}
} else {
closeReplacedBy();
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
cSetPasscodeBadTries(0);
Local::setPasscode(pwd.toUtf8());
_session->localPasscodeChanged();

View File

@ -507,14 +507,14 @@ void PeerListRow::paintDisabledCheckUserpic(
auto userpicDiameter = st::contactsPhotoCheckbox.imageRadius * 2;
auto userpicLeft = x + userpicShift;
auto userpicTop = y + userpicShift;
auto userpicEllipse = rtlrect(x, y, userpicDiameter, userpicDiameter, outerWidth);
auto userpicEllipse = style::rtlrect(x, y, userpicDiameter, userpicDiameter, outerWidth);
auto userpicBorderPen = st::contactsPhotoDisabledCheckFg->p;
userpicBorderPen.setWidth(st::contactsPhotoCheckbox.selectWidth);
auto iconDiameter = st::contactsPhotoCheckbox.check.size;
auto iconLeft = x + userpicDiameter + st::contactsPhotoCheckbox.selectWidth - iconDiameter;
auto iconTop = y + userpicDiameter + st::contactsPhotoCheckbox.selectWidth - iconDiameter;
auto iconEllipse = rtlrect(iconLeft, iconTop, iconDiameter, iconDiameter, outerWidth);
auto iconEllipse = style::rtlrect(iconLeft, iconTop, iconDiameter, iconDiameter, outerWidth);
auto iconBorderPen = st::contactsPhotoCheckbox.check.border->p;
iconBorderPen.setWidth(st::contactsPhotoCheckbox.selectWidth);

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/confirm_box.h"
#include "observer_peer.h"
#include "ui/widgets/checkbox.h"
#include "ui/ui_utility.h"
#include "main/main_session.h"
#include "data/data_session.h"
#include "data/data_channel.h"

View File

@ -202,7 +202,7 @@ void Controller::initNameFields(
return;
}
SendRequest(
make_weak(_box),
Ui::MakeWeak(_box),
_user,
_sharePhone && _sharePhone->checked(),
firstValue,

View File

@ -57,7 +57,7 @@ void SetCloudPassword(not_null<GenericBox*> box, not_null<UserData*> user) {
user->session().api().passwordState(
) | rpl::start_with_next([=] {
using namespace Settings;
const auto weak = make_weak(box);
const auto weak = Ui::MakeWeak(box);
if (CheckEditCloudPassword(&user->session())) {
box->getDelegate()->show(
EditCloudPasswordBox(&user->session()));
@ -580,7 +580,7 @@ void EditAdminBox::sendTransferRequestFrom(
if (_transferRequestId) {
return;
}
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
const auto user = this->user();
const auto api = &channel->session().api();
_transferRequestId = api->request(MTPchannels_EditCreator(
@ -626,7 +626,7 @@ void EditAdminBox::sendTransferRequestFrom(
|| (type == qstr("PASSWORD_TOO_FRESH_XXX"))
|| (type == qstr("SESSION_TOO_FRESH_XXX"));
}();
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
getDelegate()->show(Box<InformBox>(problem));
if (box) {
box->closeBox();

View File

@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_user.h"
#include "base/unixtime.h"
#include "ui/widgets/popup_menu.h"
#include "ui/ui_utility.h"
#include "window/window_session_controller.h"
#include "history/history.h"
#include "facades.h"

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "ui/widgets/buttons.h"
#include "ui/ui_utility.h"
#include "app.h"
#include "styles/style_boxes.h"
@ -260,7 +261,7 @@ void PhotoCropBox::sendPhoto() {
tosend = cropped.copy();
}
auto weak = make_weak(this);
auto weak = Ui::MakeWeak(this);
_readyImages.fire(std::move(tosend));
if (weak) {
closeBox();

View File

@ -900,7 +900,7 @@ void SingleFilePreview::paintEvent(QPaintEvent *e) {
App::roundRect(p, x, y, w, h, st::msgOutBg, MessageOutCorners, &st::msgOutShadow);
if (_fileThumb.isNull()) {
QRect inner(rtlrect(x + st::msgFilePadding.left(), y + st::msgFilePadding.top(), st::msgFileSize, st::msgFileSize, width()));
QRect inner(style::rtlrect(x + st::msgFilePadding.left(), y + st::msgFilePadding.top(), st::msgFileSize, st::msgFileSize, width()));
p.setPen(Qt::NoPen);
p.setBrush(st::msgFileOutBg);
@ -916,7 +916,7 @@ void SingleFilePreview::paintEvent(QPaintEvent *e) {
: st::historyFileOutDocument;
icon.paintInCenter(p, inner);
} else {
QRect rthumb(rtlrect(x + st::msgFileThumbPadding.left(), y + st::msgFileThumbPadding.top(), st::msgFileThumbSize, st::msgFileThumbSize, width()));
QRect rthumb(style::rtlrect(x + st::msgFileThumbPadding.left(), y + st::msgFileThumbPadding.top(), st::msgFileThumbSize, st::msgFileThumbSize, width()));
p.drawPixmap(rthumb.topLeft(), _fileThumb);
}
p.setFont(st::semiboldFont);
@ -1464,7 +1464,7 @@ void SendFilesBox::setupShadows(
bottomShadow->move(
geometry.x(),
geometry.y() + geometry.height() - st::lineWidth);
}, [t = make_weak(topShadow), b = make_weak(bottomShadow)] {
}, [t = Ui::MakeWeak(topShadow), b = Ui::MakeWeak(bottomShadow)] {
Ui::DestroyChild(t.data());
Ui::DestroyChild(b.data());
}, topShadow->lifetime());

View File

@ -643,7 +643,7 @@ void ShareBox::Inner::repaintChatAtIndex(int index) {
auto row = index / _columnCount;
auto column = index % _columnCount;
update(rtlrect(_rowsLeft + qFloor(column * _rowWidthReal), row * _rowHeight, _rowWidth, _rowHeight, width()));
update(style::rtlrect(_rowsLeft + qFloor(column * _rowWidthReal), row * _rowHeight, _rowWidth, _rowHeight, width()));
}
ShareBox::Inner::Chat *ShareBox::Inner::getChatAtIndex(int index) {

View File

@ -54,7 +54,7 @@ void SingleChoiceBox::prepare() {
st::boxOptionListSkip));
}
group->setChangedCallback([=](int value) {
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
_callback(value);
if (weak) {
closeBox();

View File

@ -879,7 +879,7 @@ void StickersBox::Inner::paintRow(Painter &p, not_null<Row*> set, int index) {
{
PainterHighQualityEnabler hq(p);
p.drawEllipse(rtlrect(namex + set->titleWidth + st::stickersFeaturedUnreadSkip, namey + st::stickersFeaturedUnreadTop, st::stickersFeaturedUnreadSize, st::stickersFeaturedUnreadSize, width()));
p.drawEllipse(style::rtlrect(namex + set->titleWidth + st::stickersFeaturedUnreadSkip, namey + st::stickersFeaturedUnreadTop, st::stickersFeaturedUnreadSize, st::stickersFeaturedUnreadSize, width()));
}
}

View File

@ -158,7 +158,7 @@ void BoxController::Row::paintAction(
_actionRipple.reset();
}
}
st::callReDial.icon.paintInCenter(p, rtlrect(x, y, size.width(), size.height(), outerWidth));
st::callReDial.icon.paintInCenter(p, style::rtlrect(x, y, size.width(), size.height(), outerWidth));
}
void BoxController::Row::refreshStatus() {

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/weak_ptr.h"
#include "base/timer.h"
#include "base/object_ptr.h"
#include "ui/rp_widget.h"
namespace Ui {

View File

@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/buttons.h"
#include "ui/widgets/shadow.h"
#include "ui/emoji_config.h"
#include "ui/ui_utility.h"
#include "lang/lang_keys.h"
#include "emoji_suggestions_data.h"
#include "emoji_suggestions_helper.h"

View File

@ -294,7 +294,7 @@ void Loader::setImplementation(
void Loader::unpack(const QString &path) {
const auto folder = internal::SetDataPath(_id);
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
crl::async([=] {
if (UnpackSet(path, folder)) {
QFile(path).remove();
@ -401,7 +401,7 @@ void Row::paintRadio(Painter &p) {
pen.setCapStyle(Qt::RoundCap);
p.setPen(pen);
p.setBrush(_st->bg);
const auto rect = rtlrect(QRectF(
const auto rect = style::rtlrect(QRectF(
left,
top,
_st->diameter,
@ -432,7 +432,7 @@ void Row::paintRadio(Painter &p) {
const auto skip0 = _st->diameter / 2.;
const auto skip1 = _st->skip / 10.;
const auto checkSkip = skip0 * (1. - toggled) + skip1 * toggled;
p.drawEllipse(rtlrect(QRectF(
p.drawEllipse(style::rtlrect(QRectF(
left,
top,
_st->diameter,

View File

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/inner_dropdown.h"
#include "ui/widgets/input_fields.h"
#include "ui/emoji_config.h"
#include "ui/ui_utility.h"
#include "platform/platform_specific.h"
#include "core/application.h"
#include "core/event_filter.h"

View File

@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lottie/lottie_single_player.h"
#include "ui/widgets/scroll_area.h"
#include "ui/image/image.h"
#include "ui/ui_utility.h"
#include "main/main_session.h"
#include "chat_helpers/stickers.h"
#include "base/unixtime.h"

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/animations.h"
#include "ui/rp_widget.h"
#include "base/timer.h"
#include "base/object_ptr.h"
#include "chat_helpers/stickers.h"
namespace Ui {

View File

@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/abstract_box.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/widgets/popup_menu.h"
#include "ui/ui_utility.h"
#include "data/data_session.h"
#include "data/data_user.h"
#include "core/event_filter.h"
@ -153,7 +154,7 @@ void EditLinkBox::prepare() {
url->showError();
return;
}
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
_callback(linkText, linkUrl);
if (weak) {
closeBox();
@ -354,7 +355,7 @@ Fn<bool(
EditLinkAction action)> DefaultEditLinkCallback(
not_null<Main::Session*> session,
not_null<Ui::InputField*> field) {
const auto weak = make_weak(field);
const auto weak = Ui::MakeWeak(field);
return [=](
EditLinkSelection selection,
QString text,

View File

@ -465,13 +465,13 @@ void StickersListWidget::Footer::paintLeftRightFading(Painter &p) const {
auto o_left = snap(_iconsX.current() / st::stickerIconLeft.width(), 0., 1.);
if (o_left > 0) {
p.setOpacity(o_left);
st::stickerIconLeft.fill(p, rtlrect(_iconsLeft, _iconsTop, st::stickerIconLeft.width(), st::emojiFooterHeight, width()));
st::stickerIconLeft.fill(p, style::rtlrect(_iconsLeft, _iconsTop, st::stickerIconLeft.width(), st::emojiFooterHeight, width()));
p.setOpacity(1.);
}
auto o_right = snap((_iconsMax - _iconsX.current()) / st::stickerIconRight.width(), 0., 1.);
if (o_right > 0) {
p.setOpacity(o_right);
st::stickerIconRight.fill(p, rtlrect(width() - _iconsRight - st::stickerIconRight.width(), _iconsTop, st::stickerIconRight.width(), st::emojiFooterHeight, width()));
st::stickerIconRight.fill(p, style::rtlrect(width() - _iconsRight - st::stickerIconRight.width(), _iconsTop, st::stickerIconRight.width(), st::emojiFooterHeight, width()));
p.setOpacity(1.);
}
}
@ -1396,7 +1396,7 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
{
PainterHighQualityEnabler hq(p);
p.drawEllipse(rtlrect(st::emojiPanHeaderLeft - st::buttonRadius + titleWidth + st::stickersFeaturedUnreadSkip, info.top + st::stickersTrendingHeaderTop + st::stickersFeaturedUnreadTop, st::stickersFeaturedUnreadSize, st::stickersFeaturedUnreadSize, width()));
p.drawEllipse(style::rtlrect(st::emojiPanHeaderLeft - st::buttonRadius + titleWidth + st::stickersFeaturedUnreadSkip, info.top + st::stickersTrendingHeaderTop + st::stickersFeaturedUnreadTop, st::stickersFeaturedUnreadSize, st::stickersFeaturedUnreadSize, width()));
}
}

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/shadow.h"
#include "ui/image/image_prepare.h"
#include "ui/ui_utility.h"
#include "chat_helpers/tabbed_selector.h"
#include "window/window_session_controller.h"
#include "mainwindow.h"

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/animations.h"
#include "ui/rp_widget.h"
#include "base/timer.h"
#include "base/object_ptr.h"
namespace Window {
class SessionController;

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/panel_animation.h"
#include "mtproto/sender.h"
#include "main/main_session.h"
#include "base/object_ptr.h"
namespace InlineBots {
class Result;

View File

@ -736,7 +736,7 @@ void Application::registerLeaveSubscription(QWidget *widget) {
#ifdef Q_OS_MAC
if (const auto topLevel = widget->window()) {
if (topLevel == _window->widget()) {
auto weak = make_weak(widget);
auto weak = Ui::MakeWeak(widget);
auto subscription = _window->widget()->leaveEvents(
) | rpl::start_with_next([weak] {
if (const auto window = weak.data()) {
@ -862,3 +862,11 @@ Application &App() {
}
} // namespace Core
namespace Ui {
void PostponeCall(FnMut<void()> &&callable) {
Core::App().postponeCall(std::move(callable));
}
} // namespace Ui

View File

@ -47,7 +47,7 @@ auto QtSignalProducer(Object *object, Signal signal) {
NoArgument,
rpl::empty_value,
std::remove_const_t<std::decay_t<Value>>>;
const auto guarded = make_weak(object);
const auto guarded = QPointer<Object>(object);
return rpl::make_producer<Produced>([=](auto consumer) {
if (!guarded) {
return rpl::lifetime();
@ -59,7 +59,7 @@ auto QtSignalProducer(Object *object, Signal signal) {
signal,
listener,
std::forward<decltype(handler)>(handler));
const auto weak = make_weak(listener);
const auto weak = QPointer<QObject>(listener);
return rpl::lifetime([=] {
if (weak) {
delete weak;

View File

@ -513,7 +513,7 @@ bool Sandbox::notify(QObject *receiver, QEvent *e) {
const auto wrap = createEventNestingLevel();
if (e->type() == QEvent::UpdateRequest) {
const auto weak = make_weak(receiver);
const auto weak = QPointer<QObject>(receiver);
_widgetUpdateRequests.fire({});
if (!weak) {
return true;

View File

@ -25,17 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace base {
template <typename D, typename T>
inline constexpr D up_cast(T object) {
using DV = std::decay_t<decltype(*D())>;
using TV = std::decay_t<decltype(*T())>;
if constexpr (std::is_base_of_v<DV, TV>) {
return object;
} else {
return nullptr;
}
}
template <typename T>
using set_of_unique_ptr = std::set<std::unique_ptr<T>, base::pointer_comparator<T>>;

View File

@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/buttons.h"
#include "ui/widgets/popup_menu.h"
#include "ui/text_options.h"
#include "ui/ui_utility.h"
#include "data/data_drafts.h"
#include "data/data_folder.h"
#include "data/data_session.h"

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/animations.h"
#include "ui/rp_widget.h"
#include "base/flags.h"
#include "base/object_ptr.h"
namespace Main {
class Session;

View File

@ -252,7 +252,7 @@ void PanelController::showCriticalError(const QString &text) {
void PanelController::showError(const QString &text) {
auto box = Box<InformBox>(text);
const auto weak = make_weak(box.data());
const auto weak = Ui::MakeWeak(box.data());
const auto hidden = _panel->isHidden();
_panel->showBox(
std::move(box),

View File

@ -141,7 +141,7 @@ void ProgressWidget::Row::toggleInstance(Instance &instance, bool shown) {
if (instance.hiding != shown) {
return;
}
const auto label = make_weak(instance.label->entity());
const auto label = Ui::MakeWeak(instance.label->entity());
instance.opacity.start(
[=] { instanceOpacityCallback(label); },
shown ? 0. : 1.,
@ -156,7 +156,7 @@ void ProgressWidget::Row::instanceOpacityCallback(
QPointer<Ui::FlatLabel> label) {
update();
const auto i = ranges::find(_old, label, [](const Instance &instance) {
return make_weak(instance.label->entity());
return Ui::MakeWeak(instance.label->entity());
});
if (i != end(_old) && i->hiding && !i->opacity.animating()) {
crl::on_main(this, [=] {
@ -167,7 +167,7 @@ void ProgressWidget::Row::instanceOpacityCallback(
void ProgressWidget::Row::removeOldInstance(QPointer<Ui::FlatLabel> label) {
const auto i = ranges::find(_old, label, [](const Instance &instance) {
return make_weak(instance.label->entity());
return Ui::MakeWeak(instance.label->entity());
});
if (i != end(_old)) {
_old.erase(i);

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/rp_widget.h"
#include "export/view/export_view_content.h"
#include "base/object_ptr.h"
namespace Ui {
class VerticalLayout;

View File

@ -397,7 +397,7 @@ void SettingsWidget::editDateLimit(
callback,
finalize,
st::exportCalendarSizes);
*shared = make_weak(box.data());
*shared = Ui::MakeWeak(box.data());
_showBoxCallback(std::move(box));
}

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "export/export_settings.h"
#include "ui/rp_widget.h"
#include "base/object_ptr.h"
class BoxContent;

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "ui/rp_widget.h"
#include "base/object_ptr.h"
namespace Ui {
class FlatLabel;

View File

@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/shadow.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h"
#include "ui/ui_utility.h"
#include "mainwidget.h"
#include "mainwindow.h"
#include "apiwrap.h"

View File

@ -7,8 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/history_drag_area.h"
#include "styles/style_chat_helpers.h"
#include "styles/style_boxes.h"
#include "boxes/confirm_box.h"
#include "boxes/sticker_set_box.h"
#include "inline_bots/inline_bot_result.h"
@ -17,11 +15,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_widget.h"
#include "storage/localstorage.h"
#include "lang/lang_keys.h"
#include "ui/widgets/shadow.h"
#include "ui/ui_utility.h"
#include "mainwindow.h"
#include "apiwrap.h"
#include "mainwidget.h"
#include "app.h"
#include "ui/widgets/shadow.h"
#include "styles/style_chat_helpers.h"
#include "styles/style_boxes.h"
DragArea::DragArea(QWidget *parent) : TWidget(parent) {
setMouseTracking(true);

View File

@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "ui/twidget.h"
#include "ui/rp_widget.h"
#include "ui/effects/animations.h"
class DragArea : public TWidget {

View File

@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/image/image.h"
#include "ui/toast/toast.h"
#include "ui/text_options.h"
#include "ui/ui_utility.h"
#include "window/window_session_controller.h"
#include "window/window_peer_menu.h"
#include "boxes/confirm_box.h"
@ -932,7 +933,7 @@ void HistoryInner::touchEvent(QTouchEvent *e) {
case QEvent::TouchEnd: {
if (!_touchInProgress) return;
_touchInProgress = false;
auto weak = make_weak(this);
auto weak = Ui::MakeWeak(this);
if (_touchSelect) {
mouseActionFinish(_touchPos, Qt::RightButton);
QContextMenuEvent contextMenu(QContextMenuEvent::Mouse, mapFromGlobal(_touchPos), _touchPos);

View File

@ -308,7 +308,7 @@ void HistoryMessageReply::paint(
if (flags & PaintFlag::InBubble) {
bar = (flags & PaintFlag::Selected) ? (outbg ? st::msgOutReplyBarSelColor : st::msgInReplyBarSelColor) : (outbg ? st::msgOutReplyBarColor : st::msgInReplyBarColor);
}
QRect rbar(rtlrect(x + st::msgReplyBarPos.x(), y + st::msgReplyPadding.top() + st::msgReplyBarPos.y(), st::msgReplyBarSize.width(), st::msgReplyBarSize.height(), w + 2 * x));
QRect rbar(style::rtlrect(x + st::msgReplyBarPos.x(), y + st::msgReplyPadding.top() + st::msgReplyBarPos.y(), st::msgReplyBarSize.width(), st::msgReplyBarSize.height(), w + 2 * x));
p.fillRect(rbar, bar);
if (w > st::msgReplyBarSkip) {
@ -321,7 +321,7 @@ void HistoryMessageReply::paint(
if (hasPreview) {
if (const auto image = replyToMsg->media()->replyPreview()) {
auto to = rtlrect(x + st::msgReplyBarSkip, y + st::msgReplyPadding.top() + st::msgReplyBarPos.y(), st::msgReplyBarSize.height(), st::msgReplyBarSize.height(), w + 2 * x);
auto to = style::rtlrect(x + st::msgReplyBarSkip, y + st::msgReplyPadding.top() + st::msgReplyBarPos.y(), st::msgReplyBarSize.height(), st::msgReplyBarSize.height(), w + 2 * x);
auto previewWidth = image->width() / cIntRetinaFactor();
auto previewHeight = image->height() / cIntRetinaFactor();
auto preview = image->pixSingle(replyToMsg->fullId(), previewWidth, previewHeight, to.width(), to.height(), ImageRoundRadius::Small, RectPart::AllCorners, selected ? &st::msgStickerOverlay : nullptr);

View File

@ -6308,7 +6308,7 @@ void HistoryWidget::forwardSelected() {
if (!_list) {
return;
}
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
Window::ShowForwardMessagesBox(controller(), getSelectedItems(), [=] {
if (const auto strong = weak.data()) {
strong->clearSelected();
@ -6323,7 +6323,7 @@ void HistoryWidget::confirmDeleteSelected() {
if (items.empty()) {
return;
}
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
const auto box = Ui::show(Box<DeleteMessagesBox>(
&session(),
std::move(items)));

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/input_fields.h"
#include "ui/special_buttons.h"
#include "ui/ui_utility.h"
#include "lang/lang_keys.h"
#include "core/event_filter.h"
#include "core/qt_signal_producer.h"

View File

@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/popup_menu.h"
#include "ui/image/image.h"
#include "ui/toast/toast.h"
#include "ui/ui_utility.h"
#include "chat_helpers/message_field.h"
#include "boxes/confirm_box.h"
#include "boxes/sticker_set_box.h"
@ -239,7 +240,7 @@ bool AddForwardSelectedAction(
}
menu->addAction(tr::lng_context_forward_selected(tr::now), [=] {
const auto weak = make_weak(list);
const auto weak = Ui::MakeWeak(list);
const auto callback = [=] {
if (const auto strong = weak.data()) {
strong->cancelSelection();
@ -324,7 +325,7 @@ bool AddSendNowSelectedAction(
const auto history = *histories.begin();
menu->addAction(tr::lng_context_send_now_selected(tr::now), [=] {
const auto weak = make_weak(list);
const auto weak = Ui::MakeWeak(list);
const auto callback = [=] {
request.navigation->showBackFromStack();
};
@ -398,7 +399,7 @@ bool AddDeleteSelectedAction(
}
menu->addAction(tr::lng_context_delete_selected(tr::now), [=] {
const auto weak = make_weak(list);
const auto weak = Ui::MakeWeak(list);
auto items = ExtractIdsList(request.selectedItems);
const auto box = Ui::show(Box<DeleteMessagesBox>(
&request.navigation->session(),

View File

@ -1447,7 +1447,7 @@ void Message::drawRightAction(
p.setBrush(st::msgServiceBg);
{
PainterHighQualityEnabler hq(p);
p.drawEllipse(rtlrect(
p.drawEllipse(style::rtlrect(
left,
top,
st::historyFastShareSize,

View File

@ -263,7 +263,7 @@ TimeInput::TimeInput(QWidget *parent, const QString &value)
GetMinute(value))
, _value(valueCurrent()) {
const auto focused = [=](const object_ptr<TimePart> &field) {
return [this, pointer = make_weak(field.data())]{
return [this, pointer = Ui::MakeWeak(field.data())]{
_borderAnimationStart = pointer->borderAnimationStart()
+ pointer->x()
- _hour->x();

View File

@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/shadow.h"
#include "ui/toast/toast.h"
#include "ui/special_buttons.h"
#include "ui/ui_utility.h"
#include "api/api_common.h"
#include "api/api_sending.h"
#include "apiwrap.h"
@ -943,7 +944,7 @@ void ScheduledWidget::confirmDeleteSelected() {
if (items.empty()) {
return;
}
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
const auto box = Ui::show(Box<DeleteMessagesBox>(
&_history->session(),
std::move(items)));

View File

@ -20,11 +20,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "lang/lang_keys.h"
#include "core/shortcuts.h"
#include "ui/special_buttons.h"
#include "ui/unread_badge.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/dropdown_menu.h"
#include "ui/effects/radial_animation.h"
#include "ui/special_buttons.h"
#include "ui/unread_badge.h"
#include "ui/ui_utility.h"
#include "window/window_session_controller.h"
#include "window/window_peer_menu.h"
#include "calls/calls_instance.h"
@ -198,23 +199,23 @@ void TopBarWidget::showMenu() {
return;
}
_menu.create(parentWidget());
_menu->setHiddenCallback([weak = make_weak(this), menu = _menu.data()]{
_menu->setHiddenCallback([weak = Ui::MakeWeak(this), menu = _menu.data()]{
menu->deleteLater();
if (weak && weak->_menu == menu) {
weak->_menu = nullptr;
weak->_menuToggle->setForceRippled(false);
}
});
});
_menu->setShowStartCallback(crl::guard(this, [this, menu = _menu.data()]{
if (_menu == menu) {
_menuToggle->setForceRippled(true);
}
}));
}));
_menu->setHideStartCallback(crl::guard(this, [this, menu = _menu.data()]{
if (_menu == menu) {
_menuToggle->setForceRippled(false);
}
}));
}));
_menuToggle->installEventFilter(_menu);
const auto addAction = [&](
const QString & text,

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/rp_widget.h"
#include "ui/effects/animations.h"
#include "base/timer.h"
#include "base/object_ptr.h"
#include "dialogs/dialogs_key.h"
namespace Main {

View File

@ -163,7 +163,7 @@ void Contact::draw(Painter &p, const QRect &r, TextSelection selection, crl::tim
statustop = st::msgFileThumbStatusTop - topMinus;
linktop = st::msgFileThumbLinkTop - topMinus;
QRect rthumb(rtlrect(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top() - topMinus, st::msgFileThumbSize, st::msgFileThumbSize, paintw));
QRect rthumb(style::rtlrect(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top() - topMinus, st::msgFileThumbSize, st::msgFileThumbSize, paintw));
if (_contact) {
_contact->paintUserpic(p, rthumb.x(), rthumb.y(), st::msgFileThumbSize);
} else {
@ -208,7 +208,7 @@ TextState Contact::textState(QPoint point, StateRequest request) const {
if (_userId) {
nameleft = st::msgFileThumbPadding.left() + st::msgFileThumbSize + st::msgFileThumbPadding.right();
linktop = st::msgFileThumbLinkTop - topMinus;
if (rtlrect(nameleft, linktop, _linkw, st::semiboldFont->height, width()).contains(point)) {
if (style::rtlrect(nameleft, linktop, _linkw, st::semiboldFont->height, width()).contains(point)) {
result.link = _linkl;
return result;
}

View File

@ -238,7 +238,7 @@ void Document::draw(Painter &p, const QRect &r, TextSelection selection, crl::ti
auto inWebPage = (_parent->media() != this);
auto roundRadius = inWebPage ? ImageRoundRadius::Small : ImageRoundRadius::Large;
QRect rthumb(rtlrect(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top() - topMinus, st::msgFileThumbSize, st::msgFileThumbSize, width()));
QRect rthumb(style::rtlrect(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top() - topMinus, st::msgFileThumbSize, st::msgFileThumbSize, width()));
QPixmap thumb;
if (const auto normal = _data->thumbnail()) {
if (normal->loaded()) {
@ -307,7 +307,7 @@ void Document::draw(Painter &p, const QRect &r, TextSelection selection, crl::ti
statustop = st::msgFileStatusTop - topMinus;
bottom = st::msgFilePadding.top() + st::msgFileSize + st::msgFilePadding.bottom() - topMinus;
QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top() - topMinus, st::msgFileSize, st::msgFileSize, width()));
QRect inner(style::rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top() - topMinus, st::msgFileSize, st::msgFileSize, width()));
p.setPen(Qt::NoPen);
if (selected) {
p.setBrush(outbg ? st::msgFileOutBgSelected : st::msgFileInBgSelected);
@ -447,7 +447,7 @@ void Document::draw(Painter &p, const QRect &r, TextSelection selection, crl::ti
{
PainterHighQualityEnabler hq(p);
p.drawEllipse(rtlrect(nameleft + w + st::mediaUnreadSkip, statustop + st::mediaUnreadTop, st::mediaUnreadSize, st::mediaUnreadSize, width()));
p.drawEllipse(style::rtlrect(nameleft + w + st::mediaUnreadSkip, statustop + st::mediaUnreadTop, st::mediaUnreadSize, st::mediaUnreadSize, width()));
}
}
}
@ -473,7 +473,7 @@ void Document::drawCornerDownload(Painter &p, bool selected) const {
auto topMinus = isBubbleTop() ? 0 : st::msgFileTopMinus;
const auto shift = st::historyAudioDownloadShift;
const auto size = st::historyAudioDownloadSize;
const auto inner = rtlrect(st::msgFilePadding.left() + shift, st::msgFilePadding.top() - topMinus + shift, size, size, width());
const auto inner = style::rtlrect(st::msgFilePadding.left() + shift, st::msgFilePadding.top() - topMinus + shift, size, size, width());
auto pen = (selected
? (outbg ? st::msgOutBgSelected : st::msgInBgSelected)
: (outbg ? st::msgOutBg : st::msgInBg))->p;
@ -512,7 +512,7 @@ TextState Document::cornerDownloadTextState(
auto topMinus = isBubbleTop() ? 0 : st::msgFileTopMinus;
const auto shift = st::historyAudioDownloadShift;
const auto size = st::historyAudioDownloadSize;
const auto inner = rtlrect(st::msgFilePadding.left() + shift, st::msgFilePadding.top() - topMinus + shift, size, size, width());
const auto inner = style::rtlrect(st::msgFilePadding.left() + shift, st::msgFilePadding.top() - topMinus + shift, size, size, width());
if (inner.contains(point)) {
result.link = _data->loading() ? _cancell : _savel;
}
@ -540,14 +540,14 @@ TextState Document::textState(QPoint point, StateRequest request) const {
linktop = st::msgFileThumbLinkTop - topMinus;
bottom = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom() - topMinus;
QRect rthumb(rtlrect(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top() - topMinus, st::msgFileThumbSize, st::msgFileThumbSize, width()));
QRect rthumb(style::rtlrect(st::msgFileThumbPadding.left(), st::msgFileThumbPadding.top() - topMinus, st::msgFileThumbSize, st::msgFileThumbSize, width()));
if ((_data->loading() || _data->uploading()) && rthumb.contains(point)) {
result.link = _cancell;
return result;
}
if (_data->status != FileUploadFailed) {
if (rtlrect(nameleft, linktop, thumbed->_linkw, st::semiboldFont->height, width()).contains(point)) {
if (style::rtlrect(nameleft, linktop, thumbed->_linkw, st::semiboldFont->height, width()).contains(point)) {
result.link = (_data->loading() || _data->uploading())
? thumbed->_linkcancell
: _data->loaded()
@ -565,7 +565,7 @@ TextState Document::textState(QPoint point, StateRequest request) const {
if (const auto state = cornerDownloadTextState(point, request); state.link) {
return state;
}
QRect inner(rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top() - topMinus, st::msgFileSize, st::msgFileSize, width()));
QRect inner(style::rtlrect(st::msgFilePadding.left(), st::msgFilePadding.top() - topMinus, st::msgFileSize, st::msgFileSize, width()));
if ((_data->loading() || _data->uploading()) && inner.contains(point) && !downloadInCorner()) {
result.link = _cancell;
return result;

View File

@ -213,7 +213,7 @@ void Game::draw(Painter &p, const QRect &r, TextSelection selection, crl::time m
bshift += bottomInfoPadding();
}
QRect bar(rtlrect(st::msgPadding.left(), tshift, st::webPageBar, height() - tshift - bshift, width()));
QRect bar(style::rtlrect(st::msgPadding.left(), tshift, st::webPageBar, height() - tshift - bshift, width()));
p.fillRect(bar, barfg);
auto lineHeight = unitedLineHeight();
@ -255,7 +255,7 @@ void Game::draw(Painter &p, const QRect &r, TextSelection selection, crl::time m
auto gameX = pixwidth - st::msgDateImgDelta - gameW;
auto gameY = pixheight - st::msgDateImgDelta - gameH;
App::roundRect(p, rtlrect(gameX, gameY, gameW, gameH, pixwidth), selected ? st::msgDateImgBgSelected : st::msgDateImgBg, selected ? DateSelectedCorners : DateCorners);
App::roundRect(p, style::rtlrect(gameX, gameY, gameW, gameH, pixwidth), selected ? st::msgDateImgBgSelected : st::msgDateImgBg, selected ? DateSelectedCorners : DateCorners);
p.setFont(st::msgDateFont);
p.setPen(st::msgDateImgFg);

View File

@ -292,7 +292,7 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms
}
if (rtl()) usex = width() - usex - usew;
QRect rthumb(rtlrect(usex + paintx, painty, usew, painth, width()));
QRect rthumb(style::rtlrect(usex + paintx, painty, usew, painth, width()));
auto roundRadius = isRound ? ImageRoundRadius::Ellipse : inWebPage ? ImageRoundRadius::Small : ImageRoundRadius::Large;
auto roundCorners = (isRound || inWebPage) ? RectPart::AllCorners : ((isBubbleTop() ? (RectPart::TopLeft | RectPart::TopRight) : RectPart::None)
@ -417,14 +417,14 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms
auto statusY = painty + st::msgDateImgDelta + st::msgDateImgPadding.y();
auto statusW = st::normalFont->width(_statusText) + 2 * st::msgDateImgPadding.x();
auto statusH = st::normalFont->height + 2 * st::msgDateImgPadding.y();
App::roundRect(p, rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, width()), selected ? st::msgDateImgBgSelected : st::msgDateImgBg, selected ? DateSelectedCorners : DateCorners);
App::roundRect(p, style::rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, width()), selected ? st::msgDateImgBgSelected : st::msgDateImgBg, selected ? DateSelectedCorners : DateCorners);
p.setFont(st::normalFont);
p.setPen(st::msgDateImgFg);
p.drawTextLeft(statusX, statusY, width(), _statusText, statusW - 2 * st::msgDateImgPadding.x());
}
}
if (displayMute) {
auto muteRect = rtlrect(rthumb.x() + (rthumb.width() - st::historyVideoMessageMuteSize) / 2, rthumb.y() + st::msgDateImgDelta, st::historyVideoMessageMuteSize, st::historyVideoMessageMuteSize, width());
auto muteRect = style::rtlrect(rthumb.x() + (rthumb.width() - st::historyVideoMessageMuteSize) / 2, rthumb.y() + st::msgDateImgDelta, st::historyVideoMessageMuteSize, st::historyVideoMessageMuteSize, width());
p.setPen(Qt::NoPen);
p.setBrush(selected ? st::msgDateImgBgSelected : st::msgDateImgBg);
PainterHighQualityEnabler hq(p);
@ -441,7 +441,7 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms
if (mediaUnread) {
statusW += st::mediaUnreadSkip + st::mediaUnreadSize;
}
App::roundRect(p, rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, width()), selected ? st::msgServiceBgSelected : st::msgServiceBg, selected ? StickerSelectedCorners : StickerCorners);
App::roundRect(p, style::rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, width()), selected ? st::msgServiceBgSelected : st::msgServiceBg, selected ? StickerSelectedCorners : StickerCorners);
p.setFont(st::normalFont);
p.setPen(st::msgServiceFg);
p.drawTextLeft(statusX, statusY, width(), _statusText, statusW - 2 * st::msgDateImgPadding.x());
@ -451,7 +451,7 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms
{
PainterHighQualityEnabler hq(p);
p.drawEllipse(rtlrect(statusX - st::msgDateImgPadding.x() + statusW - st::msgDateImgPadding.x() - st::mediaUnreadSize, statusY + st::mediaUnreadTop, st::mediaUnreadSize, st::mediaUnreadSize, width()));
p.drawEllipse(style::rtlrect(statusX - st::msgDateImgPadding.x() + statusW - st::msgDateImgPadding.x() - st::mediaUnreadSize, statusY + st::mediaUnreadTop, st::mediaUnreadSize, st::mediaUnreadSize, width()));
}
}
if (via || reply || forwarded) {

View File

@ -259,7 +259,7 @@ void Invoice::draw(Painter &p, const QRect &r, TextSelection selection, crl::tim
auto statusX = st::msgDateImgDelta;
auto statusY = st::msgDateImgDelta;
App::roundRect(p, rtlrect(statusX, statusY, statusW, statusH, pixwidth), selected ? st::msgDateImgBgSelected : st::msgDateImgBg, selected ? DateSelectedCorners : DateCorners);
App::roundRect(p, style::rtlrect(statusX, statusY, statusW, statusH, pixwidth), selected ? st::msgDateImgBgSelected : st::msgDateImgBg, selected ? DateSelectedCorners : DateCorners);
p.setFont(st::msgDateFont);
p.setPen(st::msgDateImgFg);

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "history/view/history_view_object.h"
#include "ui/rect_part.h"
class History;
struct HistoryMessageEdited;

View File

@ -164,7 +164,7 @@ void Photo::draw(Painter &p, const QRect &r, TextSelection selection, crl::time
}
const auto radial = isRadialAnimation();
auto rthumb = rtlrect(paintx, painty, paintw, painth, width());
auto rthumb = style::rtlrect(paintx, painty, paintw, painth, width());
if (_serviceWidth > 0) {
const auto pix = [&] {
if (loaded) {
@ -187,7 +187,7 @@ void Photo::draw(Painter &p, const QRect &r, TextSelection selection, crl::time
if (isBubbleBottom()) {
painth -= st::msgPadding.bottom();
}
rthumb = rtlrect(paintx, painty, paintw, painth, width());
rthumb = style::rtlrect(paintx, painty, paintw, painth, width());
}
} else {
App::roundShadow(p, 0, 0, paintw, painth, selected ? st::msgInShadowSelected : st::msgInShadow, selected ? InSelectedShadowCorners : InShadowCorners);

View File

@ -118,7 +118,7 @@ void ThemeDocument::draw(Painter &p, const QRect &r, TextSelection selection, cr
}
const auto radial = isRadialAnimation();
auto rthumb = rtlrect(paintx, painty, paintw, painth, width());
auto rthumb = style::rtlrect(paintx, painty, paintw, painth, width());
auto roundRadius = ImageRoundRadius::Small;
auto roundCorners = RectPart::AllCorners;
validateThumbnail();
@ -131,7 +131,7 @@ void ThemeDocument::draw(Painter &p, const QRect &r, TextSelection selection, cr
auto statusY = painty + st::msgDateImgDelta + st::msgDateImgPadding.y();
auto statusW = st::normalFont->width(_statusText) + 2 * st::msgDateImgPadding.x();
auto statusH = st::normalFont->height + 2 * st::msgDateImgPadding.y();
App::roundRect(p, rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, width()), selected ? st::msgDateImgBgSelected : st::msgDateImgBg, selected ? DateSelectedCorners : DateCorners);
App::roundRect(p, style::rtlrect(statusX - st::msgDateImgPadding.x(), statusY - st::msgDateImgPadding.y(), statusW, statusH, width()), selected ? st::msgDateImgBgSelected : st::msgDateImgBg, selected ? DateSelectedCorners : DateCorners);
p.setFont(st::normalFont);
p.setPen(st::msgDateImgFg);
p.drawTextLeft(statusX, statusY, width(), _statusText, statusW - 2 * st::msgDateImgPadding.x());

View File

@ -184,7 +184,7 @@ void Video::draw(Painter &p, const QRect &r, TextSelection selection, crl::time
auto roundRadius = inWebPage ? ImageRoundRadius::Small : ImageRoundRadius::Large;
auto roundCorners = inWebPage ? RectPart::AllCorners : ((isBubbleTop() ? (RectPart::TopLeft | RectPart::TopRight) : RectPart::None)
| ((isBubbleBottom() && _caption.isEmpty()) ? (RectPart::BottomLeft | RectPart::BottomRight) : RectPart::None));
QRect rthumb(rtlrect(paintx, painty, paintw, painth, width()));
QRect rthumb(style::rtlrect(paintx, painty, paintw, painth, width()));
const auto good = _data->goodThumbnail();
if (good && good->loaded()) {
@ -278,7 +278,7 @@ void Video::drawCornerStatus(Painter &p, bool selected) const {
const auto statusH = cornerDownload ? (st::historyVideoDownloadSize + 2 * padding.y()) : (st::normalFont->height + 2 * padding.y());
const auto statusX = st::msgDateImgDelta + padding.x();
const auto statusY = st::msgDateImgDelta + padding.y();
const auto around = rtlrect(statusX - padding.x(), statusY - padding.y(), statusW, statusH, width());
const auto around = style::rtlrect(statusX - padding.x(), statusY - padding.y(), statusW, statusH, width());
const auto statusTextTop = statusY + (cornerDownload ? (((statusH - 2 * st::normalFont->height) / 3) - padding.y()) : 0);
App::roundRect(p, around, selected ? st::msgDateImgBgSelected : st::msgDateImgBg, selected ? DateSelectedCorners : DateCorners);
p.setFont(st::normalFont);

View File

@ -434,7 +434,7 @@ void WebPage::draw(Painter &p, const QRect &r, TextSelection selection, crl::tim
bshift += bottomInfoPadding();
}
QRect bar(rtlrect(st::msgPadding.left(), tshift, st::webPageBar, height() - tshift - bshift, width()));
QRect bar(style::rtlrect(st::msgPadding.left(), tshift, st::webPageBar, height() - tshift - bshift, width()));
p.fillRect(bar, barfg);
auto lineHeight = unitedLineHeight();
@ -462,7 +462,7 @@ void WebPage::draw(Painter &p, const QRect &r, TextSelection selection, crl::tim
}
p.drawPixmapLeft(padding.left() + paintw - pw, tshift, width(), pix);
if (selected) {
App::roundRect(p, rtlrect(padding.left() + paintw - pw, tshift, pw, _pixh, width()), p.textPalette().selectOverlay, SelectedOverlaySmallCorners);
App::roundRect(p, style::rtlrect(padding.left() + paintw - pw, tshift, pw, _pixh, width()), p.textPalette().selectOverlay, SelectedOverlaySmallCorners);
}
paintw -= pw + st::webPagePhotoDelta;
}
@ -573,7 +573,7 @@ TextState WebPage::textState(QPoint point, StateRequest request) const {
auto inThumb = false;
if (asArticle()) {
auto pw = qMax(_pixw, lineHeight);
if (rtlrect(padding.left() + paintw - pw, 0, pw, _pixh, width()).contains(point)) {
if (style::rtlrect(padding.left() + paintw - pw, 0, pw, _pixh, width()).contains(point)) {
inThumb = true;
}
paintw -= pw + st::webPagePhotoDelta;

View File

@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/info_controller.h"
#include "ui/search_field_controller.h"
#include "ui/widgets/scroll_area.h"
#include "ui/ui_utility.h"
#include "data/data_user.h"
#include "data/data_session.h"
#include "main/main_session.h"

View File

@ -17,6 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/info_section_widget.h"
#include "info/info_layer_widget.h"
#include "info/info_controller.h"
#include "ui/ui_utility.h"
#include "boxes/peer_list_box.h"
#include "data/data_channel.h"
#include "data/data_chat.h"

View File

@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/info_wrap_widget.h"
#include "dialogs/dialogs_key.h"
#include "window/section_memento.h"
#include "base/object_ptr.h"
namespace Storage {
enum class SharedMediaType : signed char;

View File

@ -52,7 +52,7 @@ void TopBar::registerUpdateControlCallback(
QObject *guard,
Callback &&callback) {
_updateControlCallbacks[guard] =[
weak = make_weak(guard),
weak = Ui::MakeWeak(guard),
callback = std::forward<Callback>(callback)
](anim::type animated) {
if (!weak) {
@ -532,7 +532,7 @@ void TopBar::performForward() {
Window::ShowForwardMessagesBox(
_navigation,
std::move(items),
[weak = make_weak(this)] {
[weak = Ui::MakeWeak(this)] {
if (weak) {
weak->_cancelSelectionClicks.fire({});
}
@ -547,7 +547,7 @@ void TopBar::performDelete() {
const auto box = Ui::show(Box<DeleteMessagesBox>(
&_navigation->session(),
std::move(items)));
box->setDeleteConfirmedCallback([weak = make_weak(this)] {
box->setDeleteConfirmedCallback([weak = Ui::MakeWeak(this)] {
if (weak) {
weak->_cancelSelectionClicks.fire({});
}

View File

@ -1036,7 +1036,7 @@ object_ptr<Ui::RpWidget> WrapWidget::createTopBarSurrogate(
Assert(_topBar != nullptr);
auto result = object_ptr<Ui::AbstractButton>(parent);
result->addClickHandler([weak = make_weak(this)]{
result->addClickHandler([weak = Ui::MakeWeak(this)]{
if (weak) {
weak->_controller->showBackFromStack();
}

View File

@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_peer_menu.h"
#include "storage/file_download.h"
#include "ui/widgets/popup_menu.h"
#include "ui/ui_utility.h"
#include "lang/lang_keys.h"
#include "main/main_session.h"
#include "mainwidget.h"
@ -1396,7 +1397,7 @@ void ListWidget::forwardItem(UniversalMsgId universalId) {
}
void ListWidget::forwardItems(MessageIdsList &&items) {
auto callback = [weak = make_weak(this)] {
auto callback = [weak = Ui::MakeWeak(this)] {
if (const auto strong = weak.data()) {
strong->clearSelected();
}
@ -1409,7 +1410,7 @@ void ListWidget::forwardItems(MessageIdsList &&items) {
void ListWidget::deleteSelected() {
if (const auto box = deleteItems(collectSelectedIds())) {
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
box->setDeleteConfirmedCallback([=]{
if (const auto strong = weak.data()) {
strong->clearSelected();
@ -1439,7 +1440,7 @@ DeleteMessagesBox *ListWidget::deleteItems(MessageIdsList &&items) {
void ListWidget::setActionBoxWeak(QPointer<Ui::RpWidget> box) {
if ((_actionBoxWeak = box)) {
_actionBoxWeakLifetime = _actionBoxWeak->alive(
) | rpl::start_with_done([weak = make_weak(this)]{
) | rpl::start_with_done([weak = Ui::MakeWeak(this)]{
if (weak) {
weak->_checkForHide.fire({});
}

View File

@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/info_controller.h"
#include "ui/widgets/scroll_area.h"
#include "ui/search_field_controller.h"
#include "ui/ui_utility.h"
#include "styles/style_info.h"
namespace Info {

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/profile/info_profile_members.h"
#include "info/info_controller.h"
#include "ui/widgets/scroll_area.h"
#include "ui/ui_utility.h"
#include "styles/style_info.h"
namespace Info {

View File

@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "base/object_ptr.h"
namespace Ui {
class RpWidget;
} // namespace Ui

View File

@ -75,7 +75,7 @@ void SectionToggle::paint(
int top,
int outerWidth) {
auto sqrt2 = sqrt(2.);
auto vLeft = rtlpoint(left + _st.skip, 0, outerWidth).x() + 0.;
auto vLeft = style::rtlpoint(left + _st.skip, 0, outerWidth).x() + 0.;
auto vTop = top + _st.skip + 0.;
auto vWidth = _st.size - 2 * _st.skip;
auto vHeight = _st.size - 2 * _st.skip;

View File

@ -7,8 +7,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include <rpl/variable.h>
#include "ui/rp_widget.h"
#include "base/object_ptr.h"
#include <rpl/variable.h>
namespace Window {
class SessionController;

View File

@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "base/object_ptr.h"
#include <rpl/producer.h>
namespace style {

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/profile/info_profile_inner_widget.h"
#include "info/profile/info_profile_members.h"
#include "ui/widgets/scroll_area.h"
#include "ui/ui_utility.h"
#include "info/info_controller.h"
namespace Info {

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/info_memento.h"
#include "info/info_controller.h"
#include "settings/settings_common.h"
#include "ui/ui_utility.h"
namespace Info {
namespace Settings {

View File

@ -218,7 +218,7 @@ TextState Gif::getState(
QPoint point,
StateRequest request) const {
if (QRect(0, 0, _width, st::inlineMediaHeight).contains(point)) {
if (_delete && rtlpoint(point, _width).x() >= _width - st::stickerPanDeleteIconBg.width() && point.y() < st::stickerPanDeleteIconBg.height()) {
if (_delete && style::rtlpoint(point, _width).x() >= _width - st::stickerPanDeleteIconBg.width() && point.y() < st::stickerPanDeleteIconBg.height()) {
return { nullptr, _delete };
} else {
return { nullptr, _send };
@ -668,12 +668,12 @@ void Video::paint(Painter &p, const QRect &clip, const PaintContext *context) co
if (withThumb) {
prepareThumbnail({ st::inlineThumbSize, st::inlineThumbSize });
if (_thumb.isNull()) {
p.fillRect(rtlrect(0, st::inlineRowMargin, st::inlineThumbSize, st::inlineThumbSize, _width), st::overviewPhotoBg);
p.fillRect(style::rtlrect(0, st::inlineRowMargin, st::inlineThumbSize, st::inlineThumbSize, _width), st::overviewPhotoBg);
} else {
p.drawPixmapLeft(0, st::inlineRowMargin, _width, _thumb);
}
} else {
p.fillRect(rtlrect(0, st::inlineRowMargin, st::inlineThumbSize, st::inlineThumbSize, _width), st::overviewVideoBg);
p.fillRect(style::rtlrect(0, st::inlineRowMargin, st::inlineThumbSize, st::inlineThumbSize, _width), st::overviewVideoBg);
}
if (!_duration.isEmpty()) {
@ -695,7 +695,7 @@ void Video::paint(Painter &p, const QRect &clip, const PaintContext *context) co
_description.drawLeftElided(p, left, st::inlineRowMargin + titleHeight, _width - left, _width, descriptionLines);
if (!context->lastRow) {
p.fillRect(rtlrect(left, _height - st::inlineRowBorder, _width - left, st::inlineRowBorder, _width), st::inlineRowBorderFg);
p.fillRect(style::rtlrect(left, _height - st::inlineRowBorder, _width - left, st::inlineRowBorder, _width), st::inlineRowBorderFg);
}
}
@ -791,7 +791,7 @@ void File::paint(Painter &p, const QRect &clip, const PaintContext *context) con
const auto showPause = updateStatusText();
const auto radial = isRadialAnimation();
auto inner = rtlrect(0, st::inlineRowMargin, st::msgFileSize, st::msgFileSize, _width);
auto inner = style::rtlrect(0, st::inlineRowMargin, st::msgFileSize, st::msgFileSize, _width);
p.setPen(Qt::NoPen);
if (isThumbAnimation()) {
auto over = _animation->a_thumbOver.value(1.);
@ -849,7 +849,7 @@ void File::paint(Painter &p, const QRect &clip, const PaintContext *context) con
}
if (!context->lastRow) {
p.fillRect(rtlrect(left, _height - st::inlineRowBorder, _width - left, st::inlineRowBorder, _width), st::inlineRowBorderFg);
p.fillRect(style::rtlrect(left, _height - st::inlineRowBorder, _width - left, st::inlineRowBorder, _width), st::inlineRowBorderFg);
}
}
@ -994,7 +994,7 @@ void Contact::paint(Painter &p, const QRect &clip, const PaintContext *context)
left = st::msgFileSize + st::inlineThumbSkip;
prepareThumbnail(st::msgFileSize, st::msgFileSize);
QRect rthumb(rtlrect(0, st::inlineRowMargin, st::msgFileSize, st::msgFileSize, _width));
QRect rthumb(style::rtlrect(0, st::inlineRowMargin, st::msgFileSize, st::msgFileSize, _width));
p.drawPixmapLeft(rthumb.topLeft(), _width, _thumb);
int titleTop = st::inlineRowMargin + st::inlineRowFileNameTop;
@ -1007,7 +1007,7 @@ void Contact::paint(Painter &p, const QRect &clip, const PaintContext *context)
_description.drawLeftElided(p, left, descriptionTop, _width - left, _width);
if (!context->lastRow) {
p.fillRect(rtlrect(left, _height - st::inlineRowBorder, _width - left, st::inlineRowBorder, _width), st::inlineRowBorderFg);
p.fillRect(style::rtlrect(left, _height - st::inlineRowBorder, _width - left, st::inlineRowBorder, _width), st::inlineRowBorderFg);
}
}
@ -1107,7 +1107,7 @@ void Article::paint(Painter &p, const QRect &clip, const PaintContext *context)
if (_withThumb) {
left = st::inlineThumbSize + st::inlineThumbSkip;
prepareThumbnail(st::inlineThumbSize, st::inlineThumbSize);
QRect rthumb(rtlrect(0, st::inlineRowMargin, st::inlineThumbSize, st::inlineThumbSize, _width));
QRect rthumb(style::rtlrect(0, st::inlineRowMargin, st::inlineThumbSize, st::inlineThumbSize, _width));
if (_thumb.isNull()) {
const auto thumb = getResultThumb();
if (!thumb && !_thumbLetter.isEmpty()) {
@ -1147,7 +1147,7 @@ void Article::paint(Painter &p, const QRect &clip, const PaintContext *context)
}
if (!context->lastRow) {
p.fillRect(rtlrect(left, _height - st::inlineRowBorder, _width - left, st::inlineRowBorder, _width), st::inlineRowBorderFg);
p.fillRect(style::rtlrect(left, _height - st::inlineRowBorder, _width - left, st::inlineRowBorder, _width), st::inlineRowBorderFg);
}
}
@ -1164,7 +1164,7 @@ TextState Article::getState(
auto titleHeight = qMin(_title.countHeight(_width - left), st::semiboldFont->height * 2);
auto descriptionLines = 2;
auto descriptionHeight = qMin(_description.countHeight(_width - left), st::normalFont->height * descriptionLines);
if (rtlrect(left, st::inlineRowMargin + titleHeight + descriptionHeight, _urlWidth, st::normalFont->height, _width).contains(point)) {
if (style::rtlrect(left, st::inlineRowMargin + titleHeight + descriptionHeight, _urlWidth, st::normalFont->height, _width).contains(point)) {
return { nullptr, _url };
}
}
@ -1268,7 +1268,7 @@ void Game::paint(Painter &p, const QRect &clip, const PaintContext *context) con
int32 left = st::emojiPanHeaderLeft - st::inlineResultsLeft;
left = st::inlineThumbSize + st::inlineThumbSkip;
auto rthumb = rtlrect(0, st::inlineRowMargin, st::inlineThumbSize, st::inlineThumbSize, _width);
auto rthumb = style::rtlrect(0, st::inlineRowMargin, st::inlineThumbSize, st::inlineThumbSize, _width);
// Gif thumb
auto thumbDisplayed = false, radial = false;
@ -1335,7 +1335,7 @@ void Game::paint(Painter &p, const QRect &clip, const PaintContext *context) con
_description.drawLeftElided(p, left, st::inlineRowMargin + titleHeight, _width - left, _width, descriptionLines);
if (!context->lastRow) {
p.fillRect(rtlrect(left, _height - st::inlineRowBorder, _width - left, st::inlineRowBorder, _width), st::inlineRowBorderFg);
p.fillRect(style::rtlrect(left, _height - st::inlineRowBorder, _width - left, st::inlineRowBorder, _width), st::inlineRowBorderFg);
}
}

View File

@ -254,7 +254,7 @@ void Widget::historyMove(Direction direction) {
}
void Widget::hideAndDestroy(object_ptr<Ui::FadeWrap<Ui::RpWidget>> widget) {
const auto weak = make_weak(widget.data());
const auto weak = Ui::MakeWeak(widget.data());
widget->hide(anim::type::normal);
widget->shownValue(
) | rpl::start_with_next([=](bool shown) {
@ -447,7 +447,7 @@ void Widget::showTerms(Fn<void()> callback) {
if (getData()->termsLock.text.text.isEmpty()) {
return;
}
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
const auto box = Ui::show(callback
? Box<Window::TermsBox>(
getData()->termsLock,

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "data/data_auto_download.h"
#include "ui/rect_part.h"
enum class SendFilesWay;

View File

@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/buttons.h"
#include "ui/widgets/shadow.h"
#include "ui/emoji_config.h"
#include "ui/ui_utility.h"
#include "lang/lang_cloud_manager.h"
#include "lang/lang_instance.h"
#include "lang/lang_keys.h"

View File

@ -8,7 +8,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "ui/rp_widget.h"
#include "ui/rect_part.h"
#include "ui/effects/animations.h"
#include "base/object_ptr.h"
namespace Window {
class SessionController;

View File

@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_chat.h"
#include "ui/widgets/shadow.h"
#include "ui/widgets/scroll_area.h"
#include "ui/ui_utility.h"
#include "mainwindow.h"
#include "main/main_session.h"
#include "app.h"

View File

@ -11,12 +11,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/buttons.h"
#include "ui/widgets/shadow.h"
#include "ui/widgets/continuous_sliders.h"
#include "styles/style_media_player.h"
#include "styles/style_widgets.h"
#include "ui/ui_utility.h"
#include "base/object_ptr.h"
#include "mainwindow.h"
#include "main/main_session.h"
#include "facades.h"
#include "app.h"
#include "styles/style_media_player.h"
#include "styles/style_widgets.h"
namespace Media {
namespace Player {

View File

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/animations.h"
#include "ui/rp_widget.h"
#include "base/object_ptr.h"
#include <QtCore/QTimer>

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "ui/rp_widget.h"
#include "base/object_ptr.h"
class AudioMsgId;

View File

@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "ui/rect_part.h"
enum class ImageRoundRadius;
namespace Media {

View File

@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_utilities.h"
#include "ui/toast/toast.h"
#include "ui/text_options.h"
#include "ui/ui_utility.h"
#include "boxes/confirm_box.h"
#include "media/audio/media_audio.h"
#include "media/view/media_view_playback_controls.h"
@ -351,11 +352,11 @@ void OverlayWidget::moveToScreen(bool force) {
auto navSkip = 2 * st::mediaviewControlMargin + st::mediaviewControlSize;
_closeNav = myrtlrect(width() - st::mediaviewControlMargin - st::mediaviewControlSize, st::mediaviewControlMargin, st::mediaviewControlSize, st::mediaviewControlSize);
_closeNavIcon = centerrect(_closeNav, st::mediaviewClose);
_closeNavIcon = style::centerrect(_closeNav, st::mediaviewClose);
_leftNav = myrtlrect(st::mediaviewControlMargin, navSkip, st::mediaviewControlSize, height() - 2 * navSkip);
_leftNavIcon = centerrect(_leftNav, st::mediaviewLeft);
_leftNavIcon = style::centerrect(_leftNav, st::mediaviewLeft);
_rightNav = myrtlrect(width() - st::mediaviewControlMargin - st::mediaviewControlSize, navSkip, st::mediaviewControlSize, height() - 2 * navSkip);
_rightNavIcon = centerrect(_rightNav, st::mediaviewRight);
_rightNavIcon = style::centerrect(_rightNav, st::mediaviewRight);
_saveMsg.moveTo((width() - _saveMsg.width()) / 2, (height() - _saveMsg.height()) / 2);
_photoRadialRect = QRect(QPoint((width() - st::radialSize.width()) / 2, (height() - st::radialSize.height()) / 2), st::radialSize);
@ -558,9 +559,9 @@ void OverlayWidget::updateControls() {
&& _doc->filepath(DocumentData::FilePathResolve::Checked).isEmpty()
&& !_doc->loading());
_saveNav = myrtlrect(width() - st::mediaviewIconSize.width() * 2, height() - st::mediaviewIconSize.height(), st::mediaviewIconSize.width(), st::mediaviewIconSize.height());
_saveNavIcon = centerrect(_saveNav, st::mediaviewSave);
_saveNavIcon = style::centerrect(_saveNav, st::mediaviewSave);
_moreNav = myrtlrect(width() - st::mediaviewIconSize.width(), height() - st::mediaviewIconSize.height(), st::mediaviewIconSize.width(), st::mediaviewIconSize.height());
_moreNavIcon = centerrect(_moreNav, st::mediaviewMore);
_moreNavIcon = style::centerrect(_moreNav, st::mediaviewMore);
const auto dNow = QDateTime::currentDateTime();
const auto d = [&] {
@ -2256,7 +2257,7 @@ void OverlayWidget::initThemePreview() {
const auto path = _doc->location().name();
const auto id = _themePreviewId = rand_value<uint64>();
const auto weak = make_weak(this);
const auto weak = Ui::MakeWeak(this);
crl::async([=, data = std::move(current)]() mutable {
auto preview = GeneratePreview(
bytes,
@ -3588,7 +3589,7 @@ void OverlayWidget::touchEvent(QTouchEvent *e) {
case QEvent::TouchEnd: {
if (!_touchPress) return;
auto weak = make_weak(this);
auto weak = Ui::MakeWeak(this);
if (!_touchMove) {
Qt::MouseButton btn(_touchRightButton ? Qt::RightButton : Qt::LeftButton);
auto mapped = mapFromGlobal(_touchStart);

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "ui/rp_widget.h"
#include "base/object_ptr.h"
namespace Ui {
class LabelSimple;

View File

@ -645,7 +645,7 @@ void Voice::paint(Painter &p, const QRect &clip, TextSelection selection, const
const auto statustop = _st.songStatusTop;
const auto namewidth = _width - nameleft - nameright;
const auto inner = rtlrect(
const auto inner = style::rtlrect(
_st.songPadding.left(),
_st.songPadding.top(),
_st.songThumbSize,
@ -710,12 +710,12 @@ void Voice::paint(Painter &p, const QRect &clip, TextSelection selection, const
icon->paintInCenter(p, inner);
}
if (clip.intersects(rtlrect(nameleft, nametop, namewidth, st::semiboldFont->height, _width))) {
if (clip.intersects(style::rtlrect(nameleft, nametop, namewidth, st::semiboldFont->height, _width))) {
p.setPen(st::historyFileNameInFg);
_name.drawLeftElided(p, nameleft, nametop, namewidth, _width);
}
if (clip.intersects(rtlrect(nameleft, statustop, namewidth, st::normalFont->height, _width))) {
if (clip.intersects(style::rtlrect(nameleft, statustop, namewidth, st::normalFont->height, _width))) {
p.setFont(st::normalFont);
p.setPen(selected ? st::mediaInFgSelected : st::mediaInFg);
int32 unreadx = nameleft;
@ -735,7 +735,7 @@ void Voice::paint(Painter &p, const QRect &clip, TextSelection selection, const
{
PainterHighQualityEnabler hq(p);
p.drawEllipse(rtlrect(unreadx + st::mediaUnreadSkip, statustop + st::mediaUnreadTop, st::mediaUnreadSize, st::mediaUnreadSize, _width));
p.drawEllipse(style::rtlrect(unreadx + st::mediaUnreadSkip, statustop + st::mediaUnreadTop, st::mediaUnreadSize, st::mediaUnreadSize, _width));
}
}
}
@ -760,7 +760,7 @@ TextState Voice::getState(
const auto nametop = _st.songNameTop;
const auto statustop = _st.songStatusTop;
const auto inner = rtlrect(
const auto inner = style::rtlrect(
_st.songPadding.left(),
_st.songPadding.top(),
_st.songThumbSize,
@ -776,7 +776,7 @@ TextState Voice::getState(
}
auto result = TextState(parent());
const auto statusmaxwidth = _width - nameleft - nameright;
const auto statusrect = rtlrect(
const auto statusrect = style::rtlrect(
nameleft,
statustop,
statusmaxwidth,
@ -794,7 +794,7 @@ TextState Voice::getState(
const auto namewidth = std::min(
_width - nameleft - nameright,
_name.maxWidth());
const auto namerect = rtlrect(
const auto namerect = style::rtlrect(
nameleft,
nametop,
namewidth,
@ -954,7 +954,7 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con
nametop = _st.songNameTop;
statustop = _st.songStatusTop;
auto inner = rtlrect(_st.songPadding.left(), _st.songPadding.top(), _st.songThumbSize, _st.songThumbSize, _width);
auto inner = style::rtlrect(_st.songPadding.left(), _st.songPadding.top(), _st.songThumbSize, _st.songThumbSize, _width);
if (clip.intersects(inner)) {
p.setPen(Qt::NoPen);
if (selected) {
@ -995,12 +995,12 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con
statustop = st::linksBorder + _st.fileStatusTop;
datetop = st::linksBorder + _st.fileDateTop;
QRect border(rtlrect(nameleft, 0, _width - nameleft, st::linksBorder, _width));
QRect border(style::rtlrect(nameleft, 0, _width - nameleft, st::linksBorder, _width));
if (!context->isAfterDate && clip.intersects(border)) {
p.fillRect(clip.intersected(border), st::linksBorderFg);
}
QRect rthumb(rtlrect(0, st::linksBorder + _st.filePadding.top(), _st.fileThumbSize, _st.fileThumbSize, _width));
QRect rthumb(style::rtlrect(0, st::linksBorder + _st.filePadding.top(), _st.fileThumbSize, _st.fileThumbSize, _width));
if (clip.intersects(rthumb)) {
if (wthumb) {
const auto thumbLoaded = _data->thumbnail()->loaded();
@ -1069,17 +1069,17 @@ void Document::paint(Painter &p, const QRect &clip, TextSelection selection, con
const auto availwidth = _width - nameleft - nameright;
const auto namewidth = std::min(availwidth, _name.maxWidth());
if (clip.intersects(rtlrect(nameleft, nametop, namewidth, st::semiboldFont->height, _width))) {
if (clip.intersects(style::rtlrect(nameleft, nametop, namewidth, st::semiboldFont->height, _width))) {
p.setPen(st::historyFileNameInFg);
_name.drawLeftElided(p, nameleft, nametop, namewidth, _width);
}
if (clip.intersects(rtlrect(nameleft, statustop, availwidth, st::normalFont->height, _width))) {
if (clip.intersects(style::rtlrect(nameleft, statustop, availwidth, st::normalFont->height, _width))) {
p.setFont(st::normalFont);
p.setPen((isSong && selected) ? st::mediaInFgSelected : st::mediaInFg);
p.drawTextLeft(nameleft, statustop, _width, _status.text());
}
if (datetop >= 0 && clip.intersects(rtlrect(nameleft, datetop, _datew, st::normalFont->height, _width))) {
if (datetop >= 0 && clip.intersects(style::rtlrect(nameleft, datetop, _datew, st::normalFont->height, _width))) {
p.setFont(ClickHandler::showAsActive(_msgl) ? st::normalFont->underline() : st::normalFont);
p.setPen(st::mediaInFg);
p.drawTextLeft(nameleft, datetop, _width, _date, _datew);
@ -1105,7 +1105,7 @@ void Document::drawCornerDownload(Painter &p, bool selected, const PaintContext
}
const auto size = st::overviewSmallCheck.size;
const auto shift = _st.songThumbSize + st::overviewCheckSkip - size;
const auto inner = rtlrect(_st.songPadding.left() + shift, _st.songPadding.top() + shift, size, size, _width);
const auto inner = style::rtlrect(_st.songPadding.left() + shift, _st.songPadding.top() + shift, size, size, _width);
auto pen = st::windowBg->p;
pen.setWidth(st::lineWidth);
p.setPen(pen);
@ -1143,7 +1143,7 @@ TextState Document::cornerDownloadTextState(
}
const auto size = st::overviewSmallCheck.size;
const auto shift = _st.songThumbSize + st::overviewCheckSkip - size;
const auto inner = rtlrect(_st.songPadding.left() + shift, _st.songPadding.top() + shift, size, size, _width);
const auto inner = style::rtlrect(_st.songPadding.left() + shift, _st.songPadding.top() + shift, size, size, _width);
if (inner.contains(point)) {
result.link = _data->loading() ? _cancell : _savel;
}
@ -1170,7 +1170,7 @@ TextState Document::getState(
return state;
}
const auto inner = rtlrect(
const auto inner = style::rtlrect(
_st.songPadding.left(),
_st.songPadding.top(),
_st.songThumbSize,
@ -1185,7 +1185,7 @@ TextState Document::getState(
: _savel;
return { parent(), link };
}
const auto namerect = rtlrect(
const auto namerect = style::rtlrect(
nameleft,
nametop,
namewidth,
@ -1204,7 +1204,7 @@ TextState Document::getState(
const auto statustop = st::linksBorder + _st.fileStatusTop;
const auto datetop = st::linksBorder + _st.fileDateTop;
const auto rthumb = rtlrect(
const auto rthumb = style::rtlrect(
0,
st::linksBorder + _st.filePadding.top(),
_st.fileThumbSize,
@ -1221,7 +1221,7 @@ TextState Document::getState(
}
if (_data->status != FileUploadFailed) {
auto daterect = rtlrect(
auto daterect = style::rtlrect(
nameleft,
datetop,
_datew,
@ -1232,7 +1232,7 @@ TextState Document::getState(
}
}
if (!_data->loading() && !_data->isNull()) {
auto leftofnamerect = rtlrect(
auto leftofnamerect = style::rtlrect(
0,
st::linksBorder,
nameleft,
@ -1241,7 +1241,7 @@ TextState Document::getState(
if (loaded && leftofnamerect.contains(point)) {
return { parent(), _namel };
}
const auto namerect = rtlrect(
const auto namerect = style::rtlrect(
nameleft,
nametop,
namewidth,
@ -1492,7 +1492,7 @@ void Link::paint(Painter &p, const QRect &clip, TextSelection selection, const P
const auto pixLeft = 0;
const auto pixTop = st::linksMargin.top() + st::linksBorder;
if (clip.intersects(rtlrect(0, pixTop, st::linksPhotoSize, st::linksPhotoSize, _width))) {
if (clip.intersects(style::rtlrect(0, pixTop, st::linksPhotoSize, st::linksPhotoSize, _width))) {
if (_page && _page->photo) {
QPixmap pix;
if (_page->photo->thumbnail()->loaded()) {
@ -1515,7 +1515,7 @@ void Link::paint(Painter &p, const QRect &clip, TextSelection selection, const P
? 0
: (_letter[0].unicode() % 4);
const auto fill = [&](style::color color, RoundCorners corners) {
auto pixRect = rtlrect(
auto pixRect = style::rtlrect(
pixLeft,
pixTop,
st::linksPhotoSize,
@ -1533,7 +1533,7 @@ void Link::paint(Painter &p, const QRect &clip, TextSelection selection, const P
if (!_letter.isEmpty()) {
p.setFont(st::linksLetterFont);
p.setPen(st::linksLetterFg);
p.drawText(rtlrect(pixLeft, pixTop, st::linksPhotoSize, st::linksPhotoSize, _width), _letter, style::al_center);
p.drawText(style::rtlrect(pixLeft, pixTop, st::linksPhotoSize, st::linksPhotoSize, _width), _letter, style::al_center);
}
}
}
@ -1550,7 +1550,7 @@ void Link::paint(Painter &p, const QRect &clip, TextSelection selection, const P
p.setPen(st::linksTextFg);
p.setFont(st::semiboldFont);
if (!_title.isEmpty()) {
if (clip.intersects(rtlrect(left, top, qMin(w, _titlew), st::semiboldFont->height, _width))) {
if (clip.intersects(style::rtlrect(left, top, qMin(w, _titlew), st::semiboldFont->height, _width))) {
p.drawTextLeft(left, top, _width, (w < _titlew) ? st::semiboldFont->elided(_title, w) : _title);
}
top += st::semiboldFont->height;
@ -1558,7 +1558,7 @@ void Link::paint(Painter &p, const QRect &clip, TextSelection selection, const P
p.setFont(st::msgFont);
if (!_text.isEmpty()) {
int32 h = qMin(st::normalFont->height * 3, _text.countHeight(w));
if (clip.intersects(rtlrect(left, top, w, h, _width))) {
if (clip.intersects(style::rtlrect(left, top, w, h, _width))) {
_text.drawLeftElided(p, left, top, w, _width, 3);
}
top += h;
@ -1566,14 +1566,14 @@ void Link::paint(Painter &p, const QRect &clip, TextSelection selection, const P
p.setPen(st::windowActiveTextFg);
for (const auto &link : _links) {
if (clip.intersects(rtlrect(left, top, qMin(w, link.width), st::normalFont->height, _width))) {
if (clip.intersects(style::rtlrect(left, top, qMin(w, link.width), st::normalFont->height, _width))) {
p.setFont(ClickHandler::showAsActive(link.lnk) ? st::normalFont->underline() : st::normalFont);
p.drawTextLeft(left, top, _width, (w < link.width) ? st::normalFont->elided(link.text, w) : link.text);
}
top += st::normalFont->height;
}
QRect border(rtlrect(left, 0, w, st::linksBorder, _width));
QRect border(style::rtlrect(left, 0, w, st::linksBorder, _width));
if (!context->isAfterDate && clip.intersects(border)) {
p.fillRect(clip.intersected(border), st::linksBorderFg);
}
@ -1589,7 +1589,7 @@ TextState Link::getState(
QPoint point,
StateRequest request) const {
int32 left = st::linksPhotoSize + st::linksPhotoPadding, top = st::linksMargin.top() + st::linksBorder, w = _width - left;
if (rtlrect(0, top, st::linksPhotoSize, st::linksPhotoSize, _width).contains(point)) {
if (style::rtlrect(0, top, st::linksPhotoSize, st::linksPhotoSize, _width).contains(point)) {
return { parent(), _photol };
}
@ -1597,7 +1597,7 @@ TextState Link::getState(
top += (st::linksPhotoSize - st::semiboldFont->height - st::normalFont->height) / 2;
}
if (!_title.isEmpty()) {
if (rtlrect(left, top, qMin(w, _titlew), st::semiboldFont->height, _width).contains(point)) {
if (style::rtlrect(left, top, qMin(w, _titlew), st::semiboldFont->height, _width).contains(point)) {
return { parent(), _photol };
}
top += st::webPageTitleFont->height;
@ -1606,7 +1606,7 @@ TextState Link::getState(
top += qMin(st::normalFont->height * 3, _text.countHeight(w));
}
for (const auto &link : _links) {
if (rtlrect(left, top, qMin(w, link.width), st::normalFont->height, _width).contains(point)) {
if (style::rtlrect(left, top, qMin(w, link.width), st::normalFont->height, _width).contains(point)) {
return { parent(), ClickHandlerPtr(link.lnk) };
}
top += st::normalFont->height;

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "passport/passport_form_controller.h"
#include "base/object_ptr.h"
namespace Passport {

View File

@ -1223,7 +1223,7 @@ void PanelController::startScopeEdit(
std::move(scans),
std::move(translations),
PrepareSpecialFiles(*_editDocument));
const auto weak = make_weak(result.data());
const auto weak = Ui::MakeWeak(result.data());
_panelHasUnsavedChanges = [=] {
return weak ? weak->hasUnsavedChanges() : false;
};
@ -1241,7 +1241,7 @@ void PanelController::startScopeEdit(
_editValue->nativeNames),
_editValue->error,
_editValue->data.parsedInEdit);
const auto weak = make_weak(result.data());
const auto weak = Ui::MakeWeak(result.data());
_panelHasUnsavedChanges = [=] {
return weak ? weak->hasUnsavedChanges() : false;
};

Some files were not shown because too many files have changed in this diff Show More