# HG changeset patch # User Paper # Date 1698807993 14400 # Node ID e6fab256ddc4e76ed1a534d03cd5fb98395d7990 # Parent 1b19d80b3f8c108d82eb72b9884b348bedbbda5d dialog/info: make some stuff more sane diff -r 1b19d80b3f8c -r e6fab256ddc4 src/gui/dialog/information.cc --- a/src/gui/dialog/information.cc Tue Oct 31 16:18:26 2023 -0400 +++ b/src/gui/dialog/information.cc Tue Oct 31 23:06:33 2023 -0400 @@ -105,12 +105,8 @@ parent->layout()->addWidget(section); }; - const auto GRID_ADD_STRETCH = [](QGridLayout* layout) { - layout->setRowStretch(layout->rowCount(), 1); - layout->setColumnStretch(layout->columnCount(), 1); - }; - - CREATE_SECTION(sg_anime_list_content, [this, &anime, &GRID_ADD_STRETCH](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); @@ -121,44 +117,46 @@ spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); layout->addWidget(spin_box, 1, 0); - layout->addWidget(new QLabel(tr(" "), section), 0, 1); - + /* Rewatching? */ QCheckBox* checkbox = new QCheckBox(tr("Rewatching")); connect(checkbox, QOverload::of(&QCheckBox::stateChanged), this, [this](int state) { _rewatching = (state == Qt::Checked); }); checkbox->setCheckState((_rewatching = anime.GetUserIsRewatching()) ? Qt::Checked : Qt::Unchecked); checkbox->setFixedWidth(LAYOUT_ITEM_WIDTH); layout->addWidget(checkbox, 1, 1); - GRID_ADD_STRETCH(layout); + layout->setColumnStretch(layout->columnCount(), 1); }); - CREATE_SECTION(sg_anime_list_content, [this, &anime, &GRID_ADD_STRETCH](QWidget* section, QGridLayout* layout){ - /* Status & score section */ + CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout){ + /* Status */ layout->addWidget(new QLabel(tr("Status:"), section), 0, 0); - /* FIXME: this sucks */ - QStringList string_list; + QComboBox* combo_box = new QComboBox(section); + for (unsigned int i = 0; i < Anime::ListStatuses.size(); i++) - string_list.append(Strings::ToQString(Translate::ToString(Anime::ListStatuses[i]))); + combo_box->addItem(Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])), static_cast(Anime::ListStatuses[i])); - QComboBox* combo_box = new QComboBox(section); - combo_box->addItems(string_list); - connect(combo_box, QOverload::of(&QComboBox::currentIndexChanged), this, - [this](int i) { _status = Anime::ListStatuses[i]; }); + connect(combo_box, QOverload::of(&QComboBox::currentIndexChanged), this, [this, combo_box](int) { + _status = static_cast(combo_box->currentData().toInt()); + }); + /* this should NEVER, EVER, be NOT_IN_LIST */ combo_box->setCurrentIndex(static_cast(_status = anime.GetUserStatus()) - 1); combo_box->setFixedWidth(LAYOUT_ITEM_WIDTH); layout->addWidget(combo_box, 1, 0); - + + /* Score */ layout->addWidget(new QLabel(tr("Score:"), section), 0, 1); QSpinBox* spin_box = new QSpinBox(section); - connect(spin_box, QOverload::of(&QSpinBox::valueChanged), this, [this](int i) { _score = i; }); + connect(spin_box, QOverload::of(&QSpinBox::valueChanged), this, [this](int i) { + _score = i; + }); spin_box->setRange(0, 100); spin_box->setSingleStep(5); spin_box->setValue(_score = anime.GetUserScore()); spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); layout->addWidget(spin_box, 1, 1); - GRID_ADD_STRETCH(layout); + layout->setColumnStretch(layout->columnCount(), 1); }); CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout){ @@ -174,13 +172,13 @@ layout->addWidget(line_edit, 1, 0); }); - CREATE_SECTION(sg_anime_list_content, [this, &anime, &GRID_ADD_STRETCH](QWidget* section, QGridLayout* layout){ - /* Dates section */ + 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); 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()) { @@ -190,11 +188,12 @@ date->SetDate(_started); layout->addWidget(date, 1, 0); + /* Completed */ layout->addWidget(new QLabel(tr("Date completed:"), section), 0, 1); 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()) { @@ -203,11 +202,14 @@ } date->SetDate(_completed); layout->addWidget(date, 1, 1); - GRID_ADD_STRETCH(layout); + layout->setColumnStretch(layout->columnCount(), 1); }); settings_layout->addWidget(sg_anime_list_content); +/* + // commenting this out until it actually gets implemented :) + settings_layout->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget)); QWidget* sg_local_content = new QWidget(settings_widget); @@ -226,10 +228,12 @@ 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); +*/ #undef CREATE_SECTION #undef CREATE_FULL_WIDTH_SECTION - settings_layout->addWidget(sg_local_content); settings_layout->addStretch(); tabbed_widget->addTab(main_information_widget, tr("Main information"));