From 25fbc2f7e1e9cde4950fa59a5186599937df44a8 Mon Sep 17 00:00:00 2001 From: Evgenii Zheltonozhskii Date: Sun, 21 Oct 2018 19:56:59 +0300 Subject: [PATCH] Minor refactoring --- .../dialogs/dialogs_inner_widget.cpp | 32 +++++-------------- Telegram/SourceFiles/mainwindow.cpp | 8 ++--- 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index f9497320b..e03287e96 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -2026,40 +2026,24 @@ void DialogsInner::loadPeerPhotos() { _filterResults[from]->history()->peer->loadUserpic(); } } - - from = (yFrom > filteredOffset() + st::searchedBarHeight ? - ((yFrom - filteredOffset() - st::searchedBarHeight) / qint32(st::dialogsRowHeight)) : - 0) - - _filterResults.size(); + auto offset = filteredOffset() + st::searchedBarHeight; + from = (yFrom > offset ? ((yFrom - offset) / qint32(st::dialogsRowHeight)) : 0) - _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 > offset ? ((yTo - offset) / qint32(st::dialogsRowHeight)) : 0) - _filterResults.size() + 1; if (to > _peerSearchResults.size()) to = _peerSearchResults.size(); for (; from < to; ++from) { _peerSearchResults[from]->peer->loadUserpic(); } } - from = (yFrom > filteredOffset() + - ((_peerSearchResults.empty() ? 0 : st::searchedBarHeight) + st::searchedBarHeight) ? - ((yFrom - filteredOffset() - (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) - - st::searchedBarHeight) / - qint32(st::dialogsRowHeight)) : - 0) - - _filterResults.size() - _peerSearchResults.size(); + auto offset2 = offset + (_peerSearchResults.empty() ? 0 : st::searchedBarHeight); + auto results_size = _filterResults.size() + _peerSearchResults.size(); + from = (yFrom > offset2 ? ((yFrom - offset2) / qint32(st::dialogsRowHeight)) : 0) - results_size; if (from < 0) from = 0; if (from < _searchResults.size()) { - qint32 to = (yTo > filteredOffset() + (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) + - st::searchedBarHeight ? - ((yTo - filteredOffset() - (_peerSearchResults.empty() ? 0 : st::searchedBarHeight) - - st::searchedBarHeight) / - qint32(st::dialogsRowHeight)) : - 0) - - _filterResults.size() - _peerSearchResults.size() + 1, - w = width(); + qint32 to = (yTo > offset2 ? ((yTo - offset2) / qint32(st::dialogsRowHeight)) : 0) - results_size + 1; if (to > _searchResults.size()) to = _searchResults.size(); for (; from < to; ++from) { diff --git a/Telegram/SourceFiles/mainwindow.cpp b/Telegram/SourceFiles/mainwindow.cpp index cfd6b21be..87294806e 100644 --- a/Telegram/SourceFiles/mainwindow.cpp +++ b/Telegram/SourceFiles/mainwindow.cpp @@ -1609,11 +1609,9 @@ void LastCrashedWindow::updateControls() { h += _networkSettings.height() + padding; QRect scr(QApplication::primaryScreen()->availableGeometry()); - QSize s(2 * padding + - QFontMetrics(_label.font()) - .width(qsl("Last time %1 was not closed properly.").arg(str_const_toString(AppName))) + - padding + _networkSettings.width(), - h); + auto label_width = QFontMetrics(_label.font()) + .width(qsl("Last time %1 was not closed properly.").arg(str_const_toString(AppName))); + QSize s(2 * padding + label_width + padding + _networkSettings.width(), h); if (s == size()) { resizeEvent(0); } else {