Apply clang-format

This commit is contained in:
Evgenii Zheltonozhskii 2018-06-06 12:37:49 +03:00
parent 6fbecbca22
commit f9c7e0bddb
15 changed files with 72 additions and 56 deletions

View File

@ -666,8 +666,8 @@ void EditChatAdminsBoxController::Start(not_null<ChatData *> chat) {
Ui::show(Box<PeerListBox>(std::move(controller), std::move(initBox)));
}
void AddBotToGroupBoxController::Start(not_null<UserData*> bot) {
auto initBox = [](not_null<PeerListBox*> box) {
void AddBotToGroupBoxController::Start(not_null<UserData *> bot) {
auto initBox = [](not_null<PeerListBox *> box) {
box->addButton(langFactory(lng_cancel), [box] { box->closeBox(); });
};
Ui::show(Box<PeerListBox>(std::make_unique<AddBotToGroupBoxController>(bot), std::move(initBox)));

View File

@ -369,7 +369,8 @@ void StickerSetBox::Inner::paintEvent(QPaintEvent *e) {
if (_pack.isEmpty()) return;
auto ms = getms();
qint32 from = std::floor(e->rect().top() / st::stickersSize.height()), to = std::floor(e->rect().bottom() / st::stickersSize.height()) + 1;
qint32 from = std::floor(e->rect().top() / st::stickersSize.height()),
to = std::floor(e->rect().bottom() / st::stickersSize.height()) + 1;
for (qint32 i = from; i < to; ++i) {
for (qint32 j = 0; j < kStickersPanelPerRow; ++j) {

View File

@ -953,9 +953,9 @@ void StickersBox::Inner::setPressed(int pressed) {
auto &set = _rows[_pressed];
auto rippleMask = Ui::RippleAnimation::rectMask(QSize(width(), _rowHeight));
if (!set->ripple) {
set->ripple = std::make_unique<Ui::RippleAnimation>(st::contactsRipple, std::move(rippleMask), [this, index = _pressed] {
update(0, _itemsTop + index * _rowHeight, width(), _rowHeight);
});
set->ripple = std::make_unique<Ui::RippleAnimation>(
st::contactsRipple, std::move(rippleMask),
[this, index = _pressed] { update(0, _itemsTop + index * _rowHeight, width(), _rowHeight); });
}
set->ripple->add(mapFromGlobal(QCursor::pos()) - QPoint(0, _itemsTop + _pressed * _rowHeight));
}

View File

@ -927,8 +927,12 @@ void FieldAutocompleteInner::onUpdateSelected(bool force) {
qint32 sel = -1, maxSel = 0;
if (!_srows->isEmpty()) {
qint32 row = (mouse.y() >= st::stickerPanPadding) ? ((mouse.y() - st::stickerPanPadding) / st::stickerPanSize.height()) : -1;
qint32 col = (mouse.x() >= st::stickerPanPadding) ? ((mouse.x() - st::stickerPanPadding) / st::stickerPanSize.width()) : -1;
qint32 row = (mouse.y() >= st::stickerPanPadding) ?
((mouse.y() - st::stickerPanPadding) / st::stickerPanSize.height()) :
-1;
qint32 col = (mouse.x() >= st::stickerPanPadding) ?
((mouse.x() - st::stickerPanPadding) / st::stickerPanSize.width()) :
-1;
if (row >= 0 && col >= 0) {
sel = row * _stickersPerRow + col;
}

View File

@ -1690,14 +1690,17 @@ void StickersListWidget::installSet(quint64 setId) {
auto &sets = Global::StickerSets();
auto it = sets.constFind(setId);
if (it != sets.cend()) {
request(MTPmessages_InstallStickerSet(Stickers::inputSetId(*it), MTP_bool(false))).done([](const MTPmessages_StickerSetInstallResult &result) {
if (result.type() == mtpc_messages_stickerSetInstallResultArchive) {
Stickers::ApplyArchivedResult(result.c_messages_stickerSetInstallResultArchive());
}
}).fail([this, setId](const RPCError &error) {
notInstalledLocally(setId);
Stickers::UndoInstallLocally(setId);
}).send();
request(MTPmessages_InstallStickerSet(Stickers::inputSetId(*it), MTP_bool(false)))
.done([](const MTPmessages_StickerSetInstallResult &result) {
if (result.type() == mtpc_messages_stickerSetInstallResultArchive) {
Stickers::ApplyArchivedResult(result.c_messages_stickerSetInstallResultArchive());
}
})
.fail([this, setId](const RPCError &error) {
notInstalledLocally(setId);
Stickers::UndoInstallLocally(setId);
})
.send();
installedLocally(setId);
Stickers::InstallLocally(setId);

View File

@ -687,7 +687,7 @@ bool Generator::writeIncludesInSource() {
}
auto includes = QStringList();
std::function<bool(const Module&)> collector = [&collector, &includes](const Module &module) {
std::function<bool(const Module &)> collector = [&collector, &includes](const Module &module) {
module.enumIncludes(collector);
auto base = moduleBaseName(module);
if (!includes.contains(base)) {

View File

@ -2035,7 +2035,10 @@ void DialogsInner::loadPeerPhotos() {
_filterResults.size();
if (from < 0) from = 0;
if (from < _peerSearchResults.size()) {
qint32 to = (yTo > filteredOffset() + st::searchedBarHeight ? ((yTo - filteredOffset() - st::searchedBarHeight) / qint32(st::dialogsRowHeight)) : 0) - _filterResults.size() + 1;
qint32 to = (yTo > filteredOffset() + st::searchedBarHeight ?
((yTo - filteredOffset() - st::searchedBarHeight) / qint32(st::dialogsRowHeight)) :
0) -
_filterResults.size() + 1;
if (to > _peerSearchResults.size()) to = _peerSearchResults.size();
for (; from < to; ++from) {

View File

@ -347,35 +347,32 @@ void RowPainter::paint(Painter &p, const Row *row, int fullWidth, bool active, b
(st::dialogsUnreadHeight - st::dialogsUnreadFont->height) / 2;
auto unreadWidth = 0;
UnreadBadgeStyle st;
st.active = active;
st.muted = false;
st.padding = 0;
st.textTop = 0;
paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth);
availableWidth -= unreadWidth + st.padding + (hadOneBadge ? st::dialogsUnreadPadding : 0);
}
auto &color = active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService);
if (!history->paintSendAction(p, nameleft, texttop, availableWidth, fullWidth, color, ms)) {
item->drawInDialog(
p,
QRect(nameleft, texttop, availableWidth, st::dialogsTextFont->height),
active,
selected,
HistoryItem::DrawInDialog::Normal,
history->textCachedFor,
history->lastItemTextCache);
}
}, [&p, active, history, unreadCount] {
if (unreadCount) {
auto counter = QString::number(unreadCount);
if (counter.size() > 4) {
counter = qsl("..") + counter.mid(counter.size() - 3);
}
auto mutedCounter = history->mute();
auto unreadRight = st::dialogsPadding.x() + st::dialogsPhotoSize;
auto unreadTop = st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight;
auto unreadWidth = 0;
UnreadBadgeStyle st;
st.active = active;
st.muted = false;
st.padding = 0;
st.textTop = 0;
paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth);
availableWidth -= unreadWidth + st.padding + (hadOneBadge ? st::dialogsUnreadPadding : 0);
}
auto &color = active ? st::dialogsTextFgServiceActive :
(selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService);
if (!history->paintSendAction(p, nameleft, texttop, availableWidth, fullWidth, color, ms)) {
item->drawInDialog(p, QRect(nameleft, texttop, availableWidth, st::dialogsTextFont->height), active,
selected, HistoryItem::DrawInDialog::Normal, history->textCachedFor,
history->lastItemTextCache);
}
},
[&p, active, history, unreadCount] {
if (unreadCount) {
auto counter = QString::number(unreadCount);
if (counter.size() > 4) {
counter = qsl("..") + counter.mid(counter.size() - 3);
}
auto mutedCounter = history->mute();
auto unreadRight = st::dialogsPadding.x() + st::dialogsPhotoSize;
auto unreadTop = st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight;
auto unreadWidth = 0;
UnreadBadgeStyle st;
st.active = active;

View File

@ -379,7 +379,7 @@ void Widget::paintEvent(QPaintEvent *e) {
Painter p(this);
auto clip = e->rect();
//auto ms = getms();
// auto ms = getms();
//_historyDownShown.step(ms);
auto fill = QRect(0, 0, width(), App::main()->height());

View File

@ -2154,7 +2154,9 @@ void MediaView::paintThemePreview(Painter &p, QRect clip) {
p.drawTextLeft(titleRect.x(), titleRect.y(), width(), lang(lng_theme_preview_title));
}
auto buttonsRect = QRect(_themePreviewRect.x(), _themePreviewRect.y() + _themePreviewRect.height() - st::themePreviewMargin.bottom(), _themePreviewRect.width(), st::themePreviewMargin.bottom());
auto buttonsRect = QRect(_themePreviewRect.x(),
_themePreviewRect.y() + _themePreviewRect.height() - st::themePreviewMargin.bottom(),
_themePreviewRect.width(), st::themePreviewMargin.bottom());
if (buttonsRect.y() + buttonsRect.height() > height()) {
buttonsRect.moveTop(height() - buttonsRect.height());
fillOverlay(buttonsRect);

View File

@ -50,7 +50,8 @@ void SessionData::setKey(const AuthKeyPtr &key) {
void SessionData::clear(Instance *instance) {
RPCCallbackClears clearCallbacks;
{
QReadLocker locker1(haveSentMutex()), locker2(toResendMutex()), locker3(haveReceivedMutex()), locker4(wereAckedMutex());
QReadLocker locker1(haveSentMutex()), locker2(toResendMutex()), locker3(haveReceivedMutex()),
locker4(wereAckedMutex());
clearCallbacks.reserve(_haveSent.size() + _wereAcked.size());
for (auto i = _haveSent.cbegin(), e = _haveSent.cend(); i != e; ++i) {
auto requestId = i.value()->requestId;

View File

@ -1009,8 +1009,9 @@ void OverviewInner::onUpdateSelected() {
}
if (_dragAction == Selecting) {
bool canSelectMany = (_peer != 0);
if (_mousedItem == _dragItem && lnk && !_selected.isEmpty() && _selected.cbegin().value() != FullSelection) {
_selected[_dragItem] = { 0, 0 };
if (_mousedItem == _dragItem && lnk && !_selected.isEmpty() &&
_selected.cbegin().value() != FullSelection) {
_selected[_dragItem] = {0, 0};
updateDragSelection(0, -1, 0, -1, false);
} else if (canSelectMany) {
bool selectingDown =

View File

@ -1771,7 +1771,9 @@ void DocumentData::performActionOnLoad() {
auto showImage = !isVideo() && (size < App::kImageSizeLimit);
auto playVoice = voice() && (_actionOnLoad == ActionOnLoadPlayInline || _actionOnLoad == ActionOnLoadOpen);
auto playMusic = tryPlaySong() && (_actionOnLoad == ActionOnLoadPlayInline || _actionOnLoad == ActionOnLoadOpen);
auto playAnimation = isAnimation() && (_actionOnLoad == ActionOnLoadPlayInline || _actionOnLoad == ActionOnLoadOpen) && showImage && item && item->getMedia();
auto playAnimation = isAnimation() &&
(_actionOnLoad == ActionOnLoadPlayInline || _actionOnLoad == ActionOnLoadOpen) && showImage &&
item && item->getMedia();
if (isTheme()) {
if (!loc.isEmpty() && loc.accessEnable()) {
Messenger::Instance().showDocument(this, item);

View File

@ -2065,7 +2065,7 @@ QString ApplyEntities(const TextWithEntities &text) {
QString result;
qint32 size = text.text.size();
const QChar *b = text.text.constData(), *already = b;//, *e = b + size;
const QChar *b = text.text.constData(), *already = b; //, *e = b + size;
auto entity = text.entities.cbegin(), end = text.entities.cend();
auto skipTillRelevantAndGetTag = [&entity, &end, size, &tags] {
while (entity != end) {

View File

@ -219,8 +219,10 @@ enum class PrepareTextOption {
CheckLinks,
};
inline QString PrepareForSending(const QString &text, PrepareTextOption option = PrepareTextOption::IgnoreLinks) {
auto result = TextWithEntities { text }; // , {}}
auto prepareFlags = (option == PrepareTextOption::CheckLinks) ? (TextParseLinks | TextParseMentions | TextParseHashtags | TextParseBotCommands) : 0;
auto result = TextWithEntities{text}; // , {}}
auto prepareFlags = (option == PrepareTextOption::CheckLinks) ?
(TextParseLinks | TextParseMentions | TextParseHashtags | TextParseBotCommands) :
0;
PrepareForSending(result, prepareFlags);
return result.text;
}