Add UpdateCallback to AchievementManager

AchievementManager now has a SetUpdateCallback method for providing a single universal callback for anytime something important changes in the achievement state, such as logging in/out, game load/close, or events such as achievement unlocks. AchievementsWindow sets this callback in its own init to its UpdateData method so that the AchievementsWindow gets updated when one of these changes takes place.
This commit is contained in:
LillyJadeKatrin 2023-06-02 21:31:30 -04:00
commit fbaeaf305b
4 changed files with 34 additions and 3 deletions

View file

@ -11,6 +11,7 @@
#include "DolphinQt/Achievements/AchievementHeaderWidget.h"
#include "DolphinQt/Achievements/AchievementProgressWidget.h"
#include "DolphinQt/Achievements/AchievementSettingsWidget.h"
#include "DolphinQt/QtUtils/QueueOnObject.h"
#include "DolphinQt/QtUtils/WrapInScrollArea.h"
AchievementsWindow::AchievementsWindow(QWidget* parent) : QDialog(parent)
@ -20,6 +21,8 @@ AchievementsWindow::AchievementsWindow(QWidget* parent) : QDialog(parent)
CreateMainLayout();
ConnectWidgets();
AchievementManager::GetInstance()->SetUpdateCallback(
[this] { QueueOnObject(this, &AchievementsWindow::UpdateData); });
}
void AchievementsWindow::showEvent(QShowEvent* event)