2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

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

@@ -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()));
}
}