mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Decreased height of header for charts without dates.
This commit is contained in:
parent
837b256778
commit
515850ec9b
4 changed files with 26 additions and 17 deletions
|
@ -271,7 +271,7 @@ void FillOverview(
|
||||||
const auto formatter = u"d MMM yyyy"_q;
|
const auto formatter = u"d MMM yyyy"_q;
|
||||||
const auto from = QDateTime::fromSecsSinceEpoch(startDate);
|
const auto from = QDateTime::fromSecsSinceEpoch(startDate);
|
||||||
const auto to = QDateTime::fromSecsSinceEpoch(endDate);
|
const auto to = QDateTime::fromSecsSinceEpoch(endDate);
|
||||||
header->setRightInfo(QLocale().toString(from.date(), formatter)
|
header->setSubTitle(QLocale().toString(from.date(), formatter)
|
||||||
+ ' '
|
+ ' '
|
||||||
+ QChar(8212)
|
+ QChar(8212)
|
||||||
+ ' '
|
+ ' '
|
||||||
|
|
|
@ -12,6 +12,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Statistic {
|
namespace Statistic {
|
||||||
|
|
||||||
|
Header::Header(not_null<Ui::RpWidget*> parent)
|
||||||
|
: Ui::RpWidget(parent)
|
||||||
|
, _height(st::statisticsChartHeaderHeight) {
|
||||||
|
}
|
||||||
|
|
||||||
QString Header::title() const {
|
QString Header::title() const {
|
||||||
return _title.toString();
|
return _title.toString();
|
||||||
}
|
}
|
||||||
|
@ -21,13 +26,16 @@ void Header::setTitle(QString title) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int Header::resizeGetHeight(int newWidth) {
|
int Header::resizeGetHeight(int newWidth) {
|
||||||
return st::statisticsChartHeaderHeight;
|
return _height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Header::setRightInfo(QString rightInfo) {
|
void Header::setSubTitle(QString subTitle) {
|
||||||
_rightInfo.setText(
|
_height = subTitle.isEmpty()
|
||||||
|
? st::statisticsHeaderTitleTextStyle.font->height
|
||||||
|
: st::statisticsChartHeaderHeight;
|
||||||
|
_subTitle.setText(
|
||||||
st::statisticsHeaderDatesTextStyle,
|
st::statisticsHeaderDatesTextStyle,
|
||||||
std::move(rightInfo));
|
std::move(subTitle));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Header::paintEvent(QPaintEvent *e) {
|
void Header::paintEvent(QPaintEvent *e) {
|
||||||
|
@ -39,7 +47,7 @@ void Header::paintEvent(QPaintEvent *e) {
|
||||||
_title.drawLeftElided(p, 0, 0, width(), width());
|
_title.drawLeftElided(p, 0, 0, width(), width());
|
||||||
|
|
||||||
p.setPen(st::windowSubTextFg);
|
p.setPen(st::windowSubTextFg);
|
||||||
_rightInfo.drawLeftElided(p, 0, _infoTop, width(), width());
|
_subTitle.drawLeftElided(p, 0, _infoTop, width(), width());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Header::resizeEvent(QResizeEvent *e) {
|
void Header::resizeEvent(QResizeEvent *e) {
|
||||||
|
|
|
@ -13,11 +13,11 @@ namespace Statistic {
|
||||||
|
|
||||||
class Header final : public Ui::RpWidget {
|
class Header final : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
using Ui::RpWidget::RpWidget;
|
explicit Header(not_null<Ui::RpWidget*> parent);
|
||||||
|
|
||||||
[[nodiscard]] QString title() const;
|
[[nodiscard]] QString title() const;
|
||||||
void setTitle(QString title);
|
void setTitle(QString title);
|
||||||
void setRightInfo(QString rightInfo);
|
void setSubTitle(QString subTitle);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
@ -27,8 +27,9 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::Text::String _title;
|
Ui::Text::String _title;
|
||||||
Ui::Text::String _rightInfo;
|
Ui::Text::String _subTitle;
|
||||||
int _infoTop = 0;
|
int _infoTop = 0;
|
||||||
|
int _height = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ void FillLineColorsByKey(Data::StatisticalChart &chartData) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] QString HeaderRightInfo(
|
[[nodiscard]] QString HeaderSubTitle(
|
||||||
const Data::StatisticalChart &chartData,
|
const Data::StatisticalChart &chartData,
|
||||||
int xIndexMin,
|
int xIndexMin,
|
||||||
int xIndexMax) {
|
int xIndexMax) {
|
||||||
|
@ -1075,7 +1075,7 @@ void ChartWidget::updateHeader() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto i = _animationController.currentXIndices();
|
const auto i = _animationController.currentXIndices();
|
||||||
_header->setRightInfo(HeaderRightInfo(_chartData, i.min, i.max));
|
_header->setSubTitle(HeaderSubTitle(_chartData, i.min, i.max));
|
||||||
_header->update();
|
_header->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1281,7 +1281,7 @@ void ChartWidget::processLocalZoom(int xIndex) {
|
||||||
header->setGeometry(g);
|
header->setGeometry(g);
|
||||||
}, header->lifetime());
|
}, header->lifetime());
|
||||||
header->setTitle(_header->title());
|
header->setTitle(_header->title());
|
||||||
header->setRightInfo(HeaderRightInfo(_chartData, xIndex, xIndex));
|
header->setSubTitle(HeaderSubTitle(_chartData, xIndex, xIndex));
|
||||||
|
|
||||||
const auto enableMouse = [=](bool value) {
|
const auto enableMouse = [=](bool value) {
|
||||||
setAttribute(Qt::WA_TransparentForMouseEvents, !value);
|
setAttribute(Qt::WA_TransparentForMouseEvents, !value);
|
||||||
|
@ -1314,7 +1314,7 @@ void ChartWidget::processLocalZoom(int xIndex) {
|
||||||
st::statisticsHeaderButton);
|
st::statisticsHeaderButton);
|
||||||
zoomOutButton->moveToRight(
|
zoomOutButton->moveToRight(
|
||||||
0,
|
0,
|
||||||
(st::statisticsChartHeaderHeight - zoomOutButton->height()) / 2);
|
(header->height() - zoomOutButton->height()) / 2);
|
||||||
zoomOutButton->show();
|
zoomOutButton->show();
|
||||||
zoomOutButton->setTextTransform(
|
zoomOutButton->setTextTransform(
|
||||||
Ui::RoundButton::TextTransform::NoTransform);
|
Ui::RoundButton::TextTransform::NoTransform);
|
||||||
|
@ -1356,7 +1356,7 @@ void ChartWidget::processLocalZoom(int xIndex) {
|
||||||
_chartData,
|
_chartData,
|
||||||
l,
|
l,
|
||||||
zoomLimitIndices);
|
zoomLimitIndices);
|
||||||
header->setRightInfo(HeaderRightInfo(_chartData, r.min, r.max));
|
header->setSubTitle(HeaderSubTitle(_chartData, r.min, r.max));
|
||||||
header->update();
|
header->update();
|
||||||
}, header->lifetime());
|
}, header->lifetime());
|
||||||
};
|
};
|
||||||
|
@ -1514,8 +1514,8 @@ void ChartWidget::setZoomedChartData(
|
||||||
ranges::find(_chartData.x, x));
|
ranges::find(_chartData.x, x));
|
||||||
customHeader->setTitle(_header->title());
|
customHeader->setTitle(_header->title());
|
||||||
if ((xIndex >= 0) && (xIndex < _chartData.x.size())) {
|
if ((xIndex >= 0) && (xIndex < _chartData.x.size())) {
|
||||||
customHeader->setRightInfo(
|
customHeader->setSubTitle(
|
||||||
HeaderRightInfo(_chartData, xIndex, xIndex));
|
HeaderSubTitle(_chartData, xIndex, xIndex));
|
||||||
}
|
}
|
||||||
const auto &headerPadding = st::statisticsChartHeaderPadding;
|
const auto &headerPadding = st::statisticsChartHeaderPadding;
|
||||||
customHeader->moveToLeft(headerPadding.left(), headerPadding.top());
|
customHeader->moveToLeft(headerPadding.left(), headerPadding.top());
|
||||||
|
@ -1530,7 +1530,7 @@ void ChartWidget::setZoomedChartData(
|
||||||
Ui::RoundButton::TextTransform::NoTransform);
|
Ui::RoundButton::TextTransform::NoTransform);
|
||||||
zoomOutButton->moveToRight(
|
zoomOutButton->moveToRight(
|
||||||
0,
|
0,
|
||||||
(st::statisticsChartHeaderHeight - zoomOutButton->height()) / 2);
|
(customHeader->height() - zoomOutButton->height()) / 2);
|
||||||
zoomOutButton->setClickedCallback([=] {
|
zoomOutButton->setClickedCallback([=] {
|
||||||
shownValue(
|
shownValue(
|
||||||
) | rpl::start_with_next([=](bool shown) {
|
) | rpl::start_with_next([=](bool shown) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue