Add ctrl+a to select all saves in save browser (#698)

This commit is contained in:
ConnorCreate 2020-07-26 13:29:55 -04:00 committed by GitHub
parent 0959354178
commit 5ab939720a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 0 deletions

View File

@ -177,6 +177,17 @@ void SearchController::Selected(int saveID, bool selected)
searchModel->DeselectSave(saveID);
}
void SearchController::SelectAllSaves()
{
if (!Client::Ref().GetAuthUser().UserID)
return;
if (searchModel->GetShowOwn() ||
Client::Ref().GetAuthUser().UserElevation == User::ElevationModerator ||
Client::Ref().GetAuthUser().UserElevation == User::ElevationAdmin)
searchModel->SelectAllSaves();
}
void SearchController::InstantOpen(bool instant)
{
instantOpen = instant;

View File

@ -42,6 +42,7 @@ public:
void ShowOwn(bool show);
void ShowFavourite(bool show);
void Selected(int saveID, bool selected);
void SelectAllSaves();
void InstantOpen(bool instant);
void OpenSave(int saveID);
void OpenSave(int saveID, int saveDate);

View File

@ -199,6 +199,14 @@ void SearchModel::SelectSave(int saveID)
notifySelectedChanged();
}
void SearchModel::SelectAllSaves()
{
for (int i = 0; i < saveList.size(); i++)
{
SelectSave(saveList[i]->id);
}
}
void SearchModel::DeselectSave(int saveID)
{
bool changed = false;

View File

@ -69,6 +69,7 @@ public:
std::vector<int> GetSelected() { return selected; }
void ClearSelected() { selected.clear(); notifySelectedChanged(); }
void SelectSave(int saveID);
void SelectAllSaves();
void DeselectSave(int saveID);
void Update();
};

View File

@ -654,6 +654,8 @@ void SearchView::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctr
return;
if (key == SDLK_ESCAPE)
c->Exit();
else if (key == SDLK_a && ctrl)
c->SelectAllSaves();
else if (key == SDLK_LCTRL || key == SDLK_RCTRL)
c->InstantOpen(true);
}