mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Using standard library instead of std_ namespace.
Currently tested only in VS2015.
This commit is contained in:
parent
27f015561a
commit
ffc557a0f9
201 changed files with 892 additions and 1386 deletions
|
@ -2186,7 +2186,7 @@ namespace {
|
||||||
cors[3] = rect.copy(r * 2, r * 2, r, r + (shadow ? s : 0));
|
cors[3] = rect.copy(r * 2, r * 2, r, r + (shadow ? s : 0));
|
||||||
if (index != SmallMaskCorners && index != LargeMaskCorners) {
|
if (index != SmallMaskCorners && index != LargeMaskCorners) {
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
::corners[index].p[i] = new QPixmap(pixmapFromImageInPlace(std_::move(cors[i])));
|
::corners[index].p[i] = new QPixmap(pixmapFromImageInPlace(std::move(cors[i])));
|
||||||
::corners[index].p[i]->setDevicePixelRatio(cRetinaFactor());
|
::corners[index].p[i]->setDevicePixelRatio(cRetinaFactor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2424,7 +2424,7 @@ namespace {
|
||||||
QPainter p(&image);
|
QPainter p(&image);
|
||||||
emojiDraw(p, emoji, st::emojiPadding * cIntRetinaFactor(), (fontHeight * cIntRetinaFactor() - Ui::Emoji::Size()) / 2);
|
emojiDraw(p, emoji, st::emojiPadding * cIntRetinaFactor(), (fontHeight * cIntRetinaFactor() - Ui::Emoji::Size()) / 2);
|
||||||
}
|
}
|
||||||
i = map.insert(emoji->index(), App::pixmapFromImageInPlace(std_::move(image)));
|
i = map.insert(emoji->index(), App::pixmapFromImageInPlace(std::move(image)));
|
||||||
}
|
}
|
||||||
return i.value();
|
return i.value();
|
||||||
}
|
}
|
||||||
|
@ -2550,7 +2550,7 @@ namespace {
|
||||||
}
|
}
|
||||||
#endif // OS_MAC_OLD
|
#endif // OS_MAC_OLD
|
||||||
} else if (opaque) {
|
} else if (opaque) {
|
||||||
result = Images::prepareOpaque(std_::move(result));
|
result = Images::prepareOpaque(std::move(result));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -2570,7 +2570,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap pixmapFromImageInPlace(QImage &&image) {
|
QPixmap pixmapFromImageInPlace(QImage &&image) {
|
||||||
return QPixmap::fromImage(std_::move(image), Qt::ColorOnly);
|
return QPixmap::fromImage(std::move(image), Qt::ColorOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
void regPhotoItem(PhotoData *data, HistoryItem *item) {
|
void regPhotoItem(PhotoData *data, HistoryItem *item) {
|
||||||
|
@ -2860,7 +2860,7 @@ namespace {
|
||||||
|
|
||||||
CornersPixmaps pixmaps;
|
CornersPixmaps pixmaps;
|
||||||
for (int j = 0; j < 4; ++j) {
|
for (int j = 0; j < 4; ++j) {
|
||||||
pixmaps.p[j] = new QPixmap(pixmapFromImageInPlace(std_::move(images[j])));
|
pixmaps.p[j] = new QPixmap(pixmapFromImageInPlace(std::move(images[j])));
|
||||||
pixmaps.p[j]->setDevicePixelRatio(cRetinaFactor());
|
pixmaps.p[j]->setDevicePixelRatio(cRetinaFactor());
|
||||||
}
|
}
|
||||||
i = cornersMap.insert(colorKey, pixmaps);
|
i = cornersMap.insert(colorKey, pixmaps);
|
||||||
|
|
|
@ -34,15 +34,15 @@ BoxLayerTitleShadow::BoxLayerTitleShadow(QWidget *parent) : Ui::PlainShadow(pare
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointer<Ui::RoundButton> BoxContent::addButton(const QString &text, base::lambda<void()> &&clickCallback) {
|
QPointer<Ui::RoundButton> BoxContent::addButton(const QString &text, base::lambda<void()> &&clickCallback) {
|
||||||
return addButton(text, std_::move(clickCallback), st::defaultBoxButton);
|
return addButton(text, std::move(clickCallback), st::defaultBoxButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointer<Ui::RoundButton> BoxContent::addLeftButton(const QString &text, base::lambda<void()> &&clickCallback) {
|
QPointer<Ui::RoundButton> BoxContent::addLeftButton(const QString &text, base::lambda<void()> &&clickCallback) {
|
||||||
return getDelegate()->addLeftButton(text, std_::move(clickCallback), st::defaultBoxButton);
|
return getDelegate()->addLeftButton(text, std::move(clickCallback), st::defaultBoxButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoxContent::setInner(object_ptr<TWidget> inner) {
|
void BoxContent::setInner(object_ptr<TWidget> inner) {
|
||||||
setInner(std_::move(inner), st::boxLayerScroll);
|
setInner(std::move(inner), st::boxLayerScroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoxContent::setInner(object_ptr<TWidget> inner, const style::ScrollArea &st) {
|
void BoxContent::setInner(object_ptr<TWidget> inner, const style::ScrollArea &st) {
|
||||||
|
@ -50,7 +50,7 @@ void BoxContent::setInner(object_ptr<TWidget> inner, const style::ScrollArea &st
|
||||||
getDelegate()->setLayerType(true);
|
getDelegate()->setLayerType(true);
|
||||||
_scroll.create(this, st);
|
_scroll.create(this, st);
|
||||||
_scroll->setGeometryToLeft(0, _innerTopSkip, width(), 0);
|
_scroll->setGeometryToLeft(0, _innerTopSkip, width(), 0);
|
||||||
_scroll->setOwnedWidget(std_::move(inner));
|
_scroll->setOwnedWidget(std::move(inner));
|
||||||
if (_topShadow) {
|
if (_topShadow) {
|
||||||
_topShadow->raise();
|
_topShadow->raise();
|
||||||
_bottomShadow->raise();
|
_bottomShadow->raise();
|
||||||
|
@ -155,7 +155,7 @@ QPixmap BoxContent::grabInnerCache() {
|
||||||
auto result = myGrab(this, _scroll->geometry());
|
auto result = myGrab(this, _scroll->geometry());
|
||||||
if (isTopShadowVisible) _topShadow->show();
|
if (isTopShadowVisible) _topShadow->show();
|
||||||
if (isBottomShadowVisible) _bottomShadow->show();
|
if (isBottomShadowVisible) _bottomShadow->show();
|
||||||
return std_::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoxContent::resizeEvent(QResizeEvent *e) {
|
void BoxContent::resizeEvent(QResizeEvent *e) {
|
||||||
|
@ -197,14 +197,14 @@ void BoxContent::paintEvent(QPaintEvent *e) {
|
||||||
Painter p(this);
|
Painter p(this);
|
||||||
|
|
||||||
if (testAttribute(Qt::WA_OpaquePaintEvent)) {
|
if (testAttribute(Qt::WA_OpaquePaintEvent)) {
|
||||||
for_const (auto rect, e->region().rects()) {
|
for (auto rect : e->region().rects()) {
|
||||||
p.fillRect(rect, st::boxBg);
|
p.fillRect(rect, st::boxBg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractBox::AbstractBox(QWidget *parent, object_ptr<BoxContent> content) : LayerWidget(parent)
|
AbstractBox::AbstractBox(QWidget *parent, object_ptr<BoxContent> content) : LayerWidget(parent)
|
||||||
, _content(std_::move(content)) {
|
, _content(std::move(content)) {
|
||||||
_content->setParent(this);
|
_content->setParent(this);
|
||||||
_content->setDelegate(this);
|
_content->setDelegate(this);
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ void AbstractBox::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
auto other = e->region().intersected(QRect(0, st::boxRadius, width(), height() - 2 * st::boxRadius));
|
auto other = e->region().intersected(QRect(0, st::boxRadius, width(), height() - 2 * st::boxRadius));
|
||||||
if (!other.isEmpty()) {
|
if (!other.isEmpty()) {
|
||||||
for_const (auto rect, other.rects()) {
|
for (auto rect : other.rects()) {
|
||||||
p.fillRect(rect, st::boxBg);
|
p.fillRect(rect, st::boxBg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ void AbstractBox::updateSize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractBox::updateButtonsPositions() {
|
void AbstractBox::updateButtonsPositions() {
|
||||||
if (!_buttons.isEmpty() || _leftButton) {
|
if (!_buttons.empty() || _leftButton) {
|
||||||
auto padding = _layerType ? st::boxLayerButtonPadding : st::boxButtonPadding;
|
auto padding = _layerType ? st::boxLayerButtonPadding : st::boxButtonPadding;
|
||||||
auto right = padding.right();
|
auto right = padding.right();
|
||||||
auto top = buttonsTop();
|
auto top = buttonsTop();
|
||||||
|
@ -313,7 +313,7 @@ void AbstractBox::clearButtons() {
|
||||||
QPointer<Ui::RoundButton> AbstractBox::addButton(const QString &text, base::lambda<void()> &&clickCallback, const style::RoundButton &st) {
|
QPointer<Ui::RoundButton> AbstractBox::addButton(const QString &text, base::lambda<void()> &&clickCallback, const style::RoundButton &st) {
|
||||||
_buttons.push_back(object_ptr<Ui::RoundButton>(this, text, st));
|
_buttons.push_back(object_ptr<Ui::RoundButton>(this, text, st));
|
||||||
auto result = QPointer<Ui::RoundButton>(_buttons.back());
|
auto result = QPointer<Ui::RoundButton>(_buttons.back());
|
||||||
result->setClickedCallback(std_::move(clickCallback));
|
result->setClickedCallback(std::move(clickCallback));
|
||||||
result->show();
|
result->show();
|
||||||
updateButtonsPositions();
|
updateButtonsPositions();
|
||||||
return result;
|
return result;
|
||||||
|
@ -322,7 +322,7 @@ QPointer<Ui::RoundButton> AbstractBox::addButton(const QString &text, base::lamb
|
||||||
QPointer<Ui::RoundButton> AbstractBox::addLeftButton(const QString &text, base::lambda<void()> &&clickCallback, const style::RoundButton &st) {
|
QPointer<Ui::RoundButton> AbstractBox::addLeftButton(const QString &text, base::lambda<void()> &&clickCallback, const style::RoundButton &st) {
|
||||||
_leftButton = object_ptr<Ui::RoundButton>(this, text, st);
|
_leftButton = object_ptr<Ui::RoundButton>(this, text, st);
|
||||||
auto result = QPointer<Ui::RoundButton>(_leftButton);
|
auto result = QPointer<Ui::RoundButton>(_leftButton);
|
||||||
result->setClickedCallback(std_::move(clickCallback));
|
result->setClickedCallback(std::move(clickCallback));
|
||||||
result->show();
|
result->show();
|
||||||
updateButtonsPositions();
|
updateButtonsPositions();
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -101,7 +101,7 @@ protected:
|
||||||
QPointer<Ui::RoundButton> addButton(const QString &text, base::lambda<void()> &&clickCallback);
|
QPointer<Ui::RoundButton> addButton(const QString &text, base::lambda<void()> &&clickCallback);
|
||||||
QPointer<Ui::RoundButton> addLeftButton(const QString &text, base::lambda<void()> &&clickCallback);
|
QPointer<Ui::RoundButton> addLeftButton(const QString &text, base::lambda<void()> &&clickCallback);
|
||||||
QPointer<Ui::RoundButton> addButton(const QString &text, base::lambda<void()> &&clickCallback, const style::RoundButton &st) {
|
QPointer<Ui::RoundButton> addButton(const QString &text, base::lambda<void()> &&clickCallback, const style::RoundButton &st) {
|
||||||
return getDelegate()->addButton(text, std_::move(clickCallback), st);
|
return getDelegate()->addButton(text, std::move(clickCallback), st);
|
||||||
}
|
}
|
||||||
void updateButtonsGeometry() {
|
void updateButtonsGeometry() {
|
||||||
getDelegate()->updateButtonsPositions();
|
getDelegate()->updateButtonsPositions();
|
||||||
|
@ -123,7 +123,7 @@ protected:
|
||||||
QPointer<Widget> setInnerWidget(object_ptr<Widget> inner, const style::ScrollArea &st, int topSkip = 0) {
|
QPointer<Widget> setInnerWidget(object_ptr<Widget> inner, const style::ScrollArea &st, int topSkip = 0) {
|
||||||
auto result = QPointer<Widget>(inner.data());
|
auto result = QPointer<Widget>(inner.data());
|
||||||
setInnerTopSkip(topSkip);
|
setInnerTopSkip(topSkip);
|
||||||
setInner(std_::move(inner), st);
|
setInner(std::move(inner), st);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ protected:
|
||||||
QPointer<Widget> setInnerWidget(object_ptr<Widget> inner, int topSkip = 0) {
|
QPointer<Widget> setInnerWidget(object_ptr<Widget> inner, int topSkip = 0) {
|
||||||
auto result = QPointer<Widget>(inner.data());
|
auto result = QPointer<Widget>(inner.data());
|
||||||
setInnerTopSkip(topSkip);
|
setInnerTopSkip(topSkip);
|
||||||
setInner(std_::move(inner));
|
setInner(std::move(inner));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ private:
|
||||||
QString _additionalTitle;
|
QString _additionalTitle;
|
||||||
bool _layerType = false;
|
bool _layerType = false;
|
||||||
|
|
||||||
std_::vector_of_moveable<object_ptr<Ui::RoundButton>> _buttons;
|
std::vector<object_ptr<Ui::RoundButton>> _buttons;
|
||||||
object_ptr<Ui::RoundButton> _leftButton = { nullptr };
|
object_ptr<Ui::RoundButton> _leftButton = { nullptr };
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1115,7 +1115,7 @@ RevokePublicLinkBox::RevokePublicLinkBox(QWidget*, base::lambda<void()> &&revoke
|
||||||
: _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
|
: _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
|
||||||
, _revokeWidth(st::normalFont->width(lang(lng_channels_too_much_public_revoke)))
|
, _revokeWidth(st::normalFont->width(lang(lng_channels_too_much_public_revoke)))
|
||||||
, _aboutRevoke(this, lang(lng_channels_too_much_public_about), Ui::FlatLabel::InitType::Simple, st::aboutRevokePublicLabel)
|
, _aboutRevoke(this, lang(lng_channels_too_much_public_about), Ui::FlatLabel::InitType::Simple, st::aboutRevokePublicLabel)
|
||||||
, _revokeCallback(std_::move(revokeCallback)) {
|
, _revokeCallback(std::move(revokeCallback)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RevokePublicLinkBox::prepare() {
|
void RevokePublicLinkBox::prepare() {
|
||||||
|
@ -1231,7 +1231,7 @@ void RevokePublicLinkBox::getPublicDone(const MTPmessages_Chats &result) {
|
||||||
row.peer = peer;
|
row.peer = peer;
|
||||||
row.name.setText(st::contactsNameStyle, peer->name, _textNameOptions);
|
row.name.setText(st::contactsNameStyle, peer->name, _textNameOptions);
|
||||||
row.status.setText(st::defaultTextStyle, CreateInternalLink(textcmdLink(1, peer->userName())), _textDlgOptions);
|
row.status.setText(st::defaultTextStyle, CreateInternalLink(textcmdLink(1, peer->userName())), _textDlgOptions);
|
||||||
_rows.push_back(std_::move(row));
|
_rows.push_back(std::move(row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ void BackgroundBox::backgroundChosen(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BackgroundBox::Inner::Inner(QWidget *parent) : TWidget(parent)
|
BackgroundBox::Inner::Inner(QWidget *parent) : TWidget(parent)
|
||||||
, _check(std_::make_unique<Ui::RoundCheckbox>(st::overviewCheck, [this] { update(); })) {
|
, _check(std::make_unique<Ui::RoundCheckbox>(st::overviewCheck, [this] { update(); })) {
|
||||||
_check->setChecked(true, Ui::RoundCheckbox::SetStyle::Fast);
|
_check->setChecked(true, Ui::RoundCheckbox::SetStyle::Fast);
|
||||||
if (App::cServerBackgrounds().isEmpty()) {
|
if (App::cServerBackgrounds().isEmpty()) {
|
||||||
resize(BackgroundsInRow * (st::backgroundSize.width() + st::backgroundPadding) + st::backgroundPadding, 2 * (st::backgroundSize.height() + st::backgroundPadding) + st::backgroundPadding);
|
resize(BackgroundsInRow * (st::backgroundSize.width() + st::backgroundPadding) + st::backgroundPadding, 2 * (st::backgroundSize.height() + st::backgroundPadding) + st::backgroundPadding);
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
Inner(QWidget *parent);
|
Inner(QWidget *parent);
|
||||||
|
|
||||||
void setBackgroundChosenCallback(base::lambda<void(int index)> &&callback) {
|
void setBackgroundChosenCallback(base::lambda<void(int index)> &&callback) {
|
||||||
_backgroundChosenCallback = std_::move(callback);
|
_backgroundChosenCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Inner();
|
~Inner();
|
||||||
|
@ -68,6 +68,6 @@ private:
|
||||||
int _rows = 0;
|
int _rows = 0;
|
||||||
int _over = -1;
|
int _over = -1;
|
||||||
int _overDown = -1;
|
int _overDown = -1;
|
||||||
std_::unique_ptr<Ui::RoundCheckbox> _check; // this is not a widget
|
std::unique_ptr<Ui::RoundCheckbox> _check; // this is not a widget
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,8 +46,8 @@ ConfirmBox::ConfirmBox(QWidget*, const QString &text, base::lambda<void()> &&con
|
||||||
, _cancelText(lang(lng_cancel))
|
, _cancelText(lang(lng_cancel))
|
||||||
, _confirmStyle(st::defaultBoxButton)
|
, _confirmStyle(st::defaultBoxButton)
|
||||||
, _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right())
|
, _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right())
|
||||||
, _confirmedCallback(std_::move(confirmedCallback))
|
, _confirmedCallback(std::move(confirmedCallback))
|
||||||
, _cancelledCallback(std_::move(cancelledCallback)) {
|
, _cancelledCallback(std::move(cancelledCallback)) {
|
||||||
init(text);
|
init(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,8 +56,8 @@ ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText
|
||||||
, _cancelText(lang(lng_cancel))
|
, _cancelText(lang(lng_cancel))
|
||||||
, _confirmStyle(st::defaultBoxButton)
|
, _confirmStyle(st::defaultBoxButton)
|
||||||
, _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right())
|
, _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right())
|
||||||
, _confirmedCallback(std_::move(confirmedCallback))
|
, _confirmedCallback(std::move(confirmedCallback))
|
||||||
, _cancelledCallback(std_::move(cancelledCallback)) {
|
, _cancelledCallback(std::move(cancelledCallback)) {
|
||||||
init(text);
|
init(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@ ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText
|
||||||
, _cancelText(lang(lng_cancel))
|
, _cancelText(lang(lng_cancel))
|
||||||
, _confirmStyle(confirmStyle)
|
, _confirmStyle(confirmStyle)
|
||||||
, _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right())
|
, _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right())
|
||||||
, _confirmedCallback(std_::move(confirmedCallback))
|
, _confirmedCallback(std::move(confirmedCallback))
|
||||||
, _cancelledCallback(std_::move(cancelledCallback)) {
|
, _cancelledCallback(std::move(cancelledCallback)) {
|
||||||
init(text);
|
init(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText
|
||||||
, _cancelText(cancelText)
|
, _cancelText(cancelText)
|
||||||
, _confirmStyle(st::defaultBoxButton)
|
, _confirmStyle(st::defaultBoxButton)
|
||||||
, _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right())
|
, _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right())
|
||||||
, _confirmedCallback(std_::move(confirmedCallback))
|
, _confirmedCallback(std::move(confirmedCallback))
|
||||||
, _cancelledCallback(std_::move(cancelledCallback)) {
|
, _cancelledCallback(std::move(cancelledCallback)) {
|
||||||
init(text);
|
init(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,8 +86,8 @@ ConfirmBox::ConfirmBox(QWidget*, const QString &text, const QString &confirmText
|
||||||
, _cancelText(cancelText)
|
, _cancelText(cancelText)
|
||||||
, _confirmStyle(st::defaultBoxButton)
|
, _confirmStyle(st::defaultBoxButton)
|
||||||
, _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right())
|
, _text(st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right())
|
||||||
, _confirmedCallback(std_::move(confirmedCallback))
|
, _confirmedCallback(std::move(confirmedCallback))
|
||||||
, _cancelledCallback(std_::move(cancelledCallback)) {
|
, _cancelledCallback(std::move(cancelledCallback)) {
|
||||||
init(text);
|
init(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,10 +212,10 @@ void ConfirmBox::paintEvent(QPaintEvent *e) {
|
||||||
_text.drawLeftElided(p, st::boxPadding.left(), st::boxPadding.top(), _textWidth, width(), 16, style::al_left);
|
_text.drawLeftElided(p, st::boxPadding.left(), st::boxPadding.top(), _textWidth, width(), 16, style::al_left);
|
||||||
}
|
}
|
||||||
|
|
||||||
InformBox::InformBox(QWidget*, const QString &text, base::lambda_copy<void()> &&closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, lang(lng_box_ok), std_::move(closedCallback)) {
|
InformBox::InformBox(QWidget*, const QString &text, base::lambda_copy<void()> &&closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, lang(lng_box_ok), std::move(closedCallback)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
InformBox::InformBox(QWidget*, const QString &text, const QString &doneText, base::lambda_copy<void()> &&closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, doneText, std_::move(closedCallback)) {
|
InformBox::InformBox(QWidget*, const QString &text, const QString &doneText, base::lambda_copy<void()> &&closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, doneText, std::move(closedCallback)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MaxInviteBox::MaxInviteBox(QWidget*, const QString &link)
|
MaxInviteBox::MaxInviteBox(QWidget*, const QString &link)
|
||||||
|
|
|
@ -106,7 +106,7 @@ void ConfirmPhoneBox::setCallStatus(const CallStatus &status) {
|
||||||
|
|
||||||
void ConfirmPhoneBox::launch() {
|
void ConfirmPhoneBox::launch() {
|
||||||
if (!CurrentConfirmPhoneBox) return;
|
if (!CurrentConfirmPhoneBox) return;
|
||||||
Ui::show(std_::move(CurrentConfirmPhoneBox));
|
Ui::show(std::move(CurrentConfirmPhoneBox));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfirmPhoneBox::prepare() {
|
void ConfirmPhoneBox::prepare() {
|
||||||
|
|
|
@ -293,7 +293,7 @@ object_ptr<Ui::WidgetSlideWrap<Ui::MultiSelect>> ContactsBox::createMultiSelect(
|
||||||
auto entity = object_ptr<Ui::MultiSelect>(this, st::contactsMultiSelect, lang(lng_participant_filter));
|
auto entity = object_ptr<Ui::MultiSelect>(this, st::contactsMultiSelect, lang(lng_participant_filter));
|
||||||
auto margins = style::margins(0, 0, 0, 0);
|
auto margins = style::margins(0, 0, 0, 0);
|
||||||
auto callback = [this] { updateScrollSkips(); };
|
auto callback = [this] { updateScrollSkips(); };
|
||||||
return object_ptr<Ui::WidgetSlideWrap<Ui::MultiSelect>>(this, std_::move(entity), margins, std_::move(callback));
|
return object_ptr<Ui::WidgetSlideWrap<Ui::MultiSelect>>(this, std::move(entity), margins, std::move(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
int ContactsBox::getTopScrollSkip() const {
|
int ContactsBox::getTopScrollSkip() const {
|
||||||
|
@ -528,7 +528,7 @@ bool ContactsBox::creationFail(const RPCError &error) {
|
||||||
ContactsBox::Inner::ContactData::ContactData() = default;
|
ContactsBox::Inner::ContactData::ContactData() = default;
|
||||||
|
|
||||||
ContactsBox::Inner::ContactData::ContactData(PeerData *peer, const base::lambda_copy<void()> &updateCallback)
|
ContactsBox::Inner::ContactData::ContactData(PeerData *peer, const base::lambda_copy<void()> &updateCallback)
|
||||||
: checkbox(std_::make_unique<Ui::RoundImageCheckbox>(st::contactsPhotoCheckbox, updateCallback, PaintUserpicCallback(peer))) {
|
: checkbox(std::make_unique<Ui::RoundImageCheckbox>(st::contactsPhotoCheckbox, updateCallback, PaintUserpicCallback(peer))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ContactsBox::Inner::ContactData::~ContactData() = default;
|
ContactsBox::Inner::ContactData::~ContactData() = default;
|
||||||
|
@ -568,7 +568,7 @@ ContactsBox::Inner::Inner(QWidget *parent, ChatData *chat, MembersFilter members
|
||||||
, _aboutWidth(st::boxWideWidth - st::contactsPadding.left() - st::contactsPadding.right())
|
, _aboutWidth(st::boxWideWidth - st::contactsPadding.left() - st::contactsPadding.right())
|
||||||
, _aboutAllAdmins(st::defaultTextStyle, lang(lng_chat_about_all_admins), _defaultOptions, _aboutWidth)
|
, _aboutAllAdmins(st::defaultTextStyle, lang(lng_chat_about_all_admins), _defaultOptions, _aboutWidth)
|
||||||
, _aboutAdmins(st::defaultTextStyle, lang(lng_chat_about_admins), _defaultOptions, _aboutWidth)
|
, _aboutAdmins(st::defaultTextStyle, lang(lng_chat_about_admins), _defaultOptions, _aboutWidth)
|
||||||
, _customList((membersFilter == MembersFilter::Recent) ? std_::unique_ptr<Dialogs::IndexedList>() : std_::make_unique<Dialogs::IndexedList>(Dialogs::SortMode::Add))
|
, _customList((membersFilter == MembersFilter::Recent) ? std::unique_ptr<Dialogs::IndexedList>() : std::make_unique<Dialogs::IndexedList>(Dialogs::SortMode::Add))
|
||||||
, _contacts((membersFilter == MembersFilter::Recent) ? App::main()->contactsList() : _customList.get())
|
, _contacts((membersFilter == MembersFilter::Recent) ? App::main()->contactsList() : _customList.get())
|
||||||
, _addContactLnk(this, lang(lng_add_contact_button)) {
|
, _addContactLnk(this, lang(lng_add_contact_button)) {
|
||||||
initList();
|
initList();
|
||||||
|
@ -596,7 +596,7 @@ ContactsBox::Inner::Inner(QWidget *parent, UserData *bot) : TWidget(parent)
|
||||||
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
|
, _rowHeight(st::contactsPadding.top() + st::contactsPhotoSize + st::contactsPadding.bottom())
|
||||||
, _bot(bot)
|
, _bot(bot)
|
||||||
, _allAdmins(this, lang(lng_chat_all_members_admins), false, st::defaultBoxCheckbox)
|
, _allAdmins(this, lang(lng_chat_all_members_admins), false, st::defaultBoxCheckbox)
|
||||||
, _customList(std_::make_unique<Dialogs::IndexedList>(Dialogs::SortMode::Add))
|
, _customList(std::make_unique<Dialogs::IndexedList>(Dialogs::SortMode::Add))
|
||||||
, _contacts(_customList.get())
|
, _contacts(_customList.get())
|
||||||
, _addContactLnk(this, lang(lng_add_contact_button)) {
|
, _addContactLnk(this, lang(lng_add_contact_button)) {
|
||||||
if (sharingBotGame()) {
|
if (sharingBotGame()) {
|
||||||
|
@ -1297,7 +1297,7 @@ void ContactsBox::Inner::addRipple(PeerData *peer, ContactData *data) {
|
||||||
auto rowTop = getSelectedRowTop();
|
auto rowTop = getSelectedRowTop();
|
||||||
if (!data->ripple) {
|
if (!data->ripple) {
|
||||||
auto mask = Ui::RippleAnimation::rectMask(QSize(width(), _rowHeight));
|
auto mask = Ui::RippleAnimation::rectMask(QSize(width(), _rowHeight));
|
||||||
data->ripple = std_::make_unique<Ui::RippleAnimation>(st::contactsRipple, std_::move(mask), [this, data] {
|
data->ripple = std::make_unique<Ui::RippleAnimation>(st::contactsRipple, std::move(mask), [this, data] {
|
||||||
updateRowWithTop(data->rippleRowTop);
|
updateRowWithTop(data->rippleRowTop);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1471,7 +1471,7 @@ void ContactsBox::Inner::peerUnselected(PeerData *peer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsBox::Inner::setPeerSelectedChangedCallback(base::lambda<void(PeerData *peer, bool selected)> &&callback) {
|
void ContactsBox::Inner::setPeerSelectedChangedCallback(base::lambda<void(PeerData *peer, bool selected)> &&callback) {
|
||||||
_peerSelectedChangedCallback = std_::move(callback);
|
_peerSelectedChangedCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContactsBox::Inner::changePeerCheckState(ContactData *data, PeerData *peer, bool checked, ChangeStateWay useCallback) {
|
void ContactsBox::Inner::changePeerCheckState(ContactData *data, PeerData *peer, bool checked, ChangeStateWay useCallback) {
|
||||||
|
|
|
@ -165,7 +165,7 @@ public:
|
||||||
QVector<MTPInputUser> selectedInputs();
|
QVector<MTPInputUser> selectedInputs();
|
||||||
bool allAdmins() const;
|
bool allAdmins() const;
|
||||||
void setAllAdminsChangedCallback(base::lambda<void()> &&allAdminsChangedCallback) {
|
void setAllAdminsChangedCallback(base::lambda<void()> &&allAdminsChangedCallback) {
|
||||||
_allAdminsChangedCallback = std_::move(allAdminsChangedCallback);
|
_allAdminsChangedCallback = std::move(allAdminsChangedCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void chooseParticipant();
|
void chooseParticipant();
|
||||||
|
@ -221,8 +221,8 @@ private:
|
||||||
ContactData(PeerData *peer, const base::lambda_copy<void()> &updateCallback);
|
ContactData(PeerData *peer, const base::lambda_copy<void()> &updateCallback);
|
||||||
~ContactData();
|
~ContactData();
|
||||||
|
|
||||||
std_::unique_ptr<Ui::RoundImageCheckbox> checkbox;
|
std::unique_ptr<Ui::RoundImageCheckbox> checkbox;
|
||||||
std_::unique_ptr<Ui::RippleAnimation> ripple;
|
std::unique_ptr<Ui::RippleAnimation> ripple;
|
||||||
int rippleRowTop = 0;
|
int rippleRowTop = 0;
|
||||||
Text name;
|
Text name;
|
||||||
QString statusText;
|
QString statusText;
|
||||||
|
@ -297,7 +297,7 @@ private:
|
||||||
|
|
||||||
int32 _time;
|
int32 _time;
|
||||||
|
|
||||||
std_::unique_ptr<Dialogs::IndexedList> _customList;
|
std::unique_ptr<Dialogs::IndexedList> _customList;
|
||||||
Dialogs::IndexedList *_contacts = nullptr;
|
Dialogs::IndexedList *_contacts = nullptr;
|
||||||
Dialogs::Row *_selected = nullptr;
|
Dialogs::Row *_selected = nullptr;
|
||||||
Dialogs::Row *_pressed = nullptr;
|
Dialogs::Row *_pressed = nullptr;
|
||||||
|
|
|
@ -359,9 +359,9 @@ void EditColorBox::Slider::generatePixmap() {
|
||||||
++ints;
|
++ints;
|
||||||
}
|
}
|
||||||
if (!isHorizontal()) {
|
if (!isHorizontal()) {
|
||||||
image = std_::move(image).transformed(QTransform(0, -1, 1, 0, 0, 0));
|
image = std::move(image).transformed(QTransform(0, -1, 1, 0, 0, 0));
|
||||||
}
|
}
|
||||||
_pixmap = App::pixmapFromImageInPlace(std_::move(image));
|
_pixmap = App::pixmapFromImageInPlace(std::move(image));
|
||||||
} else {
|
} else {
|
||||||
auto color = anim::shifted(QColor(255, 255, 255, 255));
|
auto color = anim::shifted(QColor(255, 255, 255, 255));
|
||||||
auto transparent = anim::shifted(QColor(255, 255, 255, 0));
|
auto transparent = anim::shifted(QColor(255, 255, 255, 0));
|
||||||
|
@ -377,9 +377,9 @@ void EditColorBox::Slider::generatePixmap() {
|
||||||
ints += intsPerLineAdded;
|
ints += intsPerLineAdded;
|
||||||
}
|
}
|
||||||
if (!isHorizontal()) {
|
if (!isHorizontal()) {
|
||||||
image = std_::move(image).transformed(QTransform(0, -1, 1, 0, 0, 0));
|
image = std::move(image).transformed(QTransform(0, -1, 1, 0, 0, 0));
|
||||||
}
|
}
|
||||||
_mask = std_::move(image);
|
_mask = std::move(image);
|
||||||
updatePixmapFromMask();
|
updatePixmapFromMask();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,11 @@ public:
|
||||||
EditColorBox(QWidget*, const QString &title, QColor current = QColor(255, 255, 255));
|
EditColorBox(QWidget*, const QString &title, QColor current = QColor(255, 255, 255));
|
||||||
|
|
||||||
void setSaveCallback(base::lambda<void(QColor)> &&callback) {
|
void setSaveCallback(base::lambda<void(QColor)> &&callback) {
|
||||||
_saveCallback = std_::move(callback);
|
_saveCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCancelCallback(base::lambda<void()> &&callback) {
|
void setCancelCallback(base::lambda<void()> &&callback) {
|
||||||
_cancelCallback = std_::move(callback);
|
_cancelCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showColor(QColor color) {
|
void showColor(QColor color) {
|
||||||
|
|
|
@ -109,9 +109,9 @@ void MembersBox::onAdd() {
|
||||||
}
|
}
|
||||||
auto box = Box<ContactsBox>(_inner->channel(), _inner->filter(), _inner->already());
|
auto box = Box<ContactsBox>(_inner->channel(), _inner->filter(), _inner->already());
|
||||||
if (_inner->filter() == MembersFilter::Recent) {
|
if (_inner->filter() == MembersFilter::Recent) {
|
||||||
Ui::show(std_::move(box));
|
Ui::show(std::move(box));
|
||||||
} else {
|
} else {
|
||||||
_addBox = Ui::show(std_::move(box), KeepOtherLayers);
|
_addBox = Ui::show(std::move(box), KeepOtherLayers);
|
||||||
if (_addBox) {
|
if (_addBox) {
|
||||||
connect(_addBox, SIGNAL(adminAdded()), this, SLOT(onAdminAdded()));
|
connect(_addBox, SIGNAL(adminAdded()), this, SLOT(onAdminAdded()));
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ void MembersBox::Inner::addRipple(MemberData *data) {
|
||||||
auto rowTop = getSelectedRowTop();
|
auto rowTop = getSelectedRowTop();
|
||||||
if (!data->ripple) {
|
if (!data->ripple) {
|
||||||
auto mask = Ui::RippleAnimation::rectMask(QSize(width(), _rowHeight));
|
auto mask = Ui::RippleAnimation::rectMask(QSize(width(), _rowHeight));
|
||||||
data->ripple = std_::make_unique<Ui::RippleAnimation>(st::contactsRipple, std_::move(mask), [this, data] {
|
data->ripple = std::make_unique<Ui::RippleAnimation>(st::contactsRipple, std::move(mask), [this, data] {
|
||||||
updateRowWithTop(data->rippleRowTop);
|
updateRowWithTop(data->rippleRowTop);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ private:
|
||||||
MemberData();
|
MemberData();
|
||||||
~MemberData();
|
~MemberData();
|
||||||
|
|
||||||
std_::unique_ptr<Ui::RippleAnimation> ripple;
|
std::unique_ptr<Ui::RippleAnimation> ripple;
|
||||||
int rippleRowTop = 0;
|
int rippleRowTop = 0;
|
||||||
Text name;
|
Text name;
|
||||||
QString online;
|
QString online;
|
||||||
|
|
|
@ -250,7 +250,7 @@ void NotificationsBox::prepareNotificationSampleSmall() {
|
||||||
auto closeLeft = width - 2 * padding;
|
auto closeLeft = width - 2 * padding;
|
||||||
p.fillRect(rtlrect(closeLeft, padding, padding, padding, width), st::notificationSampleCloseFg);
|
p.fillRect(rtlrect(closeLeft, padding, padding, padding, width), st::notificationSampleCloseFg);
|
||||||
}
|
}
|
||||||
_notificationSampleSmall = App::pixmapFromImageInPlace(std_::move(sampleImage));
|
_notificationSampleSmall = App::pixmapFromImageInPlace(std::move(sampleImage));
|
||||||
_notificationSampleSmall.setDevicePixelRatio(cRetinaFactor());
|
_notificationSampleSmall.setDevicePixelRatio(cRetinaFactor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ void NotificationsBox::prepareNotificationSampleLarge() {
|
||||||
st::notifyClose.icon.paint(p, w - st::notifyClosePos.x() - st::notifyClose.width + st::notifyClose.iconPosition.x(), st::notifyClosePos.y() + st::notifyClose.iconPosition.y(), w);
|
st::notifyClose.icon.paint(p, w - st::notifyClosePos.x() - st::notifyClose.width + st::notifyClose.iconPosition.x(), st::notifyClosePos.y() + st::notifyClose.iconPosition.y(), w);
|
||||||
}
|
}
|
||||||
|
|
||||||
_notificationSampleLarge = App::pixmapFromImageInPlace(std_::move(sampleImage));
|
_notificationSampleLarge = App::pixmapFromImageInPlace(std::move(sampleImage));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationsBox::removeSample(SampleWidget *widget) {
|
void NotificationsBox::removeSample(SampleWidget *widget) {
|
||||||
|
@ -366,7 +366,7 @@ void NotificationsBox::setOverCorner(Notify::ScreenCorner corner) {
|
||||||
auto sampleLeft = (isLeft == rtl()) ? (r.x() + r.width() - st::notifyWidth - st::notifyDeltaX) : (r.x() + st::notifyDeltaX);
|
auto sampleLeft = (isLeft == rtl()) ? (r.x() + r.width() - st::notifyWidth - st::notifyDeltaX) : (r.x() + st::notifyDeltaX);
|
||||||
auto sampleTop = isTop ? (r.y() + st::notifyDeltaY) : (r.y() + r.height() - st::notifyDeltaY - st::notifyMinHeight);
|
auto sampleTop = isTop ? (r.y() + st::notifyDeltaY) : (r.y() + r.height() - st::notifyDeltaY - st::notifyMinHeight);
|
||||||
for (int i = samplesLeave; i != samplesNeeded; ++i) {
|
for (int i = samplesLeave; i != samplesNeeded; ++i) {
|
||||||
auto widget = std_::make_unique<SampleWidget>(this, _notificationSampleLarge);
|
auto widget = std::make_unique<SampleWidget>(this, _notificationSampleLarge);
|
||||||
widget->move(sampleLeft, sampleTop + (isTop ? 1 : -1) * i * (st::notifyMinHeight + st::notifyDeltaY));
|
widget->move(sampleLeft, sampleTop + (isTop ? 1 : -1) * i * (st::notifyMinHeight + st::notifyDeltaY));
|
||||||
widget->showFast();
|
widget->showFast();
|
||||||
samples.push_back(widget.release());
|
samples.push_back(widget.release());
|
||||||
|
|
|
@ -63,7 +63,7 @@ private:
|
||||||
QPixmap _notificationSampleSmall;
|
QPixmap _notificationSampleSmall;
|
||||||
QPixmap _notificationSampleLarge;
|
QPixmap _notificationSampleLarge;
|
||||||
ScreenCorner _chosenCorner;
|
ScreenCorner _chosenCorner;
|
||||||
std_::vector_of_moveable<Animation> _sampleOpacities;
|
std::vector<Animation> _sampleOpacities;
|
||||||
|
|
||||||
bool _isOverCorner = false;
|
bool _isOverCorner = false;
|
||||||
ScreenCorner _overCorner = ScreenCorner::TopLeft;
|
ScreenCorner _overCorner = ScreenCorner::TopLeft;
|
||||||
|
|
|
@ -93,9 +93,9 @@ SendFilesBox::SendFilesBox(QWidget*, const QString &filepath, QImage image, Comp
|
||||||
}
|
}
|
||||||
_previewLeft = (st::boxWideWidth - _previewWidth) / 2;
|
_previewLeft = (st::boxWideWidth - _previewWidth) / 2;
|
||||||
|
|
||||||
image = std_::move(image).scaled(_previewWidth * cIntRetinaFactor(), _previewHeight * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
image = std::move(image).scaled(_previewWidth * cIntRetinaFactor(), _previewHeight * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
image = Images::prepareOpaque(std_::move(image));
|
image = Images::prepareOpaque(std::move(image));
|
||||||
_preview = App::pixmapFromImageInPlace(std_::move(image));
|
_preview = App::pixmapFromImageInPlace(std::move(image));
|
||||||
_preview.setDevicePixelRatio(cRetinaFactor());
|
_preview.setDevicePixelRatio(cRetinaFactor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,10 @@ public:
|
||||||
SendFilesBox(QWidget*, const QString &phone, const QString &firstname, const QString &lastname);
|
SendFilesBox(QWidget*, const QString &phone, const QString &firstname, const QString &lastname);
|
||||||
|
|
||||||
void setConfirmedCallback(base::lambda<void(const QStringList &files, bool compressed, const QString &caption, bool ctrlShiftEnter)> &&callback) {
|
void setConfirmedCallback(base::lambda<void(const QStringList &files, bool compressed, const QString &caption, bool ctrlShiftEnter)> &&callback) {
|
||||||
_confirmedCallback = std_::move(callback);
|
_confirmedCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
void setCancelledCallback(base::lambda<void()> &&callback) {
|
void setCancelledCallback(base::lambda<void()> &&callback) {
|
||||||
_cancelledCallback = std_::move(callback);
|
_cancelledCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void closeHook() override;
|
void closeHook() override;
|
||||||
|
|
|
@ -41,9 +41,9 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include "boxes/contactsbox.h"
|
#include "boxes/contactsbox.h"
|
||||||
|
|
||||||
ShareBox::ShareBox(QWidget*, CopyCallback &©Callback, SubmitCallback &&submitCallback, FilterCallback &&filterCallback)
|
ShareBox::ShareBox(QWidget*, CopyCallback &©Callback, SubmitCallback &&submitCallback, FilterCallback &&filterCallback)
|
||||||
: _copyCallback(std_::move(copyCallback))
|
: _copyCallback(std::move(copyCallback))
|
||||||
, _submitCallback(std_::move(submitCallback))
|
, _submitCallback(std::move(submitCallback))
|
||||||
, _filterCallback(std_::move(filterCallback))
|
, _filterCallback(std::move(filterCallback))
|
||||||
, _select(this, st::contactsMultiSelect, lang(lng_participant_filter))
|
, _select(this, st::contactsMultiSelect, lang(lng_participant_filter))
|
||||||
, _searchTimer(this) {
|
, _searchTimer(this) {
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ void ShareBox::prepare() {
|
||||||
|
|
||||||
setTitle(lang(lng_share_title));
|
setTitle(lang(lng_share_title));
|
||||||
|
|
||||||
_inner = setInnerWidget(object_ptr<Inner>(this, std_::move(_filterCallback)), getTopScrollSkip());
|
_inner = setInnerWidget(object_ptr<Inner>(this, std::move(_filterCallback)), getTopScrollSkip());
|
||||||
connect(_inner, SIGNAL(mustScrollTo(int,int)), this, SLOT(onMustScrollTo(int,int)));
|
connect(_inner, SIGNAL(mustScrollTo(int,int)), this, SLOT(onMustScrollTo(int,int)));
|
||||||
|
|
||||||
createButtons();
|
createButtons();
|
||||||
|
@ -272,8 +272,8 @@ void ShareBox::scrollAnimationCallback() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ShareBox::Inner::Inner(QWidget *parent, ShareBox::FilterCallback &&filterCallback) : TWidget(parent)
|
ShareBox::Inner::Inner(QWidget *parent, ShareBox::FilterCallback &&filterCallback) : TWidget(parent)
|
||||||
, _filterCallback(std_::move(filterCallback))
|
, _filterCallback(std::move(filterCallback))
|
||||||
, _chatsIndexed(std_::make_unique<Dialogs::IndexedList>(Dialogs::SortMode::Add)) {
|
, _chatsIndexed(std::make_unique<Dialogs::IndexedList>(Dialogs::SortMode::Add)) {
|
||||||
_rowsTop = st::shareRowsTop;
|
_rowsTop = st::shareRowsTop;
|
||||||
_rowHeight = st::shareRowHeight;
|
_rowHeight = st::shareRowHeight;
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
|
@ -649,7 +649,7 @@ void ShareBox::Inner::peerUnselected(PeerData *peer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShareBox::Inner::setPeerSelectedChangedCallback(base::lambda<void(PeerData *peer, bool selected)> &&callback) {
|
void ShareBox::Inner::setPeerSelectedChangedCallback(base::lambda<void(PeerData *peer, bool selected)> &&callback) {
|
||||||
_peerSelectedChangedCallback = std_::move(callback);
|
_peerSelectedChangedCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShareBox::Inner::changePeerCheckState(Chat *chat, bool checked, ChangeStateWay useCallback) {
|
void ShareBox::Inner::changePeerCheckState(Chat *chat, bool checked, ChangeStateWay useCallback) {
|
||||||
|
@ -903,7 +903,7 @@ void shareGameScoreFromItem(HistoryItem *item) {
|
||||||
MTPVector<MTPlong> random = MTP_vector<MTPlong>(1, rand_value<MTPlong>());
|
MTPVector<MTPlong> random = MTP_vector<MTPlong>(1, rand_value<MTPlong>());
|
||||||
auto request = MTPmessages_ForwardMessages(MTP_flags(sendFlags), item->history()->peer->input, msgIds, random, peer->input);
|
auto request = MTPmessages_ForwardMessages(MTP_flags(sendFlags), item->history()->peer->input, msgIds, random, peer->input);
|
||||||
auto callback = doneCallback;
|
auto callback = doneCallback;
|
||||||
auto requestId = MTP::send(request, rpcDone(std_::move(callback)));
|
auto requestId = MTP::send(request, rpcDone(std::move(callback)));
|
||||||
data->requests.insert(requestId);
|
data->requests.insert(requestId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -918,7 +918,7 @@ void shareGameScoreFromItem(HistoryItem *item) {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
Ui::show(Box<ShareBox>(std_::move(copyCallback), std_::move(submitCallback), std_::move(filterCallback)));
|
Ui::show(Box<ShareBox>(std::move(copyCallback), std::move(submitCallback), std::move(filterCallback)));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -22,7 +22,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
|
|
||||||
#include "boxes/abstractbox.h"
|
#include "boxes/abstractbox.h"
|
||||||
#include "core/observer.h"
|
#include "core/observer.h"
|
||||||
#include "core/vector_of_moveable.h"
|
|
||||||
#include "ui/effects/round_checkbox.h"
|
#include "ui/effects/round_checkbox.h"
|
||||||
|
|
||||||
namespace Dialogs {
|
namespace Dialogs {
|
||||||
|
@ -194,7 +193,7 @@ private:
|
||||||
int _upon = -1;
|
int _upon = -1;
|
||||||
|
|
||||||
ShareBox::FilterCallback _filterCallback;
|
ShareBox::FilterCallback _filterCallback;
|
||||||
std_::unique_ptr<Dialogs::IndexedList> _chatsIndexed;
|
std::unique_ptr<Dialogs::IndexedList> _chatsIndexed;
|
||||||
QString _filter;
|
QString _filter;
|
||||||
using FilteredDialogs = QVector<Dialogs::Row*>;
|
using FilteredDialogs = QVector<Dialogs::Row*>;
|
||||||
FilteredDialogs _filtered;
|
FilteredDialogs _filtered;
|
||||||
|
|
|
@ -118,16 +118,16 @@ void StickersBox::CounterWidget::updateCounter() {
|
||||||
template <typename ...Args>
|
template <typename ...Args>
|
||||||
StickersBox::Tab::Tab(int index, Args&&... args)
|
StickersBox::Tab::Tab(int index, Args&&... args)
|
||||||
: _index(index)
|
: _index(index)
|
||||||
, _widget(std_::forward<Args>(args)...)
|
, _widget(std::forward<Args>(args)...)
|
||||||
, _weak(_widget) {
|
, _weak(_widget) {
|
||||||
}
|
}
|
||||||
|
|
||||||
object_ptr<StickersBox::Inner> StickersBox::Tab::takeWidget() {
|
object_ptr<StickersBox::Inner> StickersBox::Tab::takeWidget() {
|
||||||
return std_::move(_widget);
|
return std::move(_widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersBox::Tab::returnWidget(object_ptr<Inner> widget) {
|
void StickersBox::Tab::returnWidget(object_ptr<Inner> widget) {
|
||||||
_widget = std_::move(widget);
|
_widget = std::move(widget);
|
||||||
t_assert(_widget == _weak);
|
t_assert(_widget == _weak);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ void StickersBox::switchTab() {
|
||||||
auto widget = takeInnerWidget<Inner>();
|
auto widget = takeInnerWidget<Inner>();
|
||||||
widget->setParent(this);
|
widget->setParent(this);
|
||||||
widget->hide();
|
widget->hide();
|
||||||
_tab->returnWidget(std_::move(widget));
|
_tab->returnWidget(std::move(widget));
|
||||||
_tab = newTab;
|
_tab = newTab;
|
||||||
_section = newSection;
|
_section = newSection;
|
||||||
setInnerWidget(_tab->takeWidget(), getTopSkip());
|
setInnerWidget(_tab->takeWidget(), getTopSkip());
|
||||||
|
@ -410,8 +410,8 @@ void StickersBox::switchTab() {
|
||||||
auto nowCache = grabContentCache();
|
auto nowCache = grabContentCache();
|
||||||
auto nowIndex = _tab->index();
|
auto nowIndex = _tab->index();
|
||||||
|
|
||||||
_slideAnimation = std_::make_unique<Ui::SlideAnimation>();
|
_slideAnimation = std::make_unique<Ui::SlideAnimation>();
|
||||||
_slideAnimation->setSnapshots(std_::move(wasCache), std_::move(nowCache));
|
_slideAnimation->setSnapshots(std::move(wasCache), std::move(nowCache));
|
||||||
auto slideLeft = wasIndex > nowIndex;
|
auto slideLeft = wasIndex > nowIndex;
|
||||||
_slideAnimation->start(slideLeft, [this] { update(); }, st::slideDuration);
|
_slideAnimation->start(slideLeft, [this] { update(); }, st::slideDuration);
|
||||||
setInnerVisible(false);
|
setInnerVisible(false);
|
||||||
|
@ -425,7 +425,7 @@ QPixmap StickersBox::grabContentCache() {
|
||||||
_tabs->hide();
|
_tabs->hide();
|
||||||
auto result = grabInnerCache();
|
auto result = grabInnerCache();
|
||||||
_tabs->show();
|
_tabs->show();
|
||||||
return std_::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersBox::installSet(uint64 setId) {
|
void StickersBox::installSet(uint64 setId) {
|
||||||
|
@ -796,16 +796,16 @@ void StickersBox::Inner::setActionDown(int newActionDown) {
|
||||||
if (set->removed) {
|
if (set->removed) {
|
||||||
auto rippleSize = QSize(_undoWidth - st::stickersUndoRemove.width, st::stickersUndoRemove.height);
|
auto rippleSize = QSize(_undoWidth - st::stickersUndoRemove.width, st::stickersUndoRemove.height);
|
||||||
auto rippleMask = Ui::RippleAnimation::roundRectMask(rippleSize, st::buttonRadius);
|
auto rippleMask = Ui::RippleAnimation::roundRectMask(rippleSize, st::buttonRadius);
|
||||||
ensureRipple(st::stickersUndoRemove.ripple, std_::move(rippleMask), removeButton);
|
ensureRipple(st::stickersUndoRemove.ripple, std::move(rippleMask), removeButton);
|
||||||
} else {
|
} else {
|
||||||
auto rippleSize = st::stickersRemove.rippleAreaSize;
|
auto rippleSize = st::stickersRemove.rippleAreaSize;
|
||||||
auto rippleMask = Ui::RippleAnimation::ellipseMask(QSize(rippleSize, rippleSize));
|
auto rippleMask = Ui::RippleAnimation::ellipseMask(QSize(rippleSize, rippleSize));
|
||||||
ensureRipple(st::stickersRemove.ripple, std_::move(rippleMask), removeButton);
|
ensureRipple(st::stickersRemove.ripple, std::move(rippleMask), removeButton);
|
||||||
}
|
}
|
||||||
} else if (!set->installed || set->archived || set->removed) {
|
} else if (!set->installed || set->archived || set->removed) {
|
||||||
auto rippleSize = QSize(_addWidth - st::stickersTrendingAdd.width, st::stickersTrendingAdd.height);
|
auto rippleSize = QSize(_addWidth - st::stickersTrendingAdd.width, st::stickersTrendingAdd.height);
|
||||||
auto rippleMask = Ui::RippleAnimation::roundRectMask(rippleSize, st::buttonRadius);
|
auto rippleMask = Ui::RippleAnimation::roundRectMask(rippleSize, st::buttonRadius);
|
||||||
ensureRipple(st::stickersTrendingAdd.ripple, std_::move(rippleMask), removeButton);
|
ensureRipple(st::stickersTrendingAdd.ripple, std::move(rippleMask), removeButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (set->ripple) {
|
if (set->ripple) {
|
||||||
|
@ -816,7 +816,7 @@ void StickersBox::Inner::setActionDown(int newActionDown) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersBox::Inner::ensureRipple(const style::RippleAnimation &st, QImage mask, bool removeButton) {
|
void StickersBox::Inner::ensureRipple(const style::RippleAnimation &st, QImage mask, bool removeButton) {
|
||||||
_rows[_actionDown]->ripple = MakeShared<Ui::RippleAnimation>(st, std_::move(mask), [this, index = _actionDown, removeButton] {
|
_rows[_actionDown]->ripple = MakeShared<Ui::RippleAnimation>(st, std::move(mask), [this, index = _actionDown, removeButton] {
|
||||||
update(myrtlrect(relativeButtonRect(removeButton).translated(0, _itemsTop + index * _rowHeight)));
|
update(myrtlrect(relativeButtonRect(removeButton).translated(0, _itemsTop + index * _rowHeight)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ private:
|
||||||
Tab _archived;
|
Tab _archived;
|
||||||
Tab *_tab = nullptr;
|
Tab *_tab = nullptr;
|
||||||
|
|
||||||
std_::unique_ptr<Ui::SlideAnimation> _slideAnimation;
|
std::unique_ptr<Ui::SlideAnimation> _slideAnimation;
|
||||||
object_ptr<BoxLayerTitleShadow> _titleShadow = { nullptr };
|
object_ptr<BoxLayerTitleShadow> _titleShadow = { nullptr };
|
||||||
|
|
||||||
int _aboutWidth = 0;
|
int _aboutWidth = 0;
|
||||||
|
@ -164,10 +164,10 @@ public:
|
||||||
void setRemovedSets(const Stickers::Order &removed);
|
void setRemovedSets(const Stickers::Order &removed);
|
||||||
|
|
||||||
void setInstallSetCallback(base::lambda<void(uint64 setId)> &&callback) {
|
void setInstallSetCallback(base::lambda<void(uint64 setId)> &&callback) {
|
||||||
_installSetCallback = std_::move(callback);
|
_installSetCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
void setLoadMoreCallback(base::lambda<void()> &&callback) {
|
void setLoadMoreCallback(base::lambda<void()> &&callback) {
|
||||||
_loadMoreCallback = std_::move(callback);
|
_loadMoreCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setVisibleTopBottom(int visibleTop, int visibleBottom) override;
|
void setVisibleTopBottom(int visibleTop, int visibleBottom) override;
|
||||||
|
|
|
@ -21,7 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "boxes/abstractbox.h"
|
#include "boxes/abstractbox.h"
|
||||||
#include "core/vector_of_moveable.h"
|
#include <vector>
|
||||||
|
|
||||||
class ConfirmBox;
|
class ConfirmBox;
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ private:
|
||||||
return (_setFlags & MTPDstickerSet::Flag::f_masks);
|
return (_setFlags & MTPDstickerSet::Flag::f_masks);
|
||||||
}
|
}
|
||||||
|
|
||||||
std_::vector_of_moveable<Animation> _packOvers;
|
std::vector<Animation> _packOvers;
|
||||||
StickerPack _pack;
|
StickerPack _pack;
|
||||||
StickersByEmojiMap _emoji;
|
StickersByEmojiMap _emoji;
|
||||||
bool _loaded = false;
|
bool _loaded = false;
|
||||||
|
|
|
@ -22,12 +22,10 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <memory>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#include <QtCore/QReadWriteLock>
|
|
||||||
|
|
||||||
#include "core/build_config.h"
|
#include "core/build_config.h"
|
||||||
#include "core/stl_subset.h"
|
|
||||||
#include "core/ordered_set.h"
|
#include "core/ordered_set.h"
|
||||||
|
|
||||||
//using uchar = unsigned char; // Qt has uchar
|
//using uchar = unsigned char; // Qt has uchar
|
||||||
|
|
|
@ -180,7 +180,7 @@ protected:
|
||||||
|
|
||||||
class LambdaClickHandler : public ClickHandler {
|
class LambdaClickHandler : public ClickHandler {
|
||||||
public:
|
public:
|
||||||
LambdaClickHandler(base::lambda<void()> &&handler) : _handler(std_::move(handler)) {
|
LambdaClickHandler(base::lambda<void()> &&handler) : _handler(std::move(handler)) {
|
||||||
}
|
}
|
||||||
void onClick(Qt::MouseButton button) const override final {
|
void onClick(Qt::MouseButton button) const override final {
|
||||||
if (button == Qt::LeftButton && _handler) {
|
if (button == Qt::LeftButton && _handler) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "core/stl_subset.h"
|
#include <memory>
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
@ -57,7 +57,7 @@ namespace internal {
|
||||||
using alignment = uint64;
|
using alignment = uint64;
|
||||||
|
|
||||||
template <typename Lambda>
|
template <typename Lambda>
|
||||||
using IsLarge = std_::integral_constant<bool, !(sizeof(std_::decay_simple_t<Lambda>) <= kStorageSize)>;
|
using IsLarge = std::integral_constant<bool, !(sizeof(std::decay_t<Lambda>) <= kStorageSize)>;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void bad_construct_copy(void *lambda, const void *source) {
|
static void bad_construct_copy(void *lambda, const void *source) {
|
||||||
|
@ -95,20 +95,20 @@ namespace internal {
|
||||||
template <typename Lambda, typename IsLarge, typename Return, typename ...Args> struct lambda_wrap_helper_move_impl;
|
template <typename Lambda, typename IsLarge, typename Return, typename ...Args> struct lambda_wrap_helper_move_impl;
|
||||||
|
|
||||||
template <typename Lambda, typename Return, typename ...Args>
|
template <typename Lambda, typename Return, typename ...Args>
|
||||||
struct lambda_wrap_helper_move_impl<Lambda, std_::true_type, Return, Args...> : public lambda_wrap_helper_base<Return, Args...> {
|
struct lambda_wrap_helper_move_impl<Lambda, std::true_type, Return, Args...> : public lambda_wrap_helper_base<Return, Args...> {
|
||||||
using JustLambda = std_::decay_simple_t<Lambda>;
|
using JustLambda = std::decay_t<Lambda>;
|
||||||
using LambdaPtr = std_::unique_ptr<JustLambda>;
|
using LambdaPtr = std::unique_ptr<JustLambda>;
|
||||||
using Parent = lambda_wrap_helper_base<Return, Args...>;
|
using Parent = lambda_wrap_helper_base<Return, Args...>;
|
||||||
static void construct_move_other_method(void *lambda, void *source) {
|
static void construct_move_other_method(void *lambda, void *source) {
|
||||||
auto source_lambda = static_cast<LambdaPtr*>(source);
|
auto source_lambda = static_cast<LambdaPtr*>(source);
|
||||||
new (lambda) LambdaPtr(std_::move(*source_lambda));
|
new (lambda) LambdaPtr(std::move(*source_lambda));
|
||||||
}
|
}
|
||||||
static void construct_move_lambda_method(void *lambda, void *source) {
|
static void construct_move_lambda_method(void *lambda, void *source) {
|
||||||
auto source_lambda = static_cast<JustLambda*>(source);
|
auto source_lambda = static_cast<JustLambda*>(source);
|
||||||
new (lambda) LambdaPtr(std_::make_unique<JustLambda>(static_cast<JustLambda&&>(*source_lambda)));
|
new (lambda) LambdaPtr(std::make_unique<JustLambda>(static_cast<JustLambda&&>(*source_lambda)));
|
||||||
}
|
}
|
||||||
static Return call_method(const void *lambda, Args... args) {
|
static Return call_method(const void *lambda, Args... args) {
|
||||||
return (**static_cast<const LambdaPtr*>(lambda))(std_::forward<Args>(args)...);
|
return (**static_cast<const LambdaPtr*>(lambda))(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
static void destruct_method(const void *lambda) {
|
static void destruct_method(const void *lambda) {
|
||||||
static_cast<const LambdaPtr*>(lambda)->~LambdaPtr();
|
static_cast<const LambdaPtr*>(lambda)->~LambdaPtr();
|
||||||
|
@ -133,8 +133,8 @@ namespace internal {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Lambda, typename Return, typename ...Args>
|
template <typename Lambda, typename Return, typename ...Args>
|
||||||
struct lambda_wrap_helper_move_impl<Lambda, std_::false_type, Return, Args...> : public lambda_wrap_helper_base<Return, Args...> {
|
struct lambda_wrap_helper_move_impl<Lambda, std::false_type, Return, Args...> : public lambda_wrap_helper_base<Return, Args...> {
|
||||||
using JustLambda = std_::decay_simple_t<Lambda>;
|
using JustLambda = std::decay_t<Lambda>;
|
||||||
using Parent = lambda_wrap_helper_base<Return, Args...>;
|
using Parent = lambda_wrap_helper_base<Return, Args...>;
|
||||||
static void construct_move_other_method(void *lambda, void *source) {
|
static void construct_move_other_method(void *lambda, void *source) {
|
||||||
auto source_lambda = static_cast<JustLambda*>(source);
|
auto source_lambda = static_cast<JustLambda*>(source);
|
||||||
|
@ -143,13 +143,13 @@ namespace internal {
|
||||||
static void construct_move_lambda_method(void *lambda, void *source) {
|
static void construct_move_lambda_method(void *lambda, void *source) {
|
||||||
static_assert(alignof(JustLambda) <= alignof(typename Parent::alignment), "Bad lambda alignment.");
|
static_assert(alignof(JustLambda) <= alignof(typename Parent::alignment), "Bad lambda alignment.");
|
||||||
auto space = sizeof(JustLambda);
|
auto space = sizeof(JustLambda);
|
||||||
auto aligned = std_::align(alignof(JustLambda), space, lambda, space);
|
auto aligned = std::align(alignof(JustLambda), space, lambda, space);
|
||||||
t_assert(aligned == lambda);
|
t_assert(aligned == lambda);
|
||||||
auto source_lambda = static_cast<JustLambda*>(source);
|
auto source_lambda = static_cast<JustLambda*>(source);
|
||||||
new (lambda) JustLambda(static_cast<JustLambda&&>(*source_lambda));
|
new (lambda) JustLambda(static_cast<JustLambda&&>(*source_lambda));
|
||||||
}
|
}
|
||||||
static Return call_method(const void *lambda, Args... args) {
|
static Return call_method(const void *lambda, Args... args) {
|
||||||
return (*static_cast<const JustLambda*>(lambda))(std_::forward<Args>(args)...);
|
return (*static_cast<const JustLambda*>(lambda))(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
static void destruct_method(const void *lambda) {
|
static void destruct_method(const void *lambda) {
|
||||||
static_cast<const JustLambda*>(lambda)->~JustLambda();
|
static_cast<const JustLambda*>(lambda)->~JustLambda();
|
||||||
|
@ -186,17 +186,17 @@ namespace internal {
|
||||||
template <typename Lambda, typename IsLarge, typename Return, typename ...Args> struct lambda_wrap_helper_copy_impl;
|
template <typename Lambda, typename IsLarge, typename Return, typename ...Args> struct lambda_wrap_helper_copy_impl;
|
||||||
|
|
||||||
template <typename Lambda, typename Return, typename ...Args>
|
template <typename Lambda, typename Return, typename ...Args>
|
||||||
struct lambda_wrap_helper_copy_impl<Lambda, std_::true_type, Return, Args...> : public lambda_wrap_helper_move_impl<Lambda, std_::true_type, Return, Args...> {
|
struct lambda_wrap_helper_copy_impl<Lambda, std::true_type, Return, Args...> : public lambda_wrap_helper_move_impl<Lambda, std::true_type, Return, Args...> {
|
||||||
using JustLambda = std_::decay_simple_t<Lambda>;
|
using JustLambda = std::decay_t<Lambda>;
|
||||||
using LambdaPtr = std_::unique_ptr<JustLambda>;
|
using LambdaPtr = std::unique_ptr<JustLambda>;
|
||||||
using Parent = lambda_wrap_helper_move_impl<Lambda, std_::true_type, Return, Args...>;
|
using Parent = lambda_wrap_helper_move_impl<Lambda, std::true_type, Return, Args...>;
|
||||||
static void construct_copy_other_method(void *lambda, const void *source) {
|
static void construct_copy_other_method(void *lambda, const void *source) {
|
||||||
auto source_lambda = static_cast<const LambdaPtr*>(source);
|
auto source_lambda = static_cast<const LambdaPtr*>(source);
|
||||||
new (lambda) LambdaPtr(std_::make_unique<JustLambda>(*source_lambda->get()));
|
new (lambda) LambdaPtr(std::make_unique<JustLambda>(*source_lambda->get()));
|
||||||
}
|
}
|
||||||
static void construct_copy_lambda_method(void *lambda, const void *source) {
|
static void construct_copy_lambda_method(void *lambda, const void *source) {
|
||||||
auto source_lambda = static_cast<const JustLambda*>(source);
|
auto source_lambda = static_cast<const JustLambda*>(source);
|
||||||
new (lambda) LambdaPtr(std_::make_unique<JustLambda>(static_cast<const JustLambda &>(*source_lambda)));
|
new (lambda) LambdaPtr(std::make_unique<JustLambda>(static_cast<const JustLambda &>(*source_lambda)));
|
||||||
}
|
}
|
||||||
lambda_wrap_helper_copy_impl() : Parent(&lambda_wrap_helper_copy_impl::construct_copy_other_method) {
|
lambda_wrap_helper_copy_impl() : Parent(&lambda_wrap_helper_copy_impl::construct_copy_other_method) {
|
||||||
}
|
}
|
||||||
|
@ -204,9 +204,9 @@ namespace internal {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Lambda, typename Return, typename ...Args>
|
template <typename Lambda, typename Return, typename ...Args>
|
||||||
struct lambda_wrap_helper_copy_impl<Lambda, std_::false_type, Return, Args...> : public lambda_wrap_helper_move_impl<Lambda, std_::false_type, Return, Args...> {
|
struct lambda_wrap_helper_copy_impl<Lambda, std::false_type, Return, Args...> : public lambda_wrap_helper_move_impl<Lambda, std::false_type, Return, Args...> {
|
||||||
using JustLambda = std_::decay_simple_t<Lambda>;
|
using JustLambda = std::decay_t<Lambda>;
|
||||||
using Parent = lambda_wrap_helper_move_impl<Lambda, std_::false_type, Return, Args...>;
|
using Parent = lambda_wrap_helper_move_impl<Lambda, std::false_type, Return, Args...>;
|
||||||
static void construct_copy_other_method(void *lambda, const void *source) {
|
static void construct_copy_other_method(void *lambda, const void *source) {
|
||||||
auto source_lambda = static_cast<const JustLambda*>(source);
|
auto source_lambda = static_cast<const JustLambda*>(source);
|
||||||
new (lambda) JustLambda(static_cast<const JustLambda &>(*source_lambda));
|
new (lambda) JustLambda(static_cast<const JustLambda &>(*source_lambda));
|
||||||
|
@ -214,7 +214,7 @@ namespace internal {
|
||||||
static void construct_copy_lambda_method(void *lambda, const void *source) {
|
static void construct_copy_lambda_method(void *lambda, const void *source) {
|
||||||
static_assert(alignof(JustLambda) <= alignof(typename Parent::alignment), "Bad lambda alignment.");
|
static_assert(alignof(JustLambda) <= alignof(typename Parent::alignment), "Bad lambda alignment.");
|
||||||
auto space = sizeof(JustLambda);
|
auto space = sizeof(JustLambda);
|
||||||
auto aligned = std_::align(alignof(JustLambda), space, lambda, space);
|
auto aligned = std::align(alignof(JustLambda), space, lambda, space);
|
||||||
t_assert(aligned == lambda);
|
t_assert(aligned == lambda);
|
||||||
auto source_lambda = static_cast<const JustLambda*>(source);
|
auto source_lambda = static_cast<const JustLambda*>(source);
|
||||||
new (lambda) JustLambda(static_cast<const JustLambda &>(*source_lambda));
|
new (lambda) JustLambda(static_cast<const JustLambda &>(*source_lambda));
|
||||||
|
@ -245,13 +245,13 @@ class lambda<Return(Args...)> {
|
||||||
using EmptyHelper = internal::lambda_wrap_empty<Return, Args...>;
|
using EmptyHelper = internal::lambda_wrap_empty<Return, Args...>;
|
||||||
|
|
||||||
template <typename Lambda>
|
template <typename Lambda>
|
||||||
using IsUnique = std_::is_same<lambda, std_::decay_simple_t<Lambda>>;
|
using IsUnique = std::is_same<lambda, std::decay_t<Lambda>>;
|
||||||
template <typename Lambda>
|
template <typename Lambda>
|
||||||
using IsWrap = std_::is_same<lambda_copy<Return(Args...)>, std_::decay_simple_t<Lambda>>;
|
using IsWrap = std::is_same<lambda_copy<Return(Args...)>, std::decay_t<Lambda>>;
|
||||||
template <typename Lambda>
|
template <typename Lambda>
|
||||||
using IsOther = std_::enable_if_t<!IsUnique<Lambda>::value && !IsWrap<Lambda>::value>;
|
using IsOther = std::enable_if_t<!IsUnique<Lambda>::value && !IsWrap<Lambda>::value>;
|
||||||
template <typename Lambda>
|
template <typename Lambda>
|
||||||
using IsRvalue = std_::enable_if_t<std_::is_rvalue_reference<Lambda&&>::value>;
|
using IsRvalue = std::enable_if_t<std::is_rvalue_reference<Lambda&&>::value>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using return_type = Return;
|
using return_type = Return;
|
||||||
|
@ -266,7 +266,7 @@ public:
|
||||||
helper_->construct_move_other(storage_, other.storage_);
|
helper_->construct_move_other(storage_, other.storage_);
|
||||||
}
|
}
|
||||||
lambda &operator=(lambda &&other) {
|
lambda &operator=(lambda &&other) {
|
||||||
auto temp = std_::move(other);
|
auto temp = std::move(other);
|
||||||
helper_->destruct(storage_);
|
helper_->destruct(storage_);
|
||||||
helper_ = temp.helper_;
|
helper_ = temp.helper_;
|
||||||
helper_->construct_move_other(storage_, temp.storage_);
|
helper_->construct_move_other(storage_, temp.storage_);
|
||||||
|
@ -274,7 +274,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap(lambda &other) {
|
void swap(lambda &other) {
|
||||||
if (this != &other) std_::swap_moveable(*this, other);
|
if (this != &other) std::swap(*this, other);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Lambda, typename = IsOther<Lambda>, typename = IsRvalue<Lambda>>
|
template <typename Lambda, typename = IsOther<Lambda>, typename = IsRvalue<Lambda>>
|
||||||
|
@ -284,7 +284,7 @@ public:
|
||||||
|
|
||||||
template <typename Lambda, typename = IsOther<Lambda>, typename = IsRvalue<Lambda>>
|
template <typename Lambda, typename = IsOther<Lambda>, typename = IsRvalue<Lambda>>
|
||||||
lambda &operator=(Lambda &&other) {
|
lambda &operator=(Lambda &&other) {
|
||||||
auto temp = std_::move(other);
|
auto temp = std::move(other);
|
||||||
helper_->destruct(storage_);
|
helper_->destruct(storage_);
|
||||||
helper_ = &internal::lambda_wrap_helper_move<Lambda, Return, Args...>::instance;
|
helper_ = &internal::lambda_wrap_helper_move<Lambda, Return, Args...>::instance;
|
||||||
internal::lambda_wrap_helper_move<Lambda, Return, Args...>::construct_move_lambda_method(storage_, &temp);
|
internal::lambda_wrap_helper_move<Lambda, Return, Args...>::construct_move_lambda_method(storage_, &temp);
|
||||||
|
@ -292,7 +292,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Return operator()(Args... args) const {
|
inline Return operator()(Args... args) const {
|
||||||
return helper_->call(storage_, std_::forward<Args>(args)...);
|
return helper_->call(storage_, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const {
|
||||||
|
@ -322,11 +322,11 @@ class lambda_copy<Return(Args...)> : public lambda<Return(Args...)> {
|
||||||
using Parent = lambda<Return(Args...)>;
|
using Parent = lambda<Return(Args...)>;
|
||||||
|
|
||||||
template <typename Lambda>
|
template <typename Lambda>
|
||||||
using IsOther = std_::enable_if_t<!std_::is_same<lambda_copy, std_::decay_simple_t<Lambda>>::value>;
|
using IsOther = std::enable_if_t<!std::is_same<lambda_copy, std::decay_t<Lambda>>::value>;
|
||||||
template <typename Lambda>
|
template <typename Lambda>
|
||||||
using IsRvalue = std_::enable_if_t<std_::is_rvalue_reference<Lambda&&>::value>;
|
using IsRvalue = std::enable_if_t<std::is_rvalue_reference<Lambda&&>::value>;
|
||||||
template <typename Lambda>
|
template <typename Lambda>
|
||||||
using IsNotRvalue = std_::enable_if_t<!std_::is_rvalue_reference<Lambda&&>::value>;
|
using IsNotRvalue = std::enable_if_t<!std::is_rvalue_reference<Lambda&&>::value>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
lambda_copy() = default;
|
lambda_copy() = default;
|
||||||
|
@ -344,7 +344,7 @@ public:
|
||||||
lambda_copy &operator=(lambda_copy &&other) = default;
|
lambda_copy &operator=(lambda_copy &&other) = default;
|
||||||
|
|
||||||
void swap(lambda_copy &other) {
|
void swap(lambda_copy &other) {
|
||||||
if (this != &other) std_::swap_moveable(*this, other);
|
if (this != &other) std::swap(*this, other);
|
||||||
}
|
}
|
||||||
|
|
||||||
lambda_copy clone() const {
|
lambda_copy clone() const {
|
||||||
|
@ -372,7 +372,7 @@ public:
|
||||||
|
|
||||||
template <typename Lambda, typename = IsOther<Lambda>, typename = IsRvalue<Lambda>>
|
template <typename Lambda, typename = IsOther<Lambda>, typename = IsRvalue<Lambda>>
|
||||||
lambda_copy &operator=(Lambda &&other) {
|
lambda_copy &operator=(Lambda &&other) {
|
||||||
auto temp = std_::move(other);
|
auto temp = std::move(other);
|
||||||
this->helper_->destruct(this->storage_);
|
this->helper_->destruct(this->storage_);
|
||||||
this->helper_ = &internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::instance;
|
this->helper_ = &internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::instance;
|
||||||
internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::construct_move_lambda_method(this->storage_, &other);
|
internal::lambda_wrap_helper_copy<Lambda, Return, Args...>::construct_move_lambda_method(this->storage_, &other);
|
||||||
|
@ -423,7 +423,7 @@ public:
|
||||||
using return_type = typename lambda_type<Lambda>::return_type;
|
using return_type = typename lambda_type<Lambda>::return_type;
|
||||||
|
|
||||||
template <typename ...PointersAndLambda>
|
template <typename ...PointersAndLambda>
|
||||||
inline lambda_guard_data(PointersAndLambda&&... qobjectsAndLambda) : _lambda(init(_pointers, std_::forward<PointersAndLambda>(qobjectsAndLambda)...)) {
|
inline lambda_guard_data(PointersAndLambda&&... qobjectsAndLambda) : _lambda(init(_pointers, std::forward<PointersAndLambda>(qobjectsAndLambda)...)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline lambda_guard_data(const lambda_guard_data &other) : _lambda(other._lambda) {
|
inline lambda_guard_data(const lambda_guard_data &other) : _lambda(other._lambda) {
|
||||||
|
@ -439,17 +439,17 @@ public:
|
||||||
return return_type();
|
return return_type();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _lambda(std_::forward<Args>(args)...);
|
return _lambda(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename ...PointersAndLambda>
|
template <typename ...PointersAndLambda>
|
||||||
Lambda init(QPointer<QObject> *pointers, QObject *qobject, PointersAndLambda&&... qobjectsAndLambda) {
|
Lambda init(QPointer<QObject> *pointers, QObject *qobject, PointersAndLambda&&... qobjectsAndLambda) {
|
||||||
*pointers = qobject;
|
*pointers = qobject;
|
||||||
return init(++pointers, std_::forward<PointersAndLambda>(qobjectsAndLambda)...);
|
return init(++pointers, std::forward<PointersAndLambda>(qobjectsAndLambda)...);
|
||||||
}
|
}
|
||||||
Lambda init(QPointer<QObject> *pointers, Lambda &&lambda) {
|
Lambda init(QPointer<QObject> *pointers, Lambda &&lambda) {
|
||||||
return std_::move(lambda);
|
return std::move(lambda);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointer<QObject> _pointers[N];
|
QPointer<QObject> _pointers[N];
|
||||||
|
@ -463,29 +463,29 @@ public:
|
||||||
using return_type = typename lambda_type<Lambda>::return_type;
|
using return_type = typename lambda_type<Lambda>::return_type;
|
||||||
|
|
||||||
template <typename ...PointersAndLambda>
|
template <typename ...PointersAndLambda>
|
||||||
inline lambda_guard(PointersAndLambda&&... qobjectsAndLambda) : _data(std_::make_unique<lambda_guard_data<N, Lambda>>(std_::forward<PointersAndLambda>(qobjectsAndLambda)...)) {
|
inline lambda_guard(PointersAndLambda&&... qobjectsAndLambda) : _data(std::make_unique<lambda_guard_data<N, Lambda>>(std::forward<PointersAndLambda>(qobjectsAndLambda)...)) {
|
||||||
static_assert(sizeof...(PointersAndLambda) == N + 1, "Wrong argument count!");
|
static_assert(sizeof...(PointersAndLambda) == N + 1, "Wrong argument count!");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline lambda_guard(const lambda_guard &&other) : _data(std_::move(other._data)) {
|
inline lambda_guard(const lambda_guard &&other) : _data(std::move(other._data)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline lambda_guard(lambda_guard &&other) : _data(std_::move(other._data)) {
|
inline lambda_guard(lambda_guard &&other) : _data(std::move(other._data)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline lambda_guard &operator=(const lambda_guard &&other) {
|
inline lambda_guard &operator=(const lambda_guard &&other) {
|
||||||
_data = std_::move(other._data);
|
_data = std::move(other._data);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline lambda_guard &operator=(lambda_guard &&other) {
|
inline lambda_guard &operator=(lambda_guard &&other) {
|
||||||
_data = std_::move(other._data);
|
_data = std::move(other._data);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ...Args>
|
template <typename ...Args>
|
||||||
inline return_type operator()(Args&&... args) const {
|
inline return_type operator()(Args&&... args) const {
|
||||||
return (*_data)(std_::forward<Args>(args)...);
|
return (*_data)(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNull() const {
|
bool isNull() const {
|
||||||
|
@ -497,10 +497,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline lambda_guard(const lambda_guard &other) : _data(std_::make_unique<lambda_guard_data<N, Lambda>>(static_cast<const lambda_guard_data<N, Lambda> &>(*other._data))) {
|
inline lambda_guard(const lambda_guard &other) : _data(std::make_unique<lambda_guard_data<N, Lambda>>(static_cast<const lambda_guard_data<N, Lambda> &>(*other._data))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mutable std_::unique_ptr<lambda_guard_data<N, Lambda>> _data;
|
mutable std::unique_ptr<lambda_guard_data<N, Lambda>> _data;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -536,7 +536,7 @@ struct lambda_type_helper<lambda_guard<N, Lambda>> {
|
||||||
template <typename ...PointersAndLambda>
|
template <typename ...PointersAndLambda>
|
||||||
inline internal::lambda_guard_t<PointersAndLambda...> lambda_guarded(PointersAndLambda&&... qobjectsAndLambda) {
|
inline internal::lambda_guard_t<PointersAndLambda...> lambda_guarded(PointersAndLambda&&... qobjectsAndLambda) {
|
||||||
static_assert(sizeof...(PointersAndLambda) > 0, "Lambda should be passed here.");
|
static_assert(sizeof...(PointersAndLambda) > 0, "Lambda should be passed here.");
|
||||||
return internal::lambda_guard_t<PointersAndLambda...>(std_::forward<PointersAndLambda>(qobjectsAndLambda)...);
|
return internal::lambda_guard_t<PointersAndLambda...>(std::forward<PointersAndLambda>(qobjectsAndLambda)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass lambda instead of a Qt void() slot.
|
// Pass lambda instead of a Qt void() slot.
|
||||||
|
@ -545,7 +545,7 @@ class lambda_slot_wrap : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
lambda_slot_wrap(QObject *parent, lambda<void()> &&lambda) : QObject(parent), _lambda(std_::move(lambda)) {
|
lambda_slot_wrap(QObject *parent, lambda<void()> &&lambda) : QObject(parent), _lambda(std::move(lambda)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
@ -559,14 +559,14 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
inline lambda_slot_wrap *lambda_slot(QObject *parent, lambda<void()> &&lambda) {
|
inline lambda_slot_wrap *lambda_slot(QObject *parent, lambda<void()> &&lambda) {
|
||||||
return new lambda_slot_wrap(parent, std_::move(lambda));
|
return new lambda_slot_wrap(parent, std::move(lambda));
|
||||||
}
|
}
|
||||||
|
|
||||||
class lambda_slot_once_wrap : public QObject {
|
class lambda_slot_once_wrap : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
lambda_slot_once_wrap(QObject *parent, lambda<void()> &&lambda) : QObject(parent), _lambda(std_::move(lambda)) {
|
lambda_slot_once_wrap(QObject *parent, lambda<void()> &&lambda) : QObject(parent), _lambda(std::move(lambda)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public slots :
|
public slots :
|
||||||
|
@ -581,7 +581,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
inline lambda_slot_once_wrap *lambda_slot_once(QObject *parent, lambda<void()> &&lambda) {
|
inline lambda_slot_once_wrap *lambda_slot_once(QObject *parent, lambda<void()> &&lambda) {
|
||||||
return new lambda_slot_once_wrap(parent, std_::move(lambda));
|
return new lambda_slot_once_wrap(parent, std::move(lambda));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
|
@ -20,7 +20,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "core/vector_of_moveable.h"
|
#include <vector>
|
||||||
#include "core/type_traits.h"
|
#include "core/type_traits.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
@ -117,7 +117,7 @@ public:
|
||||||
if (!_data) {
|
if (!_data) {
|
||||||
_data = MakeShared<ObservableData<EventType, Handler>>(this);
|
_data = MakeShared<ObservableData<EventType, Handler>>(this);
|
||||||
}
|
}
|
||||||
return _data->append(std_::move(handler));
|
return _data->append(std::move(handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -133,7 +133,7 @@ class BaseObservable<EventType, Handler, true> : public internal::CommonObservab
|
||||||
public:
|
public:
|
||||||
void notify(EventType event, bool sync = false) {
|
void notify(EventType event, bool sync = false) {
|
||||||
if (this->_data) {
|
if (this->_data) {
|
||||||
this->_data->notify(std_::move(event), sync);
|
this->_data->notify(std::move(event), sync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class BaseObservable<EventType, Handler, false> : public internal::CommonObserva
|
||||||
public:
|
public:
|
||||||
void notify(EventType &&event, bool sync = false) {
|
void notify(EventType &&event, bool sync = false) {
|
||||||
if (this->_data) {
|
if (this->_data) {
|
||||||
this->_data->notify(std_::move(event), sync);
|
this->_data->notify(std::move(event), sync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void notify(const EventType &event, bool sync = false) {
|
void notify(const EventType &event, bool sync = false) {
|
||||||
|
@ -166,7 +166,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
Subscription append(Handler &&handler) {
|
Subscription append(Handler &&handler) {
|
||||||
auto node = new Node(_observable->_data, std_::move(handler));
|
auto node = new Node(_observable->_data, std::move(handler));
|
||||||
if (_begin) {
|
if (_begin) {
|
||||||
_end->next = node;
|
_end->next = node;
|
||||||
node->prev = _end;
|
node->prev = _end;
|
||||||
|
@ -183,7 +183,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Node : public Subscription::Node {
|
struct Node : public Subscription::Node {
|
||||||
Node(const QSharedPointer<BaseObservableData> &observer, Handler &&handler) : Subscription::Node(observer), handler(std_::move(handler)) {
|
Node(const QSharedPointer<BaseObservableData> &observer, Handler &&handler) : Subscription::Node(observer), handler(std::move(handler)) {
|
||||||
}
|
}
|
||||||
Handler handler;
|
Handler handler;
|
||||||
};
|
};
|
||||||
|
@ -253,7 +253,7 @@ public:
|
||||||
sync = false;
|
sync = false;
|
||||||
}
|
}
|
||||||
if (sync) {
|
if (sync) {
|
||||||
_events.push_back(std_::move(event));
|
_events.push_back(std::move(event));
|
||||||
callHandlers();
|
callHandlers();
|
||||||
} else {
|
} else {
|
||||||
if (!this->_callHandlers) {
|
if (!this->_callHandlers) {
|
||||||
|
@ -264,7 +264,7 @@ public:
|
||||||
if (_events.empty()) {
|
if (_events.empty()) {
|
||||||
RegisterPendingObservable(&this->_callHandlers);
|
RegisterPendingObservable(&this->_callHandlers);
|
||||||
}
|
}
|
||||||
_events.push_back(std_::move(event));
|
_events.push_back(std::move(event));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ private:
|
||||||
UnregisterActiveObservable(&this->_callHandlers);
|
UnregisterActiveObservable(&this->_callHandlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
std_::vector_of_moveable<EventType> _events;
|
std::vector<EventType> _events;
|
||||||
bool _handling = false;
|
bool _handling = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -404,23 +404,23 @@ class Subscriber {
|
||||||
protected:
|
protected:
|
||||||
template <typename EventType, typename Handler, typename Lambda>
|
template <typename EventType, typename Handler, typename Lambda>
|
||||||
int subscribe(base::Observable<EventType, Handler> &observable, Lambda &&handler) {
|
int subscribe(base::Observable<EventType, Handler> &observable, Lambda &&handler) {
|
||||||
_subscriptions.push_back(observable.add_subscription(std_::forward<Lambda>(handler)));
|
_subscriptions.push_back(observable.add_subscription(std::forward<Lambda>(handler)));
|
||||||
return _subscriptions.size();
|
return _subscriptions.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename EventType, typename Handler, typename Lambda>
|
template <typename EventType, typename Handler, typename Lambda>
|
||||||
int subscribe(base::Observable<EventType, Handler> *observable, Lambda &&handler) {
|
int subscribe(base::Observable<EventType, Handler> *observable, Lambda &&handler) {
|
||||||
return subscribe(*observable, std_::forward<Lambda>(handler));
|
return subscribe(*observable, std::forward<Lambda>(handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type, typename Lambda>
|
template <typename Type, typename Lambda>
|
||||||
int subscribe(base::Variable<Type> &variable, Lambda &&handler) {
|
int subscribe(base::Variable<Type> &variable, Lambda &&handler) {
|
||||||
return subscribe(variable.observable(), std_::forward<Lambda>(handler));
|
return subscribe(variable.observable(), std::forward<Lambda>(handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Type, typename Lambda>
|
template <typename Type, typename Lambda>
|
||||||
int subscribe(base::Variable<Type> *variable, Lambda &&handler) {
|
int subscribe(base::Variable<Type> *variable, Lambda &&handler) {
|
||||||
return subscribe(variable->observable(), std_::forward<Lambda>(handler));
|
return subscribe(variable->observable(), std::forward<Lambda>(handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
void unsubscribe(int index) {
|
void unsubscribe(int index) {
|
||||||
|
@ -442,7 +442,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std_::vector_of_moveable<base::Subscription> _subscriptions;
|
std::vector<base::Subscription> _subscriptions;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,16 +24,16 @@ namespace qthelp {
|
||||||
|
|
||||||
class RegularExpressionMatch {
|
class RegularExpressionMatch {
|
||||||
public:
|
public:
|
||||||
RegularExpressionMatch(QRegularExpressionMatch &&match) : data_(std_::move(match)) {
|
RegularExpressionMatch(QRegularExpressionMatch &&match) : data_(std::move(match)) {
|
||||||
}
|
}
|
||||||
RegularExpressionMatch(RegularExpressionMatch &&other) : data_(std_::move(other.data_)) {
|
RegularExpressionMatch(RegularExpressionMatch &&other) : data_(std::move(other.data_)) {
|
||||||
}
|
}
|
||||||
RegularExpressionMatch &operator=(QRegularExpressionMatch &&match) {
|
RegularExpressionMatch &operator=(QRegularExpressionMatch &&match) {
|
||||||
data_ = std_::move(match);
|
data_ = std::move(match);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
RegularExpressionMatch &operator=(RegularExpressionMatch &&other) {
|
RegularExpressionMatch &operator=(RegularExpressionMatch &&other) {
|
||||||
data_ = std_::move(other.data_);
|
data_ = std::move(other.data_);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
QRegularExpressionMatch *operator->() {
|
QRegularExpressionMatch *operator->() {
|
||||||
|
|
|
@ -97,7 +97,7 @@ protected:
|
||||||
((Type*)location)->~Type();
|
((Type*)location)->~Type();
|
||||||
}
|
}
|
||||||
static void RuntimeComponentMove(void *location, void *waslocation) {
|
static void RuntimeComponentMove(void *location, void *waslocation) {
|
||||||
*(Type*)location = std_::move(*(Type*)waslocation);
|
*(Type*)location = std::move(*(Type*)waslocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -164,7 +164,7 @@ public:
|
||||||
try {
|
try {
|
||||||
auto constructAt = _dataptrunsafe(offset);
|
auto constructAt = _dataptrunsafe(offset);
|
||||||
auto space = RuntimeComponentWraps[i].Size;
|
auto space = RuntimeComponentWraps[i].Size;
|
||||||
auto alignedAt = std_::align(RuntimeComponentWraps[i].Align, space, constructAt, space);
|
auto alignedAt = std::align(RuntimeComponentWraps[i].Align, space, constructAt, space);
|
||||||
t_assert(alignedAt == constructAt);
|
t_assert(alignedAt == constructAt);
|
||||||
RuntimeComponentWraps[i].Construct(constructAt, this);
|
RuntimeComponentWraps[i].Construct(constructAt, this);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
|
@ -37,7 +37,7 @@ void SingleTimer::setTimeoutHandler(base::lambda<void()> &&handler) {
|
||||||
} else if (handler && !_handler) {
|
} else if (handler && !_handler) {
|
||||||
connect(this, SIGNAL(timeout()), this, SLOT(onTimeout()));
|
connect(this, SIGNAL(timeout()), this, SLOT(onTimeout()));
|
||||||
}
|
}
|
||||||
_handler = std_::move(handler);
|
_handler = std::move(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SingleTimer::adjust() {
|
void SingleTimer::adjust() {
|
||||||
|
|
|
@ -1,297 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Telegram Desktop,
|
|
||||||
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
||||||
|
|
||||||
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
It is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
In addition, as a special exception, the copyright holders give permission
|
|
||||||
to link the code of portions of this program with the OpenSSL library.
|
|
||||||
|
|
||||||
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
|
||||||
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
// we copy some parts of C++11/14/17 std:: library, because on OS X 10.6+
|
|
||||||
// version we can use C++11/14/17, but we can not use its library :(
|
|
||||||
namespace std_ {
|
|
||||||
|
|
||||||
using nullptr_t = decltype(nullptr);
|
|
||||||
|
|
||||||
template <typename T, T V>
|
|
||||||
struct integral_constant {
|
|
||||||
static constexpr T value = V;
|
|
||||||
|
|
||||||
using value_type = T;
|
|
||||||
using type = integral_constant<T, V>;
|
|
||||||
|
|
||||||
constexpr operator value_type() const noexcept {
|
|
||||||
return (value);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr value_type operator()() const noexcept {
|
|
||||||
return (value);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
using true_type = integral_constant<bool, true>;
|
|
||||||
using false_type = integral_constant<bool, false>;
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct remove_reference {
|
|
||||||
using type = T;
|
|
||||||
};
|
|
||||||
template <typename T>
|
|
||||||
struct remove_reference<T&> {
|
|
||||||
using type = T;
|
|
||||||
};
|
|
||||||
template <typename T>
|
|
||||||
struct remove_reference<T&&> {
|
|
||||||
using type = T;
|
|
||||||
};
|
|
||||||
template <typename T>
|
|
||||||
using remove_reference_t = typename remove_reference<T>::type;
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct is_lvalue_reference : false_type {
|
|
||||||
};
|
|
||||||
template <typename T>
|
|
||||||
struct is_lvalue_reference<T&> : true_type {
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct is_rvalue_reference : false_type {
|
|
||||||
};
|
|
||||||
template <typename T>
|
|
||||||
struct is_rvalue_reference<T&&> : true_type {
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline constexpr T &&forward(typename remove_reference<T>::type &value) noexcept {
|
|
||||||
return static_cast<T&&>(value);
|
|
||||||
}
|
|
||||||
template <typename T>
|
|
||||||
inline constexpr T &&forward(typename remove_reference<T>::type &&value) noexcept {
|
|
||||||
static_assert(!is_lvalue_reference<T>::value, "bad forward call");
|
|
||||||
return static_cast<T&&>(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline constexpr typename remove_reference<T>::type &&move(T &&value) noexcept {
|
|
||||||
return static_cast<typename remove_reference<T>::type&&>(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void swap_moveable(T &a, T &b) {
|
|
||||||
T tmp = move(a);
|
|
||||||
a = move(b);
|
|
||||||
b = move(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct remove_const {
|
|
||||||
using type = T;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct remove_const<const T> {
|
|
||||||
using type = T;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct remove_volatile {
|
|
||||||
using type = T;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct remove_volatile<volatile T> {
|
|
||||||
using type = T;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
using decay_simple_t = typename remove_const<typename remove_volatile<typename remove_reference<T>::type>::type>::type;
|
|
||||||
|
|
||||||
template <typename T1, typename T2>
|
|
||||||
struct is_same : false_type {
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct is_same<T, T> : true_type {
|
|
||||||
};
|
|
||||||
|
|
||||||
template <bool, typename T = void>
|
|
||||||
struct enable_if {
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct enable_if<true, T> {
|
|
||||||
using type = T;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <bool Test, typename T = void>
|
|
||||||
using enable_if_t = typename enable_if<Test, T>::type;
|
|
||||||
|
|
||||||
template <bool, typename First, typename Second>
|
|
||||||
struct conditional {
|
|
||||||
using type = Second;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename First, typename Second>
|
|
||||||
struct conditional<true, First, Second> {
|
|
||||||
using type = First;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <bool Test, typename First, typename Second>
|
|
||||||
using conditional_t = typename conditional<Test, First, Second>::type;
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct add_const {
|
|
||||||
using type = const T;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
using add_const_t = typename add_const<T>::type;
|
|
||||||
|
|
||||||
// This is not full unique_ptr, but at least with std interface.
|
|
||||||
template <typename T>
|
|
||||||
class unique_ptr {
|
|
||||||
public:
|
|
||||||
constexpr unique_ptr() noexcept = default;
|
|
||||||
unique_ptr(const unique_ptr<T> &) = delete;
|
|
||||||
unique_ptr<T> &operator=(const unique_ptr<T> &) = delete;
|
|
||||||
|
|
||||||
constexpr unique_ptr(std_::nullptr_t) {
|
|
||||||
}
|
|
||||||
unique_ptr<T> &operator=(std_::nullptr_t) noexcept {
|
|
||||||
reset();
|
|
||||||
return (*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
explicit unique_ptr(T *p) noexcept : _p(p) {
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename U>
|
|
||||||
unique_ptr(unique_ptr<U> &&other) noexcept : _p(other.release()) {
|
|
||||||
}
|
|
||||||
template <typename U>
|
|
||||||
unique_ptr<T> &operator=(unique_ptr<U> &&other) noexcept {
|
|
||||||
reset(other.release());
|
|
||||||
return (*this);
|
|
||||||
}
|
|
||||||
unique_ptr<T> &operator=(unique_ptr<T> &&other) noexcept {
|
|
||||||
if (this != &other) {
|
|
||||||
reset(other.release());
|
|
||||||
}
|
|
||||||
return (*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void swap(unique_ptr<T> &other) noexcept {
|
|
||||||
std::swap(_p, other._p);
|
|
||||||
}
|
|
||||||
~unique_ptr() noexcept {
|
|
||||||
if (_p) {
|
|
||||||
static_assert(sizeof(T) > 0, "can't delete an incomplete type");
|
|
||||||
delete _p;
|
|
||||||
_p = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
T &operator*() const {
|
|
||||||
return (*get());
|
|
||||||
}
|
|
||||||
T *operator->() const noexcept {
|
|
||||||
return get();
|
|
||||||
}
|
|
||||||
T *get() const noexcept {
|
|
||||||
return _p;
|
|
||||||
}
|
|
||||||
explicit operator bool() const noexcept {
|
|
||||||
return get() != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
T *release() noexcept {
|
|
||||||
auto old = _p;
|
|
||||||
_p = nullptr;
|
|
||||||
return old;
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset(T *p = nullptr) noexcept {
|
|
||||||
auto old = _p;
|
|
||||||
_p = p;
|
|
||||||
if (old) {
|
|
||||||
static_assert(sizeof(T) > 0, "can't delete an incomplete type");
|
|
||||||
delete old;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
T *_p = nullptr;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
|
||||||
inline unique_ptr<T> make_unique(Args&&... args) {
|
|
||||||
return unique_ptr<T>(new T(forward<Args>(args)...));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline bool operator==(const unique_ptr<T> &a, std_::nullptr_t) noexcept {
|
|
||||||
return !a;
|
|
||||||
}
|
|
||||||
template <typename T>
|
|
||||||
inline bool operator==(std_::nullptr_t, const unique_ptr<T> &b) noexcept {
|
|
||||||
return !b;
|
|
||||||
}
|
|
||||||
template <typename T>
|
|
||||||
inline bool operator!=(const unique_ptr<T> &a, std_::nullptr_t b) noexcept {
|
|
||||||
return !(a == b);
|
|
||||||
}
|
|
||||||
template <typename T>
|
|
||||||
inline bool operator!=(std_::nullptr_t a, const unique_ptr<T> &b) noexcept {
|
|
||||||
return !(a == b);
|
|
||||||
}
|
|
||||||
|
|
||||||
using _yes = char(&)[1];
|
|
||||||
using _no = char(&)[2];
|
|
||||||
|
|
||||||
template <typename Base, typename Derived>
|
|
||||||
struct _host {
|
|
||||||
operator Base*() const;
|
|
||||||
operator Derived*();
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Base, typename Derived>
|
|
||||||
struct is_base_of {
|
|
||||||
template <typename T>
|
|
||||||
static _yes check(Derived*, T);
|
|
||||||
static _no check(Base*, int);
|
|
||||||
|
|
||||||
static constexpr bool value = sizeof(check(_host<Base, Derived>(), int())) == sizeof(_yes);
|
|
||||||
};
|
|
||||||
|
|
||||||
inline void *align(size_t alignment, size_t size, void*& ptr, size_t& space) noexcept {
|
|
||||||
#ifndef OS_MAC_OLD
|
|
||||||
using std::uintptr_t;
|
|
||||||
#endif // OS_MAC_OLD
|
|
||||||
|
|
||||||
auto p = reinterpret_cast<uintptr_t>(ptr);
|
|
||||||
auto a = (p - 1u + alignment) & -alignment;
|
|
||||||
auto d = a - p;
|
|
||||||
if ((size + d) > space) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
space -= d;
|
|
||||||
return ptr = reinterpret_cast<void*>(a);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace std_
|
|
|
@ -30,7 +30,7 @@ const auto MaxThreadsCount = qMax(QThread::idealThreadCount(), 2);
|
||||||
template <typename Lambda>
|
template <typename Lambda>
|
||||||
class Thread : public QThread {
|
class Thread : public QThread {
|
||||||
public:
|
public:
|
||||||
Thread(Lambda code) : _code(std_::move(code)) {
|
Thread(Lambda code) : _code(std::move(code)) {
|
||||||
}
|
}
|
||||||
void run() override {
|
void run() override {
|
||||||
_code();
|
_code();
|
||||||
|
@ -43,7 +43,7 @@ private:
|
||||||
|
|
||||||
template <typename Lambda>
|
template <typename Lambda>
|
||||||
object_ptr<Thread<Lambda>> MakeThread(Lambda code) {
|
object_ptr<Thread<Lambda>> MakeThread(Lambda code) {
|
||||||
return object_ptr<Thread<Lambda>>(std_::move(code));
|
return object_ptr<Thread<Lambda>>(std::move(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -88,7 +88,7 @@ private:
|
||||||
|
|
||||||
void ThreadFunction();
|
void ThreadFunction();
|
||||||
|
|
||||||
std_::vector_of_moveable<object_ptr<QThread>> threads_;
|
std::vector<object_ptr<QThread>> threads_;
|
||||||
QMutex queues_mutex_;
|
QMutex queues_mutex_;
|
||||||
|
|
||||||
// queues_mutex_ must be locked when working with the list.
|
// queues_mutex_ must be locked when working with the list.
|
||||||
|
@ -195,7 +195,7 @@ TaskQueue *TaskQueue::TaskQueueList::TakeFirst(int list_index_) {
|
||||||
void TaskQueue::TaskThreadPool::AddQueueTask(TaskQueue *queue, Task &&task) {
|
void TaskQueue::TaskThreadPool::AddQueueTask(TaskQueue *queue, Task &&task) {
|
||||||
QMutexLocker lock(&queues_mutex_);
|
QMutexLocker lock(&queues_mutex_);
|
||||||
|
|
||||||
queue->tasks_.push_back(new Task(std_::move(task)));
|
queue->tasks_.push_back(new Task(std::move(task)));
|
||||||
auto list_was_empty = queue_list_.Empty(kAllQueuesList);
|
auto list_was_empty = queue_list_.Empty(kAllQueuesList);
|
||||||
auto threads_count = threads_.size();
|
auto threads_count = threads_.size();
|
||||||
auto all_threads_processing = (threads_count == tasks_in_process_);
|
auto all_threads_processing = (threads_count == tasks_in_process_);
|
||||||
|
@ -258,7 +258,7 @@ void TaskQueue::TaskThreadPool::ThreadFunction() {
|
||||||
bool serial_queue_destroyed = false;
|
bool serial_queue_destroyed = false;
|
||||||
bool task_was_processed = false;
|
bool task_was_processed = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
std_::unique_ptr<Task> task;
|
std::unique_ptr<Task> task;
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&queues_mutex_);
|
QMutexLocker lock(&queues_mutex_);
|
||||||
|
|
||||||
|
@ -344,12 +344,12 @@ TaskQueue::~TaskQueue() {
|
||||||
void TaskQueue::Put(Task &&task) {
|
void TaskQueue::Put(Task &&task) {
|
||||||
if (type_ == Type::Main) {
|
if (type_ == Type::Main) {
|
||||||
QMutexLocker lock(&tasks_mutex_);
|
QMutexLocker lock(&tasks_mutex_);
|
||||||
tasks_.push_back(new Task(std_::move(task)));
|
tasks_.push_back(new Task(std::move(task)));
|
||||||
|
|
||||||
Sandbox::MainThreadTaskAdded();
|
Sandbox::MainThreadTaskAdded();
|
||||||
} else {
|
} else {
|
||||||
t_assert(type_ != Type::Special);
|
t_assert(type_ != Type::Special);
|
||||||
TaskThreadPool::Instance()->AddQueueTask(this, std_::move(task));
|
TaskThreadPool::Instance()->AddQueueTask(this, std::move(task));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ void TaskQueue::ProcessMainTasks(TimeMs max_time_spent) { // static
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TaskQueue::ProcessOneMainTask() { // static
|
bool TaskQueue::ProcessOneMainTask() { // static
|
||||||
std_::unique_ptr<Task> task;
|
std::unique_ptr<Task> task;
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&Main().tasks_mutex_);
|
QMutexLocker lock(&Main().tasks_mutex_);
|
||||||
auto &tasks = Main().tasks_;
|
auto &tasks = Main().tasks_;
|
||||||
|
|
|
@ -69,7 +69,7 @@ private:
|
||||||
const Type type_;
|
const Type type_;
|
||||||
const Priority priority_;
|
const Priority priority_;
|
||||||
|
|
||||||
QList<Task*> tasks_; // TODO: std_::deque_of_moveable<Task>
|
QList<Task*> tasks_; // TODO: std::deque<Task>
|
||||||
QMutex tasks_mutex_; // Only for the main queue.
|
QMutex tasks_mutex_; // Only for the main queue.
|
||||||
|
|
||||||
// Only for the other queues, not main.
|
// Only for the other queues, not main.
|
||||||
|
|
|
@ -20,16 +20,14 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "core/stl_subset.h"
|
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct custom_is_fast_copy_type : public std_::false_type {
|
struct custom_is_fast_copy_type : public std::false_type {
|
||||||
};
|
};
|
||||||
// To make your own type a fast copy type just write:
|
// To make your own type a fast copy type just write:
|
||||||
// template <>
|
// template <>
|
||||||
// struct base::custom_is_fast_copy_type<MyTinyType> : public std_::true_type {
|
// struct base::custom_is_fast_copy_type<MyTinyType> : public std::true_type {
|
||||||
// };
|
// };
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
@ -38,11 +36,11 @@ template <typename ...Types>
|
||||||
struct type_list_contains;
|
struct type_list_contains;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct type_list_contains<T> : public std_::false_type {
|
struct type_list_contains<T> : public std::false_type {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, typename Head, typename ...Types>
|
template <typename T, typename Head, typename ...Types>
|
||||||
struct type_list_contains<T, Head, Types...> : public std_::integral_constant<bool, std_::is_same<Head, T>::value || type_list_contains<T, Types...>::value> {
|
struct type_list_contains<T, Head, Types...> : public std::integral_constant<bool, std::is_same<Head, T>::value || type_list_contains<T, Types...>::value> {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -52,35 +50,35 @@ template <typename T>
|
||||||
using is_std_signed_int = type_list_contains<T, signed char, short int, int, long int>;
|
using is_std_signed_int = type_list_contains<T, signed char, short int, int, long int>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using is_std_integral = std_::integral_constant<bool, is_std_unsigned_int<T>::value || is_std_signed_int<T>::value || type_list_contains<T, bool, char, wchar_t>::value>;
|
using is_std_integral = std::integral_constant<bool, is_std_unsigned_int<T>::value || is_std_signed_int<T>::value || type_list_contains<T, bool, char, wchar_t>::value>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using is_std_float = type_list_contains<T, float, double, long double>;
|
using is_std_float = type_list_contains<T, float, double, long double>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using is_std_arith = std_::integral_constant<bool, is_std_integral<T>::value || is_std_float<T>::value>;
|
using is_std_arith = std::integral_constant<bool, is_std_integral<T>::value || is_std_float<T>::value>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using is_std_fundamental = std_::integral_constant<bool, is_std_arith<T>::value || std_::is_same<T, void>::value>;
|
using is_std_fundamental = std::integral_constant<bool, is_std_arith<T>::value || std::is_same<T, void>::value>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_pointer : public std_::false_type {
|
struct is_pointer : public std::false_type {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_pointer<T*> : public std_::true_type {
|
struct is_pointer<T*> : public std::true_type {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct is_member_pointer : public std_::false_type {
|
struct is_member_pointer : public std::false_type {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T, typename C>
|
template <typename T, typename C>
|
||||||
struct is_member_pointer<T C::*> : public std_::true_type {
|
struct is_member_pointer<T C::*> : public std::true_type {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using is_fast_copy_type = std_::integral_constant<bool, is_std_fundamental<T>::value || is_pointer<T>::value || is_member_pointer<T>::value || custom_is_fast_copy_type<T>::value>;
|
using is_fast_copy_type = std::integral_constant<bool, is_std_fundamental<T>::value || is_pointer<T>::value || is_member_pointer<T>::value || custom_is_fast_copy_type<T>::value>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct add_const_reference {
|
struct add_const_reference {
|
||||||
|
@ -122,7 +120,7 @@ struct type_traits {
|
||||||
using is_member_pointer = internal::is_member_pointer<T>;
|
using is_member_pointer = internal::is_member_pointer<T>;
|
||||||
using is_fast_copy_type = internal::is_fast_copy_type<T>;
|
using is_fast_copy_type = internal::is_fast_copy_type<T>;
|
||||||
|
|
||||||
using parameter_type = std_::conditional_t<is_fast_copy_type::value, T, internal::add_const_reference_t<T>>;
|
using parameter_type = std::conditional_t<is_fast_copy_type::value, T, internal::add_const_reference_t<T>>;
|
||||||
using pointed_type = internal::remove_pointer_t<T>;
|
using pointed_type = internal::remove_pointer_t<T>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -31,40 +31,35 @@ inline constexpr size_t array_size(const T(&)[N]) {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline T take(T &source, T &&new_value = T()) {
|
inline T take(T &source, T &&new_value = T()) {
|
||||||
std_::swap_moveable(new_value, source);
|
std::swap(new_value, source);
|
||||||
return std_::move(new_value);
|
return std::move(new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
template <typename D, typename T>
|
template <typename D, typename T>
|
||||||
inline constexpr D up_cast_helper(std_::true_type, T object) {
|
inline constexpr D up_cast_helper(std::true_type, T object) {
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename D, typename T>
|
template <typename D, typename T>
|
||||||
inline constexpr D up_cast_helper(std_::false_type, T object) {
|
inline constexpr D up_cast_helper(std::false_type, T object) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
constexpr std_::add_const_t<T> &any_as_const(T &&value) noexcept {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
template <typename D, typename T>
|
template <typename D, typename T>
|
||||||
inline constexpr D up_cast(T object) {
|
inline constexpr D up_cast(T object) {
|
||||||
using DV = std_::decay_simple_t<decltype(*D())>;
|
using DV = std::decay_t<decltype(*D())>;
|
||||||
using TV = std_::decay_simple_t<decltype(*T())>;
|
using TV = std::decay_t<decltype(*T())>;
|
||||||
return internal::up_cast_helper<D>(std_::integral_constant<bool, std_::is_base_of<DV, TV>::value || std_::is_same<DV, TV>::value>(), object);
|
return internal::up_cast_helper<D>(std::integral_constant<bool, std::is_base_of<DV, TV>::value || std::is_same<DV, TV>::value>(), object);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Lambda>
|
template <typename Lambda>
|
||||||
class scope_guard_helper {
|
class scope_guard_helper {
|
||||||
public:
|
public:
|
||||||
scope_guard_helper(Lambda on_scope_exit) : _handler(std_::move(on_scope_exit)) {
|
scope_guard_helper(Lambda on_scope_exit) : _handler(std::move(on_scope_exit)) {
|
||||||
}
|
}
|
||||||
void dismiss() {
|
void dismiss() {
|
||||||
_dismissed = true;
|
_dismissed = true;
|
||||||
|
@ -83,7 +78,7 @@ private:
|
||||||
|
|
||||||
template <typename Lambda>
|
template <typename Lambda>
|
||||||
scope_guard_helper<Lambda> scope_guard(Lambda on_scope_exit) {
|
scope_guard_helper<Lambda> scope_guard(Lambda on_scope_exit) {
|
||||||
return scope_guard_helper<Lambda>(std_::move(on_scope_exit));
|
return scope_guard_helper<Lambda>(std::move(on_scope_exit));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
@ -92,7 +87,7 @@ scope_guard_helper<Lambda> scope_guard(Lambda on_scope_exit) {
|
||||||
// it is important for the copy-on-write Qt containers
|
// it is important for the copy-on-write Qt containers
|
||||||
// if you have "QVector<T*> v" then "for (T * const p : v)" will still call QVector::detach(),
|
// if you have "QVector<T*> v" then "for (T * const p : v)" will still call QVector::detach(),
|
||||||
// while "for_const (T *p, v)" won't and "for_const (T *&p, v)" won't compile
|
// while "for_const (T *p, v)" won't and "for_const (T *&p, v)" won't compile
|
||||||
#define for_const(range_declaration, range_expression) for (range_declaration : base::internal::any_as_const(range_expression))
|
#define for_const(range_declaration, range_expression) for (range_declaration : std::as_const(range_expression))
|
||||||
|
|
||||||
template <typename Enum>
|
template <typename Enum>
|
||||||
inline QFlags<Enum> qFlags(Enum v) {
|
inline QFlags<Enum> qFlags(Enum v) {
|
||||||
|
@ -497,7 +492,7 @@ static int32 AlmostFullArcLength = (FullArcLength - MinArcLength);
|
||||||
|
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
inline QSharedPointer<T> MakeShared(Args&&... args) {
|
inline QSharedPointer<T> MakeShared(Args&&... args) {
|
||||||
return QSharedPointer<T>(new T(std_::forward<Args>(args)...));
|
return QSharedPointer<T>(new T(std::forward<Args>(args)...));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This pointer is used for global non-POD variables that are allocated
|
// This pointer is used for global non-POD variables that are allocated
|
||||||
|
@ -512,7 +507,7 @@ public:
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void createIfNull(Args&&... args) {
|
void createIfNull(Args&&... args) {
|
||||||
if (isNull()) {
|
if (isNull()) {
|
||||||
reset(new T(std_::forward<Args>(args)...));
|
reset(new T(std::forward<Args>(args)...));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,184 +0,0 @@
|
||||||
/*
|
|
||||||
This file is part of Telegram Desktop,
|
|
||||||
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
||||||
|
|
||||||
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
It is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
In addition, as a special exception, the copyright holders give permission
|
|
||||||
to link the code of portions of this program with the OpenSSL library.
|
|
||||||
|
|
||||||
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
|
||||||
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "core/stl_subset.h"
|
|
||||||
|
|
||||||
// some minimal implementation of std::vector() for moveable (but not copiable) types.
|
|
||||||
namespace std_ {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class vector_of_moveable {
|
|
||||||
typedef vector_of_moveable<T> Self;
|
|
||||||
int _size = 0, _capacity = 0;
|
|
||||||
void *_plaindata = nullptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
vector_of_moveable() = default;
|
|
||||||
vector_of_moveable(const vector_of_moveable &other) = delete;
|
|
||||||
vector_of_moveable &operator=(const vector_of_moveable &other) = delete;
|
|
||||||
vector_of_moveable(vector_of_moveable &&other)
|
|
||||||
: _size(base::take(other._size))
|
|
||||||
, _capacity(base::take(other._capacity))
|
|
||||||
, _plaindata(base::take(other._plaindata)) {
|
|
||||||
}
|
|
||||||
vector_of_moveable &operator=(vector_of_moveable &&other) {
|
|
||||||
std_::swap_moveable(_size, other._size);
|
|
||||||
std_::swap_moveable(_capacity, other._capacity);
|
|
||||||
std_::swap_moveable(_plaindata, other._plaindata);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline T *data() {
|
|
||||||
return reinterpret_cast<T*>(_plaindata);
|
|
||||||
}
|
|
||||||
inline const T *data() const {
|
|
||||||
return reinterpret_cast<const T*>(_plaindata);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool operator==(const Self &other) const {
|
|
||||||
if (this == &other) return true;
|
|
||||||
if (_size != other._size) return false;
|
|
||||||
for (int i = 0; i < _size; ++i) {
|
|
||||||
if (data()[i] != other.data()[i]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
inline bool operator!=(const Self &other) const { return !(*this == other); }
|
|
||||||
inline int size() const { return _size; }
|
|
||||||
inline bool isEmpty() const { return _size == 0; }
|
|
||||||
inline void clear() {
|
|
||||||
for (int i = 0; i < _size; ++i) {
|
|
||||||
data()[i].~T();
|
|
||||||
}
|
|
||||||
_size = 0;
|
|
||||||
|
|
||||||
operator delete[](_plaindata);
|
|
||||||
_plaindata = nullptr;
|
|
||||||
_capacity = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef T *iterator;
|
|
||||||
typedef const T *const_iterator;
|
|
||||||
|
|
||||||
// STL style
|
|
||||||
inline iterator begin() { return data(); }
|
|
||||||
inline const_iterator begin() const { return data(); }
|
|
||||||
inline const_iterator cbegin() const { return data(); }
|
|
||||||
inline iterator end() { return data() + _size; }
|
|
||||||
inline const_iterator end() const { return data() + _size; }
|
|
||||||
inline const_iterator cend() const { return data() + _size; }
|
|
||||||
inline iterator erase(iterator it) {
|
|
||||||
T tmp = std_::move(*it);
|
|
||||||
for (auto next = it + 1, e = end(); next != e; ++next) {
|
|
||||||
auto prev = next - 1;
|
|
||||||
*prev = std_::move(*next);
|
|
||||||
}
|
|
||||||
--_size;
|
|
||||||
end()->~T();
|
|
||||||
return it;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline iterator insert(const_iterator pos, T &&value) {
|
|
||||||
int insertAtIndex = pos - begin();
|
|
||||||
if (_size + 1 > _capacity) {
|
|
||||||
reallocate(_capacity + (_capacity > 1 ? _capacity / 2 : 1));
|
|
||||||
}
|
|
||||||
auto insertAt = begin() + insertAtIndex, e = end();
|
|
||||||
if (insertAt == e) {
|
|
||||||
new (&(*insertAt)) T(std_::move(value));
|
|
||||||
} else {
|
|
||||||
auto prev = e - 1;
|
|
||||||
new (&(*e)) T(std_::move(*prev));
|
|
||||||
for (auto it = prev; it != insertAt; --it) {
|
|
||||||
*it = std_::move(*--prev);
|
|
||||||
}
|
|
||||||
*insertAt = std_::move(value);
|
|
||||||
}
|
|
||||||
++_size;
|
|
||||||
return insertAt;
|
|
||||||
}
|
|
||||||
inline void push_back(T &&value) {
|
|
||||||
insert(end(), std_::move(value));
|
|
||||||
}
|
|
||||||
inline void pop_back() {
|
|
||||||
erase(end() - 1);
|
|
||||||
}
|
|
||||||
inline T &front() {
|
|
||||||
return *begin();
|
|
||||||
}
|
|
||||||
inline const T &front() const {
|
|
||||||
return *begin();
|
|
||||||
}
|
|
||||||
inline T &back() {
|
|
||||||
return *(end() - 1);
|
|
||||||
}
|
|
||||||
inline const T &back() const {
|
|
||||||
return *(end() - 1);
|
|
||||||
}
|
|
||||||
inline bool empty() const { return _size == 0; }
|
|
||||||
|
|
||||||
inline T &operator[](int index) {
|
|
||||||
return data()[index];
|
|
||||||
}
|
|
||||||
inline const T &operator[](int index) const {
|
|
||||||
return data()[index];
|
|
||||||
}
|
|
||||||
inline const T &at(int index) const {
|
|
||||||
if (index < 0 || index >= _size) {
|
|
||||||
#ifndef OS_MAC_OLD
|
|
||||||
throw std::out_of_range("");
|
|
||||||
#else // OS_MAC_OLD
|
|
||||||
throw std::exception();
|
|
||||||
#endif // OS_MAC_OLD
|
|
||||||
}
|
|
||||||
return data()[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
void reserve(int newCapacity) {
|
|
||||||
if (newCapacity > _capacity) {
|
|
||||||
reallocate(newCapacity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline ~vector_of_moveable() {
|
|
||||||
clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void reallocate(int newCapacity) {
|
|
||||||
auto newPlainData = operator new[](newCapacity * sizeof(T));
|
|
||||||
for (int i = 0; i < _size; ++i) {
|
|
||||||
auto oldLocation = data() + i;
|
|
||||||
auto newLocation = reinterpret_cast<T*>(newPlainData) + i;
|
|
||||||
new (newLocation) T(std_::move(*oldLocation));
|
|
||||||
oldLocation->~T();
|
|
||||||
}
|
|
||||||
std_::swap_moveable(_plaindata, newPlainData);
|
|
||||||
_capacity = newCapacity;
|
|
||||||
operator delete[](newPlainData);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace std_
|
|
|
@ -233,9 +233,9 @@ typename virtual_object<Object, void>::virtual_object_registrator virtual_object
|
||||||
namespace virtual_methods {
|
namespace virtual_methods {
|
||||||
|
|
||||||
template <typename Arg>
|
template <typename Arg>
|
||||||
struct is_virtual_argument : public std_::integral_constant<bool,
|
struct is_virtual_argument : public std::integral_constant<bool,
|
||||||
base::type_traits<Arg>::is_pointer::value
|
base::type_traits<Arg>::is_pointer::value
|
||||||
? std_::is_base_of<object_base, typename base::type_traits<Arg>::pointed_type>::value
|
? std::is_base_of<object_base, typename base::type_traits<Arg>::pointed_type>::value
|
||||||
: false> {
|
: false> {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -281,10 +281,10 @@ struct multi_index_collector<ConcreteArg, ConcreteArgs...> {
|
||||||
multi_index_collector<ConcreteArgs...>::call(indices.subindex(), args...);
|
multi_index_collector<ConcreteArgs...>::call(indices.subindex(), args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int computeIndex(std_::integral_constant<bool, false>, ConcreteArg arg) {
|
static inline int computeIndex(std::integral_constant<bool, false>, ConcreteArg arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static inline int computeIndex(std_::integral_constant<bool, true>, ConcreteArg arg) {
|
static inline int computeIndex(std::integral_constant<bool, true>, ConcreteArg arg) {
|
||||||
return arg->virtual_object_child_index();
|
return arg->virtual_object_child_index();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,15 +348,15 @@ public:
|
||||||
return (*this)[index.current()][index.subindex()];
|
return (*this)[index.current()][index.subindex()];
|
||||||
}
|
}
|
||||||
inline int size() const {
|
inline int size() const {
|
||||||
return count_size(std_::integral_constant<int,N>());
|
return count_size(std::integral_constant<int,N>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <int M>
|
template <int M>
|
||||||
inline int count_size(std_::integral_constant<int,M>) const {
|
inline int count_size(std::integral_constant<int,M>) const {
|
||||||
return _size.current() / _size.subindex().current();
|
return _size.current() / _size.subindex().current();
|
||||||
}
|
}
|
||||||
inline int count_size(std_::integral_constant<int,1>) const {
|
inline int count_size(std::integral_constant<int,1>) const {
|
||||||
return _size.current();
|
return _size.current();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,10 +391,10 @@ struct table_count_size<Arg, Args...> {
|
||||||
index.current() = count(is_virtual_argument<Arg>()) * subindex.current();
|
index.current() = count(is_virtual_argument<Arg>()) * subindex.current();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int count(std_::integral_constant<bool, false>) {
|
static inline int count(std::integral_constant<bool, false>) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
static inline int count(std_::integral_constant<bool, true>) {
|
static inline int count(std::integral_constant<bool, true>) {
|
||||||
return base::type_traits<Arg>::pointed_type::virtual_object_get_child_entries().size();
|
return base::type_traits<Arg>::pointed_type::virtual_object_get_child_entries().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -483,10 +483,10 @@ struct table_fill_entry_helper<Call, Arg, Args...> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool good(std_::integral_constant<bool,false>, int start, int current) {
|
static inline bool good(std::integral_constant<bool,false>, int start, int current) {
|
||||||
return (start == current);
|
return (start == current);
|
||||||
}
|
}
|
||||||
static inline bool good(std_::integral_constant<bool,true>, int start, int current) {
|
static inline bool good(std::integral_constant<bool,true>, int start, int current) {
|
||||||
using BaseObject = typename base::type_traits<Arg>::pointed_type;
|
using BaseObject = typename base::type_traits<Arg>::pointed_type;
|
||||||
auto &entries = BaseObject::virtual_object_get_child_entries();
|
auto &entries = BaseObject::virtual_object_get_child_entries();
|
||||||
return (start == current) || entries[start].check_is_parent(entries[current]);
|
return (start == current) || entries[start].check_is_parent(entries[current]);
|
||||||
|
@ -531,10 +531,10 @@ struct override_key_collector_helper<M, ConcreteArg, ConcreteArgs...> {
|
||||||
override_key_collector_helper<M + 1, ConcreteArgs...>::call(indices);
|
override_key_collector_helper<M + 1, ConcreteArgs...>::call(indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void setValue(std_::integral_constant<bool,false>, int **indices) {
|
static inline void setValue(std::integral_constant<bool,false>, int **indices) {
|
||||||
indices[M] = nullptr;
|
indices[M] = nullptr;
|
||||||
}
|
}
|
||||||
static inline void setValue(std_::integral_constant<bool,true>, int **indices) {
|
static inline void setValue(std::integral_constant<bool,true>, int **indices) {
|
||||||
using ConcreteObject = typename base::type_traits<ConcreteArg>::pointed_type;
|
using ConcreteObject = typename base::type_traits<ConcreteArg>::pointed_type;
|
||||||
using IsParentCheckStruct = is_parent<ConcreteObject>;
|
using IsParentCheckStruct = is_parent<ConcreteObject>;
|
||||||
using IsParentCheckPointer = decltype(&IsParentCheckStruct::check);
|
using IsParentCheckPointer = decltype(&IsParentCheckStruct::check);
|
||||||
|
|
|
@ -44,10 +44,10 @@ void applyPeerCloudDraft(PeerId peerId, const MTPDdraftMessage &draft) {
|
||||||
auto entities = draft.has_entities() ? entitiesFromMTP(draft.ventities.c_vector().v) : EntitiesInText();
|
auto entities = draft.has_entities() ? entitiesFromMTP(draft.ventities.c_vector().v) : EntitiesInText();
|
||||||
TextWithTags textWithTags = { textApplyEntities(text, entities), textTagsFromEntities(entities) };
|
TextWithTags textWithTags = { textApplyEntities(text, entities), textTagsFromEntities(entities) };
|
||||||
MsgId replyTo = draft.has_reply_to_msg_id() ? draft.vreply_to_msg_id.v : 0;
|
MsgId replyTo = draft.has_reply_to_msg_id() ? draft.vreply_to_msg_id.v : 0;
|
||||||
auto cloudDraft = std_::make_unique<Draft>(textWithTags, replyTo, MessageCursor(QFIXED_MAX, QFIXED_MAX, QFIXED_MAX), draft.is_no_webpage());
|
auto cloudDraft = std::make_unique<Draft>(textWithTags, replyTo, MessageCursor(QFIXED_MAX, QFIXED_MAX, QFIXED_MAX), draft.is_no_webpage());
|
||||||
cloudDraft->date = ::date(draft.vdate);
|
cloudDraft->date = ::date(draft.vdate);
|
||||||
|
|
||||||
history->setCloudDraft(std_::move(cloudDraft));
|
history->setCloudDraft(std::move(cloudDraft));
|
||||||
history->createLocalDraftFromCloud();
|
history->createLocalDraftFromCloud();
|
||||||
history->updateChatListSortPosition();
|
history->updateChatListSortPosition();
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
namespace Dialogs {
|
namespace Dialogs {
|
||||||
|
|
||||||
List::List(SortMode sortMode)
|
List::List(SortMode sortMode)
|
||||||
: _last(std_::make_unique<Row>(nullptr, nullptr, nullptr, 0))
|
: _last(std::make_unique<Row>(nullptr, nullptr, nullptr, 0))
|
||||||
, _begin(_last.get())
|
, _begin(_last.get())
|
||||||
, _end(_last.get())
|
, _end(_last.get())
|
||||||
, _sortMode(sortMode)
|
, _sortMode(sortMode)
|
||||||
|
|
|
@ -121,7 +121,7 @@ private:
|
||||||
return row->_prev;
|
return row->_prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
std_::unique_ptr<Row> _last;
|
std::unique_ptr<Row> _last;
|
||||||
Row *_begin;
|
Row *_begin;
|
||||||
Row *_end;
|
Row *_end;
|
||||||
SortMode _sortMode;
|
SortMode _sortMode;
|
||||||
|
|
|
@ -33,7 +33,7 @@ RippleRow::~RippleRow() = default;
|
||||||
void RippleRow::addRipple(QPoint origin, QSize size, base::lambda_copy<void()> &&updateCallback) {
|
void RippleRow::addRipple(QPoint origin, QSize size, base::lambda_copy<void()> &&updateCallback) {
|
||||||
if (!_ripple) {
|
if (!_ripple) {
|
||||||
auto mask = Ui::RippleAnimation::rectMask(size);
|
auto mask = Ui::RippleAnimation::rectMask(size);
|
||||||
_ripple = std_::make_unique<Ui::RippleAnimation>(st::dialogsRipple, std_::move(mask), std_::move(updateCallback));
|
_ripple = std::make_unique<Ui::RippleAnimation>(st::dialogsRipple, std::move(mask), std::move(updateCallback));
|
||||||
}
|
}
|
||||||
_ripple->add(origin);
|
_ripple->add(origin);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public:
|
||||||
void paintRipple(Painter &p, int x, int y, int outerWidth, TimeMs ms, const QColor *colorOverride = nullptr) const;
|
void paintRipple(Painter &p, int x, int y, int outerWidth, TimeMs ms, const QColor *colorOverride = nullptr) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable std_::unique_ptr<Ui::RippleAnimation> _ripple;
|
mutable std::unique_ptr<Ui::RippleAnimation> _ripple;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -72,9 +72,9 @@ struct DialogsInner::PeerSearchResult {
|
||||||
};
|
};
|
||||||
|
|
||||||
DialogsInner::DialogsInner(QWidget *parent, QWidget *main) : SplittedWidget(parent)
|
DialogsInner::DialogsInner(QWidget *parent, QWidget *main) : SplittedWidget(parent)
|
||||||
, _dialogs(std_::make_unique<Dialogs::IndexedList>(Dialogs::SortMode::Date))
|
, _dialogs(std::make_unique<Dialogs::IndexedList>(Dialogs::SortMode::Date))
|
||||||
, _contactsNoDialogs(std_::make_unique<Dialogs::IndexedList>(Dialogs::SortMode::Name))
|
, _contactsNoDialogs(std::make_unique<Dialogs::IndexedList>(Dialogs::SortMode::Name))
|
||||||
, _contacts(std_::make_unique<Dialogs::IndexedList>(Dialogs::SortMode::Name))
|
, _contacts(std::make_unique<Dialogs::IndexedList>(Dialogs::SortMode::Name))
|
||||||
, _a_pinnedShifting(animation(this, &DialogsInner::step_pinnedShifting))
|
, _a_pinnedShifting(animation(this, &DialogsInner::step_pinnedShifting))
|
||||||
, _addContactLnk(this, lang(lng_add_contact_button))
|
, _addContactLnk(this, lang(lng_add_contact_button))
|
||||||
, _cancelSearchInPeer(this, st::dialogsCancelSearchInPeer) {
|
, _cancelSearchInPeer(this, st::dialogsCancelSearchInPeer) {
|
||||||
|
@ -85,8 +85,8 @@ DialogsInner::DialogsInner(QWidget *parent, QWidget *main) : SplittedWidget(pare
|
||||||
#endif // OS_MAC_OLD
|
#endif // OS_MAC_OLD
|
||||||
|
|
||||||
if (Global::DialogsModeEnabled()) {
|
if (Global::DialogsModeEnabled()) {
|
||||||
_dialogsImportant = std_::make_unique<Dialogs::IndexedList>(Dialogs::SortMode::Date);
|
_dialogsImportant = std::make_unique<Dialogs::IndexedList>(Dialogs::SortMode::Date);
|
||||||
_importantSwitch = std_::make_unique<ImportantSwitch>();
|
_importantSwitch = std::make_unique<ImportantSwitch>();
|
||||||
}
|
}
|
||||||
connect(main, SIGNAL(peerNameChanged(PeerData*, const PeerData::Names&, const PeerData::NameFirstChars&)), this, SLOT(onPeerNameChanged(PeerData*, const PeerData::Names&, const PeerData::NameFirstChars&)));
|
connect(main, SIGNAL(peerNameChanged(PeerData*, const PeerData::Names&, const PeerData::NameFirstChars&)), this, SLOT(onPeerNameChanged(PeerData*, const PeerData::Names&, const PeerData::NameFirstChars&)));
|
||||||
connect(main, SIGNAL(peerPhotoChanged(PeerData*)), this, SLOT(onPeerPhotoChanged(PeerData*)));
|
connect(main, SIGNAL(peerPhotoChanged(PeerData*)), this, SLOT(onPeerPhotoChanged(PeerData*)));
|
||||||
|
@ -130,7 +130,7 @@ int DialogsInner::peerSearchOffset() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
int DialogsInner::searchedOffset() const {
|
int DialogsInner::searchedOffset() const {
|
||||||
int result = peerSearchOffset() + (_peerSearchResults.isEmpty() ? 0 : ((_peerSearchResults.size() * st::dialogsRowHeight) + st::searchedBarHeight));
|
int result = peerSearchOffset() + (_peerSearchResults.empty() ? 0 : ((_peerSearchResults.size() * st::dialogsRowHeight) + st::searchedBarHeight));
|
||||||
if (_searchInPeer) result += st::dialogsRowHeight;
|
if (_searchInPeer) result += st::dialogsRowHeight;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO
|
||||||
auto active = App::main()->activePeer();
|
auto active = App::main()->activePeer();
|
||||||
auto selected = _menuPeer ? _menuPeer : (isPressed() ? (_pressed ? _pressed->history()->peer : nullptr) : (_selected ? _selected->history()->peer : nullptr));
|
auto selected = _menuPeer ? _menuPeer : (isPressed() ? (_pressed ? _pressed->history()->peer : nullptr) : (_selected ? _selected->history()->peer : nullptr));
|
||||||
if (otherStart) {
|
if (otherStart) {
|
||||||
auto reorderingPinned = (_aboveIndex >= 0 && !_pinnedRows.isEmpty());
|
auto reorderingPinned = (_aboveIndex >= 0 && !_pinnedRows.empty());
|
||||||
auto &list = rows->all();
|
auto &list = rows->all();
|
||||||
if (reorderingPinned) {
|
if (reorderingPinned) {
|
||||||
dialogsClip = dialogsClip.marginsAdded(QMargins(0, st::dialogsRowHeight, 0, st::dialogsRowHeight));
|
dialogsClip = dialogsClip.marginsAdded(QMargins(0, st::dialogsRowHeight, 0, st::dialogsRowHeight));
|
||||||
|
@ -214,7 +214,7 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (_state == FilteredState || _state == SearchedState) {
|
} else if (_state == FilteredState || _state == SearchedState) {
|
||||||
if (!_hashtagResults.isEmpty()) {
|
if (!_hashtagResults.empty()) {
|
||||||
int32 from = floorclamp(r.y(), st::mentionHeight, 0, _hashtagResults.size());
|
int32 from = floorclamp(r.y(), st::mentionHeight, 0, _hashtagResults.size());
|
||||||
int32 to = ceilclamp(r.y() + r.height(), st::mentionHeight, 0, _hashtagResults.size());
|
int32 to = ceilclamp(r.y() + r.height(), st::mentionHeight, 0, _hashtagResults.size());
|
||||||
p.translate(0, from * st::mentionHeight);
|
p.translate(0, from * st::mentionHeight);
|
||||||
|
@ -279,7 +279,7 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_peerSearchResults.isEmpty()) {
|
if (!_peerSearchResults.empty()) {
|
||||||
p.fillRect(0, 0, fullWidth, st::searchedBarHeight, st::searchedBarBg);
|
p.fillRect(0, 0, fullWidth, st::searchedBarHeight, st::searchedBarBg);
|
||||||
if (!paintingOther) {
|
if (!paintingOther) {
|
||||||
p.setFont(st::searchedBarFont);
|
p.setFont(st::searchedBarFont);
|
||||||
|
@ -309,7 +309,7 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO
|
||||||
if (_searchInPeer) {
|
if (_searchInPeer) {
|
||||||
paintSearchInPeer(p, fullWidth, paintingOther);
|
paintSearchInPeer(p, fullWidth, paintingOther);
|
||||||
p.translate(0, st::dialogsRowHeight);
|
p.translate(0, st::dialogsRowHeight);
|
||||||
if (_state == FilteredState && _searchResults.isEmpty()) {
|
if (_state == FilteredState && _searchResults.empty()) {
|
||||||
p.fillRect(0, 0, fullWidth, st::searchedBarHeight, st::searchedBarBg);
|
p.fillRect(0, 0, fullWidth, st::searchedBarHeight, st::searchedBarBg);
|
||||||
if (!paintingOther) {
|
if (!paintingOther) {
|
||||||
p.setFont(st::searchedBarFont);
|
p.setFont(st::searchedBarFont);
|
||||||
|
@ -320,8 +320,8 @@ void DialogsInner::paintRegion(Painter &p, const QRegion ®ion, bool paintingO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_state == SearchedState || !_searchResults.isEmpty()) {
|
if (_state == SearchedState || !_searchResults.empty()) {
|
||||||
QString text = lng_search_found_results(lt_count, _searchResults.isEmpty() ? 0 : (_searchedMigratedCount + _searchedCount));
|
QString text = lng_search_found_results(lt_count, _searchResults.empty() ? 0 : (_searchedMigratedCount + _searchedCount));
|
||||||
p.fillRect(0, 0, fullWidth, st::searchedBarHeight, st::searchedBarBg);
|
p.fillRect(0, 0, fullWidth, st::searchedBarHeight, st::searchedBarBg);
|
||||||
if (!paintingOther) {
|
if (!paintingOther) {
|
||||||
p.setFont(st::searchedBarFont);
|
p.setFont(st::searchedBarFont);
|
||||||
|
@ -491,7 +491,7 @@ void DialogsInner::updateSelected(QPoint localPos) {
|
||||||
}
|
}
|
||||||
} else if (_state == FilteredState || _state == SearchedState) {
|
} else if (_state == FilteredState || _state == SearchedState) {
|
||||||
auto wasSelected = isSelected();
|
auto wasSelected = isSelected();
|
||||||
if (_hashtagResults.isEmpty()) {
|
if (_hashtagResults.empty()) {
|
||||||
_hashtagSelected = -1;
|
_hashtagSelected = -1;
|
||||||
_hashtagDeleteSelected = false;
|
_hashtagDeleteSelected = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -519,7 +519,7 @@ void DialogsInner::updateSelected(QPoint localPos) {
|
||||||
updateSelectedRow();
|
updateSelectedRow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!_peerSearchResults.isEmpty()) {
|
if (!_peerSearchResults.empty()) {
|
||||||
auto skip = peerSearchOffset();
|
auto skip = peerSearchOffset();
|
||||||
auto peerSearchSelected = (mouseY >= skip) ? ((mouseY - skip) / st::dialogsRowHeight) : -1;
|
auto peerSearchSelected = (mouseY >= skip) ? ((mouseY - skip) / st::dialogsRowHeight) : -1;
|
||||||
if (peerSearchSelected < 0 || peerSearchSelected >= _peerSearchResults.size()) {
|
if (peerSearchSelected < 0 || peerSearchSelected >= _peerSearchResults.size()) {
|
||||||
|
@ -531,7 +531,7 @@ void DialogsInner::updateSelected(QPoint localPos) {
|
||||||
updateSelectedRow();
|
updateSelectedRow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_state == SearchedState && !_searchResults.isEmpty()) {
|
if (_state == SearchedState && !_searchResults.empty()) {
|
||||||
auto skip = searchedOffset();
|
auto skip = searchedOffset();
|
||||||
auto searchedSelected = (mouseY >= skip) ? ((mouseY - skip) / st::dialogsRowHeight) : -1;
|
auto searchedSelected = (mouseY >= skip) ? ((mouseY - skip) / st::dialogsRowHeight) : -1;
|
||||||
if (searchedSelected < 0 || searchedSelected >= _searchResults.size()) {
|
if (searchedSelected < 0 || searchedSelected >= _searchResults.size()) {
|
||||||
|
@ -718,7 +718,7 @@ bool DialogsInner::updateReorderPinned(QPoint localPosition) {
|
||||||
shift = -floorclamp(_dragStart.y() - localPosition.y() + (rowHeight / 2), rowHeight, 0, _draggingIndex);
|
shift = -floorclamp(_dragStart.y() - localPosition.y() + (rowHeight / 2), rowHeight, 0, _draggingIndex);
|
||||||
for (auto from = _draggingIndex, to = _draggingIndex + shift; from > to; --from) {
|
for (auto from = _draggingIndex, to = _draggingIndex + shift; from > to; --from) {
|
||||||
shownDialogs()->movePinned(_dragging, -1);
|
shownDialogs()->movePinned(_dragging, -1);
|
||||||
std_::swap_moveable(_pinnedRows[from], _pinnedRows[from - 1]);
|
std::swap(_pinnedRows[from], _pinnedRows[from - 1]);
|
||||||
_pinnedRows[from].yadd = anim::value(_pinnedRows[from].yadd.current() - rowHeight, 0);
|
_pinnedRows[from].yadd = anim::value(_pinnedRows[from].yadd.current() - rowHeight, 0);
|
||||||
_pinnedRows[from].animStartTime = ms;
|
_pinnedRows[from].animStartTime = ms;
|
||||||
}
|
}
|
||||||
|
@ -726,7 +726,7 @@ bool DialogsInner::updateReorderPinned(QPoint localPosition) {
|
||||||
shift = floorclamp(localPosition.y() - _dragStart.y() + (rowHeight / 2), rowHeight, 0, pinnedCount - _draggingIndex - 1);
|
shift = floorclamp(localPosition.y() - _dragStart.y() + (rowHeight / 2), rowHeight, 0, pinnedCount - _draggingIndex - 1);
|
||||||
for (auto from = _draggingIndex, to = _draggingIndex + shift; from < to; ++from) {
|
for (auto from = _draggingIndex, to = _draggingIndex + shift; from < to; ++from) {
|
||||||
shownDialogs()->movePinned(_dragging, 1);
|
shownDialogs()->movePinned(_dragging, 1);
|
||||||
std_::swap_moveable(_pinnedRows[from], _pinnedRows[from + 1]);
|
std::swap(_pinnedRows[from], _pinnedRows[from + 1]);
|
||||||
_pinnedRows[from].yadd = anim::value(_pinnedRows[from].yadd.current() + rowHeight, 0);
|
_pinnedRows[from].yadd = anim::value(_pinnedRows[from].yadd.current() + rowHeight, 0);
|
||||||
_pinnedRows[from].animStartTime = ms;
|
_pinnedRows[from].animStartTime = ms;
|
||||||
}
|
}
|
||||||
|
@ -761,7 +761,7 @@ void DialogsInner::step_pinnedShifting(TimeMs ms, bool timer) {
|
||||||
auto animating = false;
|
auto animating = false;
|
||||||
auto updateMin = -1;
|
auto updateMin = -1;
|
||||||
auto updateMax = 0;
|
auto updateMax = 0;
|
||||||
for (auto i = 0, l = _pinnedRows.size(); i != l; ++i) {
|
for (auto i = 0, l = static_cast<int>(_pinnedRows.size()); i != l; ++i) {
|
||||||
auto start = _pinnedRows[i].animStartTime;
|
auto start = _pinnedRows[i].animStartTime;
|
||||||
if (start) {
|
if (start) {
|
||||||
if (updateMin < 0) updateMin = i;
|
if (updateMin < 0) updateMin = i;
|
||||||
|
@ -1065,7 +1065,7 @@ void DialogsInner::updateDialogRow(PeerData *peer, MsgId msgId, QRect updateRect
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((sections & UpdateRowSection::PeerSearch) && !_peerSearchResults.isEmpty()) {
|
if ((sections & UpdateRowSection::PeerSearch) && !_peerSearchResults.empty()) {
|
||||||
auto index = 0, add = peerSearchOffset();
|
auto index = 0, add = peerSearchOffset();
|
||||||
for_const (auto &result, _peerSearchResults) {
|
for_const (auto &result, _peerSearchResults) {
|
||||||
if (result->peer == peer) {
|
if (result->peer == peer) {
|
||||||
|
@ -1075,7 +1075,7 @@ void DialogsInner::updateDialogRow(PeerData *peer, MsgId msgId, QRect updateRect
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((sections & UpdateRowSection::MessageSearch) && !_searchResults.isEmpty()) {
|
if ((sections & UpdateRowSection::MessageSearch) && !_searchResults.empty()) {
|
||||||
auto index = 0, add = searchedOffset();
|
auto index = 0, add = searchedOffset();
|
||||||
for_const (auto &result, _searchResults) {
|
for_const (auto &result, _searchResults) {
|
||||||
auto item = result->item();
|
auto item = result->item();
|
||||||
|
@ -1185,7 +1185,7 @@ void DialogsInner::contextMenuEvent(QContextMenuEvent *e) {
|
||||||
|
|
||||||
_menu = new Ui::PopupMenu(nullptr);
|
_menu = new Ui::PopupMenu(nullptr);
|
||||||
App::main()->fillPeerMenu(_menuPeer, [this](const QString &text, base::lambda<void()> &&callback) {
|
App::main()->fillPeerMenu(_menuPeer, [this](const QString &text, base::lambda<void()> &&callback) {
|
||||||
return _menu->addAction(text, std_::move(callback));
|
return _menu->addAction(text, std::move(callback));
|
||||||
}, true);
|
}, true);
|
||||||
connect(_menu, SIGNAL(destroyed(QObject*)), this, SLOT(onMenuDestroyed(QObject*)));
|
connect(_menu, SIGNAL(destroyed(QObject*)), this, SLOT(onMenuDestroyed(QObject*)));
|
||||||
_menu->popup(e->globalPos());
|
_menu->popup(e->globalPos());
|
||||||
|
@ -1343,7 +1343,7 @@ void DialogsInner::onFilterUpdate(QString newFilter, bool force) {
|
||||||
void DialogsInner::onHashtagFilterUpdate(QStringRef newFilter) {
|
void DialogsInner::onHashtagFilterUpdate(QStringRef newFilter) {
|
||||||
if (newFilter.isEmpty() || newFilter.at(0) != '#' || _searchInPeer) {
|
if (newFilter.isEmpty() || newFilter.at(0) != '#' || _searchInPeer) {
|
||||||
_hashtagFilter = QString();
|
_hashtagFilter = QString();
|
||||||
if (!_hashtagResults.isEmpty()) {
|
if (!_hashtagResults.empty()) {
|
||||||
_hashtagResults.clear();
|
_hashtagResults.clear();
|
||||||
refresh(true);
|
refresh(true);
|
||||||
setMouseSelection(false, true);
|
setMouseSelection(false, true);
|
||||||
|
@ -1360,7 +1360,7 @@ void DialogsInner::onHashtagFilterUpdate(QStringRef newFilter) {
|
||||||
_hashtagResults.reserve(qMin(recent.size(), kHashtagResultsLimit));
|
_hashtagResults.reserve(qMin(recent.size(), kHashtagResultsLimit));
|
||||||
for (auto i = recent.cbegin(), e = recent.cend(); i != e; ++i) {
|
for (auto i = recent.cbegin(), e = recent.cend(); i != e; ++i) {
|
||||||
if (i->first.startsWith(_hashtagFilter.midRef(1), Qt::CaseInsensitive) && i->first.size() + 1 != newFilter.size()) {
|
if (i->first.startsWith(_hashtagFilter.midRef(1), Qt::CaseInsensitive) && i->first.size() + 1 != newFilter.size()) {
|
||||||
_hashtagResults.push_back(std_::make_unique<HashtagResult>(i->first));
|
_hashtagResults.push_back(std::make_unique<HashtagResult>(i->first));
|
||||||
if (_hashtagResults.size() == kHashtagResultsLimit) break;
|
if (_hashtagResults.size() == kHashtagResultsLimit) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1505,7 +1505,7 @@ bool DialogsInner::searchReceived(const QVector<MTPMessage> &messages, DialogsSe
|
||||||
if (auto peer = App::peerLoaded(peerId)) {
|
if (auto peer = App::peerLoaded(peerId)) {
|
||||||
if (lastDate) {
|
if (lastDate) {
|
||||||
auto item = App::histories().addNewMessage(message, NewMessageExisting);
|
auto item = App::histories().addNewMessage(message, NewMessageExisting);
|
||||||
_searchResults.push_back(std_::make_unique<Dialogs::FakeRow>(item));
|
_searchResults.push_back(std::make_unique<Dialogs::FakeRow>(item));
|
||||||
lastDateFound = lastDate;
|
lastDateFound = lastDate;
|
||||||
if (isGlobalSearch) {
|
if (isGlobalSearch) {
|
||||||
_lastSearchDate = lastDateFound;
|
_lastSearchDate = lastDateFound;
|
||||||
|
@ -1531,7 +1531,7 @@ bool DialogsInner::searchReceived(const QVector<MTPMessage> &messages, DialogsSe
|
||||||
} else {
|
} else {
|
||||||
_searchedCount = fullCount;
|
_searchedCount = fullCount;
|
||||||
}
|
}
|
||||||
if (_state == FilteredState && (!_searchResults.isEmpty() || !_searchInMigrated || type == DialogsSearchMigratedFromStart || type == DialogsSearchMigratedFromOffset)) {
|
if (_state == FilteredState && (!_searchResults.empty() || !_searchInMigrated || type == DialogsSearchMigratedFromStart || type == DialogsSearchMigratedFromOffset)) {
|
||||||
_state = SearchedState;
|
_state = SearchedState;
|
||||||
}
|
}
|
||||||
refresh();
|
refresh();
|
||||||
|
@ -1550,7 +1550,7 @@ void DialogsInner::peerSearchReceived(const QString &query, const QVector<MTPPee
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (auto peer = App::peerLoaded(peerId)) {
|
if (auto peer = App::peerLoaded(peerId)) {
|
||||||
_peerSearchResults.push_back(std_::make_unique<PeerSearchResult>(App::peer(peerId)));
|
_peerSearchResults.push_back(std::make_unique<PeerSearchResult>(App::peer(peerId)));
|
||||||
} else {
|
} else {
|
||||||
LOG(("API Error: user %1 was not loaded in DialogsInner::peopleReceived()").arg(peerId));
|
LOG(("API Error: user %1 was not loaded in DialogsInner::peopleReceived()").arg(peerId));
|
||||||
}
|
}
|
||||||
|
@ -1660,7 +1660,7 @@ void DialogsInner::refresh(bool toTop) {
|
||||||
} else {
|
} else {
|
||||||
if (!_addContactLnk->isHidden()) _addContactLnk->hide();
|
if (!_addContactLnk->isHidden()) _addContactLnk->hide();
|
||||||
if (_state == FilteredState) {
|
if (_state == FilteredState) {
|
||||||
h = searchedOffset() + (_searchResults.size() * st::dialogsRowHeight) + ((_searchResults.isEmpty() && !_searchInPeer) ? -st::searchedBarHeight : 0);
|
h = searchedOffset() + (_searchResults.size() * st::dialogsRowHeight) + ((_searchResults.empty() && !_searchInPeer) ? -st::searchedBarHeight : 0);
|
||||||
} else if (_state == SearchedState) {
|
} else if (_state == SearchedState) {
|
||||||
h = searchedOffset() + (_searchResults.size() * st::dialogsRowHeight);
|
h = searchedOffset() + (_searchResults.size() * st::dialogsRowHeight);
|
||||||
}
|
}
|
||||||
|
@ -1707,7 +1707,7 @@ DialogsInner::State DialogsInner::state() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DialogsInner::hasFilteredResults() const {
|
bool DialogsInner::hasFilteredResults() const {
|
||||||
return !_filterResults.isEmpty() && _hashtagResults.isEmpty();
|
return !_filterResults.isEmpty() && _hashtagResults.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogsInner::searchInPeer(PeerData *peer) {
|
void DialogsInner::searchInPeer(PeerData *peer) {
|
||||||
|
@ -1777,23 +1777,23 @@ void DialogsInner::selectSkip(int32 direction) {
|
||||||
emit mustScrollTo(fromY, fromY + st::dialogsRowHeight);
|
emit mustScrollTo(fromY, fromY + st::dialogsRowHeight);
|
||||||
}
|
}
|
||||||
} else if (_state == FilteredState || _state == SearchedState) {
|
} else if (_state == FilteredState || _state == SearchedState) {
|
||||||
if (_hashtagResults.isEmpty() && _filterResults.isEmpty() && _peerSearchResults.isEmpty() && _searchResults.isEmpty()) return;
|
if (_hashtagResults.empty() && _filterResults.isEmpty() && _peerSearchResults.empty() && _searchResults.empty()) return;
|
||||||
if ((_hashtagSelected < 0 || _hashtagSelected >= _hashtagResults.size()) &&
|
if ((_hashtagSelected < 0 || _hashtagSelected >= _hashtagResults.size()) &&
|
||||||
(_filteredSelected < 0 || _filteredSelected >= _filterResults.size()) &&
|
(_filteredSelected < 0 || _filteredSelected >= _filterResults.size()) &&
|
||||||
(_peerSearchSelected < 0 || _peerSearchSelected >= _peerSearchResults.size()) &&
|
(_peerSearchSelected < 0 || _peerSearchSelected >= _peerSearchResults.size()) &&
|
||||||
(_searchedSelected < 0 || _searchedSelected >= _searchResults.size())) {
|
(_searchedSelected < 0 || _searchedSelected >= _searchResults.size())) {
|
||||||
if (_hashtagResults.isEmpty() && _filterResults.isEmpty() && _peerSearchResults.isEmpty()) {
|
if (_hashtagResults.empty() && _filterResults.isEmpty() && _peerSearchResults.empty()) {
|
||||||
_searchedSelected = 0;
|
_searchedSelected = 0;
|
||||||
} else if (_hashtagResults.isEmpty() && _filterResults.isEmpty()) {
|
} else if (_hashtagResults.empty() && _filterResults.isEmpty()) {
|
||||||
_peerSearchSelected = 0;
|
_peerSearchSelected = 0;
|
||||||
} else if (_hashtagResults.isEmpty()) {
|
} else if (_hashtagResults.empty()) {
|
||||||
_filteredSelected = 0;
|
_filteredSelected = 0;
|
||||||
} else {
|
} else {
|
||||||
_hashtagSelected = 0;
|
_hashtagSelected = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int32 cur = (_hashtagSelected >= 0 && _hashtagSelected < _hashtagResults.size()) ? _hashtagSelected : ((_filteredSelected >= 0 && _filteredSelected < _filterResults.size()) ? (_hashtagResults.size() + _filteredSelected) : ((_peerSearchSelected >= 0 && _peerSearchSelected < _peerSearchResults.size()) ? (_peerSearchSelected + _filterResults.size() + _hashtagResults.size()) : (_searchedSelected + _peerSearchResults.size() + _filterResults.size() + _hashtagResults.size())));
|
int32 cur = (_hashtagSelected >= 0 && _hashtagSelected < _hashtagResults.size()) ? _hashtagSelected : ((_filteredSelected >= 0 && _filteredSelected < _filterResults.size()) ? (_hashtagResults.size() + _filteredSelected) : ((_peerSearchSelected >= 0 && _peerSearchSelected < _peerSearchResults.size()) ? (_peerSearchSelected + _filterResults.size() + _hashtagResults.size()) : (_searchedSelected + _peerSearchResults.size() + _filterResults.size() + _hashtagResults.size())));
|
||||||
cur = snap(cur + direction, 0, _hashtagResults.size() + _filterResults.size() + _peerSearchResults.size() + _searchResults.size() - 1);
|
cur = snap(cur + direction, 0, static_cast<int>(_hashtagResults.size() + _filterResults.size() + _peerSearchResults.size() + _searchResults.size()) - 1);
|
||||||
if (cur < _hashtagResults.size()) {
|
if (cur < _hashtagResults.size()) {
|
||||||
_hashtagSelected = cur;
|
_hashtagSelected = cur;
|
||||||
_filteredSelected = _peerSearchSelected = _searchedSelected = -1;
|
_filteredSelected = _peerSearchSelected = _searchedSelected = -1;
|
||||||
|
@ -1926,10 +1926,10 @@ void DialogsInner::loadPeerPhotos() {
|
||||||
_peerSearchResults[from]->peer->loadUserpic();
|
_peerSearchResults[from]->peer->loadUserpic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
from = (yFrom > filteredOffset() + ((_peerSearchResults.isEmpty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight) ? ((yFrom - filteredOffset() - (_peerSearchResults.isEmpty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size() - _peerSearchResults.size();
|
from = (yFrom > filteredOffset() + ((_peerSearchResults.empty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight) ? ((yFrom - filteredOffset() - (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size() - _peerSearchResults.size();
|
||||||
if (from < 0) from = 0;
|
if (from < 0) from = 0;
|
||||||
if (from < _searchResults.size()) {
|
if (from < _searchResults.size()) {
|
||||||
int32 to = (yTo > filteredOffset() + (_peerSearchResults.isEmpty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight ? ((yTo - filteredOffset() - (_peerSearchResults.isEmpty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size() - _peerSearchResults.size() + 1, w = width();
|
int32 to = (yTo > filteredOffset() + (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight ? ((yTo - filteredOffset() - (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) - st::searchedBarHeight) / int32(st::dialogsRowHeight)) : 0) - _filterResults.size() - _peerSearchResults.size() + 1, w = width();
|
||||||
if (to > _searchResults.size()) to = _searchResults.size();
|
if (to > _searchResults.size()) to = _searchResults.size();
|
||||||
|
|
||||||
for (; from < to; ++from) {
|
for (; from < to; ++from) {
|
||||||
|
@ -2071,7 +2071,7 @@ void DialogsInner::peerBefore(const PeerData *inPeer, MsgId inMsg, PeerData *&ou
|
||||||
outMsg = 0;
|
outMsg = 0;
|
||||||
return;
|
return;
|
||||||
} else if (_state == FilteredState || _state == SearchedState) {
|
} else if (_state == FilteredState || _state == SearchedState) {
|
||||||
if (inMsg && !_searchResults.isEmpty()) {
|
if (inMsg && !_searchResults.empty()) {
|
||||||
for (auto b = _searchResults.cbegin(), i = b + 1, e = _searchResults.cend(); i != e; ++i) {
|
for (auto b = _searchResults.cbegin(), i = b + 1, e = _searchResults.cend(); i != e; ++i) {
|
||||||
if ((*i)->item()->history()->peer == inPeer && (*i)->item()->id == inMsg) {
|
if ((*i)->item()->history()->peer == inPeer && (*i)->item()->id == inMsg) {
|
||||||
auto j = i - 1;
|
auto j = i - 1;
|
||||||
|
@ -2082,7 +2082,7 @@ void DialogsInner::peerBefore(const PeerData *inPeer, MsgId inMsg, PeerData *&ou
|
||||||
}
|
}
|
||||||
if (_searchResults.at(0)->item()->history()->peer == inPeer && _searchResults.at(0)->item()->id == inMsg) {
|
if (_searchResults.at(0)->item()->history()->peer == inPeer && _searchResults.at(0)->item()->id == inMsg) {
|
||||||
outMsg = ShowAtUnreadMsgId;
|
outMsg = ShowAtUnreadMsgId;
|
||||||
if (_peerSearchResults.isEmpty()) {
|
if (_peerSearchResults.empty()) {
|
||||||
if (_filterResults.isEmpty()) {
|
if (_filterResults.isEmpty()) {
|
||||||
outPeer = nullptr;
|
outPeer = nullptr;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2094,12 +2094,12 @@ void DialogsInner::peerBefore(const PeerData *inPeer, MsgId inMsg, PeerData *&ou
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!_peerSearchResults.isEmpty() && _peerSearchResults[0]->peer == inPeer) {
|
if (!_peerSearchResults.empty() && _peerSearchResults[0]->peer == inPeer) {
|
||||||
outPeer = _filterResults.isEmpty() ? 0 : _filterResults.back()->history()->peer;
|
outPeer = _filterResults.isEmpty() ? 0 : _filterResults.back()->history()->peer;
|
||||||
outMsg = ShowAtUnreadMsgId;
|
outMsg = ShowAtUnreadMsgId;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!_peerSearchResults.isEmpty()) {
|
if (!_peerSearchResults.empty()) {
|
||||||
for (auto b = _peerSearchResults.cbegin(), i = b + 1, e = _peerSearchResults.cend(); i != e; ++i) {
|
for (auto b = _peerSearchResults.cbegin(), i = b + 1, e = _peerSearchResults.cend(); i != e; ++i) {
|
||||||
if ((*i)->peer == inPeer) {
|
if ((*i)->peer == inPeer) {
|
||||||
outPeer = (*(i - 1))->peer;
|
outPeer = (*(i - 1))->peer;
|
||||||
|
@ -2158,7 +2158,7 @@ void DialogsInner::peerAfter(const PeerData *inPeer, MsgId inMsg, PeerData *&out
|
||||||
for (auto i = _peerSearchResults.cbegin(), e = _peerSearchResults.cend(); i != e; ++i) {
|
for (auto i = _peerSearchResults.cbegin(), e = _peerSearchResults.cend(); i != e; ++i) {
|
||||||
if ((*i)->peer == inPeer) {
|
if ((*i)->peer == inPeer) {
|
||||||
++i;
|
++i;
|
||||||
if (i == e && !_searchResults.isEmpty()) {
|
if (i == e && !_searchResults.empty()) {
|
||||||
outPeer = _searchResults.front()->item()->history()->peer;
|
outPeer = _searchResults.front()->item()->history()->peer;
|
||||||
outMsg = _searchResults.front()->item()->id;
|
outMsg = _searchResults.front()->item()->id;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2171,10 +2171,10 @@ void DialogsInner::peerAfter(const PeerData *inPeer, MsgId inMsg, PeerData *&out
|
||||||
for (FilteredDialogs::const_iterator i = _filterResults.cbegin(), e = _filterResults.cend(); i != e; ++i) {
|
for (FilteredDialogs::const_iterator i = _filterResults.cbegin(), e = _filterResults.cend(); i != e; ++i) {
|
||||||
if ((*i)->history()->peer == inPeer) {
|
if ((*i)->history()->peer == inPeer) {
|
||||||
++i;
|
++i;
|
||||||
if (i == e && !_peerSearchResults.isEmpty()) {
|
if (i == e && !_peerSearchResults.empty()) {
|
||||||
outPeer = _peerSearchResults.front()->peer;
|
outPeer = _peerSearchResults.front()->peer;
|
||||||
outMsg = ShowAtUnreadMsgId;
|
outMsg = ShowAtUnreadMsgId;
|
||||||
} else if (i == e && !_searchResults.isEmpty()) {
|
} else if (i == e && !_searchResults.empty()) {
|
||||||
outPeer = _searchResults.front()->item()->history()->peer;
|
outPeer = _searchResults.front()->item()->history()->peer;
|
||||||
outMsg = _searchResults.front()->item()->id;
|
outMsg = _searchResults.front()->item()->id;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -113,7 +113,7 @@ public:
|
||||||
PeerData *updateFromParentDrag(QPoint globalPos);
|
PeerData *updateFromParentDrag(QPoint globalPos);
|
||||||
|
|
||||||
void setLoadMoreCallback(base::lambda<void()> &&callback) {
|
void setLoadMoreCallback(base::lambda<void()> &&callback) {
|
||||||
_loadMoreCallback = std_::move(callback);
|
_loadMoreCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
void setVisibleTopBottom(int visibleTop, int visibleBottom) override;
|
void setVisibleTopBottom(int visibleTop, int visibleBottom) override;
|
||||||
|
|
||||||
|
@ -152,13 +152,13 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ImportantSwitch;
|
struct ImportantSwitch;
|
||||||
using DialogsList = std_::unique_ptr<Dialogs::IndexedList>;
|
using DialogsList = std::unique_ptr<Dialogs::IndexedList>;
|
||||||
using FilteredDialogs = QVector<Dialogs::Row*>;
|
using FilteredDialogs = QVector<Dialogs::Row*>;
|
||||||
using SearchResults = std_::vector_of_moveable<std_::unique_ptr<Dialogs::FakeRow>>;
|
using SearchResults = std::vector<std::unique_ptr<Dialogs::FakeRow>>;
|
||||||
struct HashtagResult;
|
struct HashtagResult;
|
||||||
using HashtagResults = std_::vector_of_moveable<std_::unique_ptr<HashtagResult>>;
|
using HashtagResults = std::vector<std::unique_ptr<HashtagResult>>;
|
||||||
struct PeerSearchResult;
|
struct PeerSearchResult;
|
||||||
using PeerSearchResults = std_::vector_of_moveable<std_::unique_ptr<PeerSearchResult>>;
|
using PeerSearchResults = std::vector<std::unique_ptr<PeerSearchResult>>;
|
||||||
|
|
||||||
void mousePressReleased(Qt::MouseButton button);
|
void mousePressReleased(Qt::MouseButton button);
|
||||||
void clearIrrelevantState();
|
void clearIrrelevantState();
|
||||||
|
@ -228,7 +228,7 @@ private:
|
||||||
bool _mouseSelection = false;
|
bool _mouseSelection = false;
|
||||||
Qt::MouseButton _pressButton = Qt::LeftButton;
|
Qt::MouseButton _pressButton = Qt::LeftButton;
|
||||||
|
|
||||||
std_::unique_ptr<ImportantSwitch> _importantSwitch;
|
std::unique_ptr<ImportantSwitch> _importantSwitch;
|
||||||
bool _importantSwitchSelected = false;
|
bool _importantSwitchSelected = false;
|
||||||
bool _importantSwitchPressed = false;
|
bool _importantSwitchPressed = false;
|
||||||
Dialogs::Row *_selected = nullptr;
|
Dialogs::Row *_selected = nullptr;
|
||||||
|
@ -242,7 +242,7 @@ private:
|
||||||
anim::value yadd;
|
anim::value yadd;
|
||||||
TimeMs animStartTime = 0;
|
TimeMs animStartTime = 0;
|
||||||
};
|
};
|
||||||
std_::vector_of_moveable<PinnedRow> _pinnedRows;
|
std::vector<PinnedRow> _pinnedRows;
|
||||||
BasicAnimation _a_pinnedShifting;
|
BasicAnimation _a_pinnedShifting;
|
||||||
QList<History*> _pinnedOrder;
|
QList<History*> _pinnedOrder;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "profile/profile_section_memento.h"
|
#include "profile/profile_section_memento.h"
|
||||||
#include "core/vector_of_moveable.h"
|
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
#include "observer_peer.h"
|
#include "observer_peer.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
@ -40,7 +39,7 @@ namespace App {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
void CallDelayed(int duration, base::lambda<void()> &&lambda) {
|
void CallDelayed(int duration, base::lambda<void()> &&lambda) {
|
||||||
QTimer::singleShot(duration, base::lambda_slot_once(App::app(), std_::move(lambda)), SLOT(action()));
|
QTimer::singleShot(duration, base::lambda_slot_once(App::app(), std::move(lambda)), SLOT(action()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
@ -204,7 +203,7 @@ namespace internal {
|
||||||
|
|
||||||
void showBox(object_ptr<BoxContent> content, ShowLayerOptions options) {
|
void showBox(object_ptr<BoxContent> content, ShowLayerOptions options) {
|
||||||
if (auto w = App::wnd()) {
|
if (auto w = App::wnd()) {
|
||||||
w->ui_showBox(std_::move(content), options);
|
w->ui_showBox(std::move(content), options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,19 +41,19 @@ void CallDelayed(int duration, base::lambda<void()> &&lambda);
|
||||||
|
|
||||||
template <int N, typename Lambda>
|
template <int N, typename Lambda>
|
||||||
inline void CallDelayed(int duration, base::internal::lambda_guard<N, Lambda> &&guarded) {
|
inline void CallDelayed(int duration, base::internal::lambda_guard<N, Lambda> &&guarded) {
|
||||||
return internal::CallDelayed(duration, [guarded = std_::move(guarded)] { guarded(); });
|
return internal::CallDelayed(duration, [guarded = std::move(guarded)] { guarded(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Pointer, typename ...PointersAndLambda>
|
template <typename Pointer, typename ...PointersAndLambda>
|
||||||
inline void CallDelayed(int duration, Pointer &&qobject, PointersAndLambda&&... qobjectsAndLambda) {
|
inline void CallDelayed(int duration, Pointer &&qobject, PointersAndLambda&&... qobjectsAndLambda) {
|
||||||
auto guarded = base::lambda_guarded(std_::forward<Pointer>(qobject), std_::forward<PointersAndLambda>(qobjectsAndLambda)...);
|
auto guarded = base::lambda_guarded(std::forward<Pointer>(qobject), std::forward<PointersAndLambda>(qobjectsAndLambda)...);
|
||||||
return CallDelayed(duration, std_::move(guarded));
|
return CallDelayed(duration, std::move(guarded));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ...PointersAndLambda>
|
template <typename ...PointersAndLambda>
|
||||||
inline base::lambda<void()> LambdaDelayed(int duration, PointersAndLambda&&... qobjectsAndLambda) {
|
inline base::lambda<void()> LambdaDelayed(int duration, PointersAndLambda&&... qobjectsAndLambda) {
|
||||||
auto guarded = base::lambda_guarded(std_::forward<PointersAndLambda>(qobjectsAndLambda)...);
|
auto guarded = base::lambda_guarded(std::forward<PointersAndLambda>(qobjectsAndLambda)...);
|
||||||
return [guarded = std_::move(guarded), duration] {
|
return [guarded = std::move(guarded), duration] {
|
||||||
CallDelayed(duration, guarded.clone());
|
CallDelayed(duration, guarded.clone());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ void hideMediaPreview();
|
||||||
template <typename BoxType>
|
template <typename BoxType>
|
||||||
QPointer<BoxType> show(object_ptr<BoxType> content, ShowLayerOptions options = CloseOtherLayers) {
|
QPointer<BoxType> show(object_ptr<BoxType> content, ShowLayerOptions options = CloseOtherLayers) {
|
||||||
auto result = QPointer<BoxType>(content.data());
|
auto result = QPointer<BoxType>(content.data());
|
||||||
internal::showBox(std_::move(content), options);
|
internal::showBox(std::move(content), options);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ inline bool IsTopCorner(ScreenCorner corner) {
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct custom_is_fast_copy_type<Notify::ChangeType> : public std_::true_type {
|
struct custom_is_fast_copy_type<Notify::ChangeType> : public std::true_type {
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
|
@ -106,14 +106,14 @@ void History::setHasPendingResizedItems() {
|
||||||
Global::RefHandleHistoryUpdate().call();
|
Global::RefHandleHistoryUpdate().call();
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::setLocalDraft(std_::unique_ptr<Data::Draft> &&draft) {
|
void History::setLocalDraft(std::unique_ptr<Data::Draft> &&draft) {
|
||||||
_localDraft = std_::move(draft);
|
_localDraft = std::move(draft);
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::takeLocalDraft(History *from) {
|
void History::takeLocalDraft(History *from) {
|
||||||
if (auto &draft = from->_localDraft) {
|
if (auto &draft = from->_localDraft) {
|
||||||
if (!draft->textWithTags.text.isEmpty() && !_localDraft) {
|
if (!draft->textWithTags.text.isEmpty() && !_localDraft) {
|
||||||
_localDraft = std_::move(draft);
|
_localDraft = std::move(draft);
|
||||||
|
|
||||||
// Edit and reply to drafts can't migrate.
|
// Edit and reply to drafts can't migrate.
|
||||||
// Cloud drafts do not migrate automatically.
|
// Cloud drafts do not migrate automatically.
|
||||||
|
@ -131,7 +131,7 @@ void History::createLocalDraftFromCloud() {
|
||||||
auto existing = localDraft();
|
auto existing = localDraft();
|
||||||
if (Data::draftIsNull(existing) || !existing->date.isValid() || draft->date >= existing->date) {
|
if (Data::draftIsNull(existing) || !existing->date.isValid() || draft->date >= existing->date) {
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
setLocalDraft(std_::make_unique<Data::Draft>(draft->textWithTags, draft->msgId, draft->cursor, draft->previewCancelled));
|
setLocalDraft(std::make_unique<Data::Draft>(draft->textWithTags, draft->msgId, draft->cursor, draft->previewCancelled));
|
||||||
existing = localDraft();
|
existing = localDraft();
|
||||||
} else if (existing != draft) {
|
} else if (existing != draft) {
|
||||||
existing->textWithTags = draft->textWithTags;
|
existing->textWithTags = draft->textWithTags;
|
||||||
|
@ -143,19 +143,19 @@ void History::createLocalDraftFromCloud() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::setCloudDraft(std_::unique_ptr<Data::Draft> &&draft) {
|
void History::setCloudDraft(std::unique_ptr<Data::Draft> &&draft) {
|
||||||
_cloudDraft = std_::move(draft);
|
_cloudDraft = std::move(draft);
|
||||||
cloudDraftTextCache.clear();
|
cloudDraftTextCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Data::Draft *History::createCloudDraft(Data::Draft *fromDraft) {
|
Data::Draft *History::createCloudDraft(Data::Draft *fromDraft) {
|
||||||
if (Data::draftIsNull(fromDraft)) {
|
if (Data::draftIsNull(fromDraft)) {
|
||||||
setCloudDraft(std_::make_unique<Data::Draft>(TextWithTags(), 0, MessageCursor(), false));
|
setCloudDraft(std::make_unique<Data::Draft>(TextWithTags(), 0, MessageCursor(), false));
|
||||||
cloudDraft()->date = QDateTime();
|
cloudDraft()->date = QDateTime();
|
||||||
} else {
|
} else {
|
||||||
auto existing = cloudDraft();
|
auto existing = cloudDraft();
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
setCloudDraft(std_::make_unique<Data::Draft>(fromDraft->textWithTags, fromDraft->msgId, fromDraft->cursor, fromDraft->previewCancelled));
|
setCloudDraft(std::make_unique<Data::Draft>(fromDraft->textWithTags, fromDraft->msgId, fromDraft->cursor, fromDraft->previewCancelled));
|
||||||
existing = cloudDraft();
|
existing = cloudDraft();
|
||||||
} else if (existing != fromDraft) {
|
} else if (existing != fromDraft) {
|
||||||
existing->textWithTags = fromDraft->textWithTags;
|
existing->textWithTags = fromDraft->textWithTags;
|
||||||
|
@ -172,8 +172,8 @@ Data::Draft *History::createCloudDraft(Data::Draft *fromDraft) {
|
||||||
return cloudDraft();
|
return cloudDraft();
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::setEditDraft(std_::unique_ptr<Data::Draft> &&draft) {
|
void History::setEditDraft(std::unique_ptr<Data::Draft> &&draft) {
|
||||||
_editDraft = std_::move(draft);
|
_editDraft = std::move(draft);
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::clearLocalDraft() {
|
void History::clearLocalDraft() {
|
||||||
|
|
|
@ -378,12 +378,12 @@ public:
|
||||||
Data::Draft *editDraft() {
|
Data::Draft *editDraft() {
|
||||||
return _editDraft.get();
|
return _editDraft.get();
|
||||||
}
|
}
|
||||||
void setLocalDraft(std_::unique_ptr<Data::Draft> &&draft);
|
void setLocalDraft(std::unique_ptr<Data::Draft> &&draft);
|
||||||
void takeLocalDraft(History *from);
|
void takeLocalDraft(History *from);
|
||||||
void createLocalDraftFromCloud();
|
void createLocalDraftFromCloud();
|
||||||
void setCloudDraft(std_::unique_ptr<Data::Draft> &&draft);
|
void setCloudDraft(std::unique_ptr<Data::Draft> &&draft);
|
||||||
Data::Draft *createCloudDraft(Data::Draft *fromDraft);
|
Data::Draft *createCloudDraft(Data::Draft *fromDraft);
|
||||||
void setEditDraft(std_::unique_ptr<Data::Draft> &&draft);
|
void setEditDraft(std::unique_ptr<Data::Draft> &&draft);
|
||||||
void clearLocalDraft();
|
void clearLocalDraft();
|
||||||
void clearCloudDraft();
|
void clearCloudDraft();
|
||||||
void clearEditDraft();
|
void clearEditDraft();
|
||||||
|
@ -560,14 +560,14 @@ private:
|
||||||
int expectedItemsCount = 0; // optimization for block->items.reserve() call
|
int expectedItemsCount = 0; // optimization for block->items.reserve() call
|
||||||
HistoryBlock *block = nullptr;
|
HistoryBlock *block = nullptr;
|
||||||
};
|
};
|
||||||
std_::unique_ptr<BuildingBlock> _buildingFrontBlock;
|
std::unique_ptr<BuildingBlock> _buildingFrontBlock;
|
||||||
|
|
||||||
// Creates if necessary a new block for adding item.
|
// Creates if necessary a new block for adding item.
|
||||||
// Depending on isBuildingFrontBlock() gets front or back block.
|
// Depending on isBuildingFrontBlock() gets front or back block.
|
||||||
HistoryBlock *prepareBlockForAddingItem();
|
HistoryBlock *prepareBlockForAddingItem();
|
||||||
|
|
||||||
std_::unique_ptr<Data::Draft> _localDraft, _cloudDraft;
|
std::unique_ptr<Data::Draft> _localDraft, _cloudDraft;
|
||||||
std_::unique_ptr<Data::Draft> _editDraft;
|
std::unique_ptr<Data::Draft> _editDraft;
|
||||||
|
|
||||||
using TypingUsers = QMap<UserData*, TimeMs>;
|
using TypingUsers = QMap<UserData*, TimeMs>;
|
||||||
TypingUsers _typing;
|
TypingUsers _typing;
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
void hideFast();
|
void hideFast();
|
||||||
|
|
||||||
void setDroppedCallback(base::lambda<void(const QMimeData *data)> &&callback) {
|
void setDroppedCallback(base::lambda<void(const QMimeData *data)> &&callback) {
|
||||||
_droppedCallback = std_::move(callback);
|
_droppedCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -99,7 +99,7 @@ QString ReplyMarkupClickHandler::buttonText() const {
|
||||||
ReplyKeyboard::ReplyKeyboard(const HistoryItem *item, StylePtr &&s)
|
ReplyKeyboard::ReplyKeyboard(const HistoryItem *item, StylePtr &&s)
|
||||||
: _item(item)
|
: _item(item)
|
||||||
, _a_selected(animation(this, &ReplyKeyboard::step_selected))
|
, _a_selected(animation(this, &ReplyKeyboard::step_selected))
|
||||||
, _st(std_::move(s)) {
|
, _st(std::move(s)) {
|
||||||
if (auto markup = item->Get<HistoryMessageReplyMarkup>()) {
|
if (auto markup = item->Get<HistoryMessageReplyMarkup>()) {
|
||||||
_rows.reserve(markup->rows.size());
|
_rows.reserve(markup->rows.size());
|
||||||
for (int i = 0, l = markup->rows.size(); i != l; ++i) {
|
for (int i = 0, l = markup->rows.size(); i != l; ++i) {
|
||||||
|
@ -197,7 +197,7 @@ bool ReplyKeyboard::isEnoughSpace(int width, const style::BotKeyboardButton &st)
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReplyKeyboard::setStyle(StylePtr &&st) {
|
void ReplyKeyboard::setStyle(StylePtr &&st) {
|
||||||
_st = std_::move(st);
|
_st = std::move(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ReplyKeyboard::naturalWidth() const {
|
int ReplyKeyboard::naturalWidth() const {
|
||||||
|
@ -292,7 +292,7 @@ void ReplyKeyboard::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pr
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
if (!button.ripple) {
|
if (!button.ripple) {
|
||||||
auto mask = Ui::RippleAnimation::roundRectMask(button.rect.size(), _st->buttonRadius());
|
auto mask = Ui::RippleAnimation::roundRectMask(button.rect.size(), _st->buttonRadius());
|
||||||
button.ripple = MakeShared<Ui::RippleAnimation>(_st->_st->ripple, std_::move(mask), [this] { _st->repaint(_item); });
|
button.ripple = MakeShared<Ui::RippleAnimation>(_st->_st->ripple, std::move(mask), [this] { _st->repaint(_item); });
|
||||||
}
|
}
|
||||||
button.ripple->add(_savedCoords - button.rect.topLeft());
|
button.ripple->add(_savedCoords - button.rect.topLeft());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -146,12 +146,12 @@ struct HistoryMessageReply : public RuntimeComponent<HistoryMessageReply> {
|
||||||
HistoryMessageReply &operator=(HistoryMessageReply &&other) {
|
HistoryMessageReply &operator=(HistoryMessageReply &&other) {
|
||||||
replyToMsgId = other.replyToMsgId;
|
replyToMsgId = other.replyToMsgId;
|
||||||
std::swap(replyToMsg, other.replyToMsg);
|
std::swap(replyToMsg, other.replyToMsg);
|
||||||
replyToLnk = std_::move(other.replyToLnk);
|
replyToLnk = std::move(other.replyToLnk);
|
||||||
replyToName = std_::move(other.replyToName);
|
replyToName = std::move(other.replyToName);
|
||||||
replyToText = std_::move(other.replyToText);
|
replyToText = std::move(other.replyToText);
|
||||||
replyToVersion = other.replyToVersion;
|
replyToVersion = other.replyToVersion;
|
||||||
_maxReplyWidth = other._maxReplyWidth;
|
_maxReplyWidth = other._maxReplyWidth;
|
||||||
_replyToVia = std_::move(other._replyToVia);
|
_replyToVia = std::move(other._replyToVia);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
~HistoryMessageReply() {
|
~HistoryMessageReply() {
|
||||||
|
@ -191,7 +191,7 @@ struct HistoryMessageReply : public RuntimeComponent<HistoryMessageReply> {
|
||||||
mutable Text replyToName, replyToText;
|
mutable Text replyToName, replyToText;
|
||||||
mutable int replyToVersion = 0;
|
mutable int replyToVersion = 0;
|
||||||
mutable int _maxReplyWidth = 0;
|
mutable int _maxReplyWidth = 0;
|
||||||
std_::unique_ptr<HistoryMessageVia> _replyToVia;
|
std::unique_ptr<HistoryMessageVia> _replyToVia;
|
||||||
int toWidth = 0;
|
int toWidth = 0;
|
||||||
};
|
};
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(HistoryMessageReply::PaintFlags);
|
Q_DECLARE_OPERATORS_FOR_FLAGS(HistoryMessageReply::PaintFlags);
|
||||||
|
@ -227,7 +227,7 @@ struct HistoryMessageReplyMarkup : public RuntimeComponent<HistoryMessageReplyMa
|
||||||
ButtonRows rows;
|
ButtonRows rows;
|
||||||
MTPDreplyKeyboardMarkup::Flags flags = 0;
|
MTPDreplyKeyboardMarkup::Flags flags = 0;
|
||||||
|
|
||||||
std_::unique_ptr<ReplyKeyboard> inlineKeyboard;
|
std::unique_ptr<ReplyKeyboard> inlineKeyboard;
|
||||||
|
|
||||||
// If >= 0 it holds the y coord of the inlineKeyboard before the last edition.
|
// If >= 0 it holds the y coord of the inlineKeyboard before the last edition.
|
||||||
int oldTop = -1;
|
int oldTop = -1;
|
||||||
|
@ -313,7 +313,7 @@ public:
|
||||||
friend class ReplyKeyboard;
|
friend class ReplyKeyboard;
|
||||||
|
|
||||||
};
|
};
|
||||||
typedef std_::unique_ptr<Style> StylePtr;
|
typedef std::unique_ptr<Style> StylePtr;
|
||||||
|
|
||||||
ReplyKeyboard(const HistoryItem *item, StylePtr &&s);
|
ReplyKeyboard(const HistoryItem *item, StylePtr &&s);
|
||||||
ReplyKeyboard(const ReplyKeyboard &other) = delete;
|
ReplyKeyboard(const ReplyKeyboard &other) = delete;
|
||||||
|
|
|
@ -89,7 +89,7 @@ void LocationManager::init() {
|
||||||
auto data = QImage(cIntRetinaFactor(), cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
|
auto data = QImage(cIntRetinaFactor(), cIntRetinaFactor(), QImage::Format_ARGB32_Premultiplied);
|
||||||
data.fill(st::imageBgTransparent->c);
|
data.fill(st::imageBgTransparent->c);
|
||||||
data.setDevicePixelRatio(cRetinaFactor());
|
data.setDevicePixelRatio(cRetinaFactor());
|
||||||
notLoadedPlaceholder = new ImagePtr(App::pixmapFromImageInPlace(std_::move(data)), "GIF");
|
notLoadedPlaceholder = new ImagePtr(App::pixmapFromImageInPlace(std::move(data)), "GIF");
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationManager::reinit() {
|
void LocationManager::reinit() {
|
||||||
|
|
|
@ -124,7 +124,7 @@ TextWithEntities captionedSelectedText(const QString &attachType, const Text &ca
|
||||||
result.text.append(qstr("[ ")).append(attachType).append(qstr(" ]"));
|
result.text.append(qstr("[ ")).append(attachType).append(qstr(" ]"));
|
||||||
if (!caption.isEmpty()) {
|
if (!caption.isEmpty()) {
|
||||||
result.text.append(qstr("\n"));
|
result.text.append(qstr("\n"));
|
||||||
appendTextWithEntities(result, std_::move(original));
|
appendTextWithEntities(result, std::move(original));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -171,9 +171,9 @@ void HistoryFileMedia::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryFileMedia::setLinks(ClickHandlerPtr &&openl, ClickHandlerPtr &&savel, ClickHandlerPtr &&cancell) {
|
void HistoryFileMedia::setLinks(ClickHandlerPtr &&openl, ClickHandlerPtr &&savel, ClickHandlerPtr &&cancell) {
|
||||||
_openl = std_::move(openl);
|
_openl = std::move(openl);
|
||||||
_savel = std_::move(savel);
|
_savel = std::move(savel);
|
||||||
_cancell = std_::move(cancell);
|
_cancell = std::move(cancell);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryFileMedia::setStatusSize(int32 newSize, int32 fullSize, int32 duration, qint64 realDuration) const {
|
void HistoryFileMedia::setStatusSize(int32 newSize, int32 fullSize, int32 duration, qint64 realDuration) const {
|
||||||
|
@ -204,7 +204,7 @@ void HistoryFileMedia::step_radial(TimeMs ms, bool timer) {
|
||||||
|
|
||||||
void HistoryFileMedia::ensureAnimation() const {
|
void HistoryFileMedia::ensureAnimation() const {
|
||||||
if (!_animation) {
|
if (!_animation) {
|
||||||
_animation = std_::make_unique<AnimationData>(animation(const_cast<HistoryFileMedia*>(this), &HistoryFileMedia::step_radial));
|
_animation = std::make_unique<AnimationData>(animation(const_cast<HistoryFileMedia*>(this), &HistoryFileMedia::step_radial));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -910,7 +910,7 @@ HistoryDocumentVoicePlayback::HistoryDocumentVoicePlayback(const HistoryDocument
|
||||||
|
|
||||||
void HistoryDocumentVoice::ensurePlayback(const HistoryDocument *that) const {
|
void HistoryDocumentVoice::ensurePlayback(const HistoryDocument *that) const {
|
||||||
if (!_playback) {
|
if (!_playback) {
|
||||||
_playback = std_::make_unique<HistoryDocumentVoicePlayback>(that);
|
_playback = std::make_unique<HistoryDocumentVoicePlayback>(that);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2573,16 +2573,16 @@ void HistoryWebPage::initDimensions() {
|
||||||
if (!_asArticle && !_attach) {
|
if (!_asArticle && !_attach) {
|
||||||
if (_data->document) {
|
if (_data->document) {
|
||||||
if (_data->document->sticker()) {
|
if (_data->document->sticker()) {
|
||||||
_attach = std_::make_unique<HistorySticker>(_parent, _data->document);
|
_attach = std::make_unique<HistorySticker>(_parent, _data->document);
|
||||||
} else if (_data->document->isAnimation()) {
|
} else if (_data->document->isAnimation()) {
|
||||||
_attach = std_::make_unique<HistoryGif>(_parent, _data->document, QString());
|
_attach = std::make_unique<HistoryGif>(_parent, _data->document, QString());
|
||||||
} else if (_data->document->isVideo()) {
|
} else if (_data->document->isVideo()) {
|
||||||
_attach = std_::make_unique<HistoryVideo>(_parent, _data->document, QString());
|
_attach = std::make_unique<HistoryVideo>(_parent, _data->document, QString());
|
||||||
} else {
|
} else {
|
||||||
_attach = std_::make_unique<HistoryDocument>(_parent, _data->document, QString());
|
_attach = std::make_unique<HistoryDocument>(_parent, _data->document, QString());
|
||||||
}
|
}
|
||||||
} else if (_data->photo) {
|
} else if (_data->photo) {
|
||||||
_attach = std_::make_unique<HistoryPhoto>(_parent, _data->photo, QString());
|
_attach = std::make_unique<HistoryPhoto>(_parent, _data->photo, QString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2992,7 +2992,7 @@ TextWithEntities HistoryWebPage::selectedText(TextSelection selection) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
titleResult.text += '\n';
|
titleResult.text += '\n';
|
||||||
appendTextWithEntities(titleResult, std_::move(descriptionResult));
|
appendTextWithEntities(titleResult, std::move(descriptionResult));
|
||||||
return titleResult;
|
return titleResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3046,16 +3046,16 @@ void HistoryGame::initDimensions() {
|
||||||
if (!_attach) {
|
if (!_attach) {
|
||||||
if (_data->document) {
|
if (_data->document) {
|
||||||
if (_data->document->sticker()) {
|
if (_data->document->sticker()) {
|
||||||
_attach = std_::make_unique<HistorySticker>(_parent, _data->document);
|
_attach = std::make_unique<HistorySticker>(_parent, _data->document);
|
||||||
} else if (_data->document->isAnimation()) {
|
} else if (_data->document->isAnimation()) {
|
||||||
_attach = std_::make_unique<HistoryGif>(_parent, _data->document, QString());
|
_attach = std::make_unique<HistoryGif>(_parent, _data->document, QString());
|
||||||
} else if (_data->document->isVideo()) {
|
} else if (_data->document->isVideo()) {
|
||||||
_attach = std_::make_unique<HistoryVideo>(_parent, _data->document, QString());
|
_attach = std::make_unique<HistoryVideo>(_parent, _data->document, QString());
|
||||||
} else {
|
} else {
|
||||||
_attach = std_::make_unique<HistoryDocument>(_parent, _data->document, QString());
|
_attach = std::make_unique<HistoryDocument>(_parent, _data->document, QString());
|
||||||
}
|
}
|
||||||
} else if (_data->photo) {
|
} else if (_data->photo) {
|
||||||
_attach = std_::make_unique<HistoryPhoto>(_parent, _data->photo, QString());
|
_attach = std::make_unique<HistoryPhoto>(_parent, _data->photo, QString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3363,7 +3363,7 @@ TextWithEntities HistoryGame::selectedText(TextSelection selection) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
titleResult.text += '\n';
|
titleResult.text += '\n';
|
||||||
appendTextWithEntities(titleResult, std_::move(descriptionResult));
|
appendTextWithEntities(titleResult, std::move(descriptionResult));
|
||||||
return titleResult;
|
return titleResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3636,7 +3636,7 @@ TextWithEntities HistoryLocation::selectedText(TextSelection selection) const {
|
||||||
TextWithEntities result = { qsl("[ ") + lang(lng_maps_point) + qsl(" ]\n"), EntitiesInText() };
|
TextWithEntities result = { qsl("[ ") + lang(lng_maps_point) + qsl(" ]\n"), EntitiesInText() };
|
||||||
auto info = selectedText(AllTextSelection);
|
auto info = selectedText(AllTextSelection);
|
||||||
if (!info.text.isEmpty()) {
|
if (!info.text.isEmpty()) {
|
||||||
appendTextWithEntities(result, std_::move(info));
|
appendTextWithEntities(result, std::move(info));
|
||||||
result.text.append('\n');
|
result.text.append('\n');
|
||||||
}
|
}
|
||||||
result.text += _link->dragText();
|
result.text += _link->dragText();
|
||||||
|
@ -3651,7 +3651,7 @@ TextWithEntities HistoryLocation::selectedText(TextSelection selection) const {
|
||||||
return titleResult;
|
return titleResult;
|
||||||
}
|
}
|
||||||
titleResult.text += '\n';
|
titleResult.text += '\n';
|
||||||
appendTextWithEntities(titleResult, std_::move(descriptionResult));
|
appendTextWithEntities(titleResult, std::move(descriptionResult));
|
||||||
return titleResult;
|
return titleResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ protected:
|
||||||
} else {
|
} else {
|
||||||
save.reset(new DocumentSaveClickHandler(document));
|
save.reset(new DocumentSaveClickHandler(document));
|
||||||
}
|
}
|
||||||
setLinks(std_::move(open), std_::move(save), MakeShared<DocumentCancelClickHandler>(document));
|
setLinks(std::move(open), std::move(save), MakeShared<DocumentCancelClickHandler>(document));
|
||||||
}
|
}
|
||||||
|
|
||||||
// >= 0 will contain download / upload string, _statusSize = loaded bytes
|
// >= 0 will contain download / upload string, _statusSize = loaded bytes
|
||||||
|
@ -99,12 +99,12 @@ protected:
|
||||||
|
|
||||||
struct AnimationData {
|
struct AnimationData {
|
||||||
AnimationData(AnimationCallbacks &&radialCallbacks)
|
AnimationData(AnimationCallbacks &&radialCallbacks)
|
||||||
: radial(std_::move(radialCallbacks)) {
|
: radial(std::move(radialCallbacks)) {
|
||||||
}
|
}
|
||||||
Animation a_thumbOver;
|
Animation a_thumbOver;
|
||||||
Ui::RadialAnimation radial;
|
Ui::RadialAnimation radial;
|
||||||
};
|
};
|
||||||
mutable std_::unique_ptr<AnimationData> _animation;
|
mutable std::unique_ptr<AnimationData> _animation;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ public:
|
||||||
void ensurePlayback(const HistoryDocument *interfaces) const;
|
void ensurePlayback(const HistoryDocument *interfaces) const;
|
||||||
void checkPlaybackFinished() const;
|
void checkPlaybackFinished() const;
|
||||||
|
|
||||||
mutable std_::unique_ptr<HistoryDocumentVoicePlayback> _playback;
|
mutable std::unique_ptr<HistoryDocumentVoicePlayback> _playback;
|
||||||
QSharedPointer<VoiceSeekClickHandler> _seekl;
|
QSharedPointer<VoiceSeekClickHandler> _seekl;
|
||||||
mutable int _lastDurationMs = 0;
|
mutable int _lastDurationMs = 0;
|
||||||
|
|
||||||
|
@ -757,7 +757,7 @@ private:
|
||||||
|
|
||||||
WebPageData *_data;
|
WebPageData *_data;
|
||||||
ClickHandlerPtr _openl;
|
ClickHandlerPtr _openl;
|
||||||
std_::unique_ptr<HistoryMedia> _attach;
|
std::unique_ptr<HistoryMedia> _attach;
|
||||||
|
|
||||||
bool _asArticle = false;
|
bool _asArticle = false;
|
||||||
int32 _titleLines, _descriptionLines;
|
int32 _titleLines, _descriptionLines;
|
||||||
|
@ -862,7 +862,7 @@ private:
|
||||||
|
|
||||||
GameData *_data;
|
GameData *_data;
|
||||||
ClickHandlerPtr _openl;
|
ClickHandlerPtr _openl;
|
||||||
std_::unique_ptr<HistoryMedia> _attach;
|
std::unique_ptr<HistoryMedia> _attach;
|
||||||
|
|
||||||
int32 _titleLines, _descriptionLines;
|
int32 _titleLines, _descriptionLines;
|
||||||
|
|
||||||
|
|
|
@ -826,7 +826,7 @@ void HistoryMessage::initDimensions() {
|
||||||
}
|
}
|
||||||
if (auto markup = inlineReplyMarkup()) {
|
if (auto markup = inlineReplyMarkup()) {
|
||||||
if (!markup->inlineKeyboard) {
|
if (!markup->inlineKeyboard) {
|
||||||
markup->inlineKeyboard.reset(new ReplyKeyboard(this, std_::make_unique<KeyboardStyle>(st::msgBotKbButton)));
|
markup->inlineKeyboard.reset(new ReplyKeyboard(this, std::make_unique<KeyboardStyle>(st::msgBotKbButton)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we have a text bubble we can resize it to fit the keyboard
|
// if we have a text bubble we can resize it to fit the keyboard
|
||||||
|
@ -989,7 +989,7 @@ TextWithEntities HistoryMessage::selectedText(TextSelection selection) const {
|
||||||
} else {
|
} else {
|
||||||
result.text = textResult.text + qstr("\n\n");
|
result.text = textResult.text + qstr("\n\n");
|
||||||
result.entities = textResult.entities;
|
result.entities = textResult.entities;
|
||||||
appendTextWithEntities(result, std_::move(mediaResult));
|
appendTextWithEntities(result, std::move(mediaResult));
|
||||||
}
|
}
|
||||||
if (auto fwd = Get<HistoryMessageForwarded>()) {
|
if (auto fwd = Get<HistoryMessageForwarded>()) {
|
||||||
if (selection == FullSelection) {
|
if (selection == FullSelection) {
|
||||||
|
@ -998,9 +998,9 @@ TextWithEntities HistoryMessage::selectedText(TextSelection selection) const {
|
||||||
wrapped.text.reserve(fwdinfo.text.size() + 4 + result.text.size());
|
wrapped.text.reserve(fwdinfo.text.size() + 4 + result.text.size());
|
||||||
wrapped.entities.reserve(fwdinfo.entities.size() + result.entities.size());
|
wrapped.entities.reserve(fwdinfo.entities.size() + result.entities.size());
|
||||||
wrapped.text.append('[');
|
wrapped.text.append('[');
|
||||||
appendTextWithEntities(wrapped, std_::move(fwdinfo));
|
appendTextWithEntities(wrapped, std::move(fwdinfo));
|
||||||
wrapped.text.append(qsl("]\n"));
|
wrapped.text.append(qsl("]\n"));
|
||||||
appendTextWithEntities(wrapped, std_::move(result));
|
appendTextWithEntities(wrapped, std::move(result));
|
||||||
result = wrapped;
|
result = wrapped;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1009,7 +1009,7 @@ TextWithEntities HistoryMessage::selectedText(TextSelection selection) const {
|
||||||
TextWithEntities wrapped;
|
TextWithEntities wrapped;
|
||||||
wrapped.text.reserve(lang(lng_in_reply_to).size() + reply->replyToMsg->author()->name.size() + 4 + result.text.size());
|
wrapped.text.reserve(lang(lng_in_reply_to).size() + reply->replyToMsg->author()->name.size() + 4 + result.text.size());
|
||||||
wrapped.text.append('[').append(lang(lng_in_reply_to)).append(' ').append(reply->replyToMsg->author()->name).append(qsl("]\n"));
|
wrapped.text.append('[').append(lang(lng_in_reply_to)).append(' ').append(reply->replyToMsg->author()->name).append(qsl("]\n"));
|
||||||
appendTextWithEntities(wrapped, std_::move(result));
|
appendTextWithEntities(wrapped, std::move(result));
|
||||||
result = wrapped;
|
result = wrapped;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ QPixmap circleCorner(int corner) {
|
||||||
auto part = QRect(xoffset, yoffset, size, size);
|
auto part = QRect(xoffset, yoffset, size, size);
|
||||||
auto result = style::colorizeImage(serviceMessageStyle->circle[maskType], st::msgServiceBg, part);
|
auto result = style::colorizeImage(serviceMessageStyle->circle[maskType], st::msgServiceBg, part);
|
||||||
result.setDevicePixelRatio(cRetinaFactor());
|
result.setDevicePixelRatio(cRetinaFactor());
|
||||||
serviceMessageStyle->corners[corner] = App::pixmapFromImageInPlace(std_::move(result));
|
serviceMessageStyle->corners[corner] = App::pixmapFromImageInPlace(std::move(result));
|
||||||
}
|
}
|
||||||
return serviceMessageStyle->corners[corner];
|
return serviceMessageStyle->corners[corner];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1038,7 +1038,7 @@ void HistoryInner::onDragExec() {
|
||||||
updateDragSelection(0, 0, false);
|
updateDragSelection(0, 0, false);
|
||||||
_widget->noSelectingScroll();
|
_widget->noSelectingScroll();
|
||||||
|
|
||||||
auto drag = std_::make_unique<QDrag>(App::wnd());
|
auto drag = std::make_unique<QDrag>(App::wnd());
|
||||||
if (!urls.isEmpty()) mimeData->setUrls(urls);
|
if (!urls.isEmpty()) mimeData->setUrls(urls);
|
||||||
if (uponSelected && !_selected.isEmpty() && _selected.cbegin().value() == FullSelection && !Adaptive::OneColumn()) {
|
if (uponSelected && !_selected.isEmpty() && _selected.cbegin().value() == FullSelection && !Adaptive::OneColumn()) {
|
||||||
mimeData->setData(qsl("application/x-td-forward-selected"), "1");
|
mimeData->setData(qsl("application/x-td-forward-selected"), "1");
|
||||||
|
@ -1067,8 +1067,8 @@ void HistoryInner::onDragExec() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!forwardMimeType.isEmpty()) {
|
if (!forwardMimeType.isEmpty()) {
|
||||||
auto drag = std_::make_unique<QDrag>(App::wnd());
|
auto drag = std::make_unique<QDrag>(App::wnd());
|
||||||
auto mimeData = std_::make_unique<QMimeData>();
|
auto mimeData = std::make_unique<QMimeData>();
|
||||||
|
|
||||||
mimeData->setData(forwardMimeType, "1");
|
mimeData->setData(forwardMimeType, "1");
|
||||||
if (auto document = (pressedMedia ? pressedMedia->getDocument() : nullptr)) {
|
if (auto document = (pressedMedia ? pressedMedia->getDocument() : nullptr)) {
|
||||||
|
@ -1597,7 +1597,7 @@ TextWithEntities HistoryInner::getSelectedText() const {
|
||||||
int y = itemTop(item);
|
int y = itemTop(item);
|
||||||
if (y >= 0) {
|
if (y >= 0) {
|
||||||
part.text.append(item->author()->name).append(time);
|
part.text.append(item->author()->name).append(time);
|
||||||
appendTextWithEntities(part, std_::move(unwrapped));
|
appendTextWithEntities(part, std::move(unwrapped));
|
||||||
texts.insert(y, part);
|
texts.insert(y, part);
|
||||||
fullSize += size;
|
fullSize += size;
|
||||||
}
|
}
|
||||||
|
@ -1607,7 +1607,7 @@ TextWithEntities HistoryInner::getSelectedText() const {
|
||||||
auto sep = qsl("\n\n");
|
auto sep = qsl("\n\n");
|
||||||
result.text.reserve(fullSize + (texts.size() - 1) * sep.size());
|
result.text.reserve(fullSize + (texts.size() - 1) * sep.size());
|
||||||
for (auto i = texts.begin(), e = texts.end(); i != e; ++i) {
|
for (auto i = texts.begin(), e = texts.end(); i != e; ++i) {
|
||||||
appendTextWithEntities(result, std_::move(i.value()));
|
appendTextWithEntities(result, std::move(i.value()));
|
||||||
if (i + 1 != e) {
|
if (i + 1 != e) {
|
||||||
result.text.append(sep);
|
result.text.append(sep);
|
||||||
}
|
}
|
||||||
|
@ -2672,7 +2672,7 @@ bool BotKeyboard::updateMarkup(HistoryItem *to, bool force) {
|
||||||
_impl = nullptr;
|
_impl = nullptr;
|
||||||
if (auto markup = to->Get<HistoryMessageReplyMarkup>()) {
|
if (auto markup = to->Get<HistoryMessageReplyMarkup>()) {
|
||||||
if (!markup->rows.isEmpty()) {
|
if (!markup->rows.isEmpty()) {
|
||||||
_impl.reset(new ReplyKeyboard(to, std_::make_unique<Style>(this, *_st)));
|
_impl.reset(new ReplyKeyboard(to, std::make_unique<Style>(this, *_st)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2717,7 +2717,7 @@ void BotKeyboard::updateStyle(int newWidth) {
|
||||||
int implWidth = newWidth - st::botKbButton.margin - st::botKbScroll.width;
|
int implWidth = newWidth - st::botKbButton.margin - st::botKbScroll.width;
|
||||||
_st = _impl->isEnoughSpace(implWidth, st::botKbButton) ? &st::botKbButton : &st::botKbTinyButton;
|
_st = _impl->isEnoughSpace(implWidth, st::botKbButton) ? &st::botKbButton : &st::botKbTinyButton;
|
||||||
|
|
||||||
_impl->setStyle(std_::make_unique<Style>(this, *_st));
|
_impl->setStyle(std::make_unique<Style>(this, *_st));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BotKeyboard::clearSelection() {
|
void BotKeyboard::clearSelection() {
|
||||||
|
@ -3211,7 +3211,7 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
|
||||||
connect(_fieldAutocomplete, SIGNAL(stickerChosen(DocumentData*,FieldAutocomplete::ChooseMethod)), this, SLOT(onStickerSend(DocumentData*)));
|
connect(_fieldAutocomplete, SIGNAL(stickerChosen(DocumentData*,FieldAutocomplete::ChooseMethod)), this, SLOT(onStickerSend(DocumentData*)));
|
||||||
connect(_fieldAutocomplete, SIGNAL(moderateKeyActivate(int,bool*)), this, SLOT(onModerateKeyActivate(int,bool*)));
|
connect(_fieldAutocomplete, SIGNAL(moderateKeyActivate(int,bool*)), this, SLOT(onModerateKeyActivate(int,bool*)));
|
||||||
_field->installEventFilter(_fieldAutocomplete);
|
_field->installEventFilter(_fieldAutocomplete);
|
||||||
_field->setTagMimeProcessor(std_::make_unique<FieldTagMimeProcessor>());
|
_field->setTagMimeProcessor(std::make_unique<FieldTagMimeProcessor>());
|
||||||
updateFieldSubmitSettings();
|
updateFieldSubmitSettings();
|
||||||
|
|
||||||
_field->hide();
|
_field->hide();
|
||||||
|
@ -3415,10 +3415,10 @@ void HistoryWidget::saveFieldToHistoryLocalDraft() {
|
||||||
if (!_history) return;
|
if (!_history) return;
|
||||||
|
|
||||||
if (_editMsgId) {
|
if (_editMsgId) {
|
||||||
_history->setEditDraft(std_::make_unique<Data::Draft>(_field, _editMsgId, _previewCancelled, _saveEditMsgRequestId));
|
_history->setEditDraft(std::make_unique<Data::Draft>(_field, _editMsgId, _previewCancelled, _saveEditMsgRequestId));
|
||||||
} else {
|
} else {
|
||||||
if (_replyToId || !_field->isEmpty()) {
|
if (_replyToId || !_field->isEmpty()) {
|
||||||
_history->setLocalDraft(std_::make_unique<Data::Draft>(_field, _replyToId, _previewCancelled));
|
_history->setLocalDraft(std::make_unique<Data::Draft>(_field, _replyToId, _previewCancelled));
|
||||||
} else {
|
} else {
|
||||||
_history->clearLocalDraft();
|
_history->clearLocalDraft();
|
||||||
}
|
}
|
||||||
|
@ -3658,7 +3658,7 @@ bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, U
|
||||||
TextWithTags textWithTags = { '@' + samePeerBot->username + ' ' + query, TextWithTags::Tags() };
|
TextWithTags textWithTags = { '@' + samePeerBot->username + ' ' + query, TextWithTags::Tags() };
|
||||||
MessageCursor cursor = { textWithTags.text.size(), textWithTags.text.size(), QFIXED_MAX };
|
MessageCursor cursor = { textWithTags.text.size(), textWithTags.text.size(), QFIXED_MAX };
|
||||||
auto replyTo = _history->peer->isUser() ? 0 : samePeerReplyTo;
|
auto replyTo = _history->peer->isUser() ? 0 : samePeerReplyTo;
|
||||||
_history->setLocalDraft(std_::make_unique<Data::Draft>(textWithTags, replyTo, cursor, false));
|
_history->setLocalDraft(std::make_unique<Data::Draft>(textWithTags, replyTo, cursor, false));
|
||||||
applyDraft();
|
applyDraft();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3671,7 +3671,7 @@ bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, U
|
||||||
History *h = App::history(toPeerId);
|
History *h = App::history(toPeerId);
|
||||||
TextWithTags textWithTags = { '@' + bot->username + ' ' + query, TextWithTags::Tags() };
|
TextWithTags textWithTags = { '@' + bot->username + ' ' + query, TextWithTags::Tags() };
|
||||||
MessageCursor cursor = { textWithTags.text.size(), textWithTags.text.size(), QFIXED_MAX };
|
MessageCursor cursor = { textWithTags.text.size(), textWithTags.text.size(), QFIXED_MAX };
|
||||||
h->setLocalDraft(std_::make_unique<Data::Draft>(textWithTags, 0, cursor, false));
|
h->setLocalDraft(std::make_unique<Data::Draft>(textWithTags, 0, cursor, false));
|
||||||
if (h == _history) {
|
if (h == _history) {
|
||||||
applyDraft();
|
applyDraft();
|
||||||
} else {
|
} else {
|
||||||
|
@ -6530,7 +6530,7 @@ bool HistoryWidget::showSendFilesBox(object_ptr<SendFilesBox> box, const QString
|
||||||
App::wnd()->activateWindow();
|
App::wnd()->activateWindow();
|
||||||
|
|
||||||
auto withComment = (addedComment != nullptr);
|
auto withComment = (addedComment != nullptr);
|
||||||
box->setConfirmedCallback(base::lambda_guarded(this, [this, withComment, sendCallback = std_::move(callback)](const QStringList &files, bool compressed, const QString &caption, bool ctrlShiftEnter) {
|
box->setConfirmedCallback(base::lambda_guarded(this, [this, withComment, sendCallback = std::move(callback)](const QStringList &files, bool compressed, const QString &caption, bool ctrlShiftEnter) {
|
||||||
if (!canWriteMessage()) return;
|
if (!canWriteMessage()) return;
|
||||||
|
|
||||||
auto replyTo = replyToId();
|
auto replyTo = replyToId();
|
||||||
|
@ -6552,7 +6552,7 @@ bool HistoryWidget::showSendFilesBox(object_ptr<SendFilesBox> box, const QString
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ui::show(std_::move(box));
|
Ui::show(std::move(box));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6598,7 +6598,7 @@ bool HistoryWidget::confirmSendingFiles(const SendingFilesLists &lists, Compress
|
||||||
auto type = compressed ? SendMediaType::Photo : SendMediaType::File;
|
auto type = compressed ? SendMediaType::Photo : SendMediaType::File;
|
||||||
uploadFilesAfterConfirmation(files, image, QByteArray(), type, caption);
|
uploadFilesAfterConfirmation(files, image, QByteArray(), type, caption);
|
||||||
};
|
};
|
||||||
return showSendFilesBox(std_::move(box), insertTextOnCancel, addedComment, std_::move(sendCallback));
|
return showSendFilesBox(std::move(box), insertTextOnCancel, addedComment, std::move(sendCallback));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6612,7 +6612,7 @@ bool HistoryWidget::confirmSendingFiles(const QImage &image, const QByteArray &c
|
||||||
uploadFilesAfterConfirmation(files, image, content, type, caption);
|
uploadFilesAfterConfirmation(files, image, content, type, caption);
|
||||||
};
|
};
|
||||||
auto box = Box<SendFilesBox>(QString(), image, imageCompressConfirm(image, compressed), animated);
|
auto box = Box<SendFilesBox>(QString(), image, imageCompressConfirm(image, compressed), animated);
|
||||||
return showSendFilesBox(std_::move(box), insertTextOnCancel, nullptr, std_::move(sendCallback));
|
return showSendFilesBox(std::move(box), insertTextOnCancel, nullptr, std::move(sendCallback));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::confirmSendingFiles(const QMimeData *data, CompressConfirm compressed, const QString &insertTextOnCancel) {
|
bool HistoryWidget::confirmSendingFiles(const QMimeData *data, CompressConfirm compressed, const QString &insertTextOnCancel) {
|
||||||
|
@ -6647,7 +6647,7 @@ bool HistoryWidget::confirmShareContact(const QString &phone, const QString &fna
|
||||||
shareContact(_peer->id, phone, fname, lname, replyTo);
|
shareContact(_peer->id, phone, fname, lname, replyTo);
|
||||||
};
|
};
|
||||||
auto insertTextOnCancel = QString();
|
auto insertTextOnCancel = QString();
|
||||||
return showSendFilesBox(std_::move(box), insertTextOnCancel, addedComment, std_::move(sendCallback));
|
return showSendFilesBox(std::move(box), insertTextOnCancel, addedComment, std::move(sendCallback));
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryWidget::SendingFilesLists HistoryWidget::getSendingFilesLists(const QList<QUrl> &files) {
|
HistoryWidget::SendingFilesLists HistoryWidget::getSendingFilesLists(const QList<QUrl> &files) {
|
||||||
|
@ -7726,7 +7726,7 @@ bool HistoryWidget::pinnedMsgVisibilityUpdated() {
|
||||||
}
|
}
|
||||||
if (pinnedMsgId) {
|
if (pinnedMsgId) {
|
||||||
if (!_pinnedBar) {
|
if (!_pinnedBar) {
|
||||||
_pinnedBar = std_::make_unique<PinnedBar>(pinnedMsgId, this);
|
_pinnedBar = std::make_unique<PinnedBar>(pinnedMsgId, this);
|
||||||
if (_a_show.animating()) {
|
if (_a_show.animating()) {
|
||||||
_pinnedBar->cancel->hide();
|
_pinnedBar->cancel->hide();
|
||||||
_pinnedBar->shadow->hide();
|
_pinnedBar->shadow->hide();
|
||||||
|
@ -7926,7 +7926,7 @@ void HistoryWidget::onReplyToMessage() {
|
||||||
if (auto localDraft = _history->localDraft()) {
|
if (auto localDraft = _history->localDraft()) {
|
||||||
localDraft->msgId = to->id;
|
localDraft->msgId = to->id;
|
||||||
} else {
|
} else {
|
||||||
_history->setLocalDraft(std_::make_unique<Data::Draft>(TextWithTags(), to->id, MessageCursor(), false));
|
_history->setLocalDraft(std::make_unique<Data::Draft>(TextWithTags(), to->id, MessageCursor(), false));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_replyEditMsg = to;
|
_replyEditMsg = to;
|
||||||
|
@ -7962,7 +7962,7 @@ void HistoryWidget::onEditMessage() {
|
||||||
}
|
}
|
||||||
if (!_editMsgId) {
|
if (!_editMsgId) {
|
||||||
if (_replyToId || !_field->isEmpty()) {
|
if (_replyToId || !_field->isEmpty()) {
|
||||||
_history->setLocalDraft(std_::make_unique<Data::Draft>(_field, _replyToId, _previewCancelled));
|
_history->setLocalDraft(std::make_unique<Data::Draft>(_field, _replyToId, _previewCancelled));
|
||||||
} else {
|
} else {
|
||||||
_history->clearLocalDraft();
|
_history->clearLocalDraft();
|
||||||
}
|
}
|
||||||
|
@ -7973,7 +7973,7 @@ void HistoryWidget::onEditMessage() {
|
||||||
auto editTags = textTagsFromEntities(original.entities);
|
auto editTags = textTagsFromEntities(original.entities);
|
||||||
TextWithTags editData = { editText, editTags };
|
TextWithTags editData = { editText, editTags };
|
||||||
MessageCursor cursor = { editText.size(), editText.size(), QFIXED_MAX };
|
MessageCursor cursor = { editText.size(), editText.size(), QFIXED_MAX };
|
||||||
_history->setEditDraft(std_::make_unique<Data::Draft>(editData, to->id, cursor, false));
|
_history->setEditDraft(std::make_unique<Data::Draft>(editData, to->id, cursor, false));
|
||||||
applyDraft(false);
|
applyDraft(false);
|
||||||
|
|
||||||
_previewData = nullptr;
|
_previewData = nullptr;
|
||||||
|
|
|
@ -203,7 +203,7 @@ private:
|
||||||
HistoryInner *_parent;
|
HistoryInner *_parent;
|
||||||
|
|
||||||
};
|
};
|
||||||
std_::unique_ptr<BotAbout> _botAbout;
|
std::unique_ptr<BotAbout> _botAbout;
|
||||||
|
|
||||||
HistoryWidget *_widget = nullptr;
|
HistoryWidget *_widget = nullptr;
|
||||||
Ui::ScrollArea *_scroll = nullptr;
|
Ui::ScrollArea *_scroll = nullptr;
|
||||||
|
@ -430,7 +430,7 @@ private:
|
||||||
bool _forceReply = false;
|
bool _forceReply = false;
|
||||||
|
|
||||||
QPoint _lastMousePos;
|
QPoint _lastMousePos;
|
||||||
std_::unique_ptr<ReplyKeyboard> _impl;
|
std::unique_ptr<ReplyKeyboard> _impl;
|
||||||
|
|
||||||
class Style : public ReplyKeyboard::Style {
|
class Style : public ReplyKeyboard::Style {
|
||||||
public:
|
public:
|
||||||
|
@ -920,7 +920,7 @@ private:
|
||||||
object_ptr<Ui::IconButton> cancel;
|
object_ptr<Ui::IconButton> cancel;
|
||||||
object_ptr<Ui::PlainShadow> shadow;
|
object_ptr<Ui::PlainShadow> shadow;
|
||||||
};
|
};
|
||||||
std_::unique_ptr<PinnedBar> _pinnedBar;
|
std::unique_ptr<PinnedBar> _pinnedBar;
|
||||||
void updatePinnedBar(bool force = false);
|
void updatePinnedBar(bool force = false);
|
||||||
bool pinnedMsgVisibilityUpdated();
|
bool pinnedMsgVisibilityUpdated();
|
||||||
void destroyPinnedBar();
|
void destroyPinnedBar();
|
||||||
|
|
|
@ -304,7 +304,7 @@ void Gif::prepareThumb(int32 width, int32 height, const QSize &frame) const {
|
||||||
|
|
||||||
void Gif::ensureAnimation() const {
|
void Gif::ensureAnimation() const {
|
||||||
if (!_animation) {
|
if (!_animation) {
|
||||||
_animation = std_::make_unique<AnimationData>(animation(const_cast<Gif*>(this), &Gif::step_radial));
|
_animation = std::make_unique<AnimationData>(animation(const_cast<Gif*>(this), &Gif::step_radial));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1198,7 +1198,7 @@ void Game::paint(Painter &p, const QRect &clip, const PaintContext *context) con
|
||||||
bool animating = (_gif && _gif->started());
|
bool animating = (_gif && _gif->started());
|
||||||
if (displayLoading) {
|
if (displayLoading) {
|
||||||
if (!_radial) {
|
if (!_radial) {
|
||||||
_radial = std_::make_unique<Ui::RadialAnimation>(animation(const_cast<Game*>(this), &Game::step_radial));
|
_radial = std::make_unique<Ui::RadialAnimation>(animation(const_cast<Game*>(this), &Game::step_radial));
|
||||||
}
|
}
|
||||||
if (!_radial->animating()) {
|
if (!_radial->animating()) {
|
||||||
_radial->start(document->progress());
|
_radial->start(document->progress());
|
||||||
|
|
|
@ -104,13 +104,13 @@ private:
|
||||||
struct AnimationData {
|
struct AnimationData {
|
||||||
AnimationData(AnimationCallbacks &&callbacks)
|
AnimationData(AnimationCallbacks &&callbacks)
|
||||||
: over(false)
|
: over(false)
|
||||||
, radial(std_::move(callbacks)) {
|
, radial(std::move(callbacks)) {
|
||||||
}
|
}
|
||||||
bool over;
|
bool over;
|
||||||
Animation _a_over;
|
Animation _a_over;
|
||||||
Ui::RadialAnimation radial;
|
Ui::RadialAnimation radial;
|
||||||
};
|
};
|
||||||
mutable std_::unique_ptr<AnimationData> _animation;
|
mutable std::unique_ptr<AnimationData> _animation;
|
||||||
mutable Animation _a_deleteOver;
|
mutable Animation _a_deleteOver;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -266,12 +266,12 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AnimationData {
|
struct AnimationData {
|
||||||
AnimationData(AnimationCallbacks &&radialCallbacks) : radial(std_::move(radialCallbacks)) {
|
AnimationData(AnimationCallbacks &&radialCallbacks) : radial(std::move(radialCallbacks)) {
|
||||||
}
|
}
|
||||||
Animation a_thumbOver;
|
Animation a_thumbOver;
|
||||||
Ui::RadialAnimation radial;
|
Ui::RadialAnimation radial;
|
||||||
};
|
};
|
||||||
mutable std_::unique_ptr<AnimationData> _animation;
|
mutable std::unique_ptr<AnimationData> _animation;
|
||||||
|
|
||||||
Text _title, _description;
|
Text _title, _description;
|
||||||
ClickHandlerPtr _open, _cancel;
|
ClickHandlerPtr _open, _cancel;
|
||||||
|
@ -354,7 +354,7 @@ private:
|
||||||
|
|
||||||
Media::Clip::ReaderPointer _gif;
|
Media::Clip::ReaderPointer _gif;
|
||||||
mutable QPixmap _thumb;
|
mutable QPixmap _thumb;
|
||||||
mutable std_::unique_ptr<Ui::RadialAnimation> _radial;
|
mutable std::unique_ptr<Ui::RadialAnimation> _radial;
|
||||||
Text _title, _description;
|
Text _title, _description;
|
||||||
|
|
||||||
QSize _frameSize;
|
QSize _frameSize;
|
||||||
|
|
|
@ -100,27 +100,27 @@ void ItemBase::update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std_::unique_ptr<ItemBase> ItemBase::createLayout(Result *result, bool forceThumb) {
|
std::unique_ptr<ItemBase> ItemBase::createLayout(Result *result, bool forceThumb) {
|
||||||
using Type = Result::Type;
|
using Type = Result::Type;
|
||||||
|
|
||||||
switch (result->_type) {
|
switch (result->_type) {
|
||||||
case Type::Photo: return std_::make_unique<internal::Photo>(result); break;
|
case Type::Photo: return std::make_unique<internal::Photo>(result); break;
|
||||||
case Type::Audio:
|
case Type::Audio:
|
||||||
case Type::File: return std_::make_unique<internal::File>(result); break;
|
case Type::File: return std::make_unique<internal::File>(result); break;
|
||||||
case Type::Video: return std_::make_unique<internal::Video>(result); break;
|
case Type::Video: return std::make_unique<internal::Video>(result); break;
|
||||||
case Type::Sticker: return std_::make_unique<internal::Sticker>(result); break;
|
case Type::Sticker: return std::make_unique<internal::Sticker>(result); break;
|
||||||
case Type::Gif: return std_::make_unique<internal::Gif>(result); break;
|
case Type::Gif: return std::make_unique<internal::Gif>(result); break;
|
||||||
case Type::Article:
|
case Type::Article:
|
||||||
case Type::Geo:
|
case Type::Geo:
|
||||||
case Type::Venue: return std_::make_unique<internal::Article>(result, forceThumb); break;
|
case Type::Venue: return std::make_unique<internal::Article>(result, forceThumb); break;
|
||||||
case Type::Game: return std_::make_unique<internal::Game>(result); break;
|
case Type::Game: return std::make_unique<internal::Game>(result); break;
|
||||||
case Type::Contact: return std_::make_unique<internal::Contact>(result); break;
|
case Type::Contact: return std::make_unique<internal::Contact>(result); break;
|
||||||
}
|
}
|
||||||
return std_::unique_ptr<ItemBase>();
|
return std::unique_ptr<ItemBase>();
|
||||||
}
|
}
|
||||||
|
|
||||||
std_::unique_ptr<ItemBase> ItemBase::createLayoutGif(DocumentData *document) {
|
std::unique_ptr<ItemBase> ItemBase::createLayoutGif(DocumentData *document) {
|
||||||
return std_::make_unique<internal::Gif>(document, true);
|
return std::make_unique<internal::Gif>(document, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
DocumentData *ItemBase::getResultDocument() const {
|
DocumentData *ItemBase::getResultDocument() const {
|
||||||
|
@ -150,7 +150,7 @@ QPixmap ItemBase::getResultContactAvatar(int width, int height) const {
|
||||||
if (result.height() != height * cIntRetinaFactor()) {
|
if (result.height() != height * cIntRetinaFactor()) {
|
||||||
result = result.scaled(QSize(width, height) * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
result = result.scaled(QSize(width, height) * cIntRetinaFactor(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
}
|
}
|
||||||
return std_::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
return QPixmap();
|
return QPixmap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,8 +91,8 @@ public:
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
static std_::unique_ptr<ItemBase> createLayout(Result *result, bool forceThumb);
|
static std::unique_ptr<ItemBase> createLayout(Result *result, bool forceThumb);
|
||||||
static std_::unique_ptr<ItemBase> createLayoutGif(DocumentData *document);
|
static std::unique_ptr<ItemBase> createLayoutGif(DocumentData *document);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DocumentData *getResultDocument() const;
|
DocumentData *getResultDocument() const;
|
||||||
|
|
|
@ -32,10 +32,10 @@ namespace InlineBots {
|
||||||
Result::Result(const Creator &creator) : _queryId(creator.queryId), _type(creator.type) {
|
Result::Result(const Creator &creator) : _queryId(creator.queryId), _type(creator.type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std_::unique_ptr<Result> Result::create(uint64 queryId, const MTPBotInlineResult &mtpData) {
|
std::unique_ptr<Result> Result::create(uint64 queryId, const MTPBotInlineResult &mtpData) {
|
||||||
using StringToTypeMap = QMap<QString, Result::Type>;
|
using StringToTypeMap = QMap<QString, Result::Type>;
|
||||||
static StaticNeverFreedPointer<StringToTypeMap> stringToTypeMap{ ([]() -> StringToTypeMap* {
|
static StaticNeverFreedPointer<StringToTypeMap> stringToTypeMap{ ([]() -> StringToTypeMap* {
|
||||||
auto result = std_::make_unique<StringToTypeMap>();
|
auto result = std::make_unique<StringToTypeMap>();
|
||||||
result->insert(qsl("photo"), Result::Type::Photo);
|
result->insert(qsl("photo"), Result::Type::Photo);
|
||||||
result->insert(qsl("video"), Result::Type::Video);
|
result->insert(qsl("video"), Result::Type::Video);
|
||||||
result->insert(qsl("audio"), Result::Type::Audio);
|
result->insert(qsl("audio"), Result::Type::Audio);
|
||||||
|
@ -61,10 +61,10 @@ std_::unique_ptr<Result> Result::create(uint64 queryId, const MTPBotInlineResult
|
||||||
};
|
};
|
||||||
Type type = getInlineResultType(mtpData);
|
Type type = getInlineResultType(mtpData);
|
||||||
if (type == Type::Unknown) {
|
if (type == Type::Unknown) {
|
||||||
return std_::unique_ptr<Result>();
|
return std::unique_ptr<Result>();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto result = std_::make_unique<Result>(Creator{ queryId, type });
|
auto result = std::make_unique<Result>(Creator{ queryId, type });
|
||||||
const MTPBotInlineMessage *message = nullptr;
|
const MTPBotInlineMessage *message = nullptr;
|
||||||
switch (mtpData.type()) {
|
switch (mtpData.type()) {
|
||||||
case mtpc_botInlineResult: {
|
case mtpc_botInlineResult: {
|
||||||
|
@ -101,18 +101,18 @@ std_::unique_ptr<Result> Result::create(uint64 queryId, const MTPBotInlineResult
|
||||||
bool badAttachment = (result->_photo && !result->_photo->access) || (result->_document && !result->_document->isValid());
|
bool badAttachment = (result->_photo && !result->_photo->access) || (result->_document && !result->_document->isValid());
|
||||||
|
|
||||||
if (!message) {
|
if (!message) {
|
||||||
return std_::unique_ptr<Result>();
|
return std::unique_ptr<Result>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure required media fields for layouts.
|
// Ensure required media fields for layouts.
|
||||||
if (result->_type == Type::Photo) {
|
if (result->_type == Type::Photo) {
|
||||||
if (!result->_photo && result->_content_url.isEmpty()) {
|
if (!result->_photo && result->_content_url.isEmpty()) {
|
||||||
return std_::unique_ptr<Result>();
|
return std::unique_ptr<Result>();
|
||||||
}
|
}
|
||||||
result->createPhoto();
|
result->createPhoto();
|
||||||
} else if (result->_type == Type::File || result->_type == Type::Gif || result->_type == Type::Sticker) {
|
} else if (result->_type == Type::File || result->_type == Type::Gif || result->_type == Type::Sticker) {
|
||||||
if (!result->_document && result->_content_url.isEmpty()) {
|
if (!result->_document && result->_content_url.isEmpty()) {
|
||||||
return std_::unique_ptr<Result>();
|
return std::unique_ptr<Result>();
|
||||||
}
|
}
|
||||||
result->createDocument();
|
result->createDocument();
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ std_::unique_ptr<Result> Result::create(uint64 queryId, const MTPBotInlineResult
|
||||||
result->sendData.reset(new internal::SendFile(result->_document, qs(r.vcaption)));
|
result->sendData.reset(new internal::SendFile(result->_document, qs(r.vcaption)));
|
||||||
}
|
}
|
||||||
if (r.has_reply_markup()) {
|
if (r.has_reply_markup()) {
|
||||||
result->_mtpKeyboard = std_::make_unique<MTPReplyMarkup>(r.vreply_markup);
|
result->_mtpKeyboard = std::make_unique<MTPReplyMarkup>(r.vreply_markup);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ std_::unique_ptr<Result> Result::create(uint64 queryId, const MTPBotInlineResult
|
||||||
result->createDocument();
|
result->createDocument();
|
||||||
}
|
}
|
||||||
if (r.has_reply_markup()) {
|
if (r.has_reply_markup()) {
|
||||||
result->_mtpKeyboard = std_::make_unique<MTPReplyMarkup>(r.vreply_markup);
|
result->_mtpKeyboard = std::make_unique<MTPReplyMarkup>(r.vreply_markup);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ std_::unique_ptr<Result> Result::create(uint64 queryId, const MTPBotInlineResult
|
||||||
badAttachment = true;
|
badAttachment = true;
|
||||||
}
|
}
|
||||||
if (r.has_reply_markup()) {
|
if (r.has_reply_markup()) {
|
||||||
result->_mtpKeyboard = std_::make_unique<MTPReplyMarkup>(r.vreply_markup);
|
result->_mtpKeyboard = std::make_unique<MTPReplyMarkup>(r.vreply_markup);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ std_::unique_ptr<Result> Result::create(uint64 queryId, const MTPBotInlineResult
|
||||||
badAttachment = true;
|
badAttachment = true;
|
||||||
}
|
}
|
||||||
if (r.has_reply_markup()) {
|
if (r.has_reply_markup()) {
|
||||||
result->_mtpKeyboard = std_::make_unique<MTPReplyMarkup>(r.vreply_markup);
|
result->_mtpKeyboard = std::make_unique<MTPReplyMarkup>(r.vreply_markup);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ std_::unique_ptr<Result> Result::create(uint64 queryId, const MTPBotInlineResult
|
||||||
auto &r = message->c_botInlineMessageMediaContact();
|
auto &r = message->c_botInlineMessageMediaContact();
|
||||||
result->sendData.reset(new internal::SendContact(qs(r.vfirst_name), qs(r.vlast_name), qs(r.vphone_number)));
|
result->sendData.reset(new internal::SendContact(qs(r.vfirst_name), qs(r.vlast_name), qs(r.vphone_number)));
|
||||||
if (r.has_reply_markup()) {
|
if (r.has_reply_markup()) {
|
||||||
result->_mtpKeyboard = std_::make_unique<MTPReplyMarkup>(r.vreply_markup);
|
result->_mtpKeyboard = std::make_unique<MTPReplyMarkup>(r.vreply_markup);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ std_::unique_ptr<Result> Result::create(uint64 queryId, const MTPBotInlineResult
|
||||||
}
|
}
|
||||||
|
|
||||||
if (badAttachment || !result->sendData || !result->sendData->isValid()) {
|
if (badAttachment || !result->sendData || !result->sendData->isValid()) {
|
||||||
return std_::unique_ptr<Result>();
|
return std::unique_ptr<Result>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result->_thumb->isNull() && !result->_thumb_url.isEmpty()) {
|
if (result->_thumb->isNull() && !result->_thumb_url.isEmpty()) {
|
||||||
|
|
|
@ -43,10 +43,10 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructor is public only for std_::make_unique<>() to work.
|
// Constructor is public only for std::make_unique<>() to work.
|
||||||
// You should use create() static method instead.
|
// You should use create() static method instead.
|
||||||
explicit Result(const Creator &creator);
|
explicit Result(const Creator &creator);
|
||||||
static std_::unique_ptr<Result> create(uint64 queryId, const MTPBotInlineResult &mtpData);
|
static std::unique_ptr<Result> create(uint64 queryId, const MTPBotInlineResult &mtpData);
|
||||||
Result(const Result &other) = delete;
|
Result(const Result &other) = delete;
|
||||||
Result &operator=(const Result &other) = delete;
|
Result &operator=(const Result &other) = delete;
|
||||||
|
|
||||||
|
@ -116,11 +116,11 @@ private:
|
||||||
PhotoData *_photo = nullptr;
|
PhotoData *_photo = nullptr;
|
||||||
GameData *_game = nullptr;
|
GameData *_game = nullptr;
|
||||||
|
|
||||||
std_::unique_ptr<MTPReplyMarkup> _mtpKeyboard;
|
std::unique_ptr<MTPReplyMarkup> _mtpKeyboard;
|
||||||
|
|
||||||
ImagePtr _thumb, _locationThumb;
|
ImagePtr _thumb, _locationThumb;
|
||||||
|
|
||||||
std_::unique_ptr<internal::SendData> sendData;
|
std::unique_ptr<internal::SendData> sendData;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ void PhoneWidget::showSignup() {
|
||||||
if (!_signup) {
|
if (!_signup) {
|
||||||
auto signupText = lng_phone_notreg(lt_link_start, textcmdStartLink(1), lt_link_end, textcmdStopLink(), lt_signup_start, textcmdStartLink(2), lt_signup_end, textcmdStopLink());
|
auto signupText = lng_phone_notreg(lt_link_start, textcmdStartLink(1), lt_link_end, textcmdStopLink(), lt_signup_start, textcmdStartLink(2), lt_signup_end, textcmdStopLink());
|
||||||
auto inner = object_ptr<Ui::FlatLabel>(this, signupText, Ui::FlatLabel::InitType::Rich, st::introDescription);
|
auto inner = object_ptr<Ui::FlatLabel>(this, signupText, Ui::FlatLabel::InitType::Rich, st::introDescription);
|
||||||
_signup.create(this, std_::move(inner), st::introErrorDuration);
|
_signup.create(this, std::move(inner), st::introErrorDuration);
|
||||||
_signup->entity()->setLink(1, MakeShared<UrlClickHandler>(qsl("https://telegram.org"), false));
|
_signup->entity()->setLink(1, MakeShared<UrlClickHandler>(qsl("https://telegram.org"), false));
|
||||||
_signup->entity()->setLink(2, MakeShared<LambdaClickHandler>([this] {
|
_signup->entity()->setLink(2, MakeShared<LambdaClickHandler>([this] {
|
||||||
toSignUp();
|
toSignUp();
|
||||||
|
|
|
@ -209,7 +209,7 @@ void Widget::appendStep(Step *step) {
|
||||||
void Widget::showResetButton() {
|
void Widget::showResetButton() {
|
||||||
if (!_resetAccount) {
|
if (!_resetAccount) {
|
||||||
auto entity = object_ptr<Ui::RoundButton>(this, lang(lng_signin_reset_account), st::introResetButton);
|
auto entity = object_ptr<Ui::RoundButton>(this, lang(lng_signin_reset_account), st::introResetButton);
|
||||||
_resetAccount.create(this, std_::move(entity), st::introErrorDuration);
|
_resetAccount.create(this, std::move(entity), st::introErrorDuration);
|
||||||
_resetAccount->hideFast();
|
_resetAccount->hideFast();
|
||||||
_resetAccount->entity()->setClickedCallback([this] { resetAccount(); });
|
_resetAccount->entity()->setClickedCallback([this] { resetAccount(); });
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
|
@ -579,7 +579,7 @@ void Widget::Step::prepareCoverMask() {
|
||||||
}
|
}
|
||||||
maskInts += maskIntsPerLineAdded;
|
maskInts += maskIntsPerLineAdded;
|
||||||
}
|
}
|
||||||
_coverMask = App::pixmapFromImageInPlace(std_::move(mask));
|
_coverMask = App::pixmapFromImageInPlace(std::move(mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::Step::paintCover(Painter &p, int top) {
|
void Widget::Step::paintCover(Painter &p, int top) {
|
||||||
|
@ -682,8 +682,8 @@ void Widget::Step::prepareShowAnimated(Step *after) {
|
||||||
} else {
|
} else {
|
||||||
auto leftSnapshot = after->prepareSlideAnimation();
|
auto leftSnapshot = after->prepareSlideAnimation();
|
||||||
auto rightSnapshot = prepareSlideAnimation();
|
auto rightSnapshot = prepareSlideAnimation();
|
||||||
_slideAnimation = std_::make_unique<Ui::SlideAnimation>();
|
_slideAnimation = std::make_unique<Ui::SlideAnimation>();
|
||||||
_slideAnimation->setSnapshots(std_::move(leftSnapshot), std_::move(rightSnapshot));
|
_slideAnimation->setSnapshots(std::move(leftSnapshot), std::move(rightSnapshot));
|
||||||
_slideAnimation->setOverflowHidden(false);
|
_slideAnimation->setOverflowHidden(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -694,7 +694,7 @@ Widget::Step::CoverAnimation Widget::Step::prepareCoverAnimation(Step *after) {
|
||||||
result.description = Ui::FlatLabel::CrossFade(after->_description->entity(), _description->entity(), st::introBg, after->_description->pos(), _description->pos());
|
result.description = Ui::FlatLabel::CrossFade(after->_description->entity(), _description->entity(), st::introBg, after->_description->pos(), _description->pos());
|
||||||
result.contentSnapshotWas = after->prepareContentSnapshot();
|
result.contentSnapshotWas = after->prepareContentSnapshot();
|
||||||
result.contentSnapshotNow = prepareContentSnapshot();
|
result.contentSnapshotNow = prepareContentSnapshot();
|
||||||
return std_::move(result);
|
return std::move(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap Widget::Step::prepareContentSnapshot() {
|
QPixmap Widget::Step::prepareContentSnapshot() {
|
||||||
|
@ -721,11 +721,11 @@ void Widget::Step::showAnimated(Direction direction) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::Step::setGoCallback(base::lambda<void(Step *step, Direction direction)> &&callback) {
|
void Widget::Step::setGoCallback(base::lambda<void(Step *step, Direction direction)> &&callback) {
|
||||||
_goCallback = std_::move(callback);
|
_goCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::Step::setShowResetCallback(base::lambda<void()> &&callback) {
|
void Widget::Step::setShowResetCallback(base::lambda<void()> &&callback) {
|
||||||
_showResetCallback = std_::move(callback);
|
_showResetCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::Step::showFast() {
|
void Widget::Step::showFast() {
|
||||||
|
|
|
@ -167,8 +167,8 @@ public:
|
||||||
CoverAnimation &operator=(CoverAnimation &&other) = default;
|
CoverAnimation &operator=(CoverAnimation &&other) = default;
|
||||||
~CoverAnimation();
|
~CoverAnimation();
|
||||||
|
|
||||||
std_::unique_ptr<Ui::CrossFadeAnimation> title;
|
std::unique_ptr<Ui::CrossFadeAnimation> title;
|
||||||
std_::unique_ptr<Ui::CrossFadeAnimation> description;
|
std::unique_ptr<Ui::CrossFadeAnimation> description;
|
||||||
|
|
||||||
// From content top till the next button top.
|
// From content top till the next button top.
|
||||||
QPixmap contentSnapshotWas;
|
QPixmap contentSnapshotWas;
|
||||||
|
@ -200,7 +200,7 @@ public:
|
||||||
|
|
||||||
Animation _a_show;
|
Animation _a_show;
|
||||||
CoverAnimation _coverAnimation;
|
CoverAnimation _coverAnimation;
|
||||||
std_::unique_ptr<Ui::SlideAnimation> _slideAnimation;
|
std::unique_ptr<Ui::SlideAnimation> _slideAnimation;
|
||||||
QPixmap _coverMask;
|
QPixmap _coverMask;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDoneCallback(base::lambda<void()> &&callback) {
|
void setDoneCallback(base::lambda<void()> &&callback) {
|
||||||
_doneCallback = std_::move(callback);
|
_doneCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLayerBoxes(const QRect &specialLayerBox, const QRect &layerBox);
|
void setLayerBoxes(const QRect &specialLayerBox, const QRect &layerBox);
|
||||||
|
@ -98,10 +98,10 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
void LayerStackWidget::BackgroundWidget::setCacheImages(QPixmap &&bodyCache, QPixmap &&mainMenuCache, QPixmap &&specialLayerCache, QPixmap &&layerCache) {
|
void LayerStackWidget::BackgroundWidget::setCacheImages(QPixmap &&bodyCache, QPixmap &&mainMenuCache, QPixmap &&specialLayerCache, QPixmap &&layerCache) {
|
||||||
_bodyCache = std_::move(bodyCache);
|
_bodyCache = std::move(bodyCache);
|
||||||
_mainMenuCache = std_::move(mainMenuCache);
|
_mainMenuCache = std::move(mainMenuCache);
|
||||||
_specialLayerCache = std_::move(specialLayerCache);
|
_specialLayerCache = std::move(specialLayerCache);
|
||||||
_layerCache = std_::move(layerCache);
|
_layerCache = std::move(layerCache);
|
||||||
_specialLayerCacheBox = _specialLayerBox;
|
_specialLayerCacheBox = _specialLayerBox;
|
||||||
_layerCacheBox = _layerBox;
|
_layerCacheBox = _layerBox;
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent, !_bodyCache.isNull());
|
setAttribute(Qt::WA_OpaquePaintEvent, !_bodyCache.isNull());
|
||||||
|
@ -259,7 +259,7 @@ void LayerStackWidget::BackgroundWidget::paintEvent(QPaintEvent *e) {
|
||||||
// in the transparent special layer cache corners after filling special layer
|
// in the transparent special layer cache corners after filling special layer
|
||||||
// rect above its cache with alpha_current opacity.
|
// rect above its cache with alpha_current opacity.
|
||||||
auto region = QRegion(bg) - specialLayerBox;
|
auto region = QRegion(bg) - specialLayerBox;
|
||||||
for_const (auto rect, region.rects()) {
|
for (auto rect : region.rects()) {
|
||||||
p.fillRect(rect, st::layerBg);
|
p.fillRect(rect, st::layerBg);
|
||||||
}
|
}
|
||||||
p.setOpacity((bgOpacity - overSpecialOpacity) / (1. - (overSpecialOpacity * st::layerBg->c.alphaF())));
|
p.setOpacity((bgOpacity - overSpecialOpacity) / (1. - (overSpecialOpacity * st::layerBg->c.alphaF())));
|
||||||
|
@ -410,7 +410,7 @@ void LayerStackWidget::setCacheImages() {
|
||||||
}
|
}
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent, !bodyCache.isNull());
|
setAttribute(Qt::WA_OpaquePaintEvent, !bodyCache.isNull());
|
||||||
updateLayerBoxes();
|
updateLayerBoxes();
|
||||||
_background->setCacheImages(std_::move(bodyCache), std_::move(mainMenuCache), std_::move(specialLayerCache), std_::move(layerCache));
|
_background->setCacheImages(std::move(bodyCache), std::move(mainMenuCache), std::move(specialLayerCache), std::move(layerCache));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStackWidget::onLayerClosed(LayerWidget *layer) {
|
void LayerStackWidget::onLayerClosed(LayerWidget *layer) {
|
||||||
|
@ -522,7 +522,7 @@ void LayerStackWidget::resizeEvent(QResizeEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStackWidget::showBox(object_ptr<BoxContent> box) {
|
void LayerStackWidget::showBox(object_ptr<BoxContent> box) {
|
||||||
auto pointer = pushBox(std_::move(box));
|
auto pointer = pushBox(std::move(box));
|
||||||
while (!_layers.isEmpty() && _layers.front() != pointer) {
|
while (!_layers.isEmpty() && _layers.front() != pointer) {
|
||||||
auto removingLayer = _layers.front();
|
auto removingLayer = _layers.front();
|
||||||
_layers.pop_front();
|
_layers.pop_front();
|
||||||
|
@ -590,9 +590,9 @@ void LayerStackWidget::showFinished() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStackWidget::showSpecialLayer(object_ptr<LayerWidget> layer) {
|
void LayerStackWidget::showSpecialLayer(object_ptr<LayerWidget> layer) {
|
||||||
startAnimation([this, layer = std_::move(layer)]() mutable {
|
startAnimation([this, layer = std::move(layer)]() mutable {
|
||||||
_specialLayer.destroyDelayed();
|
_specialLayer.destroyDelayed();
|
||||||
_specialLayer = std_::move(layer);
|
_specialLayer = std::move(layer);
|
||||||
initChildLayer(_specialLayer);
|
initChildLayer(_specialLayer);
|
||||||
}, [this] {
|
}, [this] {
|
||||||
clearLayers();
|
clearLayers();
|
||||||
|
@ -612,7 +612,7 @@ void LayerStackWidget::showMainMenu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerStackWidget::appendBox(object_ptr<BoxContent> box) {
|
void LayerStackWidget::appendBox(object_ptr<BoxContent> box) {
|
||||||
pushBox(std_::move(box));
|
pushBox(std::move(box));
|
||||||
}
|
}
|
||||||
|
|
||||||
LayerWidget *LayerStackWidget::pushBox(object_ptr<BoxContent> box) {
|
LayerWidget *LayerStackWidget::pushBox(object_ptr<BoxContent> box) {
|
||||||
|
@ -621,7 +621,7 @@ LayerWidget *LayerStackWidget::pushBox(object_ptr<BoxContent> box) {
|
||||||
if (oldLayer->inFocusChain()) setFocus();
|
if (oldLayer->inFocusChain()) setFocus();
|
||||||
oldLayer->hide();
|
oldLayer->hide();
|
||||||
}
|
}
|
||||||
auto layer = object_ptr<AbstractBox>(this, std_::move(box));
|
auto layer = object_ptr<AbstractBox>(this, std::move(box));
|
||||||
_layers.push_back(layer);
|
_layers.push_back(layer);
|
||||||
initChildLayer(layer);
|
initChildLayer(layer);
|
||||||
|
|
||||||
|
@ -641,9 +641,9 @@ LayerWidget *LayerStackWidget::pushBox(object_ptr<BoxContent> box) {
|
||||||
|
|
||||||
void LayerStackWidget::prependBox(object_ptr<BoxContent> box) {
|
void LayerStackWidget::prependBox(object_ptr<BoxContent> box) {
|
||||||
if (_layers.empty()) {
|
if (_layers.empty()) {
|
||||||
return showBox(std_::move(box));
|
return showBox(std::move(box));
|
||||||
}
|
}
|
||||||
auto layer = object_ptr<AbstractBox>(this, std_::move(box));
|
auto layer = object_ptr<AbstractBox>(this, std::move(box));
|
||||||
layer->hide();
|
layer->hide();
|
||||||
_layers.push_front(layer);
|
_layers.push_front(layer);
|
||||||
initChildLayer(layer);
|
initChildLayer(layer);
|
||||||
|
|
|
@ -46,10 +46,10 @@ public:
|
||||||
bool overlaps(const QRect &globalRect);
|
bool overlaps(const QRect &globalRect);
|
||||||
|
|
||||||
void setClosedCallback(base::lambda<void()> &&callback) {
|
void setClosedCallback(base::lambda<void()> &&callback) {
|
||||||
_closedCallback = std_::move(callback);
|
_closedCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
void setResizedCallback(base::lambda<void()> &&callback) {
|
void setResizedCallback(base::lambda<void()> &&callback) {
|
||||||
_resizedCallback = std_::move(callback);
|
_resizedCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -208,5 +208,5 @@ private:
|
||||||
template <typename BoxType, typename ...Args>
|
template <typename BoxType, typename ...Args>
|
||||||
inline object_ptr<BoxType> Box(Args&&... args) {
|
inline object_ptr<BoxType> Box(Args&&... args) {
|
||||||
auto parent = static_cast<QWidget*>(nullptr);
|
auto parent = static_cast<QWidget*>(nullptr);
|
||||||
return object_ptr<BoxType>(parent, std_::forward<Args>(args)...);
|
return object_ptr<BoxType>(parent, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,7 +256,7 @@ RoundCorners documentCorners(int32 colorIndex) {
|
||||||
|
|
||||||
bool documentIsValidMediaFile(const QString &filepath) {
|
bool documentIsValidMediaFile(const QString &filepath) {
|
||||||
static StaticNeverFreedPointer<QList<QString>> validMediaTypes(([] {
|
static StaticNeverFreedPointer<QList<QString>> validMediaTypes(([] {
|
||||||
std_::unique_ptr<QList<QString>> result = std_::make_unique<QList<QString>>();
|
std::unique_ptr<QList<QString>> result = std::make_unique<QList<QString>>();
|
||||||
*result = qsl("\
|
*result = qsl("\
|
||||||
webm mkv flv vob ogv ogg drc gif gifv mng avi mov qt wmv yuv rm rmvb asf amv mp4 m4p \
|
webm mkv flv vob ogv ogg drc gif gifv mng avi mov qt wmv yuv rm rmvb asf amv mp4 m4p \
|
||||||
m4v mpg mp2 mpeg mpe mpv m2v svi 3gp 3g2 mxf roq nsv f4v f4p f4a f4b wma divx evo mk3d \
|
m4v mpg mp2 mpeg mpe mpv m2v svi 3gp 3g2 mxf roq nsv f4v f4p f4a f4b wma divx evo mk3d \
|
||||||
|
@ -276,7 +276,7 @@ dwd smp aup cust mid mus sib sid ly gym vgm psf nsf mod ptb s3m xm it mt2 minips
|
||||||
|
|
||||||
bool documentIsExecutableName(const QString &filename) {
|
bool documentIsExecutableName(const QString &filename) {
|
||||||
static StaticNeverFreedPointer<QList<QString>> executableTypes(([] {
|
static StaticNeverFreedPointer<QList<QString>> executableTypes(([] {
|
||||||
std_::unique_ptr<QList<QString>> result = std_::make_unique<QList<QString>>();
|
std::unique_ptr<QList<QString>> result = std::make_unique<QList<QString>>();
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
*result = qsl("\
|
*result = qsl("\
|
||||||
action app bin command csh osx workflow\
|
action app bin command csh osx workflow\
|
||||||
|
|
|
@ -235,7 +235,7 @@ void FileLoadTask::process() {
|
||||||
auto mimeType = mimeTypeForData(_content);
|
auto mimeType = mimeTypeForData(_content);
|
||||||
filemime = mimeType.name();
|
filemime = mimeType.name();
|
||||||
if (filemime != stickerMime) {
|
if (filemime != stickerMime) {
|
||||||
fullimage = Images::prepareOpaque(std_::move(fullimage));
|
fullimage = Images::prepareOpaque(std::move(fullimage));
|
||||||
}
|
}
|
||||||
if (filemime == "image/jpeg") {
|
if (filemime == "image/jpeg") {
|
||||||
filename = filedialogDefaultName(qsl("photo"), qsl(".jpg"), QString(), true);
|
filename = filedialogDefaultName(qsl("photo"), qsl(".jpg"), QString(), true);
|
||||||
|
@ -270,7 +270,7 @@ void FileLoadTask::process() {
|
||||||
}
|
}
|
||||||
filesize = _content.size();
|
filesize = _content.size();
|
||||||
}
|
}
|
||||||
fullimage = Images::prepareOpaque(std_::move(fullimage));
|
fullimage = Images::prepareOpaque(std::move(fullimage));
|
||||||
}
|
}
|
||||||
_result->filesize = (int32)qMin(filesize, qint64(INT_MAX));
|
_result->filesize = (int32)qMin(filesize, qint64(INT_MAX));
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ void FileLoadTask::process() {
|
||||||
if (!cover.isNull()) { // cover to thumb
|
if (!cover.isNull()) { // cover to thumb
|
||||||
int32 cw = cover.width(), ch = cover.height();
|
int32 cw = cover.width(), ch = cover.height();
|
||||||
if (cw < 20 * ch && ch < 20 * cw) {
|
if (cw < 20 * ch && ch < 20 * cw) {
|
||||||
QPixmap full = (cw > 90 || ch > 90) ? App::pixmapFromImageInPlace(cover.scaled(90, 90, Qt::KeepAspectRatio, Qt::SmoothTransformation)) : App::pixmapFromImageInPlace(std_::move(cover));
|
QPixmap full = (cw > 90 || ch > 90) ? App::pixmapFromImageInPlace(cover.scaled(90, 90, Qt::KeepAspectRatio, Qt::SmoothTransformation)) : App::pixmapFromImageInPlace(std::move(cover));
|
||||||
{
|
{
|
||||||
QByteArray thumbFormat = "JPG";
|
QByteArray thumbFormat = "JPG";
|
||||||
int32 thumbQuality = 87;
|
int32 thumbQuality = 87;
|
||||||
|
@ -329,7 +329,7 @@ void FileLoadTask::process() {
|
||||||
attributes.push_back(animatedAttribute);
|
attributes.push_back(animatedAttribute);
|
||||||
gif = true;
|
gif = true;
|
||||||
|
|
||||||
QPixmap full = (cw > 90 || ch > 90) ? App::pixmapFromImageInPlace(cover.scaled(90, 90, Qt::KeepAspectRatio, Qt::SmoothTransformation)) : App::pixmapFromImageInPlace(std_::move(cover));
|
QPixmap full = (cw > 90 || ch > 90) ? App::pixmapFromImageInPlace(cover.scaled(90, 90, Qt::KeepAspectRatio, Qt::SmoothTransformation)) : App::pixmapFromImageInPlace(std::move(cover));
|
||||||
{
|
{
|
||||||
QByteArray thumbFormat = "JPG";
|
QByteArray thumbFormat = "JPG";
|
||||||
int32 thumbQuality = 87;
|
int32 thumbQuality = 87;
|
||||||
|
|
|
@ -2550,13 +2550,13 @@ void readDraftsWithCursors(History *h) {
|
||||||
if (msgData.text.isEmpty() && !msgReplyTo) {
|
if (msgData.text.isEmpty() && !msgReplyTo) {
|
||||||
h->clearLocalDraft();
|
h->clearLocalDraft();
|
||||||
} else {
|
} else {
|
||||||
h->setLocalDraft(std_::make_unique<Data::Draft>(msgData, msgReplyTo, msgCursor, msgPreviewCancelled));
|
h->setLocalDraft(std::make_unique<Data::Draft>(msgData, msgReplyTo, msgCursor, msgPreviewCancelled));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!editMsgId) {
|
if (!editMsgId) {
|
||||||
h->clearEditDraft();
|
h->clearEditDraft();
|
||||||
} else {
|
} else {
|
||||||
h->setEditDraft(std_::make_unique<Data::Draft>(editData, editMsgId, editCursor, editPreviewCancelled));
|
h->setEditDraft(std::make_unique<Data::Draft>(editData, editMsgId, editCursor, editPreviewCancelled));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3754,7 +3754,7 @@ bool readBackground() {
|
||||||
#endif // OS_MAC_OLD
|
#endif // OS_MAC_OLD
|
||||||
if (reader.read(&image)) {
|
if (reader.read(&image)) {
|
||||||
_backgroundCanWrite = false;
|
_backgroundCanWrite = false;
|
||||||
Window::Theme::Background()->setImage(id, std_::move(image));
|
Window::Theme::Background()->setImage(id, std::move(image));
|
||||||
_backgroundCanWrite = true;
|
_backgroundCanWrite = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -746,7 +746,7 @@ namespace internal {
|
||||||
struct SomeAllocatedMemoryChunk {
|
struct SomeAllocatedMemoryChunk {
|
||||||
char data[1024 * 1024];
|
char data[1024 * 1024];
|
||||||
};
|
};
|
||||||
std_::unique_ptr<SomeAllocatedMemoryChunk> SomeAllocatedMemory;
|
std::unique_ptr<SomeAllocatedMemoryChunk> SomeAllocatedMemory;
|
||||||
|
|
||||||
void OperatorNewHandler() {
|
void OperatorNewHandler() {
|
||||||
std::set_new_handler(nullptr);
|
std::set_new_handler(nullptr);
|
||||||
|
@ -755,7 +755,7 @@ namespace internal {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstallOperatorNewHandler() {
|
void InstallOperatorNewHandler() {
|
||||||
SomeAllocatedMemory = std_::make_unique<SomeAllocatedMemoryChunk>();
|
SomeAllocatedMemory = std::make_unique<SomeAllocatedMemoryChunk>();
|
||||||
std::set_new_handler(OperatorNewHandler);
|
std::set_new_handler(OperatorNewHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include "window/player_wrap_widget.h"
|
#include "window/player_wrap_widget.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
|
||||||
StackItemSection::StackItemSection(std_::unique_ptr<Window::SectionMemento> &&memento) : StackItem(nullptr)
|
StackItemSection::StackItemSection(std::unique_ptr<Window::SectionMemento> &&memento) : StackItem(nullptr)
|
||||||
, _memento(std_::move(memento)) {
|
, _memento(std::move(memento)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
StackItemSection::~StackItemSection() {
|
StackItemSection::~StackItemSection() {
|
||||||
|
@ -229,7 +229,7 @@ bool MainWidget::onShareUrl(const PeerId &peer, const QString &url, const QStrin
|
||||||
History *h = App::history(peer);
|
History *h = App::history(peer);
|
||||||
TextWithTags textWithTags = { url + '\n' + text, TextWithTags::Tags() };
|
TextWithTags textWithTags = { url + '\n' + text, TextWithTags::Tags() };
|
||||||
MessageCursor cursor = { url.size() + 1, url.size() + 1 + text.size(), QFIXED_MAX };
|
MessageCursor cursor = { url.size() + 1, url.size() + 1 + text.size(), QFIXED_MAX };
|
||||||
h->setLocalDraft(std_::make_unique<Data::Draft>(textWithTags, 0, cursor, false));
|
h->setLocalDraft(std::make_unique<Data::Draft>(textWithTags, 0, cursor, false));
|
||||||
h->clearEditDraft();
|
h->clearEditDraft();
|
||||||
bool opened = _history->peer() && (_history->peer()->id == peer);
|
bool opened = _history->peer() && (_history->peer()->id == peer);
|
||||||
if (opened) {
|
if (opened) {
|
||||||
|
@ -249,7 +249,7 @@ bool MainWidget::onInlineSwitchChosen(const PeerId &peer, const QString &botAndQ
|
||||||
History *h = App::history(peer);
|
History *h = App::history(peer);
|
||||||
TextWithTags textWithTags = { botAndQuery, TextWithTags::Tags() };
|
TextWithTags textWithTags = { botAndQuery, TextWithTags::Tags() };
|
||||||
MessageCursor cursor = { botAndQuery.size(), botAndQuery.size(), QFIXED_MAX };
|
MessageCursor cursor = { botAndQuery.size(), botAndQuery.size(), QFIXED_MAX };
|
||||||
h->setLocalDraft(std_::make_unique<Data::Draft>(textWithTags, 0, cursor, false));
|
h->setLocalDraft(std::make_unique<Data::Draft>(textWithTags, 0, cursor, false));
|
||||||
h->clearEditDraft();
|
h->clearEditDraft();
|
||||||
bool opened = _history->peer() && (_history->peer()->id == peer);
|
bool opened = _history->peer() && (_history->peer()->id == peer);
|
||||||
if (opened) {
|
if (opened) {
|
||||||
|
@ -638,7 +638,7 @@ void MainWidget::hiderLayer(object_ptr<HistoryHider> h) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_hider = std_::move(h);
|
_hider = std::move(h);
|
||||||
connect(_hider, SIGNAL(forwarded()), _dialogs, SLOT(onCancelSearch()));
|
connect(_hider, SIGNAL(forwarded()), _dialogs, SLOT(onCancelSearch()));
|
||||||
if (Adaptive::OneColumn()) {
|
if (Adaptive::OneColumn()) {
|
||||||
dialogsToUp();
|
dialogsToUp();
|
||||||
|
@ -1104,7 +1104,7 @@ void MainWidget::onCacheBackground() {
|
||||||
}
|
}
|
||||||
_cachedX = 0;
|
_cachedX = 0;
|
||||||
_cachedY = 0;
|
_cachedY = 0;
|
||||||
_cachedBackground = App::pixmapFromImageInPlace(std_::move(result));
|
_cachedBackground = App::pixmapFromImageInPlace(std::move(result));
|
||||||
} else {
|
} else {
|
||||||
auto &bg = Window::Theme::Background()->pixmap();
|
auto &bg = Window::Theme::Background()->pixmap();
|
||||||
|
|
||||||
|
@ -1874,7 +1874,7 @@ void MainWidget::updateScrollColors() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::setChatBackground(const App::WallPaper &wp) {
|
void MainWidget::setChatBackground(const App::WallPaper &wp) {
|
||||||
_background = std_::make_unique<App::WallPaper>(wp);
|
_background = std::make_unique<App::WallPaper>(wp);
|
||||||
_background->full->loadEvenCancelled();
|
_background->full->loadEvenCancelled();
|
||||||
checkChatBackground();
|
checkChatBackground();
|
||||||
}
|
}
|
||||||
|
@ -2014,7 +2014,7 @@ void MainWidget::fillPeerMenu(PeerData *peer, base::lambda<QAction*(const QStrin
|
||||||
if (update.peer != peer) return;
|
if (update.peer != peer) return;
|
||||||
pinAction->setText(lang(App::history(peer)->isPinnedDialog() ? lng_context_unpin_from_top : lng_context_pin_to_top));
|
pinAction->setText(lang(App::history(peer)->isPinnedDialog() ? lng_context_unpin_from_top : lng_context_pin_to_top));
|
||||||
});
|
});
|
||||||
*pinSubscription = Notify::PeerUpdated().add_subscription(std_::move(pinChangedHandler));
|
*pinSubscription = Notify::PeerUpdated().add_subscription(std::move(pinChangedHandler));
|
||||||
}
|
}
|
||||||
callback(lang((peer->isChat() || peer->isMegagroup()) ? lng_context_view_group : (peer->isUser() ? lng_context_view_profile : lng_context_view_channel)), [peer] {
|
callback(lang((peer->isChat() || peer->isMegagroup()) ? lng_context_view_group : (peer->isUser() ? lng_context_view_profile : lng_context_view_channel)), [peer] {
|
||||||
Ui::showPeerProfile(peer);
|
Ui::showPeerProfile(peer);
|
||||||
|
@ -2027,7 +2027,7 @@ void MainWidget::fillPeerMenu(PeerData *peer, base::lambda<QAction*(const QStrin
|
||||||
if (update.peer != peer) return;
|
if (update.peer != peer) return;
|
||||||
muteAction->setText(lang(peer->isMuted() ? lng_enable_notifications_from_tray : lng_disable_notifications_from_tray));
|
muteAction->setText(lang(peer->isMuted() ? lng_enable_notifications_from_tray : lng_disable_notifications_from_tray));
|
||||||
});
|
});
|
||||||
*muteSubscription = Notify::PeerUpdated().add_subscription(std_::move(muteChangedHandler));
|
*muteSubscription = Notify::PeerUpdated().add_subscription(std::move(muteChangedHandler));
|
||||||
|
|
||||||
callback(lang(lng_profile_search_messages), [peer] {
|
callback(lang(lng_profile_search_messages), [peer] {
|
||||||
App::main()->searchInPeer(peer);
|
App::main()->searchInPeer(peer);
|
||||||
|
@ -2066,8 +2066,8 @@ void MainWidget::fillPeerMenu(PeerData *peer, base::lambda<QAction*(const QStrin
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
if (auto user = peer->asUser()) {
|
if (auto user = peer->asUser()) {
|
||||||
callback(lang(lng_profile_delete_conversation), std_::move(deleteAndLeaveHandler));
|
callback(lang(lng_profile_delete_conversation), std::move(deleteAndLeaveHandler));
|
||||||
callback(lang(lng_profile_clear_history), std_::move(clearHistoryHandler));
|
callback(lang(lng_profile_clear_history), std::move(clearHistoryHandler));
|
||||||
if (!user->isInaccessible() && user != App::self()) {
|
if (!user->isInaccessible() && user != App::self()) {
|
||||||
auto blockSubscription = MakeShared<base::Subscription>();
|
auto blockSubscription = MakeShared<base::Subscription>();
|
||||||
auto blockAction = callback(lang(user->isBlocked() ? (user->botInfo ? lng_profile_unblock_bot : lng_profile_unblock_user) : (user->botInfo ? lng_profile_block_bot : lng_profile_block_user)), [user, blockSubscription] {
|
auto blockAction = callback(lang(user->isBlocked() ? (user->botInfo ? lng_profile_unblock_bot : lng_profile_unblock_user) : (user->botInfo ? lng_profile_block_bot : lng_profile_block_user)), [user, blockSubscription] {
|
||||||
|
@ -2077,26 +2077,26 @@ void MainWidget::fillPeerMenu(PeerData *peer, base::lambda<QAction*(const QStrin
|
||||||
emit App::main()->peerUpdated(user);
|
emit App::main()->peerUpdated(user);
|
||||||
});
|
});
|
||||||
if (willBeBlocked) {
|
if (willBeBlocked) {
|
||||||
MTP::send(MTPcontacts_Block(user->inputUser), std_::move(handler));
|
MTP::send(MTPcontacts_Block(user->inputUser), std::move(handler));
|
||||||
} else {
|
} else {
|
||||||
MTP::send(MTPcontacts_Unblock(user->inputUser), std_::move(handler));
|
MTP::send(MTPcontacts_Unblock(user->inputUser), std::move(handler));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
auto blockChangedHandler = Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::UserIsBlocked, [blockAction, peer](const Notify::PeerUpdate &update) {
|
auto blockChangedHandler = Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::UserIsBlocked, [blockAction, peer](const Notify::PeerUpdate &update) {
|
||||||
if (update.peer != peer) return;
|
if (update.peer != peer) return;
|
||||||
blockAction->setText(lang(peer->asUser()->isBlocked() ? (peer->asUser()->botInfo ? lng_profile_unblock_bot : lng_profile_unblock_user) : (peer->asUser()->botInfo ? lng_profile_block_bot : lng_profile_block_user)));
|
blockAction->setText(lang(peer->asUser()->isBlocked() ? (peer->asUser()->botInfo ? lng_profile_unblock_bot : lng_profile_unblock_user) : (peer->asUser()->botInfo ? lng_profile_block_bot : lng_profile_block_user)));
|
||||||
});
|
});
|
||||||
*blockSubscription = Notify::PeerUpdated().add_subscription(std_::move(blockChangedHandler));
|
*blockSubscription = Notify::PeerUpdated().add_subscription(std::move(blockChangedHandler));
|
||||||
|
|
||||||
if (user->blockStatus() == UserData::BlockStatus::Unknown) {
|
if (user->blockStatus() == UserData::BlockStatus::Unknown) {
|
||||||
App::api()->requestFullPeer(user);
|
App::api()->requestFullPeer(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (peer->isChat()) {
|
} else if (peer->isChat()) {
|
||||||
callback(lang(lng_profile_clear_and_exit), std_::move(deleteAndLeaveHandler));
|
callback(lang(lng_profile_clear_and_exit), std::move(deleteAndLeaveHandler));
|
||||||
callback(lang(lng_profile_clear_history), std_::move(clearHistoryHandler));
|
callback(lang(lng_profile_clear_history), std::move(clearHistoryHandler));
|
||||||
} else if (peer->isChannel() && peer->asChannel()->amIn() && !peer->asChannel()->amCreator()) {
|
} else if (peer->isChannel() && peer->asChannel()->amIn() && !peer->asChannel()->amCreator()) {
|
||||||
callback(lang(peer->isMegagroup() ? lng_profile_leave_group : lng_profile_leave_channel), std_::move(deleteAndLeaveHandler));
|
callback(lang(peer->isMegagroup() ? lng_profile_leave_group : lng_profile_leave_channel), std::move(deleteAndLeaveHandler));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2398,13 +2398,13 @@ bool MainWidget::mediaTypeSwitch() {
|
||||||
|
|
||||||
void MainWidget::saveSectionInStack() {
|
void MainWidget::saveSectionInStack() {
|
||||||
if (_overview) {
|
if (_overview) {
|
||||||
_stack.push_back(std_::make_unique<StackItemOverview>(_overview->peer(), _overview->type(), _overview->lastWidth(), _overview->lastScrollTop()));
|
_stack.push_back(std::make_unique<StackItemOverview>(_overview->peer(), _overview->type(), _overview->lastWidth(), _overview->lastScrollTop()));
|
||||||
} else if (_wideSection) {
|
} else if (_wideSection) {
|
||||||
_stack.push_back(std_::make_unique<StackItemSection>(_wideSection->createMemento()));
|
_stack.push_back(std::make_unique<StackItemSection>(_wideSection->createMemento()));
|
||||||
} else if (_history->peer()) {
|
} else if (_history->peer()) {
|
||||||
_peerInStack = _history->peer();
|
_peerInStack = _history->peer();
|
||||||
_msgIdInStack = _history->msgId();
|
_msgIdInStack = _history->msgId();
|
||||||
_stack.push_back(std_::make_unique<StackItemHistory>(_peerInStack, _msgIdInStack, _history->replyReturns()));
|
_stack.push_back(std::make_unique<StackItemHistory>(_peerInStack, _msgIdInStack, _history->replyReturns()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2608,7 +2608,7 @@ void MainWidget::showNewWideSection(const Window::SectionMemento *memento, bool
|
||||||
_wideSection->deleteLater();
|
_wideSection->deleteLater();
|
||||||
_wideSection = nullptr;
|
_wideSection = nullptr;
|
||||||
}
|
}
|
||||||
_wideSection = std_::move(newWideSection);
|
_wideSection = std::move(newWideSection);
|
||||||
_topBar->hide();
|
_topBar->hide();
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
_history->finishAnimation();
|
_history->finishAnimation();
|
||||||
|
@ -2631,17 +2631,17 @@ bool MainWidget::isSectionShown() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWidget::stackIsEmpty() const {
|
bool MainWidget::stackIsEmpty() const {
|
||||||
return _stack.isEmpty();
|
return _stack.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::showBackFromStack() {
|
void MainWidget::showBackFromStack() {
|
||||||
if (selectingPeer()) return;
|
if (selectingPeer()) return;
|
||||||
if (_stack.isEmpty()) {
|
if (_stack.empty()) {
|
||||||
Ui::showChatsList();
|
Ui::showChatsList();
|
||||||
if (App::wnd()) QTimer::singleShot(0, App::wnd(), SLOT(setInnerFocus()));
|
if (App::wnd()) QTimer::singleShot(0, App::wnd(), SLOT(setInnerFocus()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto item = std_::move(_stack.back());
|
auto item = std::move(_stack.back());
|
||||||
_stack.pop_back();
|
_stack.pop_back();
|
||||||
if (auto currentHistoryPeer = _history->peer()) {
|
if (auto currentHistoryPeer = _history->peer()) {
|
||||||
clearBotStartToken(currentHistoryPeer);
|
clearBotStartToken(currentHistoryPeer);
|
||||||
|
|
|
@ -93,7 +93,7 @@ public:
|
||||||
|
|
||||||
class StackItemSection : public StackItem {
|
class StackItemSection : public StackItem {
|
||||||
public:
|
public:
|
||||||
StackItemSection(std_::unique_ptr<Window::SectionMemento> &&memento);
|
StackItemSection(std::unique_ptr<Window::SectionMemento> &&memento);
|
||||||
~StackItemSection();
|
~StackItemSection();
|
||||||
|
|
||||||
StackItemType type() const {
|
StackItemType type() const {
|
||||||
|
@ -104,7 +104,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std_::unique_ptr<Window::SectionMemento> _memento;
|
std::unique_ptr<Window::SectionMemento> _memento;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -608,7 +608,7 @@ private:
|
||||||
|
|
||||||
QPointer<ConfirmBox> _forwardConfirm; // for single column layout
|
QPointer<ConfirmBox> _forwardConfirm; // for single column layout
|
||||||
object_ptr<HistoryHider> _hider = { nullptr };
|
object_ptr<HistoryHider> _hider = { nullptr };
|
||||||
std_::vector_of_moveable<std_::unique_ptr<StackItem>> _stack;
|
std::vector<std::unique_ptr<StackItem>> _stack;
|
||||||
PeerData *_peerInStack = nullptr;
|
PeerData *_peerInStack = nullptr;
|
||||||
MsgId _msgIdInStack = 0;
|
MsgId _msgIdInStack = 0;
|
||||||
|
|
||||||
|
@ -693,9 +693,9 @@ private:
|
||||||
void viewsIncrementDone(QVector<MTPint> ids, const MTPVector<MTPint> &result, mtpRequestId req);
|
void viewsIncrementDone(QVector<MTPint> ids, const MTPVector<MTPint> &result, mtpRequestId req);
|
||||||
bool viewsIncrementFail(const RPCError &error, mtpRequestId req);
|
bool viewsIncrementFail(const RPCError &error, mtpRequestId req);
|
||||||
|
|
||||||
std_::unique_ptr<App::WallPaper> _background;
|
std::unique_ptr<App::WallPaper> _background;
|
||||||
|
|
||||||
std_::unique_ptr<ApiWrap> _api;
|
std::unique_ptr<ApiWrap> _api;
|
||||||
|
|
||||||
bool _resizingSide = false;
|
bool _resizingSide = false;
|
||||||
int _resizingSideShift = 0;
|
int _resizingSideShift = 0;
|
||||||
|
|
|
@ -391,7 +391,7 @@ void MainWindow::showSpecialLayer(object_ptr<LayerWidget> layer) {
|
||||||
if (!_layerBg) {
|
if (!_layerBg) {
|
||||||
_layerBg.create(bodyWidget());
|
_layerBg.create(bodyWidget());
|
||||||
}
|
}
|
||||||
_layerBg->showSpecialLayer(std_::move(layer));
|
_layerBg->showSpecialLayer(std::move(layer));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showMainMenu() {
|
void MainWindow::showMainMenu() {
|
||||||
|
@ -450,12 +450,12 @@ void MainWindow::ui_showBox(object_ptr<BoxContent> box, ShowLayerOptions options
|
||||||
}
|
}
|
||||||
if (options.testFlag(KeepOtherLayers)) {
|
if (options.testFlag(KeepOtherLayers)) {
|
||||||
if (options.testFlag(ShowAfterOtherLayers)) {
|
if (options.testFlag(ShowAfterOtherLayers)) {
|
||||||
_layerBg->prependBox(std_::move(box));
|
_layerBg->prependBox(std::move(box));
|
||||||
} else {
|
} else {
|
||||||
_layerBg->appendBox(std_::move(box));
|
_layerBg->appendBox(std::move(box));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_layerBg->showBox(std_::move(box));
|
_layerBg->showBox(std::move(box));
|
||||||
}
|
}
|
||||||
if (options.testFlag(ForceFastShowLayer)) {
|
if (options.testFlag(ForceFastShowLayer)) {
|
||||||
_layerBg->finishAnimation();
|
_layerBg->finishAnimation();
|
||||||
|
|
|
@ -777,7 +777,7 @@ void Mixer::play(const AudioMsgId &audio, int64 position) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mixer::initFromVideo(uint64 videoPlayId, std_::unique_ptr<VideoSoundData> &&data, int64 position) {
|
void Mixer::initFromVideo(uint64 videoPlayId, std::unique_ptr<VideoSoundData> &&data, int64 position) {
|
||||||
AudioMsgId stopped;
|
AudioMsgId stopped;
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&AudioMutex);
|
QMutexLocker lock(&AudioMutex);
|
||||||
|
@ -811,7 +811,7 @@ void Mixer::initFromVideo(uint64 videoPlayId, std_::unique_ptr<VideoSoundData> &
|
||||||
current->clear();
|
current->clear();
|
||||||
current->state.id = AudioMsgId(AudioMsgId::Type::Video);
|
current->state.id = AudioMsgId(AudioMsgId::Type::Video);
|
||||||
current->videoPlayId = videoPlayId;
|
current->videoPlayId = videoPlayId;
|
||||||
current->videoData = std_::move(data);
|
current->videoData = std::move(data);
|
||||||
{
|
{
|
||||||
QMutexLocker videoLock(&_lastVideoMutex);
|
QMutexLocker videoLock(&_lastVideoMutex);
|
||||||
_lastVideoPlayId = current->videoPlayId;
|
_lastVideoPlayId = current->videoPlayId;
|
||||||
|
@ -947,7 +947,7 @@ void Mixer::resumeFromVideo(uint64 videoPlayId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mixer::feedFromVideo(VideoSoundPart &&part) {
|
void Mixer::feedFromVideo(VideoSoundPart &&part) {
|
||||||
_loader->feedFromVideo(std_::move(part));
|
_loader->feedFromVideo(std::move(part));
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeMs Mixer::getVideoCorrectedTime(uint64 playId, TimeMs frameMs, TimeMs systemMs) {
|
TimeMs Mixer::getVideoCorrectedTime(uint64 playId, TimeMs frameMs, TimeMs systemMs) {
|
||||||
|
|
|
@ -101,7 +101,7 @@ public:
|
||||||
void stop(AudioMsgId::Type type);
|
void stop(AudioMsgId::Type type);
|
||||||
|
|
||||||
// Video player audio stream interface.
|
// Video player audio stream interface.
|
||||||
void initFromVideo(uint64 videoPlayId, std_::unique_ptr<VideoSoundData> &&data, int64 position);
|
void initFromVideo(uint64 videoPlayId, std::unique_ptr<VideoSoundData> &&data, int64 position);
|
||||||
void feedFromVideo(VideoSoundPart &&part);
|
void feedFromVideo(VideoSoundPart &&part);
|
||||||
int64 getVideoCorrectedTime(uint64 playId, TimeMs frameMs, TimeMs systemMs);
|
int64 getVideoCorrectedTime(uint64 playId, TimeMs frameMs, TimeMs systemMs);
|
||||||
TrackState currentVideoState(uint64 videoPlayId);
|
TrackState currentVideoState(uint64 videoPlayId);
|
||||||
|
@ -183,7 +183,7 @@ private:
|
||||||
Stream stream;
|
Stream stream;
|
||||||
|
|
||||||
uint64 videoPlayId = 0;
|
uint64 videoPlayId = 0;
|
||||||
std_::unique_ptr<VideoSoundData> videoData;
|
std::unique_ptr<VideoSoundData> videoData;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createStream();
|
void createStream();
|
||||||
|
|
|
@ -312,7 +312,7 @@ AudioPlayerLoader *Loaders::setupLoader(const AudioMsgId &audio, SetupError &err
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!l) {
|
if (!l) {
|
||||||
std_::unique_ptr<AudioPlayerLoader> *loader = nullptr;
|
std::unique_ptr<AudioPlayerLoader> *loader = nullptr;
|
||||||
switch (audio.type()) {
|
switch (audio.type()) {
|
||||||
case AudioMsgId::Type::Voice: _audio = audio; loader = &_audioLoader; break;
|
case AudioMsgId::Type::Voice: _audio = audio; loader = &_audioLoader; break;
|
||||||
case AudioMsgId::Type::Song: _song = audio; loader = &_songLoader; break;
|
case AudioMsgId::Type::Song: _song = audio; loader = &_songLoader; break;
|
||||||
|
@ -326,10 +326,10 @@ AudioPlayerLoader *Loaders::setupLoader(const AudioMsgId &audio, SetupError &err
|
||||||
LOG(("Audio Error: video sound data not ready"));
|
LOG(("Audio Error: video sound data not ready"));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
_videoLoader = std_::make_unique<ChildFFMpegLoader>(track->videoPlayId, std_::move(track->videoData));
|
_videoLoader = std::make_unique<ChildFFMpegLoader>(track->videoPlayId, std::move(track->videoData));
|
||||||
l = _videoLoader.get();
|
l = _videoLoader.get();
|
||||||
} else {
|
} else {
|
||||||
*loader = std_::make_unique<FFMpegLoader>(track->file, track->data);
|
*loader = std::make_unique<FFMpegLoader>(track->file, track->data);
|
||||||
l = loader->get();
|
l = loader->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,9 +57,9 @@ private:
|
||||||
void clearFromVideoQueue();
|
void clearFromVideoQueue();
|
||||||
|
|
||||||
AudioMsgId _audio, _song, _video;
|
AudioMsgId _audio, _song, _video;
|
||||||
std_::unique_ptr<AudioPlayerLoader> _audioLoader;
|
std::unique_ptr<AudioPlayerLoader> _audioLoader;
|
||||||
std_::unique_ptr<AudioPlayerLoader> _songLoader;
|
std::unique_ptr<AudioPlayerLoader> _songLoader;
|
||||||
std_::unique_ptr<ChildFFMpegLoader> _videoLoader;
|
std::unique_ptr<ChildFFMpegLoader> _videoLoader;
|
||||||
|
|
||||||
QMutex _fromVideoMutex;
|
QMutex _fromVideoMutex;
|
||||||
uint64 _fromVideoPlayId;
|
uint64 _fromVideoPlayId;
|
||||||
|
|
|
@ -33,9 +33,9 @@ VideoSoundData::~VideoSoundData() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChildFFMpegLoader::ChildFFMpegLoader(uint64 videoPlayId, std_::unique_ptr<VideoSoundData> &&data) : AudioPlayerLoader(FileLocation(), QByteArray())
|
ChildFFMpegLoader::ChildFFMpegLoader(uint64 videoPlayId, std::unique_ptr<VideoSoundData> &&data) : AudioPlayerLoader(FileLocation(), QByteArray())
|
||||||
, _videoPlayId(videoPlayId)
|
, _videoPlayId(videoPlayId)
|
||||||
, _parentData(std_::move(data)) {
|
, _parentData(std::move(data)) {
|
||||||
_frame = av_frame_alloc();
|
_frame = av_frame_alloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ AudioPlayerLoader::ReadResult ChildFFMpegLoader::readFromReadyFrame(QByteArray &
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChildFFMpegLoader::enqueuePackets(QQueue<FFMpeg::AVPacketDataWrap> &packets) {
|
void ChildFFMpegLoader::enqueuePackets(QQueue<FFMpeg::AVPacketDataWrap> &packets) {
|
||||||
_queue += std_::move(packets);
|
_queue += std::move(packets);
|
||||||
packets.clear();
|
packets.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ inline void freePacket(AVPacket *packet) {
|
||||||
|
|
||||||
class ChildFFMpegLoader : public AudioPlayerLoader {
|
class ChildFFMpegLoader : public AudioPlayerLoader {
|
||||||
public:
|
public:
|
||||||
ChildFFMpegLoader(uint64 videoPlayId, std_::unique_ptr<VideoSoundData> &&data);
|
ChildFFMpegLoader(uint64 videoPlayId, std::unique_ptr<VideoSoundData> &&data);
|
||||||
|
|
||||||
bool open(qint64 &position) override;
|
bool open(qint64 &position) override;
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ private:
|
||||||
uint8_t **_dstSamplesData = nullptr;
|
uint8_t **_dstSamplesData = nullptr;
|
||||||
|
|
||||||
uint64 _videoPlayId = 0;
|
uint64 _videoPlayId = 0;
|
||||||
std_::unique_ptr<VideoSoundData> _parentData;
|
std::unique_ptr<VideoSoundData> _parentData;
|
||||||
AVSampleFormat _inputFormat;
|
AVSampleFormat _inputFormat;
|
||||||
AVFrame *_frame = nullptr;
|
AVFrame *_frame = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -389,7 +389,7 @@ bool FFMpegReaderImplementation::start(Mode mode, TimeMs &positionMs) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std_::unique_ptr<VideoSoundData> soundData;
|
std::unique_ptr<VideoSoundData> soundData;
|
||||||
if (_audioStreamId >= 0) {
|
if (_audioStreamId >= 0) {
|
||||||
AVCodecContext *audioContext = avcodec_alloc_context3(nullptr);
|
AVCodecContext *audioContext = avcodec_alloc_context3(nullptr);
|
||||||
if (!audioContext) {
|
if (!audioContext) {
|
||||||
|
@ -409,7 +409,7 @@ bool FFMpegReaderImplementation::start(Mode mode, TimeMs &positionMs) {
|
||||||
LOG(("Gif Error: Unable to avcodec_open2 %1, error %2, %3").arg(logData()).arg(res).arg(av_make_error_string(err, sizeof(err), res)));
|
LOG(("Gif Error: Unable to avcodec_open2 %1, error %2, %3").arg(logData()).arg(res).arg(av_make_error_string(err, sizeof(err), res)));
|
||||||
_audioStreamId = -1;
|
_audioStreamId = -1;
|
||||||
} else {
|
} else {
|
||||||
soundData = std_::make_unique<VideoSoundData>();
|
soundData = std::make_unique<VideoSoundData>();
|
||||||
soundData->context = audioContext;
|
soundData->context = audioContext;
|
||||||
soundData->frequency = _fmtContext->streams[_audioStreamId]->codecpar->sample_rate;
|
soundData->frequency = _fmtContext->streams[_audioStreamId]->codecpar->sample_rate;
|
||||||
if (_fmtContext->streams[_audioStreamId]->duration == AV_NOPTS_VALUE) {
|
if (_fmtContext->streams[_audioStreamId]->duration == AV_NOPTS_VALUE) {
|
||||||
|
@ -437,7 +437,7 @@ bool FFMpegReaderImplementation::start(Mode mode, TimeMs &positionMs) {
|
||||||
|
|
||||||
if (_audioStreamId >= 0) {
|
if (_audioStreamId >= 0) {
|
||||||
auto position = (positionMs * soundData->frequency) / 1000LL;
|
auto position = (positionMs * soundData->frequency) / 1000LL;
|
||||||
Player::mixer()->initFromVideo(_playId, std_::move(soundData), position);
|
Player::mixer()->initFromVideo(_playId, std::move(soundData), position);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (readResult == PacketResult::Ok) {
|
if (readResult == PacketResult::Ok) {
|
||||||
|
@ -490,7 +490,7 @@ FFMpegReaderImplementation::PacketResult FFMpegReaderImplementation::readPacket(
|
||||||
VideoSoundPart part;
|
VideoSoundPart part;
|
||||||
part.packet = &_packetNull;
|
part.packet = &_packetNull;
|
||||||
part.videoPlayId = _playId;
|
part.videoPlayId = _playId;
|
||||||
Player::mixer()->feedFromVideo(std_::move(part));
|
Player::mixer()->feedFromVideo(std::move(part));
|
||||||
}
|
}
|
||||||
return PacketResult::EndOfFile;
|
return PacketResult::EndOfFile;
|
||||||
}
|
}
|
||||||
|
@ -516,7 +516,7 @@ void FFMpegReaderImplementation::processPacket(AVPacket *packet) {
|
||||||
VideoSoundPart part;
|
VideoSoundPart part;
|
||||||
part.packet = packet;
|
part.packet = packet;
|
||||||
part.videoPlayId = _playId;
|
part.videoPlayId = _playId;
|
||||||
Player::mixer()->feedFromVideo(std_::move(part));
|
Player::mixer()->feedFromVideo(std::move(part));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
av_packet_unref(packet);
|
av_packet_unref(packet);
|
||||||
|
|
|
@ -86,7 +86,7 @@ QPixmap _prepareFrame(const FrameRequest &request, const QImage &original, bool
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Reader::Reader(const FileLocation &location, const QByteArray &data, Callback &&callback, Mode mode, int64 seekMs)
|
Reader::Reader(const FileLocation &location, const QByteArray &data, Callback &&callback, Mode mode, int64 seekMs)
|
||||||
: _callback(std_::move(callback))
|
: _callback(std::move(callback))
|
||||||
, _mode(mode)
|
, _mode(mode)
|
||||||
, _playId(rand_value<uint64>())
|
, _playId(rand_value<uint64>())
|
||||||
, _seekPositionMs(seekMs) {
|
, _seekPositionMs(seekMs) {
|
||||||
|
@ -336,7 +336,7 @@ public:
|
||||||
, _seekPositionMs(reader->seekPositionMs())
|
, _seekPositionMs(reader->seekPositionMs())
|
||||||
, _data(data) {
|
, _data(data) {
|
||||||
if (_data.isEmpty()) {
|
if (_data.isEmpty()) {
|
||||||
_location = std_::make_unique<FileLocation>(location);
|
_location = std::make_unique<FileLocation>(location);
|
||||||
if (!_location->accessEnable()) {
|
if (!_location->accessEnable()) {
|
||||||
error();
|
error();
|
||||||
return;
|
return;
|
||||||
|
@ -357,7 +357,7 @@ public:
|
||||||
|
|
||||||
auto firstFramePlayId = 0LL;
|
auto firstFramePlayId = 0LL;
|
||||||
auto firstFramePositionMs = 0LL;
|
auto firstFramePositionMs = 0LL;
|
||||||
auto reader = std_::make_unique<internal::FFMpegReaderImplementation>(_location.get(), &_data, firstFramePlayId);
|
auto reader = std::make_unique<internal::FFMpegReaderImplementation>(_location.get(), &_data, firstFramePlayId);
|
||||||
if (reader->start(internal::ReaderImplementation::Mode::Normal, firstFramePositionMs)) {
|
if (reader->start(internal::ReaderImplementation::Mode::Normal, firstFramePositionMs)) {
|
||||||
auto firstFrameReadResult = reader->readFramesTill(-1, ms);
|
auto firstFrameReadResult = reader->readFramesTill(-1, ms);
|
||||||
if (firstFrameReadResult == internal::ReaderImplementation::ReadResult::Success) {
|
if (firstFrameReadResult == internal::ReaderImplementation::ReadResult::Success) {
|
||||||
|
@ -464,7 +464,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_implementation = std_::make_unique<internal::FFMpegReaderImplementation>(_location.get(), &_data, _playId);
|
_implementation = std::make_unique<internal::FFMpegReaderImplementation>(_location.get(), &_data, _playId);
|
||||||
// _implementation = new QtGifReaderImplementation(_location, &_data);
|
// _implementation = new QtGifReaderImplementation(_location, &_data);
|
||||||
|
|
||||||
auto implementationMode = [this]() {
|
auto implementationMode = [this]() {
|
||||||
|
@ -530,11 +530,11 @@ private:
|
||||||
TimeMs _seekPositionMs = 0;
|
TimeMs _seekPositionMs = 0;
|
||||||
|
|
||||||
QByteArray _data;
|
QByteArray _data;
|
||||||
std_::unique_ptr<FileLocation> _location;
|
std::unique_ptr<FileLocation> _location;
|
||||||
bool _accessed = false;
|
bool _accessed = false;
|
||||||
|
|
||||||
QBuffer _buffer;
|
QBuffer _buffer;
|
||||||
std_::unique_ptr<internal::ReaderImplementation> _implementation;
|
std::unique_ptr<internal::ReaderImplementation> _implementation;
|
||||||
|
|
||||||
FrameRequest _request;
|
FrameRequest _request;
|
||||||
struct Frame {
|
struct Frame {
|
||||||
|
@ -839,7 +839,7 @@ MTPDocumentAttribute readAttributes(const QString &fname, const QByteArray &data
|
||||||
|
|
||||||
auto playId = 0ULL;
|
auto playId = 0ULL;
|
||||||
auto seekPositionMs = 0LL;
|
auto seekPositionMs = 0LL;
|
||||||
auto reader = std_::make_unique<internal::FFMpegReaderImplementation>(&localloc, &localdata, playId);
|
auto reader = std::make_unique<internal::FFMpegReaderImplementation>(&localloc, &localdata, playId);
|
||||||
if (reader->start(internal::ReaderImplementation::Mode::OnlyGifv, seekPositionMs)) {
|
if (reader->start(internal::ReaderImplementation::Mode::OnlyGifv, seekPositionMs)) {
|
||||||
bool hasAlpha = false;
|
bool hasAlpha = false;
|
||||||
auto readResult = reader->readFramesTill(-1, getms());
|
auto readResult = reader->readFramesTill(-1, getms());
|
||||||
|
|
|
@ -175,7 +175,7 @@ private:
|
||||||
|
|
||||||
template <typename ...Args>
|
template <typename ...Args>
|
||||||
inline ReaderPointer MakeReader(Args&&... args) {
|
inline ReaderPointer MakeReader(Args&&... args) {
|
||||||
return ReaderPointer(new Reader(std_::forward<Args>(args)...));
|
return ReaderPointer(new Reader(std::forward<Args>(args)...));
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class ProcessResult {
|
enum class ProcessResult {
|
||||||
|
|
|
@ -47,7 +47,7 @@ QPainterPath interpolatePaths(QPointF (&from)[N], QPointF (&to)[N], float64 k) {
|
||||||
|
|
||||||
PlayButtonLayout::PlayButtonLayout(const style::MediaPlayerButton &st, base::lambda<void()> &&callback)
|
PlayButtonLayout::PlayButtonLayout(const style::MediaPlayerButton &st, base::lambda<void()> &&callback)
|
||||||
: _st(st)
|
: _st(st)
|
||||||
, _callback(std_::move(callback)) {
|
, _callback(std::move(callback)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayButtonLayout::setState(State state) {
|
void PlayButtonLayout::setState(State state) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ CoverWidget::CoverWidget(QWidget *parent) : TWidget(parent)
|
||||||
, _nameLabel(this, st::mediaPlayerName)
|
, _nameLabel(this, st::mediaPlayerName)
|
||||||
, _timeLabel(this, st::mediaPlayerTime)
|
, _timeLabel(this, st::mediaPlayerTime)
|
||||||
, _close(this, st::mediaPlayerPanelClose)
|
, _close(this, st::mediaPlayerPanelClose)
|
||||||
, _playback(std_::make_unique<Clip::Playback>(new Ui::MediaSlider(this, st::mediaPlayerPanelPlayback)))
|
, _playback(std::make_unique<Clip::Playback>(new Ui::MediaSlider(this, st::mediaPlayerPanelPlayback)))
|
||||||
, _playPause(this)
|
, _playPause(this)
|
||||||
, _volumeToggle(this, st::mediaPlayerVolumeToggle)
|
, _volumeToggle(this, st::mediaPlayerVolumeToggle)
|
||||||
, _volumeController(this)
|
, _volumeController(this)
|
||||||
|
@ -127,11 +127,11 @@ CoverWidget::CoverWidget(QWidget *parent) : TWidget(parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoverWidget::setPinCallback(ButtonCallback &&callback) {
|
void CoverWidget::setPinCallback(ButtonCallback &&callback) {
|
||||||
_pinPlayer->setClickedCallback(std_::move(callback));
|
_pinPlayer->setClickedCallback(std::move(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoverWidget::setCloseCallback(ButtonCallback &&callback) {
|
void CoverWidget::setCloseCallback(ButtonCallback &&callback) {
|
||||||
_close->setClickedCallback(std_::move(callback));
|
_close->setClickedCallback(std::move(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoverWidget::handleSeekProgress(float64 progress) {
|
void CoverWidget::handleSeekProgress(float64 progress) {
|
||||||
|
|
|
@ -80,7 +80,7 @@ private:
|
||||||
object_ptr<Ui::FlatLabel> _nameLabel;
|
object_ptr<Ui::FlatLabel> _nameLabel;
|
||||||
object_ptr<Ui::LabelSimple> _timeLabel;
|
object_ptr<Ui::LabelSimple> _timeLabel;
|
||||||
object_ptr<Ui::IconButton> _close;
|
object_ptr<Ui::IconButton> _close;
|
||||||
std_::unique_ptr<Clip::Playback> _playback;
|
std::unique_ptr<Clip::Playback> _playback;
|
||||||
object_ptr<Ui::IconButton> _previousTrack = { nullptr };
|
object_ptr<Ui::IconButton> _previousTrack = { nullptr };
|
||||||
object_ptr<PlayButton> _playPause;
|
object_ptr<PlayButton> _playPause;
|
||||||
object_ptr<Ui::IconButton> _nextTrack = { nullptr };
|
object_ptr<Ui::IconButton> _nextTrack = { nullptr };
|
||||||
|
|
|
@ -222,14 +222,14 @@ void Panel::ensureCreated() {
|
||||||
|
|
||||||
if (_layout == Layout::Full) {
|
if (_layout == Layout::Full) {
|
||||||
_cover.create(this);
|
_cover.create(this);
|
||||||
setPinCallback(std_::move(_pinCallback));
|
setPinCallback(std::move(_pinCallback));
|
||||||
setCloseCallback(std_::move(_closeCallback));
|
setCloseCallback(std::move(_closeCallback));
|
||||||
|
|
||||||
_scrollShadow.create(this, st::mediaPlayerScrollShadow, Ui::Shadow::Side::Bottom);
|
_scrollShadow.create(this, st::mediaPlayerScrollShadow, Ui::Shadow::Side::Bottom);
|
||||||
}
|
}
|
||||||
auto list = object_ptr<ListWidget>(this);
|
auto list = object_ptr<ListWidget>(this);
|
||||||
connect(list, SIGNAL(heightUpdated()), this, SLOT(onListHeightUpdated()));
|
connect(list, SIGNAL(heightUpdated()), this, SLOT(onListHeightUpdated()));
|
||||||
_scroll->setOwnedWidget(std_::move(list));
|
_scroll->setOwnedWidget(std::move(list));
|
||||||
|
|
||||||
if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) {
|
if (cPlatform() == dbipMac || cPlatform() == dbipMacOld) {
|
||||||
if (auto window = App::wnd()) {
|
if (auto window = App::wnd()) {
|
||||||
|
@ -256,14 +256,14 @@ void Panel::performDestroy() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Panel::setPinCallback(ButtonCallback &&callback) {
|
void Panel::setPinCallback(ButtonCallback &&callback) {
|
||||||
_pinCallback = std_::move(callback);
|
_pinCallback = std::move(callback);
|
||||||
if (_cover) {
|
if (_cover) {
|
||||||
_cover->setPinCallback(ButtonCallback(_pinCallback));
|
_cover->setPinCallback(ButtonCallback(_pinCallback));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Panel::setCloseCallback(ButtonCallback &&callback) {
|
void Panel::setCloseCallback(ButtonCallback &&callback) {
|
||||||
_closeCallback = std_::move(callback);
|
_closeCallback = std::move(callback);
|
||||||
if (_cover) {
|
if (_cover) {
|
||||||
_cover->setCloseCallback(ButtonCallback(_closeCallback));
|
_cover->setCloseCallback(ButtonCallback(_closeCallback));
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ Widget::Widget(QWidget *parent) : TWidget(parent)
|
||||||
, _repeatTrack(this, st::mediaPlayerRepeatButton)
|
, _repeatTrack(this, st::mediaPlayerRepeatButton)
|
||||||
, _close(this, st::mediaPlayerClose)
|
, _close(this, st::mediaPlayerClose)
|
||||||
, _shadow(this, st::shadowFg)
|
, _shadow(this, st::shadowFg)
|
||||||
, _playback(std_::make_unique<Clip::Playback>(new Ui::FilledSlider(this, st::mediaPlayerPlayback))) {
|
, _playback(std::make_unique<Clip::Playback>(new Ui::FilledSlider(this, st::mediaPlayerPlayback))) {
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
resize(width(), st::mediaPlayerHeight + st::lineWidth);
|
resize(width(), st::mediaPlayerHeight + st::lineWidth);
|
||||||
|
@ -157,7 +157,7 @@ void Widget::updateVolumeToggleIcon() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::setCloseCallback(CloseCallback &&callback) {
|
void Widget::setCloseCallback(CloseCallback &&callback) {
|
||||||
_close->setClickedCallback(std_::move(callback));
|
_close->setClickedCallback(std::move(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::setShadowGeometryToLeft(int x, int y, int w, int h) {
|
void Widget::setShadowGeometryToLeft(int x, int y, int w, int h) {
|
||||||
|
|
|
@ -101,7 +101,7 @@ private:
|
||||||
object_ptr<Ui::IconButton> _repeatTrack;
|
object_ptr<Ui::IconButton> _repeatTrack;
|
||||||
object_ptr<Ui::IconButton> _close;
|
object_ptr<Ui::IconButton> _close;
|
||||||
object_ptr<Ui::PlainShadow> _shadow = { nullptr };
|
object_ptr<Ui::PlainShadow> _shadow = { nullptr };
|
||||||
std_::unique_ptr<Clip::Playback> _playback;
|
std::unique_ptr<Clip::Playback> _playback;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -35,12 +35,12 @@ namespace Clip {
|
||||||
|
|
||||||
Controller::Controller(QWidget *parent) : TWidget(parent)
|
Controller::Controller(QWidget *parent) : TWidget(parent)
|
||||||
, _playPauseResume(this, st::mediaviewPlayButton)
|
, _playPauseResume(this, st::mediaviewPlayButton)
|
||||||
, _playback(std_::make_unique<Playback>(new Ui::MediaSlider(this, st::mediaviewPlayback)))
|
, _playback(std::make_unique<Playback>(new Ui::MediaSlider(this, st::mediaviewPlayback)))
|
||||||
, _volumeController(this)
|
, _volumeController(this)
|
||||||
, _fullScreenToggle(this, st::mediaviewFullScreenButton)
|
, _fullScreenToggle(this, st::mediaviewFullScreenButton)
|
||||||
, _playedAlready(this, st::mediaviewPlayProgressLabel)
|
, _playedAlready(this, st::mediaviewPlayProgressLabel)
|
||||||
, _toPlayLeft(this, st::mediaviewPlayProgressLabel)
|
, _toPlayLeft(this, st::mediaviewPlayProgressLabel)
|
||||||
, _fadeAnimation(std_::make_unique<Ui::FadeAnimation>(this)) {
|
, _fadeAnimation(std::make_unique<Ui::FadeAnimation>(this)) {
|
||||||
_fadeAnimation->show();
|
_fadeAnimation->show();
|
||||||
_fadeAnimation->setFinishedCallback([this] { fadeFinished(); });
|
_fadeAnimation->setFinishedCallback([this] { fadeFinished(); });
|
||||||
_fadeAnimation->setUpdatedCallback([this](float64 opacity) { fadeUpdated(opacity); });
|
_fadeAnimation->setUpdatedCallback([this](float64 opacity) { fadeUpdated(opacity); });
|
||||||
|
|
|
@ -86,13 +86,13 @@ private:
|
||||||
TimeMs _lastDurationMs = 0;
|
TimeMs _lastDurationMs = 0;
|
||||||
|
|
||||||
object_ptr<Ui::IconButton> _playPauseResume;
|
object_ptr<Ui::IconButton> _playPauseResume;
|
||||||
std_::unique_ptr<Playback> _playback;
|
std::unique_ptr<Playback> _playback;
|
||||||
object_ptr<VolumeController> _volumeController;
|
object_ptr<VolumeController> _volumeController;
|
||||||
object_ptr<Ui::IconButton> _fullScreenToggle;
|
object_ptr<Ui::IconButton> _fullScreenToggle;
|
||||||
object_ptr<Ui::LabelSimple> _playedAlready;
|
object_ptr<Ui::LabelSimple> _playedAlready;
|
||||||
object_ptr<Ui::LabelSimple> _toPlayLeft;
|
object_ptr<Ui::LabelSimple> _toPlayLeft;
|
||||||
|
|
||||||
std_::unique_ptr<Ui::FadeAnimation> _fadeAnimation;
|
std::unique_ptr<Ui::FadeAnimation> _fadeAnimation;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,10 @@ public:
|
||||||
_slider->setFadeOpacity(opacity);
|
_slider->setFadeOpacity(opacity);
|
||||||
}
|
}
|
||||||
void setChangeProgressCallback(Ui::ContinuousSlider::Callback &&callback) {
|
void setChangeProgressCallback(Ui::ContinuousSlider::Callback &&callback) {
|
||||||
_slider->setChangeProgressCallback(std_::move(callback));
|
_slider->setChangeProgressCallback(std::move(callback));
|
||||||
}
|
}
|
||||||
void setChangeFinishedCallback(Ui::ContinuousSlider::Callback &&callback) {
|
void setChangeFinishedCallback(Ui::ContinuousSlider::Callback &&callback) {
|
||||||
_slider->setChangeFinishedCallback(std_::move(callback));
|
_slider->setChangeFinishedCallback(std::move(callback));
|
||||||
}
|
}
|
||||||
void setGeometry(int x, int y, int w, int h) {
|
void setGeometry(int x, int y, int w, int h) {
|
||||||
_slider->setGeometry(x, y, w, h);
|
_slider->setGeometry(x, y, w, h);
|
||||||
|
|
|
@ -1405,7 +1405,7 @@ void MediaView::createClipReader() {
|
||||||
_current = _doc->thumb->pixNoCache(_doc->thumb->width(), _doc->thumb->height(), Images::Option::Smooth | Images::Option::Blurred, st::mediaviewFileIconSize, st::mediaviewFileIconSize);
|
_current = _doc->thumb->pixNoCache(_doc->thumb->width(), _doc->thumb->height(), Images::Option::Smooth | Images::Option::Blurred, st::mediaviewFileIconSize, st::mediaviewFileIconSize);
|
||||||
}
|
}
|
||||||
auto mode = _doc->isVideo() ? Media::Clip::Reader::Mode::Video : Media::Clip::Reader::Mode::Gif;
|
auto mode = _doc->isVideo() ? Media::Clip::Reader::Mode::Video : Media::Clip::Reader::Mode::Gif;
|
||||||
_gif = std_::make_unique<Media::Clip::Reader>(_doc->location(), _doc->data(), [this](Media::Clip::Notification notification) {
|
_gif = std::make_unique<Media::Clip::Reader>(_doc->location(), _doc->data(), [this](Media::Clip::Notification notification) {
|
||||||
clipCallback(notification);
|
clipCallback(notification);
|
||||||
}, mode);
|
}, mode);
|
||||||
|
|
||||||
|
@ -1425,19 +1425,19 @@ void MediaView::initThemePreview() {
|
||||||
_themePreviewShown = true;
|
_themePreviewShown = true;
|
||||||
auto path = _doc->location().name();
|
auto path = _doc->location().name();
|
||||||
auto id = _themePreviewId = rand_value<uint64>();
|
auto id = _themePreviewId = rand_value<uint64>();
|
||||||
auto ready = base::lambda_guarded(this, [this, id](std_::unique_ptr<Window::Theme::Preview> result) {
|
auto ready = base::lambda_guarded(this, [this, id](std::unique_ptr<Window::Theme::Preview> result) {
|
||||||
if (id != _themePreviewId) {
|
if (id != _themePreviewId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_themePreviewId = 0;
|
_themePreviewId = 0;
|
||||||
_themePreview = std_::move(result);
|
_themePreview = std::move(result);
|
||||||
if (_themePreview) {
|
if (_themePreview) {
|
||||||
_themeApply.create(this, lang(lng_theme_preview_apply), st::themePreviewApplyButton);
|
_themeApply.create(this, lang(lng_theme_preview_apply), st::themePreviewApplyButton);
|
||||||
_themeApply->show();
|
_themeApply->show();
|
||||||
_themeApply->setClickedCallback([this] {
|
_themeApply->setClickedCallback([this] {
|
||||||
auto preview = std_::move(_themePreview);
|
auto preview = std::move(_themePreview);
|
||||||
close();
|
close();
|
||||||
Window::Theme::Apply(std_::move(preview));
|
Window::Theme::Apply(std::move(preview));
|
||||||
});
|
});
|
||||||
_themeCancel.create(this, lang(lng_cancel), st::themePreviewCancelButton);
|
_themeCancel.create(this, lang(lng_cancel), st::themePreviewCancelButton);
|
||||||
_themeCancel->show();
|
_themeCancel->show();
|
||||||
|
@ -1447,23 +1447,23 @@ void MediaView::initThemePreview() {
|
||||||
update();
|
update();
|
||||||
});
|
});
|
||||||
struct mutable_ready {
|
struct mutable_ready {
|
||||||
mutable_ready(decltype(ready) value) : value(std_::move(value)) {
|
mutable_ready(decltype(ready) value) : value(std::move(value)) {
|
||||||
}
|
}
|
||||||
mutable decltype(ready) value;
|
mutable decltype(ready) value;
|
||||||
};
|
};
|
||||||
struct mutable_result {
|
struct mutable_result {
|
||||||
mutable_result(std_::unique_ptr<Window::Theme::Preview> value) : value(std_::move(value)) {
|
mutable_result(std::unique_ptr<Window::Theme::Preview> value) : value(std::move(value)) {
|
||||||
}
|
}
|
||||||
mutable std_::unique_ptr<Window::Theme::Preview> value;
|
mutable std::unique_ptr<Window::Theme::Preview> value;
|
||||||
};
|
};
|
||||||
Window::Theme::CurrentData current;
|
Window::Theme::CurrentData current;
|
||||||
current.backgroundId = Window::Theme::Background()->id();
|
current.backgroundId = Window::Theme::Background()->id();
|
||||||
current.backgroundImage = Window::Theme::Background()->pixmap();
|
current.backgroundImage = Window::Theme::Background()->pixmap();
|
||||||
current.backgroundTiled = Window::Theme::Background()->tile();
|
current.backgroundTiled = Window::Theme::Background()->tile();
|
||||||
base::TaskQueue::Normal().Put([path, current, callback = mutable_ready(std_::move(ready))]() {
|
base::TaskQueue::Normal().Put([path, current, callback = mutable_ready(std::move(ready))]() {
|
||||||
auto preview = Window::Theme::GeneratePreview(path, current);
|
auto preview = Window::Theme::GeneratePreview(path, current);
|
||||||
base::TaskQueue::Main().Put([result = mutable_result(std_::move(preview)), callback = std_::move(callback.value)]() {
|
base::TaskQueue::Main().Put([result = mutable_result(std::move(preview)), callback = std::move(callback.value)]() {
|
||||||
callback(std_::move(result.value));
|
callback(std::move(result.value));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
location.accessDisable();
|
location.accessDisable();
|
||||||
|
@ -1528,7 +1528,7 @@ void MediaView::restartVideoAtSeekPosition(TimeMs positionMs) {
|
||||||
if (_current.isNull()) {
|
if (_current.isNull()) {
|
||||||
_current = _gif->current(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), ImageRoundRadius::None, ImageRoundCorner::None, getms());
|
_current = _gif->current(_gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), _gif->width() / cIntRetinaFactor(), _gif->height() / cIntRetinaFactor(), ImageRoundRadius::None, ImageRoundCorner::None, getms());
|
||||||
}
|
}
|
||||||
_gif = std_::make_unique<Media::Clip::Reader>(_doc->location(), _doc->data(), [this](Media::Clip::Notification notification) {
|
_gif = std::make_unique<Media::Clip::Reader>(_doc->location(), _doc->data(), [this](Media::Clip::Notification notification) {
|
||||||
clipCallback(notification);
|
clipCallback(notification);
|
||||||
}, Media::Clip::Reader::Mode::Video, positionMs);
|
}, Media::Clip::Reader::Mode::Video, positionMs);
|
||||||
|
|
||||||
|
|
|
@ -256,7 +256,7 @@ private:
|
||||||
bool _pressed = false;
|
bool _pressed = false;
|
||||||
int32 _dragging = 0;
|
int32 _dragging = 0;
|
||||||
QPixmap _current;
|
QPixmap _current;
|
||||||
std_::unique_ptr<Media::Clip::Reader> _gif;
|
std::unique_ptr<Media::Clip::Reader> _gif;
|
||||||
int32 _full = -1; // -1 - thumb, 0 - medium, 1 - full
|
int32 _full = -1; // -1 - thumb, 0 - medium, 1 - full
|
||||||
|
|
||||||
// Video without audio stream playback information.
|
// Video without audio stream playback information.
|
||||||
|
@ -365,7 +365,7 @@ private:
|
||||||
bool _themePreviewShown = false;
|
bool _themePreviewShown = false;
|
||||||
uint64 _themePreviewId = 0;
|
uint64 _themePreviewId = 0;
|
||||||
QRect _themePreviewRect;
|
QRect _themePreviewRect;
|
||||||
std_::unique_ptr<Window::Theme::Preview> _themePreview;
|
std::unique_ptr<Window::Theme::Preview> _themePreview;
|
||||||
object_ptr<Ui::RoundButton> _themeApply = { nullptr };
|
object_ptr<Ui::RoundButton> _themeApply = { nullptr };
|
||||||
object_ptr<Ui::RoundButton> _themeCancel = { nullptr };
|
object_ptr<Ui::RoundButton> _themeCancel = { nullptr };
|
||||||
|
|
||||||
|
|
|
@ -2383,8 +2383,8 @@ void ConnectionPrivate::updateAuthKey() {
|
||||||
return authKeyCreated();
|
return authKeyCreated();
|
||||||
}
|
}
|
||||||
|
|
||||||
_authKeyData = std_::make_unique<ConnectionPrivate::AuthKeyCreateData>();
|
_authKeyData = std::make_unique<ConnectionPrivate::AuthKeyCreateData>();
|
||||||
_authKeyStrings = std_::make_unique<ConnectionPrivate::AuthKeyCreateStrings>();
|
_authKeyStrings = std::make_unique<ConnectionPrivate::AuthKeyCreateStrings>();
|
||||||
_authKeyData->req_num = 0;
|
_authKeyData->req_num = 0;
|
||||||
_authKeyData->nonce = rand_value<MTPint128>();
|
_authKeyData->nonce = rand_value<MTPint128>();
|
||||||
|
|
||||||
|
|
|
@ -262,8 +262,8 @@ private:
|
||||||
QByteArray dh_prime;
|
QByteArray dh_prime;
|
||||||
QByteArray g_a;
|
QByteArray g_a;
|
||||||
};
|
};
|
||||||
std_::unique_ptr<AuthKeyCreateData> _authKeyData;
|
std::unique_ptr<AuthKeyCreateData> _authKeyData;
|
||||||
std_::unique_ptr<AuthKeyCreateStrings> _authKeyStrings;
|
std::unique_ptr<AuthKeyCreateStrings> _authKeyStrings;
|
||||||
|
|
||||||
void dhClientParamsSend();
|
void dhClientParamsSend();
|
||||||
void authKeyCreated();
|
void authKeyCreated();
|
||||||
|
|
|
@ -98,7 +98,7 @@ void FileLoader::readImage(const QSize &shrinkBox) const {
|
||||||
if (!shrinkBox.isEmpty() && (image.width() > shrinkBox.width() || image.height() > shrinkBox.height())) {
|
if (!shrinkBox.isEmpty() && (image.width() > shrinkBox.width() || image.height() > shrinkBox.height())) {
|
||||||
_imagePixmap = App::pixmapFromImageInPlace(image.scaled(shrinkBox, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
_imagePixmap = App::pixmapFromImageInPlace(image.scaled(shrinkBox, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||||
} else {
|
} else {
|
||||||
_imagePixmap = App::pixmapFromImageInPlace(std_::move(image));
|
_imagePixmap = App::pixmapFromImageInPlace(std::move(image));
|
||||||
}
|
}
|
||||||
_imageFormat = format;
|
_imageFormat = format;
|
||||||
}
|
}
|
||||||
|
|
|
@ -834,7 +834,7 @@ protected:
|
||||||
using Parent = RPCHandlerImplementation<Base, FunctionType>;
|
using Parent = RPCHandlerImplementation<Base, FunctionType>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RPCHandlerImplementation(Lambda &&handler) : _handler(std_::move(handler)) {
|
RPCHandlerImplementation(Lambda &&handler) : _handler(std::move(handler)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -907,37 +907,37 @@ public:
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R(const mtpPrime*, const mtpPrime*)> &&lambda) {
|
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R(const mtpPrime*, const mtpPrime*)> &&lambda) {
|
||||||
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationBare<R>(std_::move(lambda)));
|
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationBare<R>(std::move(lambda)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R(const mtpPrime*, const mtpPrime*, mtpRequestId)> &&lambda) {
|
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R(const mtpPrime*, const mtpPrime*, mtpRequestId)> &&lambda) {
|
||||||
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationBareReq<R>(std_::move(lambda)));
|
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationBareReq<R>(std::move(lambda)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R, typename T>
|
template <typename R, typename T>
|
||||||
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R(const T&)> &&lambda) {
|
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R(const T&)> &&lambda) {
|
||||||
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationPlain<R, T>(std_::move(lambda)));
|
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationPlain<R, T>(std::move(lambda)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R, typename T>
|
template <typename R, typename T>
|
||||||
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R(const T&, mtpRequestId)> &&lambda) {
|
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R(const T&, mtpRequestId)> &&lambda) {
|
||||||
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationReq<R, T>(std_::move(lambda)));
|
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationReq<R, T>(std::move(lambda)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R()> &&lambda) {
|
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R()> &&lambda) {
|
||||||
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationNo<R>(std_::move(lambda)));
|
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationNo<R>(std::move(lambda)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R>
|
template <typename R>
|
||||||
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R(mtpRequestId)> &&lambda) {
|
inline RPCDoneHandlerPtr rpcDone_lambda_wrap_helper(base::lambda<R(mtpRequestId)> &&lambda) {
|
||||||
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationNoReq<R>(std_::move(lambda)));
|
return RPCDoneHandlerPtr(new RPCDoneHandlerImplementationNoReq<R>(std::move(lambda)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Lambda, typename = std_::enable_if_t<std_::is_rvalue_reference<Lambda&&>::value>>
|
template <typename Lambda, typename = std::enable_if_t<std::is_rvalue_reference<Lambda&&>::value>>
|
||||||
RPCDoneHandlerPtr rpcDone(Lambda &&lambda) {
|
RPCDoneHandlerPtr rpcDone(Lambda &&lambda) {
|
||||||
return rpcDone_lambda_wrap_helper(base::lambda_type<Lambda>(std_::move(lambda)));
|
return rpcDone_lambda_wrap_helper(base::lambda_type<Lambda>(std::move(lambda)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename FunctionType>
|
template <typename FunctionType>
|
||||||
|
@ -980,22 +980,22 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda<bool(const RPCError&)> &&lambda) {
|
inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda<bool(const RPCError&)> &&lambda) {
|
||||||
return RPCFailHandlerPtr(new RPCFailHandlerImplementationPlain(std_::move(lambda)));
|
return RPCFailHandlerPtr(new RPCFailHandlerImplementationPlain(std::move(lambda)));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda<bool(const RPCError&, mtpRequestId)> &&lambda) {
|
inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda<bool(const RPCError&, mtpRequestId)> &&lambda) {
|
||||||
return RPCFailHandlerPtr(new RPCFailHandlerImplementationReq(std_::move(lambda)));
|
return RPCFailHandlerPtr(new RPCFailHandlerImplementationReq(std::move(lambda)));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda<bool()> &&lambda) {
|
inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda<bool()> &&lambda) {
|
||||||
return RPCFailHandlerPtr(new RPCFailHandlerImplementationNo(std_::move(lambda)));
|
return RPCFailHandlerPtr(new RPCFailHandlerImplementationNo(std::move(lambda)));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda<bool(mtpRequestId)> &&lambda) {
|
inline RPCFailHandlerPtr rpcFail_lambda_wrap_helper(base::lambda<bool(mtpRequestId)> &&lambda) {
|
||||||
return RPCFailHandlerPtr(new RPCFailHandlerImplementationNoReq(std_::move(lambda)));
|
return RPCFailHandlerPtr(new RPCFailHandlerImplementationNoReq(std::move(lambda)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Lambda, typename = std_::enable_if_t<std_::is_rvalue_reference<Lambda&&>::value>>
|
template <typename Lambda, typename = std::enable_if_t<std::is_rvalue_reference<Lambda&&>::value>>
|
||||||
RPCFailHandlerPtr rpcFail(Lambda &&lambda) {
|
RPCFailHandlerPtr rpcFail(Lambda &&lambda) {
|
||||||
return rpcFail_lambda_wrap_helper(base::lambda_type<Lambda>(std_::move(lambda)));
|
return rpcFail_lambda_wrap_helper(base::lambda_type<Lambda>(std::move(lambda)));
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue