Mercurial > minori
comparison src/gui/dialog/information.cc @ 348:6b0768158dcd
text: redesign almost every widget
i.e. Paragraph is now a QLabel, etc etc, some things will probably
break, idc
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Tue, 25 Jun 2024 11:19:54 -0400 |
| parents | 5d3c9b31aa6e |
| children | 6d37a998cf91 |
comparison
equal
deleted
inserted
replaced
| 347:a0aa8c8c4307 | 348:6b0768158dcd |
|---|---|
| 44 anime->SetUserDateStarted(_started); | 44 anime->SetUserDateStarted(_started); |
| 45 anime->SetUserDateCompleted(_completed); | 45 anime->SetUserDateCompleted(_completed); |
| 46 } | 46 } |
| 47 | 47 |
| 48 InformationDialog::InformationDialog(Anime::Anime* anime, std::function<void(Anime::Anime*)> accept, enum Pages page, | 48 InformationDialog::InformationDialog(Anime::Anime* anime, std::function<void(Anime::Anime*)> accept, enum Pages page, |
| 49 QWidget* parent) | 49 QWidget* parent) |
| 50 : QDialog(parent) { | 50 : QDialog(parent) { |
| 51 /* ack. lots of brackets here, but MUCH, MUCH MUCH better than what it used to be */ | 51 /* ack. lots of brackets here, but MUCH, MUCH MUCH better than what it used to be */ |
| 52 setFixedSize(842, 613); | 52 setFixedSize(842, 613); |
| 53 setWindowTitle(tr("Anime Information")); | 53 setWindowTitle(tr("Anime Information")); |
| 54 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); | 54 setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); |
| 87 | 87 |
| 88 main_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | 88 main_widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
| 89 | 89 |
| 90 { | 90 { |
| 91 /* Anime title */ | 91 /* Anime title */ |
| 92 TextWidgets::Title* anime_title = | 92 TextWidgets::Title* anime_title = new TextWidgets::Title(main_widget); |
| 93 new TextWidgets::Title(Strings::ToQString(anime->GetUserPreferredTitle()), main_widget); | 93 anime_title->SetText(anime->GetUserPreferredTitle()); |
| 94 main_layout->addWidget(anime_title); | 94 main_layout->addWidget(anime_title); |
| 95 } | 95 } |
| 96 | 96 |
| 97 { | 97 { |
| 98 /* Tab widget, contains main info and settings */ | 98 /* Tab widget, contains main info and settings */ |
| 109 /* My list and settings */ | 109 /* My list and settings */ |
| 110 QWidget* settings_widget = new QWidget(tabbed_widget); | 110 QWidget* settings_widget = new QWidget(tabbed_widget); |
| 111 settings_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); | 111 settings_widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); |
| 112 | 112 |
| 113 QVBoxLayout* settings_layout = new QVBoxLayout(settings_widget); | 113 QVBoxLayout* settings_layout = new QVBoxLayout(settings_widget); |
| 114 settings_layout->addWidget(new TextWidgets::Header(tr("Anime list"), settings_widget)); | 114 |
| 115 TextWidgets::Header* header = new TextWidgets::Header(settings_widget); | |
| 116 header->SetText(Strings::Translate("Anime list")); | |
| 117 settings_layout->addWidget(header); | |
| 115 | 118 |
| 116 { | 119 { |
| 117 /* Anime List */ | 120 /* Anime List */ |
| 118 QWidget* sg_anime_list_content = new QWidget(settings_widget); | 121 QWidget* sg_anime_list_content = new QWidget(settings_widget); |
| 119 | 122 |
| 141 /* Episodes watched... */ | 144 /* Episodes watched... */ |
| 142 layout->addWidget(new QLabel(tr("Episodes watched:"), section), 0, 0); | 145 layout->addWidget(new QLabel(tr("Episodes watched:"), section), 0, 0); |
| 143 | 146 |
| 144 QSpinBox* spin_box = new QSpinBox(section); | 147 QSpinBox* spin_box = new QSpinBox(section); |
| 145 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, | 148 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, |
| 146 [this](int i) { _progress = i; }); | 149 [this](int i) { _progress = i; }); |
| 147 spin_box->setRange(0, anime->GetEpisodes()); | 150 spin_box->setRange(0, anime->GetEpisodes()); |
| 148 spin_box->setSingleStep(1); | 151 spin_box->setSingleStep(1); |
| 149 spin_box->setValue(_progress = anime->GetUserProgress()); | 152 spin_box->setValue(_progress = anime->GetUserProgress()); |
| 150 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); | 153 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); |
| 151 layout->addWidget(spin_box, 1, 0); | 154 layout->addWidget(spin_box, 1, 0); |
| 153 | 156 |
| 154 { | 157 { |
| 155 /* Rewatching? */ | 158 /* Rewatching? */ |
| 156 QCheckBox* checkbox = new QCheckBox(tr("Rewatching")); | 159 QCheckBox* checkbox = new QCheckBox(tr("Rewatching")); |
| 157 connect(checkbox, QOverload<int>::of(&QCheckBox::stateChanged), this, | 160 connect(checkbox, QOverload<int>::of(&QCheckBox::stateChanged), this, |
| 158 [this](int state) { _rewatching = (state == Qt::Checked); }); | 161 [this](int state) { _rewatching = (state == Qt::Checked); }); |
| 159 checkbox->setCheckState((_rewatching = anime->GetUserIsRewatching()) ? Qt::Checked | 162 checkbox->setCheckState((_rewatching = anime->GetUserIsRewatching()) ? Qt::Checked |
| 160 : Qt::Unchecked); | 163 : Qt::Unchecked); |
| 161 checkbox->setFixedWidth(LAYOUT_ITEM_WIDTH); | 164 checkbox->setFixedWidth(LAYOUT_ITEM_WIDTH); |
| 162 layout->addWidget(checkbox, 1, 1); | 165 layout->addWidget(checkbox, 1, 1); |
| 163 } | 166 } |
| 164 layout->setColumnStretch(layout->columnCount(), 1); | 167 layout->setColumnStretch(layout->columnCount(), 1); |
| 165 }); | 168 }); |
| 172 QComboBox* combo_box = new QComboBox(section); | 175 QComboBox* combo_box = new QComboBox(section); |
| 173 | 176 |
| 174 _status = anime->GetUserStatus(); | 177 _status = anime->GetUserStatus(); |
| 175 for (unsigned int i = 0; i < Anime::ListStatuses.size(); i++) { | 178 for (unsigned int i = 0; i < Anime::ListStatuses.size(); i++) { |
| 176 combo_box->addItem(Strings::ToQString(Translate::ToLocalString(Anime::ListStatuses[i])), | 179 combo_box->addItem(Strings::ToQString(Translate::ToLocalString(Anime::ListStatuses[i])), |
| 177 static_cast<int>(Anime::ListStatuses[i])); | 180 static_cast<int>(Anime::ListStatuses[i])); |
| 178 if (Anime::ListStatuses[i] == _status) | 181 if (Anime::ListStatuses[i] == _status) |
| 179 combo_box->setCurrentIndex(i); | 182 combo_box->setCurrentIndex(i); |
| 180 } | 183 } |
| 181 | 184 |
| 182 connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, | 185 connect(combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, |
| 183 [this, combo_box](int) { | 186 [this, combo_box](int) { |
| 184 _status = static_cast<Anime::ListStatus>(combo_box->currentData().toInt()); | 187 _status = static_cast<Anime::ListStatus>(combo_box->currentData().toInt()); |
| 185 }); | 188 }); |
| 186 | 189 |
| 187 /* this should NEVER, EVER, be NOT_IN_LIST */ | 190 /* this should NEVER, EVER, be NOT_IN_LIST */ |
| 188 combo_box->setFixedWidth(LAYOUT_ITEM_WIDTH); | 191 combo_box->setFixedWidth(LAYOUT_ITEM_WIDTH); |
| 189 layout->addWidget(combo_box, 1, 0); | 192 layout->addWidget(combo_box, 1, 0); |
| 190 } | 193 } |
| 193 /* Score */ | 196 /* Score */ |
| 194 layout->addWidget(new QLabel(tr("Score:"), section), 0, 1); | 197 layout->addWidget(new QLabel(tr("Score:"), section), 0, 1); |
| 195 | 198 |
| 196 QSpinBox* spin_box = new QSpinBox(section); | 199 QSpinBox* spin_box = new QSpinBox(section); |
| 197 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, | 200 connect(spin_box, QOverload<int>::of(&QSpinBox::valueChanged), this, |
| 198 [this](int i) { _score = i; }); | 201 [this](int i) { _score = i; }); |
| 199 spin_box->setRange(0, 100); | 202 spin_box->setRange(0, 100); |
| 200 spin_box->setSingleStep(5); | 203 spin_box->setSingleStep(5); |
| 201 spin_box->setValue(_score = anime->GetUserScore()); | 204 spin_box->setValue(_score = anime->GetUserScore()); |
| 202 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); | 205 spin_box->setFixedWidth(LAYOUT_ITEM_WIDTH); |
| 203 layout->addWidget(spin_box, 1, 1); | 206 layout->addWidget(spin_box, 1, 1); |
| 223 { | 226 { |
| 224 layout->addWidget(new QLabel(tr("Date started:"), section), 0, 0); | 227 layout->addWidget(new QLabel(tr("Date started:"), section), 0, 0); |
| 225 | 228 |
| 226 OptionalDate* date = new OptionalDate(true, section); | 229 OptionalDate* date = new OptionalDate(true, section); |
| 227 connect(date, &OptionalDate::DataChanged, this, | 230 connect(date, &OptionalDate::DataChanged, this, |
| 228 [this](bool enabled, Date date) { _started = enabled ? date : Date(); }); | 231 [this](bool enabled, Date date) { _started = enabled ? date : Date(); }); |
| 229 date->setFixedWidth(LAYOUT_ITEM_WIDTH); | 232 date->setFixedWidth(LAYOUT_ITEM_WIDTH); |
| 230 _started = anime->GetUserDateStarted(); | 233 _started = anime->GetUserDateStarted(); |
| 231 if (!_started.IsValid()) { | 234 if (!_started.IsValid()) { |
| 232 date->SetEnabled(false); | 235 date->SetEnabled(false); |
| 233 _started = anime->GetStartedDate(); | 236 _started = anime->GetStartedDate(); |
| 240 { | 243 { |
| 241 layout->addWidget(new QLabel(tr("Date completed:"), section), 0, 1); | 244 layout->addWidget(new QLabel(tr("Date completed:"), section), 0, 1); |
| 242 | 245 |
| 243 OptionalDate* date = new OptionalDate(true, section); | 246 OptionalDate* date = new OptionalDate(true, section); |
| 244 connect(date, &OptionalDate::DataChanged, this, | 247 connect(date, &OptionalDate::DataChanged, this, |
| 245 [this](bool enabled, Date date) { _completed = enabled ? date : Date(); }); | 248 [this](bool enabled, Date date) { _completed = enabled ? date : Date(); }); |
| 246 date->setFixedWidth(LAYOUT_ITEM_WIDTH); | 249 date->setFixedWidth(LAYOUT_ITEM_WIDTH); |
| 247 _completed = anime->GetUserDateCompleted(); | 250 _completed = anime->GetUserDateCompleted(); |
| 248 if (!_completed.IsValid()) { | 251 if (!_completed.IsValid()) { |
| 249 date->SetEnabled(false); | 252 date->SetEnabled(false); |
| 250 _completed = anime->GetCompletedDate(); | 253 _completed = anime->GetCompletedDate(); |
| 258 settings_layout->addWidget(sg_anime_list_content); | 261 settings_layout->addWidget(sg_anime_list_content); |
| 259 } | 262 } |
| 260 | 263 |
| 261 /* | 264 /* |
| 262 { | 265 { |
| 263 // commenting this out until it actually gets implemented :) | 266 // commenting this out until it actually gets implemented :) |
| 264 | 267 |
| 265 settings_layout->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget)); | 268 settings_layout->addWidget(new TextWidgets::Header(tr("Local settings"), settings_widget)); |
| 266 | 269 |
| 267 QWidget* sg_local_content = new QWidget(settings_widget); | 270 QWidget* sg_local_content = new QWidget(settings_widget); |
| 268 QVBoxLayout* sg_local_layout = new QVBoxLayout(sg_local_content); | 271 QVBoxLayout* sg_local_layout = new QVBoxLayout(sg_local_content); |
| 269 sg_local_layout->setSpacing(5); | 272 sg_local_layout->setSpacing(5); |
| 270 sg_local_layout->setContentsMargins(12, 0, 0, 0); | 273 sg_local_layout->setContentsMargins(12, 0, 0, 0); |
| 271 | 274 |
| 272 CREATE_SECTION(sg_local_content, [this, &anime](QWidget* section, QGridLayout* layout){ | 275 CREATE_SECTION(sg_local_content, [this, &anime](QWidget* section, QGridLayout* layout){ |
| 273 layout->addWidget(new QLabel(tr("Alternative titles:"), section), 0, 0); | 276 layout->addWidget(new QLabel(tr("Alternative titles:"), section), 0, 0); |
| 274 | 277 |
| 275 QLineEdit* line_edit = new QLineEdit("", section); | 278 QLineEdit* line_edit = new QLineEdit("", section); |
| 276 line_edit->setPlaceholderText( | 279 line_edit->setPlaceholderText( |
| 277 tr("Enter alternative titles here, separated by a semicolon (i.e. Title 1; Title 2)")); | 280 tr("Enter alternative titles here, separated by a semicolon (i.e. Title 1; Title 2)")); |
| 278 layout->addWidget(line_edit, 1, 0); | 281 layout->addWidget(line_edit, 1, 0); |
| 279 | 282 |
| 280 QCheckBox* checkbox = new QCheckBox(tr("Use the first alternative title to search for | 283 QCheckBox* checkbox = new QCheckBox(tr("Use the first alternative title to search for |
| 281 torrents")); layout->addWidget(checkbox, 2, 0); | 284 torrents")); layout->addWidget(checkbox, 2, 0); |
| 282 }); | 285 }); |
| 283 | 286 |
| 284 settings_layout->addWidget(sg_local_content); | 287 settings_layout->addWidget(sg_local_content); |
| 285 } | 288 } |
| 286 */ | 289 */ |
| 287 | 290 |
| 288 settings_layout->addStretch(); | 291 settings_layout->addStretch(); |
| 289 | 292 |
