Mercurial > minori
comparison src/gui/dialog/information.cc @ 258:862d0d8619f6
*: HUUUGE changes
animia has been renamed to animone, so instead of thinking of a
health condition, you think of a beautiful flower :)
I've also edited some of the code for animone, but I have no idea
if it even works or not because I don't have a mac or windows
machine lying around. whoops!
... anyway, all of the changes divergent from Anisthesia are now
licensed under BSD. it's possible that I could even rewrite most
of the code to where I don't even have to keep the MIT license,
but that's thinking too far into the future
I've been slacking off on implementing the anime seasons page,
mostly out of laziness. I think I'd have to create another db file
specifically for the seasons
anyway, this code is being pushed *primarily* because the hard drive
it's on is failing! yay :)
| author | Paper <paper@paper.us.eu.org> | 
|---|---|
| date | Mon, 01 Apr 2024 02:43:44 -0400 | 
| parents | b3549da699a6 | 
| children | 9a88e1725fd2 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 257:699a20c57dc8 | 258:862d0d8619f6 | 
|---|---|
| 1 #include "gui/dialog/information.h" | 1 #include "gui/dialog/information.h" | 
| 2 #include "core/anime.h" | 2 #include "core/anime.h" | 
| 3 #include "core/anime_db.h" | 3 #include "core/anime_db.h" | 
| 4 #include "core/session.h" | |
| 4 #include "core/strings.h" | 5 #include "core/strings.h" | 
| 5 #include "core/session.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/anime_info.h" | 
| 9 #include "gui/widgets/optional_date.h" | 9 #include "gui/widgets/optional_date.h" | 
| 10 #include "gui/widgets/poster.h" | 10 #include "gui/widgets/poster.h" | 
| 11 #include "gui/widgets/text.h" | 11 #include "gui/widgets/text.h" | 
| 12 #include "gui/window.h" | 12 #include "gui/window.h" | 
| 13 | |
| 13 #include <QCheckBox> | 14 #include <QCheckBox> | 
| 14 #include <QComboBox> | 15 #include <QComboBox> | 
| 15 #include <QDateEdit> | 16 #include <QDateEdit> | 
| 16 #include <QDebug> | 17 #include <QDebug> | 
| 17 #include <QDialogButtonBox> | 18 #include <QDialogButtonBox> | 
| 20 #include <QPlainTextEdit> | 21 #include <QPlainTextEdit> | 
| 21 #include <QSpinBox> | 22 #include <QSpinBox> | 
| 22 #include <QStringList> | 23 #include <QStringList> | 
| 23 #include <QTextStream> | 24 #include <QTextStream> | 
| 24 #include <QVBoxLayout> | 25 #include <QVBoxLayout> | 
| 26 | |
| 25 #include <functional> | 27 #include <functional> | 
| 26 #ifdef WIN32 | 28 #ifdef WIN32 | 
| 27 #include "sys/win32/dark_theme.h" | 29 # include "sys/win32/dark_theme.h" | 
| 28 #endif | 30 #endif | 
| 29 | 31 | 
| 30 /* TODO: Taiga disables rendering of the tab widget entirely when the anime is not part of a list, | 32 /* TODO: Taiga disables rendering of the tab widget entirely when the anime is not part of a list, | 
| 31 which sucks. Think of a better way to implement this later. */ | 33 which sucks. Think of a better way to implement this later. */ | 
| 32 void InformationDialog::SaveData(Anime::Anime& anime) { | 34 void InformationDialog::SaveData(Anime::Anime& anime) { | 
| 40 anime.SetUserNotes(_notes); | 42 anime.SetUserNotes(_notes); | 
| 41 anime.SetUserDateStarted(_started); | 43 anime.SetUserDateStarted(_started); | 
| 42 anime.SetUserDateCompleted(_completed); | 44 anime.SetUserDateCompleted(_completed); | 
| 43 } | 45 } | 
| 44 | 46 | 
| 45 InformationDialog::InformationDialog(Anime::Anime& anime, std::function<void()> accept, enum Pages page, QWidget* parent) | 47 InformationDialog::InformationDialog(Anime::Anime& anime, std::function<void()> accept, enum Pages page, | 
| 48 QWidget* parent) | |
| 46 : QDialog(parent) { | 49 : QDialog(parent) { | 
| 47 /* ack. lots of brackets here, but MUCH, MUCH MUCH better than what it used to be */ | 50 /* ack. lots of brackets here, but MUCH, MUCH MUCH better than what it used to be */ | 
| 48 setFixedSize(842, 613); | 51 setFixedSize(842, 613); | 
| 49 setWindowTitle(tr("Anime Information")); | 52 setWindowTitle(tr("Anime Information")); | 
| 50 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | 53 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | 
| 51 | 54 | 
| 52 { | 55 { | 
| 112 { | 115 { | 
| 113 /* Anime List */ | 116 /* Anime List */ | 
| 114 QWidget* sg_anime_list_content = new QWidget(settings_widget); | 117 QWidget* sg_anime_list_content = new QWidget(settings_widget); | 
| 115 | 118 | 
| 116 constexpr int LAYOUT_HORIZ_SPACING = 25; | 119 constexpr int LAYOUT_HORIZ_SPACING = 25; | 
| 117 constexpr int LAYOUT_VERT_SPACING = 5; | 120 constexpr int LAYOUT_VERT_SPACING = 5; | 
| 118 constexpr int LAYOUT_ITEM_WIDTH = 175; | 121 constexpr int LAYOUT_ITEM_WIDTH = 175; | 
| 119 | 122 | 
| 120 QVBoxLayout* al_layout = new QVBoxLayout(sg_anime_list_content); | 123 QVBoxLayout* al_layout = new QVBoxLayout(sg_anime_list_content); | 
| 121 al_layout->setSpacing(LAYOUT_VERT_SPACING); | 124 al_layout->setSpacing(LAYOUT_VERT_SPACING); | 
| 122 al_layout->setContentsMargins(12, 0, 0, 0); | 125 al_layout->setContentsMargins(12, 0, 0, 0); | 
| 123 | 126 | 
| 130 layout->setContentsMargins(0, 0, 0, 0); | 133 layout->setContentsMargins(0, 0, 0, 0); | 
| 131 x(section, layout); | 134 x(section, layout); | 
| 132 parent->layout()->addWidget(section); | 135 parent->layout()->addWidget(section); | 
| 133 }; | 136 }; | 
| 134 | 137 | 
| 135 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout){ | 138 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout) { | 
| 136 { | 139 { | 
| 137 /* Episodes watched... */ | 140 /* Episodes watched... */ | 
| 138 layout->addWidget(new QLabel(tr("Episodes watched:"), section), 0, 0); | 141 layout->addWidget(new QLabel(tr("Episodes watched:"), section), 0, 0); | 
| 139 | 142 | 
| 140 QSpinBox* spin_box = new QSpinBox(section); | 143 QSpinBox* spin_box = new QSpinBox(section); | 
| 141 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { _progress = i; }); | 144 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, | 
| 145 [this](int i) { _progress = i; }); | |
| 142 spin_box->setRange(0, anime.GetEpisodes()); | 146 spin_box->setRange(0, anime.GetEpisodes()); | 
| 143 spin_box->setSingleStep(1); | 147 spin_box->setSingleStep(1); | 
| 144 spin_box->setValue(_progress = anime.GetUserProgress()); | 148 spin_box->setValue(_progress = anime.GetUserProgress()); | 
| 145 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); | 149 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); | 
| 146 layout->addWidget(spin_box, 1, 0); | 150 layout->addWidget(spin_box, 1, 0); | 
| 149 { | 153 { | 
| 150 /* Rewatching? */ | 154 /* Rewatching? */ | 
| 151 QCheckBox* checkbox = new QCheckBox(tr("Rewatching")); | 155 QCheckBox* checkbox = new QCheckBox(tr("Rewatching")); | 
| 152 connect(checkbox, QOverload<int>::of(&QCheckBox::stateChanged), this, | 156 connect(checkbox, QOverload<int>::of(&QCheckBox::stateChanged), this, | 
| 153 [this](int state) { _rewatching = (state == Qt::Checked); }); | 157 [this](int state) { _rewatching = (state == Qt::Checked); }); | 
| 154 checkbox->setCheckState((_rewatching = anime.GetUserIsRewatching()) ? Qt::Checked : Qt::Unchecked); | 158 checkbox->setCheckState((_rewatching = anime.GetUserIsRewatching()) ? Qt::Checked | 
| 159 : Qt::Unchecked); | |
| 155 checkbox->setFixedWidth(LAYOUT_ITEM_WIDTH); | 160 checkbox->setFixedWidth(LAYOUT_ITEM_WIDTH); | 
| 156 layout->addWidget(checkbox, 1, 1); | 161 layout->addWidget(checkbox, 1, 1); | 
| 157 } | 162 } | 
| 158 layout->setColumnStretch(layout->columnCount(), 1); | 163 layout->setColumnStretch(layout->columnCount(), 1); | 
| 159 }); | 164 }); | 
| 160 | 165 | 
| 161 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout){ | 166 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout) { | 
| 162 { | 167 { | 
| 163 /* Status */ | 168 /* Status */ | 
| 164 layout->addWidget(new QLabel(tr("Status:"), section), 0, 0); | 169 layout->addWidget(new QLabel(tr("Status:"), section), 0, 0); | 
| 165 | 170 | 
| 166 QComboBox* combo_box = new QComboBox(section); | 171 QComboBox* combo_box = new QComboBox(section); | 
| 167 | 172 | 
| 168 for (unsigned int i = 0; i < Anime::ListStatuses.size(); i++) | 173 for (unsigned int i = 0; i < Anime::ListStatuses.size(); i++) | 
| 169 combo_box->addItem(Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])), static_cast<int>(Anime::ListStatuses[i])); | 174 combo_box->addItem(Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])), | 
| 170 | 175 static_cast<int>(Anime::ListStatuses[i])); | 
| 171 connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this, combo_box](int) { | 176 | 
| 172 _status = static_cast<Anime::ListStatus>(combo_box->currentData().toInt()); | 177 connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, | 
| 173 }); | 178 [this, combo_box](int) { | 
| 179 _status = static_cast<Anime::ListStatus>(combo_box->currentData().toInt()); | |
| 180 }); | |
| 174 | 181 | 
| 175 /* this should NEVER, EVER, be NOT_IN_LIST */ | 182 /* this should NEVER, EVER, be NOT_IN_LIST */ | 
| 176 combo_box->setCurrentIndex(static_cast<int>(_status = anime.GetUserStatus()) - 1); | 183 combo_box->setCurrentIndex(static_cast<int>(_status = anime.GetUserStatus()) - 1); | 
| 177 combo_box->setFixedWidth(LAYOUT_ITEM_WIDTH); | 184 combo_box->setFixedWidth(LAYOUT_ITEM_WIDTH); | 
| 178 layout->addWidget(combo_box, 1, 0); | 185 layout->addWidget(combo_box, 1, 0); | 
| 181 { | 188 { | 
| 182 /* Score */ | 189 /* Score */ | 
| 183 layout->addWidget(new QLabel(tr("Score:"), section), 0, 1); | 190 layout->addWidget(new QLabel(tr("Score:"), section), 0, 1); | 
| 184 | 191 | 
| 185 QSpinBox* spin_box = new QSpinBox(section); | 192 QSpinBox* spin_box = new QSpinBox(section); | 
| 186 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { | 193 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, | 
| 187 _score = i; | 194 [this](int i) { _score = i; }); | 
| 188 }); | |
| 189 spin_box->setRange(0, 100); | 195 spin_box->setRange(0, 100); | 
| 190 spin_box->setSingleStep(5); | 196 spin_box->setSingleStep(5); | 
| 191 spin_box->setValue(_score = anime.GetUserScore()); | 197 spin_box->setValue(_score = anime.GetUserScore()); | 
| 192 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); | 198 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); | 
| 193 layout->addWidget(spin_box, 1, 1); | 199 layout->addWidget(spin_box, 1, 1); | 
| 194 } | 200 } | 
| 195 layout->setColumnStretch(layout->columnCount(), 1); | 201 layout->setColumnStretch(layout->columnCount(), 1); | 
| 196 }); | 202 }); | 
| 197 | 203 | 
| 198 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout){ | 204 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout) { | 
| 199 layout->addWidget(new QLabel(tr("Notes:"), section), 0, 0); | 205 layout->addWidget(new QLabel(tr("Notes:"), section), 0, 0); | 
| 200 | 206 | 
| 201 QLineEdit* line_edit = new QLineEdit(section); | 207 QLineEdit* line_edit = new QLineEdit(section); | 
| 202 connect(line_edit, &QLineEdit::textChanged, this, [this](const QString& text) { | 208 connect(line_edit, &QLineEdit::textChanged, this, [this](const QString& text) { | 
| 203 /* this sucks but I don't really want to implement anything smarter :) */ | 209 /* this sucks but I don't really want to implement anything smarter :) */ | 
| 206 line_edit->setText(Strings::ToQString(_notes = anime.GetUserNotes())); | 212 line_edit->setText(Strings::ToQString(_notes = anime.GetUserNotes())); | 
| 207 line_edit->setPlaceholderText(tr("Enter your notes about this anime")); | 213 line_edit->setPlaceholderText(tr("Enter your notes about this anime")); | 
| 208 layout->addWidget(line_edit, 1, 0); | 214 layout->addWidget(line_edit, 1, 0); | 
| 209 }); | 215 }); | 
| 210 | 216 | 
| 211 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout){ | 217 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout) { | 
| 212 /* Started */ | 218 /* Started */ | 
| 213 { | 219 { | 
| 214 layout->addWidget(new QLabel(tr("Date started:"), section), 0, 0); | 220 layout->addWidget(new QLabel(tr("Date started:"), section), 0, 0); | 
| 215 | 221 | 
| 216 OptionalDate* date = new OptionalDate(true, section); | 222 OptionalDate* date = new OptionalDate(true, section); | 
| 248 settings_layout->addWidget(sg_anime_list_content); | 254 settings_layout->addWidget(sg_anime_list_content); | 
| 249 } | 255 } | 
| 250 | 256 | 
| 251 /* | 257 /* | 
| 252 { | 258 { | 
| 253 // commenting this out until it actually gets implemented :) | 259 // commenting this out until it actually gets implemented :) | 
| 254 | 260 | 
| 255 settings_layout->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget)); | 261 settings_layout->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget)); | 
| 256 | 262 | 
| 257 QWidget* sg_local_content = new QWidget(settings_widget); | 263 QWidget* sg_local_content = new QWidget(settings_widget); | 
| 258 QVBoxLayout* sg_local_layout = new QVBoxLayout(sg_local_content); | 264 QVBoxLayout* sg_local_layout = new QVBoxLayout(sg_local_content); | 
| 259 sg_local_layout->setSpacing(5); | 265 sg_local_layout->setSpacing(5); | 
| 260 sg_local_layout->setContentsMargins(12, 0, 0, 0); | 266 sg_local_layout->setContentsMargins(12, 0, 0, 0); | 
| 261 | 267 | 
| 262 CREATE_SECTION(sg_local_content, [this, &anime](QWidget* section, QGridLayout* layout){ | 268 CREATE_SECTION(sg_local_content, [this, &anime](QWidget* section, QGridLayout* layout){ | 
| 263 layout->addWidget(new QLabel(tr("Alternative titles:"), section), 0, 0); | 269 layout->addWidget(new QLabel(tr("Alternative titles:"), section), 0, 0); | 
| 264 | 270 | 
| 265 QLineEdit* line_edit = new QLineEdit("", section); | 271 QLineEdit* line_edit = new QLineEdit("", section); | 
| 266 line_edit->setPlaceholderText( | 272 line_edit->setPlaceholderText( | 
| 267 tr("Enter alternative titles here, separated by a semicolon (i.e. Title 1; Title 2)")); | 273 tr("Enter alternative titles here, separated by a semicolon (i.e. Title 1; Title 2)")); | 
| 268 layout->addWidget(line_edit, 1, 0); | 274 layout->addWidget(line_edit, 1, 0); | 
| 269 | 275 | 
| 270 QCheckBox* checkbox = new QCheckBox(tr("Use the first alternative title to search for torrents")); | 276 QCheckBox* checkbox = new QCheckBox(tr("Use the first alternative title to search for | 
| 271 layout->addWidget(checkbox, 2, 0); | 277 torrents")); layout->addWidget(checkbox, 2, 0); | 
| 272 }); | 278 }); | 
| 273 | 279 | 
| 274 settings_layout->addWidget(sg_local_content); | 280 settings_layout->addWidget(sg_local_content); | 
| 275 } | 281 } | 
| 276 */ | 282 */ | 
| 277 | 283 | 
| 278 settings_layout->addStretch(); | 284 settings_layout->addStretch(); | 
| 279 | 285 | 
