comparison src/gui/pages/anime_list.cpp @ 51:75c804f713b2

window: add about window, *: use tr() when applicable (useful for i18n)
author Paper <mrpapersonic@gmail.com>
date Mon, 25 Sep 2023 20:29:26 -0400
parents d8eb763e6661
children 0c4138de2ea7
comparison
equal deleted inserted replaced
50:10868c3fb2be 51:75c804f713b2
45 static_cast<int>(index.siblingAtColumn(AnimeListWidgetModel::AL_EPISODES).data(Qt::UserRole).toReal()); 45 static_cast<int>(index.siblingAtColumn(AnimeListWidgetModel::AL_EPISODES).data(Qt::UserRole).toReal());
46 46
47 int text_width = 59; 47 int text_width = 59;
48 QRectF text_rect(option.rect.x() + text_width, option.rect.y(), text_width, option.decorationSize.height()); 48 QRectF text_rect(option.rect.x() + text_width, option.rect.y(), text_width, option.decorationSize.height());
49 painter->save(); 49 painter->save();
50 painter->drawText(text_rect, "/", QTextOption(Qt::AlignCenter | Qt::AlignVCenter)); 50 painter->drawText(text_rect, tr("/"), QTextOption(Qt::AlignCenter | Qt::AlignVCenter));
51 // drawText(const QRectF &rectangle, const QString &text, const QTextOption &option = 51 drawText(const QRectF &rectangle, const QString &text, const QTextOption &option =
52 QTextOption()) painter->drawText(QRectF(text_rect.x(), text_rect.y(), text_width / 2 - 2, 52 QTextOption()) painter->drawText(QRectF(text_rect.x(), text_rect.y(), text_width / 2 - 2,
53 text_rect.height()), QString::number(progress), QTextOption(Qt::AlignRight | Qt::AlignVCenter)); 53 text_rect.height()), QString::number(progress), QTextOption(Qt::AlignRight | Qt::AlignVCenter));
54 painter->drawText( 54 painter->drawText(
55 QRectF(text_rect.x() + text_width / 2 + 2, text_rect.y(), text_width / 2 - 2, text_rect.height()), 55 QRectF(text_rect.x() + text_width / 2 + 2, text_rect.y(), text_width / 2 - 2, text_rect.height()),
56 QString::number(episodes), QTextOption(Qt::AlignLeft | Qt::AlignVCenter)); 56 QString::number(episodes), QTextOption(Qt::AlignLeft | Qt::AlignVCenter));
304 sort_models[tab_bar->currentIndex()]->mapSelectionToSource(tree_view->selectionModel()->selection()); 304 sort_models[tab_bar->currentIndex()]->mapSelectionToSource(tree_view->selectionModel()->selection());
305 if (!selection.indexes().first().isValid()) { 305 if (!selection.indexes().first().isValid()) {
306 return; 306 return;
307 } 307 }
308 308
309 QAction* action = menu->addAction("Information", [this, selection] { 309 QAction* action = menu->addAction(tr("Information"), [this, selection] {
310 const QModelIndex index = ((AnimeListWidgetModel*)sort_models[tab_bar->currentIndex()]->sourceModel()) 310 const QModelIndex index = ((AnimeListWidgetModel*)sort_models[tab_bar->currentIndex()]->sourceModel())
311 ->index(selection.indexes().first().row()); 311 ->index(selection.indexes().first().row());
312 Anime::Anime* anime = 312 Anime::Anime* anime =
313 ((AnimeListWidgetModel*)sort_models[tab_bar->currentIndex()]->sourceModel())->GetAnimeFromIndex(index); 313 ((AnimeListWidgetModel*)sort_models[tab_bar->currentIndex()]->sourceModel())->GetAnimeFromIndex(index);
314 if (!anime) { 314 if (!anime) {
315 return; 315 return;
316 } 316 }
317 317
318 InformationDialog* dialog = new InformationDialog( 318 InformationDialog* dialog = new InformationDialog(*anime, [this] {
319 *anime, 319 Refresh();
320 [this, anime] { 320 }, this);
321 ((AnimeListWidgetModel*)sort_models[tab_bar->currentIndex()]->sourceModel())
322 ->UpdateAnime(anime->GetId());
323 },
324 this);
325 321
326 dialog->show(); 322 dialog->show();
327 dialog->raise(); 323 dialog->raise();
328 dialog->activateWindow(); 324 dialog->activateWindow();
329 }); 325 });
341 const QModelIndex index = ((AnimeListWidgetModel*)sort_models[tab_bar->currentIndex()]->sourceModel()) 337 const QModelIndex index = ((AnimeListWidgetModel*)sort_models[tab_bar->currentIndex()]->sourceModel())
342 ->index(selection.indexes().first().row()); 338 ->index(selection.indexes().first().row());
343 Anime::Anime* anime = 339 Anime::Anime* anime =
344 ((AnimeListWidgetModel*)sort_models[tab_bar->currentIndex()]->sourceModel())->GetAnimeFromIndex(index); 340 ((AnimeListWidgetModel*)sort_models[tab_bar->currentIndex()]->sourceModel())->GetAnimeFromIndex(index);
345 341
346 InformationDialog* dialog = new InformationDialog( 342 InformationDialog* dialog = new InformationDialog(*anime, [this] {
347 *anime, 343 Refresh();
348 [this, anime] { 344 }, this);
349 ((AnimeListWidgetModel*)sort_models[tab_bar->currentIndex()]->sourceModel())->UpdateAnime(anime->GetId());
350 },
351 this);
352 345
353 dialog->show(); 346 dialog->show();
354 dialog->raise(); 347 dialog->raise();
355 dialog->activateWindow(); 348 dialog->activateWindow();
356 } 349 }