Mercurial > minori
diff src/gui/dialog/information.cc @ 370:ea3a74ed2ef9
*: hm, last commit wasn't quite finished?
author | Paper <paper@tflc.us> |
---|---|
date | Fri, 25 Jul 2025 10:22:04 -0400 |
parents | 6d37a998cf91 |
children |
line wrap: on
line diff
--- a/src/gui/dialog/information.cc Fri Jul 25 10:16:02 2025 -0400 +++ b/src/gui/dialog/information.cc Fri Jul 25 10:22:04 2025 -0400 @@ -27,12 +27,13 @@ #include <functional> #include <iostream> #ifdef WIN32 -# include "sys/win32/dark_theme.h" +# include "sys/win32/dark_theme.h" #endif /* TODO: Taiga disables rendering of the tab widget entirely when the anime is not part of a list, which sucks. Think of a better way to implement this later. */ -void InformationDialog::SaveData(Anime::Anime* anime) { +void InformationDialog::SaveData(Anime::Anime *anime) +{ if (!anime->IsInUserList()) return; @@ -45,9 +46,10 @@ anime->SetUserDateCompleted(_completed); } -InformationDialog::InformationDialog(Anime::Anime* anime, std::function<void(Anime::Anime*)> accept, enum Pages page, - QWidget* parent) - : Dialog(parent) { +InformationDialog::InformationDialog(Anime::Anime *anime, std::function<void(Anime::Anime *)> accept, enum Pages page, + QWidget *parent) + : Dialog(parent) +{ /* ack. lots of brackets here, but MUCH, MUCH MUCH better than what it used to be */ setFixedSize(842, 613); setWindowTitle(tr("Anime Information")); @@ -59,20 +61,20 @@ setPalette(pal); } - QVBoxLayout* full_layout = new QVBoxLayout(this); + QVBoxLayout *full_layout = new QVBoxLayout(this); { /* this handles the actual page. */ - QWidget* widget = new QWidget(this); - QHBoxLayout* layout = new QHBoxLayout(widget); + QWidget *widget = new QWidget(this); + QHBoxLayout *layout = new QHBoxLayout(widget); { /* Sidebar */ - QWidget* sidebar = new QWidget(widget); - QVBoxLayout* sidebar_layout = new QVBoxLayout(sidebar); + QWidget *sidebar = new QWidget(widget); + QVBoxLayout *sidebar_layout = new QVBoxLayout(sidebar); { /* Poster */ - Poster* poster = new Poster(*anime, sidebar); + Poster *poster = new Poster(*anime, sidebar); sidebar_layout->addWidget(poster); } sidebar_layout->setContentsMargins(0, 0, 0, 0); @@ -82,56 +84,57 @@ { /* ... everything else. */ - QWidget* main_widget = new QWidget(widget); - QVBoxLayout* main_layout = new QVBoxLayout(main_widget); + QWidget *main_widget = new QWidget(widget); + QVBoxLayout *main_layout = new QVBoxLayout(main_widget); main_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); { /* Anime title */ - TextWidgets::Title* anime_title = new TextWidgets::Title(main_widget); + TextWidgets::Title *anime_title = new TextWidgets::Title(main_widget); anime_title->SetText(anime->GetUserPreferredTitle()); main_layout->addWidget(anime_title); } { /* Tab widget, contains main info and settings */ - QTabWidget* tabbed_widget = new QTabWidget(main_widget); + QTabWidget *tabbed_widget = new QTabWidget(main_widget); tabbed_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); { /* Main information */ - AnimeInfoWidget* main_information_widget = new AnimeInfoWidget(*anime, tabbed_widget); + AnimeInfoWidget *main_information_widget = new AnimeInfoWidget(*anime, tabbed_widget); tabbed_widget->addTab(main_information_widget, tr("Main information")); } if (anime->IsInUserList()) { /* My list and settings */ - QWidget* settings_widget = new QWidget(tabbed_widget); + QWidget *settings_widget = new QWidget(tabbed_widget); settings_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); - QVBoxLayout* settings_layout = new QVBoxLayout(settings_widget); + QVBoxLayout *settings_layout = new QVBoxLayout(settings_widget); - TextWidgets::Header* header = new TextWidgets::Header(settings_widget); + TextWidgets::Header *header = new TextWidgets::Header(settings_widget); header->SetText(Strings::Translate("Anime list")); settings_layout->addWidget(header); { /* Anime List */ - QWidget* sg_anime_list_content = new QWidget(settings_widget); + QWidget *sg_anime_list_content = new QWidget(settings_widget); constexpr int LAYOUT_HORIZ_SPACING = 25; constexpr int LAYOUT_VERT_SPACING = 5; constexpr int LAYOUT_ITEM_WIDTH = 175; - QVBoxLayout* al_layout = new QVBoxLayout(sg_anime_list_content); + QVBoxLayout *al_layout = new QVBoxLayout(sg_anime_list_content); al_layout->setSpacing(LAYOUT_VERT_SPACING); al_layout->setContentsMargins(12, 0, 0, 0); /* Helper function for creating sections, reduces clutter. */ - const auto CREATE_SECTION = [](QWidget* parent, std::function<void(QWidget*, QGridLayout*)> x) { - QWidget* section = new QWidget(parent); - QGridLayout* layout = new QGridLayout(section); + const auto CREATE_SECTION = [](QWidget *parent, + std::function<void(QWidget *, QGridLayout *)> x) { + QWidget *section = new QWidget(parent); + QGridLayout *layout = new QGridLayout(section); layout->setHorizontalSpacing(LAYOUT_HORIZ_SPACING); layout->setVerticalSpacing(LAYOUT_VERT_SPACING); layout->setContentsMargins(0, 0, 0, 0); @@ -139,14 +142,14 @@ parent->layout()->addWidget(section); }; - CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout) { + CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget *section, QGridLayout *layout) { { /* Episodes watched... */ layout->addWidget(new QLabel(tr("Episodes watched:"), section), 0, 0); - QSpinBox* spin_box = new QSpinBox(section); + QSpinBox *spin_box = new QSpinBox(section); connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, - [this](int i) { _progress = i; }); + [this](int i) { _progress = i; }); spin_box->setRange(0, anime->GetEpisodes()); spin_box->setSingleStep(1); spin_box->setValue(_progress = anime->GetUserProgress()); @@ -156,36 +159,37 @@ { /* Rewatching? */ - QCheckBox* checkbox = new QCheckBox(tr("Rewatching")); + QCheckBox *checkbox = new QCheckBox(tr("Rewatching")); connect(checkbox, QOverload<int>::of(&QCheckBox::stateChanged), this, - [this](int state) { _rewatching = (state == Qt::Checked); }); + [this](int state) { _rewatching = (state == Qt::Checked); }); checkbox->setCheckState((_rewatching = anime->GetUserIsRewatching()) ? Qt::Checked - : Qt::Unchecked); + : Qt::Unchecked); checkbox->setFixedWidth(LAYOUT_ITEM_WIDTH); layout->addWidget(checkbox, 1, 1); } layout->setColumnStretch(layout->columnCount(), 1); }); - CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout) { + CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget *section, QGridLayout *layout) { { /* Status */ layout->addWidget(new QLabel(tr("Status:"), section), 0, 0); - QComboBox* combo_box = new QComboBox(section); + QComboBox *combo_box = new QComboBox(section); _status = anime->GetUserStatus(); for (unsigned int i = 0; i < Anime::ListStatuses.size(); i++) { - combo_box->addItem(Strings::ToQString(Translate::ToLocalString(Anime::ListStatuses[i])), - static_cast<int>(Anime::ListStatuses[i])); + combo_box->addItem( + Strings::ToQString(Translate::ToLocalString(Anime::ListStatuses[i])), + static_cast<int>(Anime::ListStatuses[i])); if (Anime::ListStatuses[i] == _status) combo_box->setCurrentIndex(i); } connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, - [this, combo_box](int) { - _status = static_cast<Anime::ListStatus>(combo_box->currentData().toInt()); - }); + [this, combo_box](int) { + _status = static_cast<Anime::ListStatus>(combo_box->currentData().toInt()); + }); /* this should NEVER, EVER, be NOT_IN_LIST */ combo_box->setFixedWidth(LAYOUT_ITEM_WIDTH); @@ -196,9 +200,9 @@ /* Score */ layout->addWidget(new QLabel(tr("Score:"), section), 0, 1); - QSpinBox* spin_box = new QSpinBox(section); + QSpinBox *spin_box = new QSpinBox(section); connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, - [this](int i) { _score = i; }); + [this](int i) { _score = i; }); spin_box->setRange(0, 100); spin_box->setSingleStep(5); spin_box->setValue(_score = anime->GetUserScore()); @@ -208,11 +212,11 @@ layout->setColumnStretch(layout->columnCount(), 1); }); - CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout) { + CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget *section, QGridLayout *layout) { layout->addWidget(new QLabel(tr("Notes:"), section), 0, 0); - QLineEdit* line_edit = new QLineEdit(section); - connect(line_edit, &QLineEdit::textChanged, this, [this](const QString& text) { + QLineEdit *line_edit = new QLineEdit(section); + connect(line_edit, &QLineEdit::textChanged, this, [this](const QString &text) { /* this sucks but I don't really want to implement anything smarter :) */ _notes = Strings::ToUtf8String(text); }); @@ -221,14 +225,14 @@ layout->addWidget(line_edit, 1, 0); }); - CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout) { + CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget *section, QGridLayout *layout) { /* Started */ { layout->addWidget(new QLabel(tr("Date started:"), section), 0, 0); - OptionalDate* date = new OptionalDate(true, section); + OptionalDate *date = new OptionalDate(true, section); connect(date, &OptionalDate::DataChanged, this, - [this](bool enabled, Date date) { _started = enabled ? date : Date(); }); + [this](bool enabled, Date date) { _started = enabled ? date : Date(); }); date->setFixedWidth(LAYOUT_ITEM_WIDTH); _started = anime->GetUserDateStarted(); if (!_started.IsValid()) { @@ -243,9 +247,9 @@ { layout->addWidget(new QLabel(tr("Date completed:"), section), 0, 1); - OptionalDate* date = new OptionalDate(true, section); + OptionalDate *date = new OptionalDate(true, section); connect(date, &OptionalDate::DataChanged, this, - [this](bool enabled, Date date) { _completed = enabled ? date : Date(); }); + [this](bool enabled, Date date) { _completed = enabled ? date : Date(); }); date->setFixedWidth(LAYOUT_ITEM_WIDTH); _completed = anime->GetUserDateCompleted(); if (!_completed.IsValid()) { @@ -263,28 +267,28 @@ /* { - // commenting this out until it actually gets implemented :) + // commenting this out until it actually gets implemented :) - settings_layout->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget)); + settings_layout->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget)); - QWidget* sg_local_content = new QWidget(settings_widget); - QVBoxLayout* sg_local_layout = new QVBoxLayout(sg_local_content); - sg_local_layout->setSpacing(5); - sg_local_layout->setContentsMargins(12, 0, 0, 0); + QWidget* sg_local_content = new QWidget(settings_widget); + QVBoxLayout* sg_local_layout = new QVBoxLayout(sg_local_content); + sg_local_layout->setSpacing(5); + sg_local_layout->setContentsMargins(12, 0, 0, 0); - CREATE_SECTION(sg_local_content, [this, &anime](QWidget* section, QGridLayout* layout){ - layout->addWidget(new QLabel(tr("Alternative titles:"), section), 0, 0); + CREATE_SECTION(sg_local_content, [this, &anime](QWidget* section, QGridLayout* layout){ + layout->addWidget(new QLabel(tr("Alternative titles:"), section), 0, 0); - QLineEdit* line_edit = new QLineEdit("", section); - line_edit->setPlaceholderText( - tr("Enter alternative titles here, separated by a semicolon (i.e. Title 1; Title 2)")); - layout->addWidget(line_edit, 1, 0); + QLineEdit* line_edit = new QLineEdit("", section); + line_edit->setPlaceholderText( + tr("Enter alternative titles here, separated by a semicolon (i.e. Title 1; Title 2)")); + layout->addWidget(line_edit, 1, 0); - QCheckBox* checkbox = new QCheckBox(tr("Use the first alternative title to search for + QCheckBox* checkbox = new QCheckBox(tr("Use the first alternative title to search for torrents")); layout->addWidget(checkbox, 2, 0); - }); + }); - settings_layout->addWidget(sg_local_content); + settings_layout->addWidget(sg_local_content); } */ @@ -307,7 +311,7 @@ { /* Dialog box buttons */ - QDialogButtonBox* button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); + QDialogButtonBox *button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); connect(button_box, &QDialogButtonBox::accepted, this, [this, accept, anime] { SaveData(anime); accept(anime);