mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +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 "data/data_boosts.h"
|
||||
#include "data/data_channel_earn.h"
|
||||
#include "data/data_statistics.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;
|
||||
};
|
||||
|
||||
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
|
||||
|
|
|
@ -49,7 +49,6 @@ namespace {
|
|||
|
||||
using EarnInt = Data::EarnInt;
|
||||
|
||||
constexpr auto kMultiplier = EarnInt(1000000000);
|
||||
constexpr auto kMinorPartLength = 9;
|
||||
constexpr auto kZero = QChar('0');
|
||||
constexpr auto kDot = QChar('.');
|
||||
|
@ -86,8 +85,8 @@ constexpr auto kDot = QChar('.');
|
|||
|
||||
[[nodiscard]] QString ToUsd(EarnInt value, float64 rate) {
|
||||
constexpr auto kApproximately = QChar(0x2248);
|
||||
const auto multiplier = EarnInt(rate * kMultiplier);
|
||||
const auto result = (value * multiplier) / kMultiplier;
|
||||
const auto multiplier = EarnInt(rate * Data::kEarnMultiplier);
|
||||
const auto result = (value * multiplier) / Data::kEarnMultiplier;
|
||||
return QString(kApproximately)
|
||||
+ QChar('$')
|
||||
+ MajorPart(result)
|
||||
|
@ -856,7 +855,7 @@ void InnerWidget::fill() {
|
|||
const auto right = Ui::CreateChild<Ui::FlatLabel>(
|
||||
line,
|
||||
st::defaultFlatLabel);
|
||||
addEmojiToMajor(right, kMaxCPM * kMultiplier);
|
||||
addEmojiToMajor(right, kMaxCPM * Data::kEarnMultiplier);
|
||||
const auto slider = Ui::CreateChild<Ui::MediaSlider>(
|
||||
line,
|
||||
st::settingsScale);
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "data/data_statistics.h"
|
||||
#include "data/data_channel_earn.h"
|
||||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "data/data_statistics.h"
|
||||
#include "data/data_channel_earn.h"
|
||||
#include "info/info_content_widget.h"
|
||||
|
||||
namespace Info::ChannelEarn {
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#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/statistics_common.h"
|
||||
#include "styles/style_basic.h"
|
||||
|
@ -142,7 +142,7 @@ void ChartRulersView::add(Limits newHeight, bool animated) {
|
|||
newHeight.min,
|
||||
true,
|
||||
_isDouble ? _scaledLineRatio : 0.,
|
||||
_currencyIcon ? 1000000000 : 0);
|
||||
_currencyIcon ? Data::kEarnMultiplier : 0);
|
||||
if (_isDouble) {
|
||||
const auto &font = st::statisticsDetailsBottomCaptionStyle.font;
|
||||
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 "data/data_channel_earn.h" // Data::kEarnMultiplier.
|
||||
#include "statistics/statistics_common.h"
|
||||
#include "statistics/statistics_format_values.h"
|
||||
#include "statistics/view/stack_linear_chart_common.h"
|
||||
|
@ -270,6 +271,7 @@ void PointDetailsWidget::setXIndex(int xIndex) {
|
|||
nullptr,
|
||||
{ float64(xIndex), float64(xIndex) }).parts
|
||||
: std::vector<PiePartData::Part>();
|
||||
const auto multiplier = float64(Data::kEarnMultiplier);
|
||||
for (auto i = 0; i < _chartData.lines.size(); i++) {
|
||||
const auto &dataLine = _chartData.lines[i];
|
||||
auto textLine = Line();
|
||||
|
@ -281,7 +283,7 @@ void PointDetailsWidget::setXIndex(int xIndex) {
|
|||
textLine.value.setText(
|
||||
_textStyle,
|
||||
_chartData.isCurrency
|
||||
? QString::number(dataLine.y[xIndex] / float64(1000000000))
|
||||
? QString::number(dataLine.y[xIndex] / multiplier)
|
||||
: QString("%L1").arg(dataLine.y[xIndex]));
|
||||
hasPositiveValues |= (dataLine.y[xIndex] > 0);
|
||||
textLine.valueColor = QColor(dataLine.color);
|
||||
|
|
|
@ -79,6 +79,7 @@ PRIVATE
|
|||
|
||||
data/data_birthday.cpp
|
||||
data/data_birthday.h
|
||||
data/data_channel_earn.h
|
||||
data/data_statistics_chart.cpp
|
||||
data/data_statistics_chart.h
|
||||
data/data_subscription_option.h
|
||||
|
|
Loading…
Add table
Reference in a new issue