Mercurial > minori
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 88:1b19d80b3f8c | 89:e6fab256ddc4 |
|---|---|
| 103 layout->setContentsMargins(0, 0, 0, 0); | 103 layout->setContentsMargins(0, 0, 0, 0); |
| 104 x(section, layout); | 104 x(section, layout); |
| 105 parent->layout()->addWidget(section); | 105 parent->layout()->addWidget(section); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 const auto GRID_ADD_STRETCH = [](QGridLayout* layout) { | 108 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout){ |
| 109 layout->setRowStretch(layout->rowCount(), 1); | 109 /* Episodes watched... */ |
| 110 layout->setColumnStretch(layout->columnCount(), 1); | |
| 111 }; | |
| 112 | |
| 113 CREATE_SECTION(sg_anime_list_content, [this, &anime, &GRID_ADD_STRETCH](QWidget* section, QGridLayout* layout){ | |
| 114 layout->addWidget(new QLabel(tr("Episodes watched:"), section), 0, 0); | 110 layout->addWidget(new QLabel(tr("Episodes watched:"), section), 0, 0); |
| 115 | 111 |
| 116 QSpinBox* spin_box = new QSpinBox(section); | 112 QSpinBox* spin_box = new QSpinBox(section); |
| 117 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { _progress = i; }); | 113 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { _progress = i; }); |
| 118 spin_box->setRange(0, anime.GetEpisodes()); | 114 spin_box->setRange(0, anime.GetEpisodes()); |
| 119 spin_box->setSingleStep(1); | 115 spin_box->setSingleStep(1); |
| 120 spin_box->setValue(_progress = anime.GetUserProgress()); | 116 spin_box->setValue(_progress = anime.GetUserProgress()); |
| 121 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); | 117 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); |
| 122 layout->addWidget(spin_box, 1, 0); | 118 layout->addWidget(spin_box, 1, 0); |
| 123 | 119 |
| 124 layout->addWidget(new QLabel(tr(" "), section), 0, 1); | 120 /* Rewatching? */ |
| 125 | |
| 126 QCheckBox* checkbox = new QCheckBox(tr("Rewatching")); | 121 QCheckBox* checkbox = new QCheckBox(tr("Rewatching")); |
| 127 connect(checkbox, QOverload<int>::of(&QCheckBox::stateChanged), this, | 122 connect(checkbox, QOverload<int>::of(&QCheckBox::stateChanged), this, |
| 128 [this](int state) { _rewatching = (state == Qt::Checked); }); | 123 [this](int state) { _rewatching = (state == Qt::Checked); }); |
| 129 checkbox->setCheckState((_rewatching = anime.GetUserIsRewatching()) ? Qt::Checked : Qt::Unchecked); | 124 checkbox->setCheckState((_rewatching = anime.GetUserIsRewatching()) ? Qt::Checked : Qt::Unchecked); |
| 130 checkbox->setFixedWidth(LAYOUT_ITEM_WIDTH); | 125 checkbox->setFixedWidth(LAYOUT_ITEM_WIDTH); |
| 131 layout->addWidget(checkbox, 1, 1); | 126 layout->addWidget(checkbox, 1, 1); |
| 132 GRID_ADD_STRETCH(layout); | 127 layout->setColumnStretch(layout->columnCount(), 1); |
| 133 }); | 128 }); |
| 134 | 129 |
| 135 CREATE_SECTION(sg_anime_list_content, [this, &anime, &GRID_ADD_STRETCH](QWidget* section, QGridLayout* layout){ | 130 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout){ |
| 136 /* Status & score section */ | 131 /* Status */ |
| 137 layout->addWidget(new QLabel(tr("Status:"), section), 0, 0); | 132 layout->addWidget(new QLabel(tr("Status:"), section), 0, 0); |
| 138 | 133 |
| 139 /* FIXME: this sucks */ | 134 QComboBox* combo_box = new QComboBox(section); |
| 140 QStringList string_list; | 135 |
| 141 for (unsigned int i = 0; i < Anime::ListStatuses.size(); i++) | 136 for (unsigned int i = 0; i < Anime::ListStatuses.size(); i++) |
| 142 string_list.append(Strings::ToQString(Translate::ToString(Anime::ListStatuses[i]))); | 137 combo_box->addItem(Strings::ToQString(Translate::ToString(Anime::ListStatuses[i])), static_cast<int>(Anime::ListStatuses[i])); |
| 143 | 138 |
| 144 QComboBox* combo_box = new QComboBox(section); | 139 connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this, combo_box](int) { |
| 145 combo_box->addItems(string_list); | 140 _status = static_cast<Anime::ListStatus>(combo_box->currentData().toInt()); |
| 146 connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, | 141 }); |
| 147 [this](int i) { _status = Anime::ListStatuses[i]; }); | 142 /* this should NEVER, EVER, be NOT_IN_LIST */ |
| 148 combo_box->setCurrentIndex(static_cast<int>(_status = anime.GetUserStatus()) - 1); | 143 combo_box->setCurrentIndex(static_cast<int>(_status = anime.GetUserStatus()) - 1); |
| 149 combo_box->setFixedWidth(LAYOUT_ITEM_WIDTH); | 144 combo_box->setFixedWidth(LAYOUT_ITEM_WIDTH); |
| 150 layout->addWidget(combo_box, 1, 0); | 145 layout->addWidget(combo_box, 1, 0); |
| 151 | 146 |
| 147 /* Score */ | |
| 152 layout->addWidget(new QLabel(tr("Score:"), section), 0, 1); | 148 layout->addWidget(new QLabel(tr("Score:"), section), 0, 1); |
| 153 | 149 |
| 154 QSpinBox* spin_box = new QSpinBox(section); | 150 QSpinBox* spin_box = new QSpinBox(section); |
| 155 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { _score = i; }); | 151 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, [this](int i) { |
| 152 _score = i; | |
| 153 }); | |
| 156 spin_box->setRange(0, 100); | 154 spin_box->setRange(0, 100); |
| 157 spin_box->setSingleStep(5); | 155 spin_box->setSingleStep(5); |
| 158 spin_box->setValue(_score = anime.GetUserScore()); | 156 spin_box->setValue(_score = anime.GetUserScore()); |
| 159 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); | 157 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); |
| 160 layout->addWidget(spin_box, 1, 1); | 158 layout->addWidget(spin_box, 1, 1); |
| 161 GRID_ADD_STRETCH(layout); | 159 layout->setColumnStretch(layout->columnCount(), 1); |
| 162 }); | 160 }); |
| 163 | 161 |
| 164 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout){ | 162 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout){ |
| 165 layout->addWidget(new QLabel(tr("Notes:"), section), 0, 0); | 163 layout->addWidget(new QLabel(tr("Notes:"), section), 0, 0); |
| 166 | 164 |
| 172 line_edit->setText(Strings::ToQString(_notes = anime.GetUserNotes())); | 170 line_edit->setText(Strings::ToQString(_notes = anime.GetUserNotes())); |
| 173 line_edit->setPlaceholderText(tr("Enter your notes about this anime")); | 171 line_edit->setPlaceholderText(tr("Enter your notes about this anime")); |
| 174 layout->addWidget(line_edit, 1, 0); | 172 layout->addWidget(line_edit, 1, 0); |
| 175 }); | 173 }); |
| 176 | 174 |
| 177 CREATE_SECTION(sg_anime_list_content, [this, &anime, &GRID_ADD_STRETCH](QWidget* section, QGridLayout* layout){ | 175 CREATE_SECTION(sg_anime_list_content, [this, &anime](QWidget* section, QGridLayout* layout){ |
| 178 /* Dates section */ | 176 /* Started */ |
| 179 layout->addWidget(new QLabel(tr("Date started:"), section), 0, 0); | 177 layout->addWidget(new QLabel(tr("Date started:"), section), 0, 0); |
| 180 | 178 |
| 181 OptionalDate* date = new OptionalDate(true, section); | 179 OptionalDate* date = new OptionalDate(true, section); |
| 182 connect(date, &OptionalDate::DataChanged, this, | 180 connect(date, &OptionalDate::DataChanged, this, |
| 183 [this](bool enabled, Date date) { _started = (enabled) ? date : Date(); }); | 181 [this](bool enabled, Date date) { _started = enabled ? date : Date(); }); |
| 184 date->setFixedWidth(LAYOUT_ITEM_WIDTH); | 182 date->setFixedWidth(LAYOUT_ITEM_WIDTH); |
| 185 _started = anime.GetUserDateStarted(); | 183 _started = anime.GetUserDateStarted(); |
| 186 if (!_started.IsValid()) { | 184 if (!_started.IsValid()) { |
| 187 date->SetEnabled(false); | 185 date->SetEnabled(false); |
| 188 _started = anime.GetAirDate(); | 186 _started = anime.GetAirDate(); |
| 189 } | 187 } |
| 190 date->SetDate(_started); | 188 date->SetDate(_started); |
| 191 layout->addWidget(date, 1, 0); | 189 layout->addWidget(date, 1, 0); |
| 192 | 190 |
| 191 /* Completed */ | |
| 193 layout->addWidget(new QLabel(tr("Date completed:"), section), 0, 1); | 192 layout->addWidget(new QLabel(tr("Date completed:"), section), 0, 1); |
| 194 | 193 |
| 195 date = new OptionalDate(true, section); | 194 date = new OptionalDate(true, section); |
| 196 connect(date, &OptionalDate::DataChanged, this, | 195 connect(date, &OptionalDate::DataChanged, this, |
| 197 [this](bool enabled, Date date) { _completed = (enabled) ? date : Date(); }); | 196 [this](bool enabled, Date date) { _completed = enabled ? date : Date(); }); |
| 198 date->setFixedWidth(LAYOUT_ITEM_WIDTH); | 197 date->setFixedWidth(LAYOUT_ITEM_WIDTH); |
| 199 _completed = anime.GetUserDateCompleted(); | 198 _completed = anime.GetUserDateCompleted(); |
| 200 if (!_completed.IsValid()) { | 199 if (!_completed.IsValid()) { |
| 201 date->SetEnabled(false); | 200 date->SetEnabled(false); |
| 202 _completed = anime.GetAirDate(); | 201 _completed = anime.GetAirDate(); |
| 203 } | 202 } |
| 204 date->SetDate(_completed); | 203 date->SetDate(_completed); |
| 205 layout->addWidget(date, 1, 1); | 204 layout->addWidget(date, 1, 1); |
| 206 GRID_ADD_STRETCH(layout); | 205 layout->setColumnStretch(layout->columnCount(), 1); |
| 207 }); | 206 }); |
| 208 | 207 |
| 209 settings_layout->addWidget(sg_anime_list_content); | 208 settings_layout->addWidget(sg_anime_list_content); |
| 209 | |
| 210 /* | |
| 211 // commenting this out until it actually gets implemented :) | |
| 210 | 212 |
| 211 settings_layout->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget)); | 213 settings_layout->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget)); |
| 212 | 214 |
| 213 QWidget* sg_local_content = new QWidget(settings_widget); | 215 QWidget* sg_local_content = new QWidget(settings_widget); |
| 214 QVBoxLayout* sg_local_layout = new QVBoxLayout(sg_local_content); | 216 QVBoxLayout* sg_local_layout = new QVBoxLayout(sg_local_content); |
| 224 layout->addWidget(line_edit, 1, 0); | 226 layout->addWidget(line_edit, 1, 0); |
| 225 | 227 |
| 226 QCheckBox* checkbox = new QCheckBox(tr("Use the first alternative title to search for torrents")); | 228 QCheckBox* checkbox = new QCheckBox(tr("Use the first alternative title to search for torrents")); |
| 227 layout->addWidget(checkbox, 2, 0); | 229 layout->addWidget(checkbox, 2, 0); |
| 228 }); | 230 }); |
| 231 | |
| 232 settings_layout->addWidget(sg_local_content); | |
| 233 */ | |
| 229 #undef CREATE_SECTION | 234 #undef CREATE_SECTION |
| 230 #undef CREATE_FULL_WIDTH_SECTION | 235 #undef CREATE_FULL_WIDTH_SECTION |
| 231 | 236 |
| 232 settings_layout->addWidget(sg_local_content); | |
| 233 settings_layout->addStretch(); | 237 settings_layout->addStretch(); |
| 234 | 238 |
| 235 tabbed_widget->addTab(main_information_widget, tr("Main information")); | 239 tabbed_widget->addTab(main_information_widget, tr("Main information")); |
| 236 tabbed_widget->addTab(settings_widget, tr("My list and settings")); | 240 tabbed_widget->addTab(settings_widget, tr("My list and settings")); |
| 237 | 241 |
