diff --git a/Telegram/SourceFiles/info/statistics/info_statistics_widget.cpp b/Telegram/SourceFiles/info/statistics/info_statistics_widget.cpp index 2898c63fb9..e5c3000923 100644 --- a/Telegram/SourceFiles/info/statistics/info_statistics_widget.cpp +++ b/Telegram/SourceFiles/info/statistics/info_statistics_widget.cpp @@ -271,7 +271,7 @@ void FillOverview( const auto formatter = u"d MMM yyyy"_q; const auto from = QDateTime::fromSecsSinceEpoch(startDate); const auto to = QDateTime::fromSecsSinceEpoch(endDate); - header->setRightInfo(QLocale().toString(from.date(), formatter) + header->setSubTitle(QLocale().toString(from.date(), formatter) + ' ' + QChar(8212) + ' ' diff --git a/Telegram/SourceFiles/statistics/chart_header_widget.cpp b/Telegram/SourceFiles/statistics/chart_header_widget.cpp index 88dea41508..35858c008f 100644 --- a/Telegram/SourceFiles/statistics/chart_header_widget.cpp +++ b/Telegram/SourceFiles/statistics/chart_header_widget.cpp @@ -12,6 +12,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Statistic { +Header::Header(not_null parent) +: Ui::RpWidget(parent) +, _height(st::statisticsChartHeaderHeight) { +} + QString Header::title() const { return _title.toString(); } @@ -21,13 +26,16 @@ void Header::setTitle(QString title) { } int Header::resizeGetHeight(int newWidth) { - return st::statisticsChartHeaderHeight; + return _height; } -void Header::setRightInfo(QString rightInfo) { - _rightInfo.setText( +void Header::setSubTitle(QString subTitle) { + _height = subTitle.isEmpty() + ? st::statisticsHeaderTitleTextStyle.font->height + : st::statisticsChartHeaderHeight; + _subTitle.setText( st::statisticsHeaderDatesTextStyle, - std::move(rightInfo)); + std::move(subTitle)); } void Header::paintEvent(QPaintEvent *e) { @@ -39,7 +47,7 @@ void Header::paintEvent(QPaintEvent *e) { _title.drawLeftElided(p, 0, 0, width(), width()); p.setPen(st::windowSubTextFg); - _rightInfo.drawLeftElided(p, 0, _infoTop, width(), width()); + _subTitle.drawLeftElided(p, 0, _infoTop, width(), width()); } void Header::resizeEvent(QResizeEvent *e) { diff --git a/Telegram/SourceFiles/statistics/chart_header_widget.h b/Telegram/SourceFiles/statistics/chart_header_widget.h index 0f82505df8..22056db3f1 100644 --- a/Telegram/SourceFiles/statistics/chart_header_widget.h +++ b/Telegram/SourceFiles/statistics/chart_header_widget.h @@ -13,11 +13,11 @@ namespace Statistic { class Header final : public Ui::RpWidget { public: - using Ui::RpWidget::RpWidget; + explicit Header(not_null parent); [[nodiscard]] QString title() const; void setTitle(QString title); - void setRightInfo(QString rightInfo); + void setSubTitle(QString subTitle); protected: void paintEvent(QPaintEvent *e) override; @@ -27,8 +27,9 @@ protected: private: Ui::Text::String _title; - Ui::Text::String _rightInfo; + Ui::Text::String _subTitle; int _infoTop = 0; + int _height = 0; }; diff --git a/Telegram/SourceFiles/statistics/chart_widget.cpp b/Telegram/SourceFiles/statistics/chart_widget.cpp index 3b3599e0ba..4325bdeb4f 100644 --- a/Telegram/SourceFiles/statistics/chart_widget.cpp +++ b/Telegram/SourceFiles/statistics/chart_widget.cpp @@ -63,7 +63,7 @@ void FillLineColorsByKey(Data::StatisticalChart &chartData) { } } -[[nodiscard]] QString HeaderRightInfo( +[[nodiscard]] QString HeaderSubTitle( const Data::StatisticalChart &chartData, int xIndexMin, int xIndexMax) { @@ -1075,7 +1075,7 @@ void ChartWidget::updateHeader() { return; } const auto i = _animationController.currentXIndices(); - _header->setRightInfo(HeaderRightInfo(_chartData, i.min, i.max)); + _header->setSubTitle(HeaderSubTitle(_chartData, i.min, i.max)); _header->update(); } @@ -1281,7 +1281,7 @@ void ChartWidget::processLocalZoom(int xIndex) { header->setGeometry(g); }, header->lifetime()); header->setTitle(_header->title()); - header->setRightInfo(HeaderRightInfo(_chartData, xIndex, xIndex)); + header->setSubTitle(HeaderSubTitle(_chartData, xIndex, xIndex)); const auto enableMouse = [=](bool value) { setAttribute(Qt::WA_TransparentForMouseEvents, !value); @@ -1314,7 +1314,7 @@ void ChartWidget::processLocalZoom(int xIndex) { st::statisticsHeaderButton); zoomOutButton->moveToRight( 0, - (st::statisticsChartHeaderHeight - zoomOutButton->height()) / 2); + (header->height() - zoomOutButton->height()) / 2); zoomOutButton->show(); zoomOutButton->setTextTransform( Ui::RoundButton::TextTransform::NoTransform); @@ -1356,7 +1356,7 @@ void ChartWidget::processLocalZoom(int xIndex) { _chartData, l, zoomLimitIndices); - header->setRightInfo(HeaderRightInfo(_chartData, r.min, r.max)); + header->setSubTitle(HeaderSubTitle(_chartData, r.min, r.max)); header->update(); }, header->lifetime()); }; @@ -1514,8 +1514,8 @@ void ChartWidget::setZoomedChartData( ranges::find(_chartData.x, x)); customHeader->setTitle(_header->title()); if ((xIndex >= 0) && (xIndex < _chartData.x.size())) { - customHeader->setRightInfo( - HeaderRightInfo(_chartData, xIndex, xIndex)); + customHeader->setSubTitle( + HeaderSubTitle(_chartData, xIndex, xIndex)); } const auto &headerPadding = st::statisticsChartHeaderPadding; customHeader->moveToLeft(headerPadding.left(), headerPadding.top()); @@ -1530,7 +1530,7 @@ void ChartWidget::setZoomedChartData( Ui::RoundButton::TextTransform::NoTransform); zoomOutButton->moveToRight( 0, - (st::statisticsChartHeaderHeight - zoomOutButton->height()) / 2); + (customHeader->height() - zoomOutButton->height()) / 2); zoomOutButton->setClickedCallback([=] { shownValue( ) | rpl::start_with_next([=](bool shown) {