Mercurial > minori
comparison 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 |
comparison
equal
deleted
inserted
replaced
63:3d2decf093bb | 64:fe719c109dbc |
---|---|
3 #include "core/anime_db.h" | 3 #include "core/anime_db.h" |
4 #include "core/array.h" | 4 #include "core/array.h" |
5 #include "core/strings.h" | 5 #include "core/strings.h" |
6 #include "gui/pages/anime_list.h" | 6 #include "gui/pages/anime_list.h" |
7 #include "gui/translate/anime.h" | 7 #include "gui/translate/anime.h" |
8 #include "gui/widgets/anime_info.h" | |
8 #include "gui/widgets/optional_date.h" | 9 #include "gui/widgets/optional_date.h" |
9 #include "gui/widgets/text.h" | 10 #include "gui/widgets/text.h" |
10 #include "gui/window.h" | 11 #include "gui/window.h" |
11 #include <QCheckBox> | 12 #include <QCheckBox> |
12 #include <QComboBox> | 13 #include <QComboBox> |
63 | 64 |
64 main_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | 65 main_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
65 | 66 |
66 id = anime.GetId(); | 67 id = anime.GetId(); |
67 /* anime title header text */ | 68 /* anime title header text */ |
68 TextWidgets::Paragraph* anime_title = | 69 TextWidgets::Title* anime_title = |
69 new TextWidgets::Paragraph(QString::fromUtf8(anime.GetUserPreferredTitle().c_str()), main_widget); | 70 new TextWidgets::Title(QString::fromStdString(anime.GetUserPreferredTitle()), main_widget); |
70 anime_title->setReadOnly(true); | |
71 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
72 anime_title->setWordWrapMode(QTextOption::NoWrap); | |
73 anime_title->setFrameShape(QFrame::NoFrame); | |
74 anime_title->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
75 anime_title->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
76 anime_title->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | |
77 | |
78 { | |
79 QFont font(anime_title->font()); | |
80 font.setPointSize(12); | |
81 anime_title->setFont(font); | |
82 } | |
83 | |
84 { | |
85 QPalette pal; | |
86 pal.setColor(QPalette::Window, Qt::transparent); | |
87 pal.setColor(QPalette::WindowText, Qt::blue); | |
88 } | |
89 | 71 |
90 /* tabbed widget */ | 72 /* tabbed widget */ |
91 QTabWidget* tabbed_widget = new QTabWidget(main_widget); | 73 QTabWidget* tabbed_widget = new QTabWidget(main_widget); |
92 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); | 74 tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); |
93 | 75 |
94 /* main info tab */ | 76 /* main info tab */ |
95 QWidget* main_information_widget = new QWidget(tabbed_widget); | 77 AnimeInfoWidget* main_information_widget = new AnimeInfoWidget(anime, tabbed_widget); |
96 main_information_widget->setLayout(new QVBoxLayout); | |
97 | |
98 /* alt titles */ | |
99 main_information_widget->layout()->addWidget(new TextWidgets::SelectableTextParagraph( | |
100 tr("Alternative titles"), QString::fromUtf8(Strings::Implode(anime.GetTitleSynonyms(), ", ").c_str()), | |
101 main_information_widget)); | |
102 | |
103 /* details */ | |
104 QString details_data; | |
105 QTextStream details_data_s(&details_data); | |
106 details_data_s << Translate::ToString(anime.GetFormat()).c_str() << "\n" | |
107 << anime.GetEpisodes() << "\n" | |
108 << Translate::ToString(anime.GetUserStatus()).c_str() << "\n" | |
109 << Translate::ToString(anime.GetSeason()).c_str() << " " << anime.GetAirDate().GetYear() << "\n" | |
110 << Strings::Implode(anime.GetGenres(), ", ").c_str() << "\n" | |
111 << anime.GetAudienceScore() << "%"; | |
112 main_information_widget->layout()->addWidget( | |
113 new TextWidgets::LabelledTextParagraph(tr("Details"), tr("Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:"), | |
114 details_data, main_information_widget)); | |
115 | |
116 /* synopsis */ | |
117 TextWidgets::SelectableTextParagraph* synopsis = new TextWidgets::SelectableTextParagraph( | |
118 tr("Synopsis"), QString::fromUtf8(anime.GetSynopsis().c_str()), main_information_widget); | |
119 | |
120 synopsis->GetParagraph()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); | |
121 main_information_widget->layout()->addWidget(synopsis); | |
122 | 78 |
123 QWidget* settings_widget = new QWidget(tabbed_widget); | 79 QWidget* settings_widget = new QWidget(tabbed_widget); |
124 settings_widget->setLayout(new QVBoxLayout); | 80 settings_widget->setLayout(new QVBoxLayout); |
125 settings_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); | 81 settings_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); |
126 | 82 |
134 | 90 |
135 /* these macros make this a lot easier to edit */ | 91 /* these macros make this a lot easier to edit */ |
136 #define LAYOUT_HORIZ_SPACING 25 | 92 #define LAYOUT_HORIZ_SPACING 25 |
137 #define LAYOUT_VERT_SPACING 5 | 93 #define LAYOUT_VERT_SPACING 5 |
138 #define LAYOUT_ITEM_WIDTH 175 | 94 #define LAYOUT_ITEM_WIDTH 175 |
139 /* Creates a subsection with a width of 175 */ | |
140 #define CREATE_SUBSECTION(x) \ | |
141 { \ | |
142 QWidget* subsection = new QWidget(section); \ | |
143 subsection->setLayout(new QVBoxLayout); \ | |
144 subsection->setFixedWidth(LAYOUT_ITEM_WIDTH); \ | |
145 subsection->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); \ | |
146 subsection->layout()->setSpacing(LAYOUT_VERT_SPACING); \ | |
147 subsection->layout()->setContentsMargins(0, 0, 0, 0); \ | |
148 x; \ | |
149 layout->addWidget(subsection); \ | |
150 } | |
151 /* Creates a section in the parent `a` */ | |
152 #define CREATE_SECTION(a, x) \ | |
153 { \ | |
154 QWidget* section = new QWidget(a); \ | |
155 QHBoxLayout* layout = new QHBoxLayout(section); \ | |
156 layout->setSpacing(LAYOUT_HORIZ_SPACING); \ | |
157 layout->setContentsMargins(0, 0, 0, 0); \ | |
158 x; \ | |
159 layout->addStretch(); \ | |
160 a->layout()->addWidget(section); \ | |
161 } | |
162 /* Creates a subsection that takes up whatever space is necessary */ | 95 /* Creates a subsection that takes up whatever space is necessary */ |
163 #define CREATE_FULL_WIDTH_SUBSECTION(x) \ | 96 #define CREATE_FULL_WIDTH_SUBSECTION(x) \ |
164 { \ | 97 { \ |
165 QWidget* subsection = new QWidget(section); \ | 98 QWidget* subsection = new QWidget(section); \ |
166 subsection->setLayout(new QVBoxLayout); \ | 99 subsection->setLayout(new QVBoxLayout); \ |
168 subsection->layout()->setSpacing(LAYOUT_VERT_SPACING); \ | 101 subsection->layout()->setSpacing(LAYOUT_VERT_SPACING); \ |
169 subsection->layout()->setContentsMargins(0, 0, 0, 0); \ | 102 subsection->layout()->setContentsMargins(0, 0, 0, 0); \ |
170 x; \ | 103 x; \ |
171 layout->addWidget(subsection); \ | 104 layout->addWidget(subsection); \ |
172 } | 105 } |
106 | |
107 /* Creates a subsection with a width of 175 */ | |
108 #define CREATE_SUBSECTION(x) CREATE_FULL_WIDTH_SUBSECTION(x subsection->setFixedWidth(LAYOUT_ITEM_WIDTH);) | |
109 | |
173 /* Creates a section in the parent `a` */ | 110 /* Creates a section in the parent `a` */ |
174 #define CREATE_FULL_WIDTH_SECTION(a, x) \ | 111 #define CREATE_FULL_WIDTH_SECTION(a, x) \ |
175 { \ | 112 { \ |
176 QWidget* section = new QWidget(a); \ | 113 QWidget* section = new QWidget(a); \ |
177 QHBoxLayout* layout = new QHBoxLayout(section); \ | 114 QHBoxLayout* layout = new QHBoxLayout(section); \ |
178 layout->setSpacing(LAYOUT_HORIZ_SPACING); \ | 115 layout->setSpacing(LAYOUT_HORIZ_SPACING); \ |
179 layout->setContentsMargins(0, 0, 0, 0); \ | 116 layout->setContentsMargins(0, 0, 0, 0); \ |
180 x; \ | 117 x; \ |
181 a->layout()->addWidget(section); \ | 118 a->layout()->addWidget(section); \ |
182 } | 119 } |
120 | |
121 /* Creates a section in the parent `a` */ | |
122 #define CREATE_SECTION(a, x) CREATE_FULL_WIDTH_SECTION(a, x layout->addStretch();) | |
183 | 123 |
184 CREATE_SECTION(sg_anime_list_content, { | 124 CREATE_SECTION(sg_anime_list_content, { |
185 /* Episodes watched section */ | 125 /* Episodes watched section */ |
186 CREATE_SUBSECTION({ | 126 CREATE_SUBSECTION({ |
187 subsection->layout()->addWidget(new QLabel(tr("Episodes watched:"), subsection)); | 127 subsection->layout()->addWidget(new QLabel(tr("Episodes watched:"), subsection)); |
302 #undef CREATE_SECTION | 242 #undef CREATE_SECTION |
303 #undef CREATE_SUBSECTION | 243 #undef CREATE_SUBSECTION |
304 #undef CREATE_FULL_WIDTH_SECTION | 244 #undef CREATE_FULL_WIDTH_SECTION |
305 #undef CREATE_FULL_WIDTH_SUBSECTION | 245 #undef CREATE_FULL_WIDTH_SUBSECTION |
306 | 246 |
307 static_cast<QBoxLayout*>(settings_widget->layout())->addStretch(); | 247 reinterpret_cast<QBoxLayout*>(settings_widget->layout())->addStretch(); |
308 | 248 |
309 tabbed_widget->addTab(main_information_widget, tr("Main information")); | 249 tabbed_widget->addTab(main_information_widget, tr("Main information")); |
310 tabbed_widget->addTab(settings_widget, tr("My list and settings")); | 250 tabbed_widget->addTab(settings_widget, tr("My list and settings")); |
311 | 251 |
312 QVBoxLayout* main_layout = new QVBoxLayout; | 252 QVBoxLayout* main_layout = new QVBoxLayout; |