Moved formatting of image size text to single place.

Fixed wrong size display on retina screens.
Replaced "x" with special character.
This commit is contained in:
23rd 2021-07-08 22:15:11 +03:00
parent cab8a52f8f
commit f1669674d8
6 changed files with 15 additions and 10 deletions

View file

@ -646,9 +646,7 @@ void EditCaptionBox::updateEditPreview() {
: _preparedList.files.front().content.size()); : _preparedList.files.front().content.size());
// Show image dimensions if it should be sent as doc. // Show image dimensions if it should be sent as doc.
if (_isImage && docPhotoSize.isValid()) { if (_isImage && docPhotoSize.isValid()) {
_status = qsl("%1x%2") _status = Ui::FormatImageSizeText(docPhotoSize);
.arg(docPhotoSize.width())
.arg(docPhotoSize.height());
} }
_doc = true; _doc = true;
} }

View file

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "export/output/export_output_result.h" #include "export/output/export_output_result.h"
#include "export/data/export_data_types.h" #include "export/data/export_data_types.h"
#include "core/utils.h" #include "core/utils.h"
#include "ui/text/format_values.h"
#include <QtCore/QSize> #include <QtCore/QSize>
#include <QtCore/QFile> #include <QtCore/QFile>
@ -1536,9 +1537,8 @@ QByteArray HtmlWriter::Wrap::pushPhotoMedia(
if (thumb.isEmpty()) { if (thumb.isEmpty()) {
auto generic = MediaData(); auto generic = MediaData();
generic.title = "Photo"; generic.title = "Photo";
generic.status = NumberToString(data.image.width) generic.status = Ui::FormatImageSizeText(
+ "x" QSize(data.image.width, data.image.height)).toUtf8();
+ NumberToString(data.image.height);
if (data.image.file.relativePath.isEmpty()) { if (data.image.file.relativePath.isEmpty()) {
generic.status += ", " + FormatFileSize(data.image.file.size); generic.status += ", " + FormatFileSize(data.image.file.size);
} else { } else {

View file

@ -76,9 +76,8 @@ AlbumThumbnail::AlbumThumbnail(
const auto filepath = file.path; const auto filepath = file.path;
if (filepath.isEmpty()) { if (filepath.isEmpty()) {
_name = "image.png"; _name = "image.png";
_status = u"%1x%2"_q _status = FormatImageSizeText(_fullPreview.size()
.arg(_fullPreview.width()) / _fullPreview.devicePixelRatio());
.arg(_fullPreview.height());
} else { } else {
auto fileinfo = QFileInfo(filepath); auto fileinfo = QFileInfo(filepath);
_name = fileinfo.fileName(); _name = fileinfo.fileName();

View file

@ -92,7 +92,8 @@ void SingleFilePreview::preparePreview(const PreparedFile &file) {
if (filepath.isEmpty()) { if (filepath.isEmpty()) {
auto filename = "image.png"; auto filename = "image.png";
_name = filename; _name = filename;
_statusText = u"%1x%2"_q.arg(preview.width()).arg(preview.height()); _statusText = FormatImageSizeText(preview.size()
/ preview.devicePixelRatio());
_fileIsImage = true; _fileIsImage = true;
} else { } else {
auto fileinfo = QFileInfo(filepath); auto fileinfo = QFileInfo(filepath);

View file

@ -363,4 +363,10 @@ CurrencyRule LookupCurrencyRule(const QString &currency) {
return result; return result;
} }
QString FormatImageSizeText(const QSize &size) {
return QString::number(size.width())
+ QChar(215)
+ QString::number(size.height());
}
} // namespace Ui } // namespace Ui

View file

@ -22,6 +22,7 @@ inline constexpr auto FileStatusSizeFailed = 0x7FFFFFF2;
[[nodiscard]] QString FormatDurationAndSizeText(qint64 duration, qint64 size); [[nodiscard]] QString FormatDurationAndSizeText(qint64 duration, qint64 size);
[[nodiscard]] QString FormatGifAndSizeText(qint64 size); [[nodiscard]] QString FormatGifAndSizeText(qint64 size);
[[nodiscard]] QString FormatPlayedText(qint64 played, qint64 duration); [[nodiscard]] QString FormatPlayedText(qint64 played, qint64 duration);
[[nodiscard]] QString FormatImageSizeText(const QSize &size);
struct CurrencyRule { struct CurrencyRule {
const char *international = ""; const char *international = "";