mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Added mouse click support to point details widget.
This commit is contained in:
parent
eb0ab9609f
commit
fcc6aaed91
3 changed files with 17 additions and 6 deletions
|
@ -1125,7 +1125,8 @@ void ChartWidget::setupDetails() {
|
||||||
_details.widget = base::make_unique_q<PointDetailsWidget>(
|
_details.widget = base::make_unique_q<PointDetailsWidget>(
|
||||||
this,
|
this,
|
||||||
_chartData,
|
_chartData,
|
||||||
maxAbsoluteValue);
|
maxAbsoluteValue,
|
||||||
|
false);
|
||||||
|
|
||||||
_details.widget->shownValue(
|
_details.widget->shownValue(
|
||||||
) | rpl::start_with_next([=](bool shown) {
|
) | rpl::start_with_next([=](bool shown) {
|
||||||
|
|
|
@ -33,8 +33,10 @@ namespace {
|
||||||
PointDetailsWidget::PointDetailsWidget(
|
PointDetailsWidget::PointDetailsWidget(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
const Data::StatisticalChart &chartData,
|
const Data::StatisticalChart &chartData,
|
||||||
float64 maxAbsoluteValue)
|
float64 maxAbsoluteValue,
|
||||||
: Ui::RpWidget(parent)
|
bool zoomEnabled)
|
||||||
|
: Ui::AbstractButton(parent)
|
||||||
|
, _zoomEnabled(zoomEnabled)
|
||||||
, _chartData(chartData)
|
, _chartData(chartData)
|
||||||
, _textStyle(st::statisticsDetailsPopupStyle)
|
, _textStyle(st::statisticsDetailsPopupStyle)
|
||||||
, _headerStyle(st::semiboldTextStyle)
|
, _headerStyle(st::semiboldTextStyle)
|
||||||
|
@ -118,6 +120,7 @@ void PointDetailsWidget::setXIndex(int xIndex) {
|
||||||
|
|
||||||
_lines.clear();
|
_lines.clear();
|
||||||
_lines.reserve(_chartData.lines.size());
|
_lines.reserve(_chartData.lines.size());
|
||||||
|
auto hasPositiveValues = false;
|
||||||
for (const auto &dataLine : _chartData.lines) {
|
for (const auto &dataLine : _chartData.lines) {
|
||||||
auto textLine = Line();
|
auto textLine = Line();
|
||||||
textLine.id = dataLine.id;
|
textLine.id = dataLine.id;
|
||||||
|
@ -125,9 +128,14 @@ void PointDetailsWidget::setXIndex(int xIndex) {
|
||||||
textLine.value.setText(
|
textLine.value.setText(
|
||||||
_textStyle,
|
_textStyle,
|
||||||
QString("%L1").arg(dataLine.y[xIndex]));
|
QString("%L1").arg(dataLine.y[xIndex]));
|
||||||
|
hasPositiveValues |= (dataLine.y[xIndex] > 0);
|
||||||
textLine.valueColor = QColor(dataLine.color);
|
textLine.valueColor = QColor(dataLine.color);
|
||||||
_lines.push_back(std::move(textLine));
|
_lines.push_back(std::move(textLine));
|
||||||
}
|
}
|
||||||
|
const auto clickable = _zoomEnabled && hasPositiveValues;
|
||||||
|
setAttribute(
|
||||||
|
Qt::WA_TransparentForMouseEvents,
|
||||||
|
!clickable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PointDetailsWidget::setAlpha(float64 alpha) {
|
void PointDetailsWidget::setAlpha(float64 alpha) {
|
||||||
|
|
|
@ -8,16 +8,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "data/data_statistics.h"
|
#include "data/data_statistics.h"
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/abstract_button.h"
|
||||||
|
|
||||||
namespace Statistic {
|
namespace Statistic {
|
||||||
|
|
||||||
class PointDetailsWidget : public Ui::RpWidget {
|
class PointDetailsWidget : public Ui::AbstractButton {
|
||||||
public:
|
public:
|
||||||
PointDetailsWidget(
|
PointDetailsWidget(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
const Data::StatisticalChart &chartData,
|
const Data::StatisticalChart &chartData,
|
||||||
float64 maxAbsoluteValue);
|
float64 maxAbsoluteValue,
|
||||||
|
bool zoomEnabled);
|
||||||
|
|
||||||
[[nodiscard]] int xIndex() const;
|
[[nodiscard]] int xIndex() const;
|
||||||
void setXIndex(int xIndex);
|
void setXIndex(int xIndex);
|
||||||
|
@ -28,6 +29,7 @@ protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
const bool _zoomEnabled;
|
||||||
const Data::StatisticalChart &_chartData;
|
const Data::StatisticalChart &_chartData;
|
||||||
const style::TextStyle &_textStyle;
|
const style::TextStyle &_textStyle;
|
||||||
const style::TextStyle &_headerStyle;
|
const style::TextStyle &_headerStyle;
|
||||||
|
|
Loading…
Add table
Reference in a new issue