Mercurial > minori
comparison src/gui/pages/statistics.cc @ 102:b315f3759c56
*: big patch
1. use a wrapper for mINI that enables case sensitivity
(personal preference)
2. rename dark_theme.cc to theme.cc and change it to be
a class
3. include the "dep" folder so we don't have stupidity in
json.h or ini.h
4. I think the graph was also tweaked a lot in this, nothing
is constexpr and size is found at runtime...
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Fri, 03 Nov 2023 21:32:52 -0400 |
parents | 2f373d48f889 |
children | 6d8da6e64d61 |
comparison
equal
deleted
inserted
replaced
101:c537996cf67b | 102:b315f3759c56 |
---|---|
38 class, but whatever. */ | 38 class, but whatever. */ |
39 QWidget* content = new QWidget(score_dist_widget); | 39 QWidget* content = new QWidget(score_dist_widget); |
40 QVBoxLayout* content_layout = new QVBoxLayout(content); | 40 QVBoxLayout* content_layout = new QVBoxLayout(content); |
41 _score_distribution_graph.reset(new Graph<int>(content)); | 41 _score_distribution_graph.reset(new Graph<int>(content)); |
42 content_layout->addWidget(_score_distribution_graph.get()); | 42 content_layout->addWidget(_score_distribution_graph.get()); |
43 content_layout->setContentsMargins(0, 0, 0, 0); | 43 content_layout->setSpacing(0); |
44 content->setContentsMargins(12, 0, 0, 0); | 44 /* For some reason, when we set the margin to 12 on any paragraphs it |
45 actually doesn't draw them 12 pixels away. It draws them ~15 pixels | |
46 away! I'm assuming this is just Qt's widgets being weird (they usually are) | |
47 and I hope it's nothing I *really* have to worry about... */ | |
48 content_layout->setContentsMargins(15, 0, 0, 0); | |
49 content->setContentsMargins(0, 0, 0, 0); | |
45 | 50 |
46 score_dist_layout->addWidget(content); | 51 score_dist_layout->addWidget(content); |
47 score_dist_layout->setContentsMargins(0, 0, 0, 0); | 52 score_dist_layout->setContentsMargins(0, 0, 0, 0); |
48 | 53 |
49 _application.reset(new TextWidgets::LabelledSection(tr("Minori"), tr("Uptime:\nRequests made:"), "\n\n", this)); | 54 _application.reset(new TextWidgets::LabelledSection(tr("Minori"), tr("Uptime:\nRequests made:"), "\n\n", this)); |
67 | 72 |
68 /* me abusing macros :) */ | 73 /* me abusing macros :) */ |
69 #define ADD_TIME_SEGMENT(r, x, s, p) \ | 74 #define ADD_TIME_SEGMENT(r, x, s, p) \ |
70 if (x > 0) \ | 75 if (x > 0) \ |
71 r << x << ((x == 1) ? s : p) | 76 r << x << ((x == 1) ? s : p) |
72 std::string StatisticsPage::MinutesToDateString(int minutes) { | 77 std::string StatisticsPage::MinutesToDateString(const int minutes) { |
73 /* ew */ | 78 /* ew */ |
74 int years = (minutes * (1 / 525949.2F)); | 79 int years = (minutes * (1 / 525949.2F)); |
75 int months = (minutes * (1 / 43829.1F)) - (years * 12); | 80 int months = (minutes * (1 / 43829.1F)) - (years * 12); |
76 int days = (minutes * (1 / 1440.0F)) - (years * 365.2425F) - (months * 30.436875F); | 81 int days = (minutes * (1 / 1440.0F)) - (years * 365.2425F) - (months * 30.436875F); |
77 int hours = (minutes * (1 / 60.0F)) - (years * 8765.82F) - (months * 730.485F) - (days * 24); | 82 int hours = (minutes * (1 / 60.0F)) - (years * 8765.82F) - (months * 730.485F) - (days * 24); |
84 if (rest_minutes > 0 || return_stream.str().size() == 0) | 89 if (rest_minutes > 0 || return_stream.str().size() == 0) |
85 return_stream << rest_minutes << ((rest_minutes == 1) ? " minute" : " minutes"); | 90 return_stream << rest_minutes << ((rest_minutes == 1) ? " minute" : " minutes"); |
86 return return_stream.str(); | 91 return return_stream.str(); |
87 } | 92 } |
88 | 93 |
89 std::string StatisticsPage::SecondsToDateString(int sec) { | 94 std::string StatisticsPage::SecondsToDateString(const int sec) { |
90 /* this is all fairly unnecessary, but works:tm: */ | 95 /* this is all fairly unnecessary, but works:tm: */ |
91 int years = sec * (1 / 31556952.0F); | 96 int years = sec * (1 / 31556952.0F); |
92 int months = sec * (1 / 2629746.0F) - (years * 12); | 97 int months = sec * (1 / 2629746.0F) - (years * 12); |
93 int days = sec * (1 / 86400.0F) - (years * 365.2425F) - (months * 30.436875F); | 98 int days = sec * (1 / 86400.0F) - (years * 365.2425F) - (months * 30.436875F); |
94 int hours = sec * (1 / 3600.0F) - (years * 8765.82F) - (months * 730.485F) - (days * 24); | 99 int hours = sec * (1 / 3600.0F) - (years * 8765.82F) - (months * 730.485F) - (days * 24); |
105 return_stream << seconds << ((seconds == 1) ? " second" : " seconds"); | 110 return_stream << seconds << ((seconds == 1) ? " second" : " seconds"); |
106 return return_stream.str(); | 111 return return_stream.str(); |
107 } | 112 } |
108 #undef ADD_TIME_SEGMENT | 113 #undef ADD_TIME_SEGMENT |
109 | 114 |
110 inline int GetTotalWithScore(int score) { | 115 inline int GetTotalWithScore(const int score) { |
111 int count = 0; | 116 int count = 0; |
112 for (const auto& item : Anime::db.items) | 117 for (const auto& item : Anime::db.items) |
113 if (item.second.IsInUserList() && item.second.GetUserScore() == score) | 118 if (item.second.IsInUserList() && item.second.GetUserScore() == score) |
114 count++; | 119 count++; |
115 return count; | 120 return count; |