Mercurial > minori
comparison src/gui/dialog/information.cpp @ 63:3d2decf093bb
*: fix many clang warnings
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Sun, 01 Oct 2023 06:39:47 -0400 |
| parents | 4c6dd5999b39 |
| children | fe719c109dbc |
comparison
equal
deleted
inserted
replaced
| 62:4c6dd5999b39 | 63:3d2decf093bb |
|---|---|
| 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/optional_date.h" | |
| 8 #include "gui/widgets/text.h" | 9 #include "gui/widgets/text.h" |
| 9 #include "gui/widgets/optional_date.h" | |
| 10 #include "gui/window.h" | 10 #include "gui/window.h" |
| 11 #include <QCheckBox> | 11 #include <QCheckBox> |
| 12 #include <QComboBox> | 12 #include <QComboBox> |
| 13 #include <QDateEdit> | 13 #include <QDateEdit> |
| 14 #include <QDebug> | 14 #include <QDebug> |
| 107 << anime.GetEpisodes() << "\n" | 107 << anime.GetEpisodes() << "\n" |
| 108 << Translate::ToString(anime.GetUserStatus()).c_str() << "\n" | 108 << Translate::ToString(anime.GetUserStatus()).c_str() << "\n" |
| 109 << Translate::ToString(anime.GetSeason()).c_str() << " " << anime.GetAirDate().GetYear() << "\n" | 109 << Translate::ToString(anime.GetSeason()).c_str() << " " << anime.GetAirDate().GetYear() << "\n" |
| 110 << Strings::Implode(anime.GetGenres(), ", ").c_str() << "\n" | 110 << Strings::Implode(anime.GetGenres(), ", ").c_str() << "\n" |
| 111 << anime.GetAudienceScore() << "%"; | 111 << anime.GetAudienceScore() << "%"; |
| 112 main_information_widget->layout()->addWidget(new TextWidgets::LabelledTextParagraph( | 112 main_information_widget->layout()->addWidget( |
| 113 tr("Details"), tr("Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:"), details_data, main_information_widget)); | 113 new TextWidgets::LabelledTextParagraph(tr("Details"), tr("Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:"), |
| 114 details_data, main_information_widget)); | |
| 114 | 115 |
| 115 /* synopsis */ | 116 /* synopsis */ |
| 116 TextWidgets::SelectableTextParagraph* synopsis = new TextWidgets::SelectableTextParagraph( | 117 TextWidgets::SelectableTextParagraph* synopsis = new TextWidgets::SelectableTextParagraph( |
| 117 tr("Synopsis"), QString::fromUtf8(anime.GetSynopsis().c_str()), main_information_widget); | 118 tr("Synopsis"), QString::fromUtf8(anime.GetSynopsis().c_str()), main_information_widget); |
| 118 | 119 |
| 184 /* Episodes watched section */ | 185 /* Episodes watched section */ |
| 185 CREATE_SUBSECTION({ | 186 CREATE_SUBSECTION({ |
| 186 subsection->layout()->addWidget(new QLabel(tr("Episodes watched:"), subsection)); | 187 subsection->layout()->addWidget(new QLabel(tr("Episodes watched:"), subsection)); |
| 187 | 188 |
| 188 QSpinBox* spin_box = new QSpinBox(subsection); | 189 QSpinBox* spin_box = new QSpinBox(subsection); |
| 189 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { | 190 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { progress = i; }); |
| 190 progress = i; | |
| 191 }); | |
| 192 spin_box->setRange(0, anime.GetEpisodes()); | 191 spin_box->setRange(0, anime.GetEpisodes()); |
| 193 spin_box->setSingleStep(1); | 192 spin_box->setSingleStep(1); |
| 194 spin_box->setValue(progress = anime.GetUserProgress()); | 193 spin_box->setValue(progress = anime.GetUserProgress()); |
| 195 subsection->layout()->addWidget(spin_box); | 194 subsection->layout()->addWidget(spin_box); |
| 196 }); | 195 }); |
| 197 CREATE_SUBSECTION({ | 196 CREATE_SUBSECTION({ |
| 198 subsection->layout()->addWidget(new QLabel(tr(" "), subsection)); | 197 subsection->layout()->addWidget(new QLabel(tr(" "), subsection)); |
| 199 | 198 |
| 200 QCheckBox* checkbox = new QCheckBox(tr("Rewatching")); | 199 QCheckBox* checkbox = new QCheckBox(tr("Rewatching")); |
| 201 connect(checkbox, QOverload<int>::of(&QCheckBox::stateChanged), this, [this](int state) { | 200 connect(checkbox, QOverload<int>::of(&QCheckBox::stateChanged), this, |
| 202 rewatching = (state == Qt::Checked); | 201 [this](int state) { rewatching = (state == Qt::Checked); }); |
| 203 }); | |
| 204 checkbox->setCheckState(anime.GetUserIsRewatching() ? Qt::Checked : Qt::Unchecked); | 202 checkbox->setCheckState(anime.GetUserIsRewatching() ? Qt::Checked : Qt::Unchecked); |
| 205 subsection->layout()->addWidget(checkbox); | 203 subsection->layout()->addWidget(checkbox); |
| 206 }); | 204 }); |
| 207 }); | 205 }); |
| 208 CREATE_SECTION(sg_anime_list_content, { | 206 CREATE_SECTION(sg_anime_list_content, { |
| 214 for (unsigned int i = 0; i < ARRAYSIZE(Anime::ListStatuses); i++) | 212 for (unsigned int i = 0; i < ARRAYSIZE(Anime::ListStatuses); i++) |
| 215 string_list.append(QString::fromStdString(Translate::ToString(Anime::ListStatuses[i]))); | 213 string_list.append(QString::fromStdString(Translate::ToString(Anime::ListStatuses[i]))); |
| 216 | 214 |
| 217 QComboBox* combo_box = new QComboBox(subsection); | 215 QComboBox* combo_box = new QComboBox(subsection); |
| 218 combo_box->addItems(string_list); | 216 combo_box->addItems(string_list); |
| 219 connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this](int i) { | 217 connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, |
| 220 status = Anime::ListStatuses[i]; | 218 [this](int i) { status = Anime::ListStatuses[i]; }); |
| 221 }); | 219 combo_box->setCurrentIndex(static_cast<int>(status = anime.GetUserStatus()) - 1); |
| 222 combo_box->setCurrentIndex(static_cast<int>(status = anime.GetUserStatus())-1); | |
| 223 subsection->layout()->addWidget(combo_box); | 220 subsection->layout()->addWidget(combo_box); |
| 224 }); | 221 }); |
| 225 CREATE_SUBSECTION({ | 222 CREATE_SUBSECTION({ |
| 226 subsection->layout()->addWidget(new QLabel(tr("Score:"), subsection)); | 223 subsection->layout()->addWidget(new QLabel(tr("Score:"), subsection)); |
| 227 | 224 |
| 228 QSpinBox* spin_box = new QSpinBox(subsection); | 225 QSpinBox* spin_box = new QSpinBox(subsection); |
| 229 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { | 226 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { score = i; }); |
| 230 score = i; | |
| 231 }); | |
| 232 spin_box->setRange(0, 100); | 227 spin_box->setRange(0, 100); |
| 233 spin_box->setSingleStep(5); | 228 spin_box->setSingleStep(5); |
| 234 spin_box->setValue(score = anime.GetUserScore()); | 229 spin_box->setValue(score = anime.GetUserScore()); |
| 235 subsection->layout()->addWidget(spin_box); | 230 subsection->layout()->addWidget(spin_box); |
| 236 }); | 231 }); |
| 254 /* Dates section */ | 249 /* Dates section */ |
| 255 CREATE_SUBSECTION({ | 250 CREATE_SUBSECTION({ |
| 256 subsection->layout()->addWidget(new QLabel(tr("Date started:"), subsection)); | 251 subsection->layout()->addWidget(new QLabel(tr("Date started:"), subsection)); |
| 257 | 252 |
| 258 OptionalDate* date = new OptionalDate(true, subsection); | 253 OptionalDate* date = new OptionalDate(true, subsection); |
| 259 connect(date, &OptionalDate::DataChanged, this, [this](bool enabled, Date date) { | 254 connect(date, &OptionalDate::DataChanged, this, |
| 260 started = (enabled) ? date : Date(); | 255 [this](bool enabled, Date date) { started = (enabled) ? date : Date(); }); |
| 261 }); | |
| 262 started = anime.GetUserDateStarted(); | 256 started = anime.GetUserDateStarted(); |
| 263 if (!started.IsValid()) { | 257 if (!started.IsValid()) { |
| 264 date->SetEnabled(false); | 258 date->SetEnabled(false); |
| 265 started = anime.GetAirDate(); | 259 started = anime.GetAirDate(); |
| 266 } | 260 } |
| 269 }); | 263 }); |
| 270 CREATE_SUBSECTION({ | 264 CREATE_SUBSECTION({ |
| 271 subsection->layout()->addWidget(new QLabel(tr("Date completed:"), subsection)); | 265 subsection->layout()->addWidget(new QLabel(tr("Date completed:"), subsection)); |
| 272 | 266 |
| 273 OptionalDate* date = new OptionalDate(true, subsection); | 267 OptionalDate* date = new OptionalDate(true, subsection); |
| 274 connect(date, &OptionalDate::DataChanged, this, [this](bool enabled, Date date) { | 268 connect(date, &OptionalDate::DataChanged, this, |
| 275 completed = (enabled) ? date : Date(); | 269 [this](bool enabled, Date date) { completed = (enabled) ? date : Date(); }); |
| 276 }); | |
| 277 completed = anime.GetUserDateCompleted(); | 270 completed = anime.GetUserDateCompleted(); |
| 278 if (!completed.IsValid()) { | 271 if (!completed.IsValid()) { |
| 279 date->SetEnabled(false); | 272 date->SetEnabled(false); |
| 280 completed = anime.GetAirDate(); | 273 completed = anime.GetAirDate(); |
| 281 } | 274 } |
