mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Moved out data structures for channel earn to td_ui.
This commit is contained in:
parent
32a3952524
commit
3c266b6dc4
9 changed files with 82 additions and 61 deletions
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
#include "data/data_boosts.h"
|
#include "data/data_boosts.h"
|
||||||
|
#include "data/data_channel_earn.h"
|
||||||
#include "data/data_statistics.h"
|
#include "data/data_statistics.h"
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
|
|
||||||
|
|
70
Telegram/SourceFiles/data/data_channel_earn.h
Normal file
70
Telegram/SourceFiles/data/data_channel_earn.h
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "data/data_statistics_chart.h"
|
||||||
|
|
||||||
|
#include <QtCore/QDateTime>
|
||||||
|
|
||||||
|
namespace Data {
|
||||||
|
|
||||||
|
using EarnInt = uint64;
|
||||||
|
|
||||||
|
constexpr auto kEarnMultiplier = EarnInt(1000000000);
|
||||||
|
|
||||||
|
struct EarnHistoryEntry final {
|
||||||
|
enum class Type {
|
||||||
|
In,
|
||||||
|
Out,
|
||||||
|
Return,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class Status {
|
||||||
|
Success,
|
||||||
|
Failed,
|
||||||
|
Pending,
|
||||||
|
};
|
||||||
|
|
||||||
|
Type type;
|
||||||
|
Status status;
|
||||||
|
|
||||||
|
EarnInt amount = 0;
|
||||||
|
QDateTime date;
|
||||||
|
QDateTime dateTo;
|
||||||
|
|
||||||
|
QString provider;
|
||||||
|
|
||||||
|
QDateTime successDate;
|
||||||
|
QString successLink;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EarnHistorySlice final {
|
||||||
|
using OffsetToken = int;
|
||||||
|
std::vector<EarnHistoryEntry> list;
|
||||||
|
int total = 0;
|
||||||
|
bool allLoaded = false;
|
||||||
|
OffsetToken token;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EarnStatistics final {
|
||||||
|
explicit operator bool() const {
|
||||||
|
return !!usdRate;
|
||||||
|
}
|
||||||
|
Data::StatisticalGraph topHoursGraph;
|
||||||
|
Data::StatisticalGraph revenueGraph;
|
||||||
|
EarnInt currentBalance = 0;
|
||||||
|
EarnInt availableBalance = 0;
|
||||||
|
EarnInt overallRevenue = 0;
|
||||||
|
float64 usdRate = 0.;
|
||||||
|
int minCpm = -1;
|
||||||
|
|
||||||
|
EarnHistorySlice firstHistorySlice;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Data
|
|
@ -155,56 +155,4 @@ struct PublicForwardsSlice final {
|
||||||
OffsetToken token;
|
OffsetToken token;
|
||||||
};
|
};
|
||||||
|
|
||||||
using EarnInt = uint64;
|
|
||||||
|
|
||||||
struct EarnHistoryEntry final {
|
|
||||||
enum class Type {
|
|
||||||
In,
|
|
||||||
Out,
|
|
||||||
Return,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class Status {
|
|
||||||
Success,
|
|
||||||
Failed,
|
|
||||||
Pending,
|
|
||||||
};
|
|
||||||
|
|
||||||
Type type;
|
|
||||||
Status status;
|
|
||||||
|
|
||||||
EarnInt amount = 0;
|
|
||||||
QDateTime date;
|
|
||||||
QDateTime dateTo;
|
|
||||||
|
|
||||||
QString provider;
|
|
||||||
|
|
||||||
QDateTime successDate;
|
|
||||||
QString successLink;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EarnHistorySlice final {
|
|
||||||
using OffsetToken = int;
|
|
||||||
std::vector<EarnHistoryEntry> list;
|
|
||||||
int total = 0;
|
|
||||||
bool allLoaded = false;
|
|
||||||
OffsetToken token;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EarnStatistics final {
|
|
||||||
explicit operator bool() const {
|
|
||||||
return !!usdRate;
|
|
||||||
}
|
|
||||||
Data::StatisticalGraph topHoursGraph;
|
|
||||||
Data::StatisticalGraph revenueGraph;
|
|
||||||
EarnInt currentBalance = 0;
|
|
||||||
EarnInt availableBalance = 0;
|
|
||||||
EarnInt overallRevenue = 0;
|
|
||||||
float64 usdRate = 0.;
|
|
||||||
int minCpm = -1;
|
|
||||||
|
|
||||||
EarnHistorySlice firstHistorySlice;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
|
@ -49,7 +49,6 @@ namespace {
|
||||||
|
|
||||||
using EarnInt = Data::EarnInt;
|
using EarnInt = Data::EarnInt;
|
||||||
|
|
||||||
constexpr auto kMultiplier = EarnInt(1000000000);
|
|
||||||
constexpr auto kMinorPartLength = 9;
|
constexpr auto kMinorPartLength = 9;
|
||||||
constexpr auto kZero = QChar('0');
|
constexpr auto kZero = QChar('0');
|
||||||
constexpr auto kDot = QChar('.');
|
constexpr auto kDot = QChar('.');
|
||||||
|
@ -86,8 +85,8 @@ constexpr auto kDot = QChar('.');
|
||||||
|
|
||||||
[[nodiscard]] QString ToUsd(EarnInt value, float64 rate) {
|
[[nodiscard]] QString ToUsd(EarnInt value, float64 rate) {
|
||||||
constexpr auto kApproximately = QChar(0x2248);
|
constexpr auto kApproximately = QChar(0x2248);
|
||||||
const auto multiplier = EarnInt(rate * kMultiplier);
|
const auto multiplier = EarnInt(rate * Data::kEarnMultiplier);
|
||||||
const auto result = (value * multiplier) / kMultiplier;
|
const auto result = (value * multiplier) / Data::kEarnMultiplier;
|
||||||
return QString(kApproximately)
|
return QString(kApproximately)
|
||||||
+ QChar('$')
|
+ QChar('$')
|
||||||
+ MajorPart(result)
|
+ MajorPart(result)
|
||||||
|
@ -856,7 +855,7 @@ void InnerWidget::fill() {
|
||||||
const auto right = Ui::CreateChild<Ui::FlatLabel>(
|
const auto right = Ui::CreateChild<Ui::FlatLabel>(
|
||||||
line,
|
line,
|
||||||
st::defaultFlatLabel);
|
st::defaultFlatLabel);
|
||||||
addEmojiToMajor(right, kMaxCPM * kMultiplier);
|
addEmojiToMajor(right, kMaxCPM * Data::kEarnMultiplier);
|
||||||
const auto slider = Ui::CreateChild<Ui::MediaSlider>(
|
const auto slider = Ui::CreateChild<Ui::MediaSlider>(
|
||||||
line,
|
line,
|
||||||
st::settingsScale);
|
st::settingsScale);
|
||||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "data/data_statistics.h"
|
#include "data/data_channel_earn.h"
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "data/data_statistics.h"
|
#include "data/data_channel_earn.h"
|
||||||
#include "info/info_content_widget.h"
|
#include "info/info_content_widget.h"
|
||||||
|
|
||||||
namespace Info::ChannelEarn {
|
namespace Info::ChannelEarn {
|
||||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "statistics/view/chart_rulers_view.h"
|
#include "statistics/view/chart_rulers_view.h"
|
||||||
|
|
||||||
#include "data/data_statistics_chart.h"
|
#include "data/data_channel_earn.h" // Data::kEarnMultiplier.
|
||||||
#include "statistics/chart_lines_filter_controller.h"
|
#include "statistics/chart_lines_filter_controller.h"
|
||||||
#include "statistics/statistics_common.h"
|
#include "statistics/statistics_common.h"
|
||||||
#include "styles/style_basic.h"
|
#include "styles/style_basic.h"
|
||||||
|
@ -142,7 +142,7 @@ void ChartRulersView::add(Limits newHeight, bool animated) {
|
||||||
newHeight.min,
|
newHeight.min,
|
||||||
true,
|
true,
|
||||||
_isDouble ? _scaledLineRatio : 0.,
|
_isDouble ? _scaledLineRatio : 0.,
|
||||||
_currencyIcon ? 1000000000 : 0);
|
_currencyIcon ? Data::kEarnMultiplier : 0);
|
||||||
if (_isDouble) {
|
if (_isDouble) {
|
||||||
const auto &font = st::statisticsDetailsBottomCaptionStyle.font;
|
const auto &font = st::statisticsDetailsBottomCaptionStyle.font;
|
||||||
for (auto &line : newLinesData.lines) {
|
for (auto &line : newLinesData.lines) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "statistics/widgets/point_details_widget.h"
|
#include "statistics/widgets/point_details_widget.h"
|
||||||
|
|
||||||
|
#include "data/data_channel_earn.h" // Data::kEarnMultiplier.
|
||||||
#include "statistics/statistics_common.h"
|
#include "statistics/statistics_common.h"
|
||||||
#include "statistics/statistics_format_values.h"
|
#include "statistics/statistics_format_values.h"
|
||||||
#include "statistics/view/stack_linear_chart_common.h"
|
#include "statistics/view/stack_linear_chart_common.h"
|
||||||
|
@ -270,6 +271,7 @@ void PointDetailsWidget::setXIndex(int xIndex) {
|
||||||
nullptr,
|
nullptr,
|
||||||
{ float64(xIndex), float64(xIndex) }).parts
|
{ float64(xIndex), float64(xIndex) }).parts
|
||||||
: std::vector<PiePartData::Part>();
|
: std::vector<PiePartData::Part>();
|
||||||
|
const auto multiplier = float64(Data::kEarnMultiplier);
|
||||||
for (auto i = 0; i < _chartData.lines.size(); i++) {
|
for (auto i = 0; i < _chartData.lines.size(); i++) {
|
||||||
const auto &dataLine = _chartData.lines[i];
|
const auto &dataLine = _chartData.lines[i];
|
||||||
auto textLine = Line();
|
auto textLine = Line();
|
||||||
|
@ -281,7 +283,7 @@ void PointDetailsWidget::setXIndex(int xIndex) {
|
||||||
textLine.value.setText(
|
textLine.value.setText(
|
||||||
_textStyle,
|
_textStyle,
|
||||||
_chartData.isCurrency
|
_chartData.isCurrency
|
||||||
? QString::number(dataLine.y[xIndex] / float64(1000000000))
|
? QString::number(dataLine.y[xIndex] / multiplier)
|
||||||
: QString("%L1").arg(dataLine.y[xIndex]));
|
: QString("%L1").arg(dataLine.y[xIndex]));
|
||||||
hasPositiveValues |= (dataLine.y[xIndex] > 0);
|
hasPositiveValues |= (dataLine.y[xIndex] > 0);
|
||||||
textLine.valueColor = QColor(dataLine.color);
|
textLine.valueColor = QColor(dataLine.color);
|
||||||
|
|
|
@ -79,6 +79,7 @@ PRIVATE
|
||||||
|
|
||||||
data/data_birthday.cpp
|
data/data_birthday.cpp
|
||||||
data/data_birthday.h
|
data/data_birthday.h
|
||||||
|
data/data_channel_earn.h
|
||||||
data/data_statistics_chart.cpp
|
data/data_statistics_chart.cpp
|
||||||
data/data_statistics_chart.h
|
data/data_statistics_chart.h
|
||||||
data/data_subscription_option.h
|
data/data_subscription_option.h
|
||||||
|
|
Loading…
Add table
Reference in a new issue