From fa109a1d017adb0253913cbe09866aefddf0e6fe Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Wed, 7 Feb 2024 00:37:09 +0100 Subject: [PATCH] game_list: Mark games as favorite to make them appear at the top Co-Authored-By: Colin E. <5352197+Kewlan@users.noreply.github.com> --- dist/license.md | 3 + dist/qt_themes/colorful/icons/48x48/star.png | Bin 0 -> 1108 bytes dist/qt_themes/colorful/style.qrc | 1 + dist/qt_themes/colorful_dark/style.qrc | 1 + dist/qt_themes/default/default.qrc | 1 + dist/qt_themes/default/icons/48x48/star.png | Bin 0 -> 1029 bytes .../qt_themes/qdarkstyle/icons/48x48/star.png | Bin 0 -> 1055 bytes dist/qt_themes/qdarkstyle/style.qrc | 1 + .../icons/48x48/star.png | Bin 0 -> 725 bytes .../qdarkstyle_midnight_blue/style.qrc | 1 + license.txt | 1 + src/lime_qt/configuration/config.cpp | 16 +++ src/lime_qt/game_list.cpp | 106 +++++++++++++++++- src/lime_qt/game_list.h | 5 + src/lime_qt/game_list_p.h | 26 ++++- src/lime_qt/uisettings.h | 2 + 16 files changed, 159 insertions(+), 5 deletions(-) create mode 100644 dist/qt_themes/colorful/icons/48x48/star.png create mode 100644 dist/qt_themes/default/icons/48x48/star.png create mode 100644 dist/qt_themes/qdarkstyle/icons/48x48/star.png create mode 100644 dist/qt_themes/qdarkstyle_midnight_blue/icons/48x48/star.png diff --git a/dist/license.md b/dist/license.md index b3e8d05a4..207fc638e 100644 --- a/dist/license.md +++ b/dist/license.md @@ -15,6 +15,7 @@ qt_themes/default/icons/48x48/folder.png | CC BY-ND 3.0 | https://icons8.com qt_themes/default/icons/48x48/no_avatar.png | CC BY-ND 3.0 | https://icons8.com qt_themes/default/icons/48x48/plus.png | CC0 1.0 | Designed by BreadFish64 from the Citra team qt_themes/default/icons/48x48/sd_card.png | CC BY-ND 3.0 | https://icons8.com +qt_themes/default/icons/48x48/star.png | CC BY-ND 3.0 | https://icons8.com qt_themes/qdarkstyle/icons/16x16/connected.png | CC BY-ND 3.0 | https://icons8.com qt_themes/qdarkstyle/icons/16x16/connected_notification.png | CC BY-ND 3.0 | https://icons8.com qt_themes/qdarkstyle/icons/16x16/disconnected.png | CC BY-ND 3.0 | https://icons8.com @@ -26,6 +27,7 @@ qt_themes/qdarkstyle/icons/48x48/folder.png | CC BY-ND 3.0 | https://icons8.com qt_themes/qdarkstyle/icons/48x48/no_avatar.png | CC BY-ND 3.0 | https://icons8.com qt_themes/qdarkstyle/icons/48x48/plus.png | CC0 1.0 | Designed by BreadFish64 from the Citra team qt_themes/qdarkstyle/icons/48x48/sd_card.png | CC BY-ND 3.0 | https://icons8.com +qt_themes/qdarkstyle/icons/48x48/star.png | CC BY-ND 3.0 | https://icons8.com qt_themes/colorful/icons/16x16/connected.png | CC BY-ND 3.0 | https://icons8.com qt_themes/colorful/icons/16x16/connected_notification.png | CC BY-ND 3.0 | https://icons8.com qt_themes/colorful/icons/16x16/disconnected.png | CC BY-ND 3.0 | https://icons8.com @@ -36,6 +38,7 @@ qt_themes/colorful/icons/48x48/chip.png | CC BY-ND 3.0 | https://icons8.com qt_themes/colorful/icons/48x48/folder.png | CC BY-ND 3.0 | https://icons8.com qt_themes/colorful/icons/48x48/plus.png | CC BY-ND 3.0 | https://icons8.com qt_themes/colorful/icons/48x48/sd_card.png | CC BY-ND 3.0 | https://icons8.com +qt_themes/colorful/icons/48x48/star.png | CC BY-ND 3.0 | https://icons8.com qt_themes/colorful_dark/icons/16x16/connected.png | CC BY-ND 3.0 | https://icons8.com diff --git a/dist/qt_themes/colorful/icons/48x48/star.png b/dist/qt_themes/colorful/icons/48x48/star.png new file mode 100644 index 0000000000000000000000000000000000000000..19d55a0a8065cf4168752568bc67d4ebc3b8ec9f GIT binary patch literal 1108 zcmV-a1grarP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGff&c&uf&sqz;-vrp1L;XbK~!i%?U~PS zOi>ia&v{dXiliH?Ea>m5YV=J@_#cF(BsMmFOT@16TZoX5NLUE55E8}4qVW$P%nb1( zn$EO{AYwr)%!F#a<9pxSl&Kl>?zm68m``)xJLk-u`|dgC{+d@RQ>ILKNUVOj#2Qy= zH543u4+o~h}$Yl66AKfZVTN z1_u%lf3?qEJG%pMtyv?S3^;TM*WBQU6Utn$o&iZTwvu=cA^zF6h|BG%2U@d&{S0_= z5ZC;HacHlWtYI|+602FVnIO`WGQ!~RNa5ZVg^L5`$5`c)UviOSjm9gt7)J}8Ennd_IIhAYjbzV_$ z-R3U(L9hBZLcElHUSGJ0}_t za#K6u#u;t;A6y91c|}nN6uuK}$z90DX>AG*=5ypGw*=|DB9H?LhAYw#E3y`AjA6H(U1-B9gn0&roO)bscV1CJA0u^I4ve`2%!{>TpAy09=b-!WT>Oda@r{HvE!H;BCkj^gxa@IHsz20kcfvGmtMh4a|N#xYyvOee95 zjyfs!k|(V=Idicons/48x48/folder.png icons/48x48/plus.png icons/48x48/sd_card.png + icons/48x48/star.png icons/256x256/plus_folder.png diff --git a/dist/qt_themes/colorful_dark/style.qrc b/dist/qt_themes/colorful_dark/style.qrc index 9c531fe1b..ec328117d 100644 --- a/dist/qt_themes/colorful_dark/style.qrc +++ b/dist/qt_themes/colorful_dark/style.qrc @@ -11,6 +11,7 @@ ../qdarkstyle/icons/48x48/no_avatar.png ../colorful/icons/48x48/plus.png ../colorful/icons/48x48/sd_card.png + ../colorful/icons/48x48/star.png ../colorful/icons/256x256/plus_folder.png diff --git a/dist/qt_themes/default/default.qrc b/dist/qt_themes/default/default.qrc index c59831641..34e5608dc 100644 --- a/dist/qt_themes/default/default.qrc +++ b/dist/qt_themes/default/default.qrc @@ -14,6 +14,7 @@ icons/48x48/plus.png icons/48x48/sd_card.png icons/256x256/lime.png + icons/48x48/star.png icons/256x256/plus_folder.png diff --git a/dist/qt_themes/default/icons/48x48/star.png b/dist/qt_themes/default/icons/48x48/star.png new file mode 100644 index 0000000000000000000000000000000000000000..c2b78f0c3e543913b18d4f95956109c7d2646ba8 GIT binary patch literal 1029 zcmV+g1p51lP)X)lQZo@-L=cu)ZHg3&%A{3AU{olP z1-a8`)uIOkK?H#db72rfkkLY-$D*Q0B3jg{0v8dMp}mlZe3E70Z83B4od0>=d**0_ z9}GA%|M|Xej&tVxXD-ZPc9DpYdjqf?NCHoQS21cCMHX-wW!zdW0rO_jS7;o=X+Bks z&Z4hSNC5qKPoST8mu+NJV>djmi?yxVq@d|Fxlh#Z0}n*oUc;J3@gDort_K=K+lN_m z7l8HHjZOghz(U}s=v!w>)Z`M9%jXd=hI$7c2gLppc!T{ZAF}iv7JYAL++6_HU^h4k z6j}Ng0l!7eY7@eymXKT$-N2BgK8#8y{KjO2Y>)N@Kn<`gB+o%nzwHup3)o?)Hv->6 z@(%#dP#Z%awgI2<{+b4rKR}5KZ;9^9l=l;`HOTxDU^IeA61d{Se>Eca2vF)bfin>W zo}%`CFBG7bLKKbDRzmp>tP=HJZ7K*qfakzHE#ieypcdE-YyuXC;I0MAeLUK50sCyH zfQvwG2qDwR)!I|S(|Nx^<+#6SuYrmf%}P{gP3dD2SQ#|h?r?fl42qN*&`iR&v&woIo+~%R@L- zt`Y7dl&@p`xF!g9;7<$ZJj6y&w`}R6QIB=wJR9Av6A9oXY8y>Un14sh237!t2005+lkvK%ox>dF@W0|O*YW8UHg=Uy00000NkvXXu0mjfk8a2c literal 0 HcmV?d00001 diff --git a/dist/qt_themes/qdarkstyle/icons/48x48/star.png b/dist/qt_themes/qdarkstyle/icons/48x48/star.png new file mode 100644 index 0000000000000000000000000000000000000000..546779e2a810e73169f65a79850aa07dffd70267 GIT binary patch literal 1055 zcmV+)1mOFLP)6O$xyr@ zPaa%KDJkUv50sKZ9we6sL?n6O3FSd@YsM`}W;l~^srh+0Yd71s*WUY_v)6V?^RNA| z*80}}|Nqumd+oK>5$Qv9Ve%pdW{JpR5kW-m7-JsgrR5bs4RC@ejsyLw?JpI;c8B=@ z+p6s^5r6^O5)xPZUG@p1(Wj>GIk{SuuZhTYRkzBsrau5L)o8Z>YgOIr zYWs8on5m3*19iX<;Ja#@;Y-)&6w=e@rZJ{qjOh}QTPd;C2k=yl@`g~`M%DJLnqDIS zrYVEJfDxhg;lNK7Gu4N-uPLOb#BF0tM^G@vbc)EGls*-qzpD}$EFw)JGOk3P^{RZy z5pz*QmW0Z!z^4-V+ePG_F{V2;5?BPhqjLNPMmcy#*|tjY7Fd{Oehly}g9yOM1pZSQ zxxWIVlM>jQQQ$66m%u+1xR+65Pnc7`1Cv$xxrp42&A1m|MC87RTs6iJ7i5h21~iMv zauJy)A|p%SZWfV-1dqJ{4ytT>fFnR{2|`{0)LQKx<>^3Drv}_F+GAkKKQuqZYHIuf zCZ%;=X9G35fX)BF{AQwC@WA}qQc30jFB~KQ7YTi3JsKYhoQu(H1Ll`YSO=VqA#4X0 zcr-tU=vF+yg-inmYyt`n;@`j)59YVve(wsvrmXydNCWWDA<_dZNoR=VT}E`3!D=<6 zGn6M*3mkR`>b-tBoVOhVa+o}qZK6lSHyOC}o~yJ~CWK11(*sobLj@cG-luS>^0E-oQ z-1W$FV0Hq}Y#ZZ(=4|$vKt1pyMmWG}O85v-JZGFv;pzrTIq;X2#QqquuRv=Be66;x z3;Vp9w}J-PMR6H~;@0;vFd+ly1mFt2Tl7v~Cwcyl2J{Ce0>eCV4ztNP?`r$dhd%tr Z_yd6az_icons/48x48/no_avatar.png icons/48x48/plus.png icons/48x48/sd_card.png + icons/48x48/star.png icons/256x256/plus_folder.png diff --git a/dist/qt_themes/qdarkstyle_midnight_blue/icons/48x48/star.png b/dist/qt_themes/qdarkstyle_midnight_blue/icons/48x48/star.png new file mode 100644 index 0000000000000000000000000000000000000000..90d423a1d4c1e05ccec0a01fa34abca9fe99676d GIT binary patch literal 725 zcmV;`0xJE9P)_t6%-62 zVr82q2v*vNjbd-7sEw6YRw`;*Au;C>A_fF=QIp5w_Hek|?d?ovvLg4u7RTQAeeXLn zyE7jvb?MS28bBE+=dHsFpda|2T>Y`?tcsOb(ukyDa$SyCCp)c4X8n|W{fGxmW%IG(!0i{rNL(aezNm<_Y1^sIq8_-96v&zaeuqH(9)t-X;C2fn8;Z;z&BvnNxWrZ0C<<9_zG~)OT1-b1Mn&b@#DbGWr?>;6o5x7DE>9D zDTsK>L=SLp1;jrF)&>>dWaLIf@ecv7V=iHZ#CAz!8~vaYn?A6 zZwYt+ELi!6LTGL-v=Mkiy|LL7A^&0Oo!icons/48x48/no_avatar.png icons/48x48/plus.png icons/48x48/sd_card.png + icons/48x48/star.png icons/256x256/plus_folder.png diff --git a/license.txt b/license.txt index 09f9ad2d5..f94c73f1a 100644 --- a/license.txt +++ b/license.txt @@ -356,3 +356,4 @@ folder.png | CC BY-ND 3.0 | https://icons8.com plus.png (Default, Dark) | CC0 1.0 | Designed by BreadFish64 from the Citra team plus.png (Colorful, Colorful Dark) | CC BY-ND 3.0 | https://icons8.com sd_card.png | CC BY-ND 3.0 | https://icons8.com +star.png | CC BY-ND 3.0 | https://icons8.com diff --git a/src/lime_qt/configuration/config.cpp b/src/lime_qt/configuration/config.cpp index 3cadfb8ca..728a00c8c 100644 --- a/src/lime_qt/configuration/config.cpp +++ b/src/lime_qt/configuration/config.cpp @@ -805,6 +805,14 @@ void Config::ReadUIGameListValues() { ReadBasicSetting(UISettings::values.show_type_column); ReadBasicSetting(UISettings::values.show_size_column); + const int favorites_size = qt_config->beginReadArray(QStringLiteral("favorites")); + for (int i = 0; i < favorites_size; i++) { + qt_config->setArrayIndex(i); + UISettings::values.favorited_ids.append( + ReadSetting(QStringLiteral("program_id")).toULongLong()); + } + qt_config->endArray(); + qt_config->endGroup(); } @@ -1286,6 +1294,14 @@ void Config::SaveUIGameListValues() { WriteBasicSetting(UISettings::values.show_type_column); WriteBasicSetting(UISettings::values.show_size_column); + qt_config->beginWriteArray(QStringLiteral("favorites")); + for (int i = 0; i < UISettings::values.favorited_ids.size(); i++) { + qt_config->setArrayIndex(i); + WriteSetting(QStringLiteral("program_id"), + QVariant::fromValue(UISettings::values.favorited_ids[i])); + } + qt_config->endArray(); + qt_config->endGroup(); } diff --git a/src/lime_qt/game_list.cpp b/src/lime_qt/game_list.cpp index c7ba12473..5dd6b4a9b 100644 --- a/src/lime_qt/game_list.cpp +++ b/src/lime_qt/game_list.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -105,6 +106,10 @@ void GameListSearchField::setFilterResult(int visible, int total) { QStringLiteral("%1 %2 %3 %4").arg(visible).arg(result_of_text).arg(total).arg(result_text)); } +bool GameListSearchField::IsEmpty() const { + return edit_filter->text().isEmpty(); +} + QString GameList::GetLastFilterResultItem() const { QString file_path; const int folderCount = item_model->rowCount(); @@ -206,7 +211,9 @@ void GameList::OnTextChanged(const QString& new_text) { // If the searchfield is empty every item is visible // Otherwise the filter gets applied if (edit_filter_text.isEmpty()) { - for (int i = 0; i < folder_count; ++i) { + tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), + UISettings::values.favorited_ids.size() == 0); + for (int i = 1; i < folder_count; ++i) { folder = item_model->item(i, 0); const QModelIndex folder_index = folder->index(); const int children_count = folder->rowCount(); @@ -217,8 +224,9 @@ void GameList::OnTextChanged(const QString& new_text) { } search_field->setFilterResult(children_total, children_total); } else { + tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), true); int result_count = 0; - for (int i = 0; i < folder_count; ++i) { + for (int i = 1; i < folder_count; ++i) { folder = item_model->item(i, 0); const QModelIndex folder_index = folder->index(); const int children_count = folder->rowCount(); @@ -281,6 +289,13 @@ void GameList::OnUpdateThemedIcons() { child->setData(QIcon::fromTheme(QStringLiteral("plus")).pixmap(icon_size), Qt::DecorationRole); break; + case GameListItemType::Favorites: + child->setData( + QIcon::fromTheme(QStringLiteral("star")) + .pixmap(icon_size) + .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), + Qt::DecorationRole); + break; default: break; } @@ -422,6 +437,15 @@ void GameList::DonePopulating(const QStringList& watch_list) { item_model->invisibleRootItem()->appendRow(new GameListAddDir()); + // Add favorites row + item_model->invisibleRootItem()->insertRow(0, new GameListFavorites()); + tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), + UISettings::values.favorited_ids.size() == 0); + tree_view->expand(item_model->invisibleRootItem()->child(0)->index()); + for (const auto id : UISettings::values.favorited_ids) { + AddFavorite(id); + } + // Clear out the old directories to watch for changes and add the new ones auto watch_dirs = watcher->directories(); if (!watch_dirs.isEmpty()) { @@ -440,7 +464,7 @@ void GameList::DonePopulating(const QStringList& watch_list) { tree_view->setEnabled(true); const int folderCount = tree_view->model()->rowCount(); int children_total = 0; - for (int i = 0; i < folderCount; ++i) { + for (int i = 1; i < folderCount; ++i) { children_total += item_model->item(i, 0)->rowCount(); } search_field->setFilterResult(children_total, children_total); @@ -477,6 +501,9 @@ void GameList::PopupContextMenu(const QPoint& menu_location) { case GameListItemType::SystemDir: AddPermDirPopup(context_menu, selected); break; + case GameListItemType::Favorites: + AddFavoritesPopup(context_menu); + break; default: break; } @@ -533,6 +560,8 @@ void ForEachOpenGLCacheFile(u64 program_id, auto func) { void GameList::AddGamePopup(QMenu& context_menu, const QString& path, const QString& name, u64 program_id, u64 extdata_id, Service::FS::MediaType media_type) { + QAction* favorite = context_menu.addAction(tr("Favorite")); + context_menu.addSeparator(); QMenu* open_menu = context_menu.addMenu(tr("Open")); QAction* open_application_location = open_menu->addAction(tr("Application Location")); open_menu->addSeparator(); @@ -577,6 +606,10 @@ void GameList::AddGamePopup(QMenu& context_menu, const QString& path, const QStr program_id, [&opengl_cache_exists](QFile& file) { opengl_cache_exists |= file.exists(); }); #endif + favorite->setVisible(program_id != 0); + favorite->setCheckable(true); + favorite->setChecked(UISettings::values.favorited_ids.contains(program_id)); + std::string sdmc_dir = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir); open_save_location->setEnabled( is_application && FileUtil::Exists(FileSys::ArchiveSource_SDSaveData::GetSaveDataPathFor( @@ -624,6 +657,7 @@ void GameList::AddGamePopup(QMenu& context_menu, const QString& path, const QStr auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); navigate_to_gamedb_entry->setVisible(it != compatibility_list.end()); + connect(favorite, &QAction::triggered, [this, program_id]() { ToggleFavorite(program_id); }); connect(open_save_location, &QAction::triggered, this, [this, program_id] { emit OpenFolderRequested(program_id, GameListOpenTarget::SAVE_DATA); }); @@ -774,7 +808,7 @@ void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) { const int row = selected.row(); - move_up->setEnabled(row > 0); + move_up->setEnabled(row > 1); move_down->setEnabled(row < item_model->rowCount() - 2); connect(move_up, &QAction::triggered, this, [this, selected, row, game_dir_index] { @@ -812,6 +846,18 @@ void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) { }); } +void GameList::AddFavoritesPopup(QMenu& context_menu) { + QAction* clear = context_menu.addAction(tr("Clear")); + + connect(clear, &QAction::triggered, [this] { + for (const auto id : UISettings::values.favorited_ids) { + RemoveFavorite(id); + } + UISettings::values.favorited_ids.clear(); + tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), true); + }); +} + void GameList::LoadCompatibilityList() { QFile compat_list{QStringLiteral(":compatibility_list/compatibility_list.json")}; @@ -944,6 +990,58 @@ void GameList::RefreshGameDirectory() { } } +void GameList::ToggleFavorite(u64 program_id) { + if (!UISettings::values.favorited_ids.contains(program_id)) { + tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), + !search_field->IsEmpty()); + UISettings::values.favorited_ids.append(program_id); + AddFavorite(program_id); + item_model->sort(tree_view->header()->sortIndicatorSection(), + tree_view->header()->sortIndicatorOrder()); + } else { + UISettings::values.favorited_ids.removeOne(program_id); + RemoveFavorite(program_id); + if (UISettings::values.favorited_ids.size() == 0) { + tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), true); + } + } +} + +void GameList::AddFavorite(u64 program_id) { + auto* favorites_row = item_model->item(0); + + for (int i = 1; i < item_model->rowCount() - 1; i++) { + const auto* folder = item_model->item(i); + for (int j = 0; j < folder->rowCount(); j++) { + if (folder->child(j)->data(GameListItemPath::ProgramIdRole).toULongLong() == + program_id) { + QList list; + for (int k = 0; k < COLUMN_COUNT; k++) { + list.append(folder->child(j, k)->clone()); + } + list[0]->setData(folder->child(j)->data(GameListItem::SortRole), + GameListItem::SortRole); + list[0]->setText(folder->child(j)->data(Qt::DisplayRole).toString()); + + favorites_row->appendRow(list); + return; + } + } + } +} + +void GameList::RemoveFavorite(u64 program_id) { + auto* favorites_row = item_model->item(0); + + for (int i = 0; i < favorites_row->rowCount(); i++) { + const auto* game = favorites_row->child(i); + if (game->data(GameListItemPath::ProgramIdRole).toULongLong() == program_id) { + favorites_row->removeRow(i); + return; + } + } +} + QString GameList::FindGameByProgramID(u64 program_id, int role) { return FindGameByProgramID(item_model->invisibleRootItem(), program_id, role); } diff --git a/src/lime_qt/game_list.h b/src/lime_qt/game_list.h index 83a629219..20c9bd11f 100644 --- a/src/lime_qt/game_list.h +++ b/src/lime_qt/game_list.h @@ -80,6 +80,10 @@ public: void RefreshGameDirectory(); + void ToggleFavorite(u64 program_id); + void AddFavorite(u64 program_id); + void RemoveFavorite(u64 program_id); + static const QStringList supported_file_extensions; signals: @@ -113,6 +117,7 @@ private: u64 extdata_id, Service::FS::MediaType media_type); void AddCustomDirPopup(QMenu& context_menu, QModelIndex selected); void AddPermDirPopup(QMenu& context_menu, QModelIndex selected); + void AddFavoritesPopup(QMenu& context_menu); void UpdateColumnVisibility(); QString FindGameByProgramID(QStandardItem* current_item, u64 program_id, int role); diff --git a/src/lime_qt/game_list_p.h b/src/lime_qt/game_list_p.h index f6ef22229..48924819e 100644 --- a/src/lime_qt/game_list_p.h +++ b/src/lime_qt/game_list_p.h @@ -34,7 +34,8 @@ enum class GameListItemType { CustomDir = QStandardItem::UserType + 2, InstalledDir = QStandardItem::UserType + 3, SystemDir = QStandardItem::UserType + 4, - AddDir = QStandardItem::UserType + 5 + AddDir = QStandardItem::UserType + 5, + Favorites = QStandardItem::UserType + 6, }; Q_DECLARE_METATYPE(GameListItemType); @@ -430,6 +431,28 @@ public: } }; +class GameListFavorites : public GameListItem { +public: + explicit GameListFavorites() { + setData(type(), TypeRole); + + const int icon_size = IconSizes.at(UISettings::values.game_list_icon_size.GetValue()); + setData(QIcon::fromTheme(QStringLiteral("star")) + .pixmap(icon_size) + .scaled(icon_size, icon_size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), + Qt::DecorationRole); + setData(QObject::tr("Favorites"), Qt::DisplayRole); + } + + int type() const override { + return static_cast(GameListItemType::Favorites); + } + + bool operator<(const QStandardItem& other) const override { + return false; + } +}; + class GameList; class QHBoxLayout; class QTreeView; @@ -444,6 +467,7 @@ public: explicit GameListSearchField(GameList* parent = nullptr); void setFilterResult(int visible, int total); + bool IsEmpty() const; void clear(); void setFocus(); diff --git a/src/lime_qt/uisettings.h b/src/lime_qt/uisettings.h index 6dedff0f0..f83435070 100644 --- a/src/lime_qt/uisettings.h +++ b/src/lime_qt/uisettings.h @@ -116,6 +116,8 @@ struct Values { bool game_dir_deprecated_deepscan; QVector game_dirs; QStringList recent_files; + QVector favorited_ids; + QString language; QString theme;