format_values.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. namespace Ui {
  9. inline constexpr auto FileStatusSizeReady = 0xFFFFFFF0LL;
  10. inline constexpr auto FileStatusSizeLoaded = 0xFFFFFFF1LL;
  11. inline constexpr auto FileStatusSizeFailed = 0xFFFFFFF2LL;
  12. inline const QString kCreditsCurrency = u"XTR"_q;
  13. [[nodiscard]] QString FormatSizeText(qint64 size);
  14. [[nodiscard]] QString FormatDownloadText(qint64 ready, qint64 total);
  15. [[nodiscard]] QString FormatProgressText(qint64 ready, qint64 total);
  16. [[nodiscard]] QString FormatDateTime(QDateTime date);
  17. [[nodiscard]] QString FormatDurationText(qint64 duration);
  18. [[nodiscard]] QString FormatDurationWords(qint64 duration);
  19. [[nodiscard]] QString FormatDurationWordsSlowmode(qint64 duration);
  20. [[nodiscard]] QString FormatDurationAndSizeText(qint64 duration, qint64 size);
  21. [[nodiscard]] QString FormatGifAndSizeText(qint64 size);
  22. [[nodiscard]] QString FormatPlayedText(qint64 played, qint64 duration);
  23. [[nodiscard]] QString FormatImageSizeText(const QSize &size);
  24. [[nodiscard]] QString FormatPhone(QString phone);
  25. [[nodiscard]] QString FormatTTL(float64 ttl);
  26. [[nodiscard]] QString FormatTTLAfter(float64 ttl);
  27. [[nodiscard]] QString FormatTTLTiny(float64 ttl);
  28. [[nodiscard]] QString FormatMuteFor(float64 sec);
  29. [[nodiscard]] QString FormatMuteForTiny(float64 sec);
  30. [[nodiscard]] QString FormatResetCloudPasswordIn(float64 sec);
  31. [[nodiscard]] QString FormatDialogsDate(const QDateTime &lastTime);
  32. struct CurrencyRule {
  33. const char *international = "";
  34. char thousands = ',';
  35. char decimal = '.';
  36. bool left = true;
  37. bool space = false;
  38. int exponent = 2;
  39. bool stripDotZero = false;
  40. };
  41. [[nodiscard]] QString FillAmountAndCurrency(
  42. int64 amount,
  43. const QString &currency,
  44. bool forceStripDotZero = false);
  45. [[nodiscard]] CurrencyRule LookupCurrencyRule(const QString &currency);
  46. [[nodiscard]] QString FormatWithSeparators(
  47. double amount,
  48. int precision,
  49. char decimal,
  50. char thousands);
  51. } // namespace Ui