diff src/gui/pages/statistics.cpp @ 64:fe719c109dbc

*: update 1. add media tracking ability, and it displays info on the `now playing` page 2. the `now playing` page now actually shows something 3. renamed every page class to be more accurate to what it is 4. ...
author Paper <mrpapersonic@gmail.com>
date Sun, 01 Oct 2023 23:15:43 -0400
parents 3d2decf093bb
children d3e9310598b1
line wrap: on
line diff
--- a/src/gui/pages/statistics.cpp	Sun Oct 01 06:39:47 2023 -0400
+++ b/src/gui/pages/statistics.cpp	Sun Oct 01 23:15:43 2023 -0400
@@ -11,10 +11,10 @@
 #include <QWidget>
 #include <sstream>
 
-StatisticsWidget::StatisticsWidget(QWidget* parent) : QFrame(parent) {
-	setLayout(new QVBoxLayout);
+StatisticsPage::StatisticsPage(QWidget* parent) : QFrame(parent) {
+	QVBoxLayout* layout = new QVBoxLayout(this);
 
-	setFrameShape(QFrame::Panel);
+	setFrameShape(QFrame::Box);
 	setFrameShadow(QFrame::Sunken);
 
 	QPalette pal = QPalette();
@@ -32,9 +32,9 @@
 	    new TextWidgets::LabelledTextParagraph(tr("Minori"), tr("Uptime:\nRequests made:"), "\n\n", this);
 	application_data = application_paragraph->GetParagraph();
 
-	layout()->addWidget(anime_list_paragraph);
-	layout()->addWidget(application_paragraph);
-	((QBoxLayout*)layout())->addStretch();
+	layout->addWidget(anime_list_paragraph);
+	layout->addWidget(application_paragraph);
+	layout->addStretch();
 
 	QTimer* timer = new QTimer(this);
 	connect(timer, &QTimer::timeout, this, [this] {
@@ -44,17 +44,15 @@
 	timer->start(1000); // update statistics every second
 }
 
-void StatisticsWidget::showEvent(QShowEvent*) {
+void StatisticsPage::showEvent(QShowEvent*) {
 	UpdateStatistics();
 }
 
 /* me abusing macros :) */
 #define ADD_TIME_SEGMENT(r, x, s, p) \
-	{ \
-		if (x > 0) \
-			r << x << ((x == 1) ? s : p); \
-	}
-std::string StatisticsWidget::MinutesToDateString(int minutes) {
+	if (x > 0) \
+	r << x << ((x == 1) ? s : p)
+std::string StatisticsPage::MinutesToDateString(int minutes) {
 	/* ew */
 	int years = (minutes * (1 / 525949.2F));
 	int months = (minutes * (1 / 43829.1F)) - (years * 12);
@@ -71,7 +69,7 @@
 	return return_stream.str();
 }
 
-std::string StatisticsWidget::SecondsToDateString(int sec) {
+std::string StatisticsPage::SecondsToDateString(int sec) {
 	/* this is all fairly unnecessary, but works:tm: */
 	int years = sec * (1 / 31556952.0F);
 	int months = sec * (1 / 2629746.0F) - (years * 12);
@@ -92,7 +90,7 @@
 }
 #undef ADD_TIME_SEGMENT
 
-void StatisticsWidget::UpdateStatistics() {
+void StatisticsPage::UpdateStatistics() {
 	/* Anime list */
 	QString string = "";
 	QTextStream ts(&string);
@@ -102,14 +100,14 @@
 	ts << MinutesToDateString(Anime::db.GetTotalPlannedAmount()).c_str() << '\n';
 	ts << Anime::db.GetAverageScore() << '\n';
 	ts << Anime::db.GetScoreDeviation();
-	TextWidgets::SetPlainTextEditData(anime_list_data, string);
+	anime_list_data->SetText(string);
 
 	string = "";
 	ts << QString::fromUtf8(SecondsToDateString(session.uptime() / 1000).c_str()) << '\n';
 	ts << session.GetRequests();
 	/* Application */
 	// UiUtils::SetPlainTextEditData(application_data, QString::number(session.uptime() / 1000));
-	TextWidgets::SetPlainTextEditData(application_data, string);
+	application_data->SetText(string);
 }
 
 #include "gui/pages/moc_statistics.cpp"