diff src/gui/dialog/information.cc @ 89:e6fab256ddc4

dialog/info: make some stuff more sane
author Paper <mrpapersonic@gmail.com>
date Tue, 31 Oct 2023 23:06:33 -0400
parents 1b19d80b3f8c
children 6d8da6e64d61
line wrap: on
line diff
--- 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<int>::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<int>(Anime::ListStatuses[i]));
 
-		QComboBox* combo_box = new QComboBox(section);
-		combo_box->addItems(string_list);
-		connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
-		        [this](int i) { _status = Anime::ListStatuses[i]; });
+		connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this, combo_box](int) {
+			_status = static_cast<Anime::ListStatus>(combo_box->currentData().toInt());
+		});
+		/* this should NEVER, EVER, be NOT_IN_LIST */
 		combo_box->setCurrentIndex(static_cast<int>(_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<int>::of(&QSpinBox::valueChanged), this, [this](int i) { _score = i; });
+		connect(spin_box, QOverload<int>::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"));