diff src/gui/dialog/information.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 26721c28bf22
line wrap: on
line diff
--- a/src/gui/dialog/information.cpp	Sun Oct 01 06:39:47 2023 -0400
+++ b/src/gui/dialog/information.cpp	Sun Oct 01 23:15:43 2023 -0400
@@ -5,6 +5,7 @@
 #include "core/strings.h"
 #include "gui/pages/anime_list.h"
 #include "gui/translate/anime.h"
+#include "gui/widgets/anime_info.h"
 #include "gui/widgets/optional_date.h"
 #include "gui/widgets/text.h"
 #include "gui/window.h"
@@ -65,60 +66,15 @@
 
 	id = anime.GetId();
 	/* anime title header text */
-	TextWidgets::Paragraph* anime_title =
-	    new TextWidgets::Paragraph(QString::fromUtf8(anime.GetUserPreferredTitle().c_str()), main_widget);
-	anime_title->setReadOnly(true);
-	anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-	anime_title->setWordWrapMode(QTextOption::NoWrap);
-	anime_title->setFrameShape(QFrame::NoFrame);
-	anime_title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
-	anime_title->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-	anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-
-	{
-		QFont font(anime_title->font());
-		font.setPointSize(12);
-		anime_title->setFont(font);
-	}
-
-	{
-		QPalette pal;
-		pal.setColor(QPalette::Window, Qt::transparent);
-		pal.setColor(QPalette::WindowText, Qt::blue);
-	}
+	TextWidgets::Title* anime_title =
+	    new TextWidgets::Title(QString::fromStdString(anime.GetUserPreferredTitle()), main_widget);
 
 	/* tabbed widget */
 	QTabWidget* tabbed_widget = new QTabWidget(main_widget);
 	tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
 
 	/* main info tab */
-	QWidget* main_information_widget = new QWidget(tabbed_widget);
-	main_information_widget->setLayout(new QVBoxLayout);
-
-	/* alt titles */
-	main_information_widget->layout()->addWidget(new TextWidgets::SelectableTextParagraph(
-	    tr("Alternative titles"), QString::fromUtf8(Strings::Implode(anime.GetTitleSynonyms(), ", ").c_str()),
-	    main_information_widget));
-
-	/* details */
-	QString details_data;
-	QTextStream details_data_s(&details_data);
-	details_data_s << Translate::ToString(anime.GetFormat()).c_str() << "\n"
-	               << anime.GetEpisodes() << "\n"
-	               << Translate::ToString(anime.GetUserStatus()).c_str() << "\n"
-	               << Translate::ToString(anime.GetSeason()).c_str() << " " << anime.GetAirDate().GetYear() << "\n"
-	               << Strings::Implode(anime.GetGenres(), ", ").c_str() << "\n"
-	               << anime.GetAudienceScore() << "%";
-	main_information_widget->layout()->addWidget(
-	    new TextWidgets::LabelledTextParagraph(tr("Details"), tr("Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:"),
-	                                           details_data, main_information_widget));
-
-	/* synopsis */
-	TextWidgets::SelectableTextParagraph* synopsis = new TextWidgets::SelectableTextParagraph(
-	    tr("Synopsis"), QString::fromUtf8(anime.GetSynopsis().c_str()), main_information_widget);
-
-	synopsis->GetParagraph()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
-	main_information_widget->layout()->addWidget(synopsis);
+	AnimeInfoWidget* main_information_widget = new AnimeInfoWidget(anime, tabbed_widget);
 
 	QWidget* settings_widget = new QWidget(tabbed_widget);
 	settings_widget->setLayout(new QVBoxLayout);
@@ -136,29 +92,6 @@
 #define LAYOUT_HORIZ_SPACING 25
 #define LAYOUT_VERT_SPACING  5
 #define LAYOUT_ITEM_WIDTH    175
-/* Creates a subsection with a width of 175 */
-#define CREATE_SUBSECTION(x) \
-	{ \
-		QWidget* subsection = new QWidget(section); \
-		subsection->setLayout(new QVBoxLayout); \
-		subsection->setFixedWidth(LAYOUT_ITEM_WIDTH); \
-		subsection->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); \
-		subsection->layout()->setSpacing(LAYOUT_VERT_SPACING); \
-		subsection->layout()->setContentsMargins(0, 0, 0, 0); \
-		x; \
-		layout->addWidget(subsection); \
-	}
-/* Creates a section in the parent `a` */
-#define CREATE_SECTION(a, x) \
-	{ \
-		QWidget* section = new QWidget(a); \
-		QHBoxLayout* layout = new QHBoxLayout(section); \
-		layout->setSpacing(LAYOUT_HORIZ_SPACING); \
-		layout->setContentsMargins(0, 0, 0, 0); \
-		x; \
-		layout->addStretch(); \
-		a->layout()->addWidget(section); \
-	}
 /* Creates a subsection that takes up whatever space is necessary */
 #define CREATE_FULL_WIDTH_SUBSECTION(x) \
 	{ \
@@ -170,6 +103,10 @@
 		x; \
 		layout->addWidget(subsection); \
 	}
+
+/* Creates a subsection with a width of 175 */
+#define CREATE_SUBSECTION(x) CREATE_FULL_WIDTH_SUBSECTION(x subsection->setFixedWidth(LAYOUT_ITEM_WIDTH);)
+
 /* Creates a section in the parent `a` */
 #define CREATE_FULL_WIDTH_SECTION(a, x) \
 	{ \
@@ -181,6 +118,9 @@
 		a->layout()->addWidget(section); \
 	}
 
+/* Creates a section in the parent `a` */
+#define CREATE_SECTION(a, x) CREATE_FULL_WIDTH_SECTION(a, x layout->addStretch();)
+
 	CREATE_SECTION(sg_anime_list_content, {
 		/* Episodes watched section */
 		CREATE_SUBSECTION({
@@ -304,7 +244,7 @@
 #undef CREATE_FULL_WIDTH_SECTION
 #undef CREATE_FULL_WIDTH_SUBSECTION
 
-	static_cast<QBoxLayout*>(settings_widget->layout())->addStretch();
+	reinterpret_cast<QBoxLayout*>(settings_widget->layout())->addStretch();
 
 	tabbed_widget->addTab(main_information_widget, tr("Main information"));
 	tabbed_widget->addTab(settings_widget, tr("My list and settings"));