mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-22 04:24:44 +00:00
Changed getInstance implementation with Singleton class.
This commit is contained in:
parent
fb18a7e508
commit
c8867545ca
4 changed files with 12 additions and 14 deletions
|
@ -20,11 +20,6 @@ class RPC {
|
|||
RPCStatus status;
|
||||
|
||||
public:
|
||||
static RPC& getInstance() {
|
||||
static RPC instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
void init();
|
||||
void setStatusIdling();
|
||||
void setStatusPlaying(const std::string& game_name, const std::string& game_id);
|
||||
|
|
|
@ -213,10 +213,11 @@ void Emulator::Run(const std::filesystem::path& file) {
|
|||
|
||||
// Discord RPC
|
||||
if (Config::getEnableDiscordRPC()) {
|
||||
if (DiscordRPCHandler::RPC::getInstance().getRPCEnabled() == false) {
|
||||
DiscordRPCHandler::RPC::getInstance().init();
|
||||
auto* rpc = Common::Singleton<DiscordRPCHandler::RPC>::Instance();
|
||||
if (rpc->getRPCEnabled() == false) {
|
||||
rpc->init();
|
||||
}
|
||||
DiscordRPCHandler::RPC::getInstance().setStatusPlaying(game_info.title, id);
|
||||
rpc->setStatusPlaying(game_info.title, id);
|
||||
}
|
||||
|
||||
// start execution
|
||||
|
|
|
@ -72,8 +72,9 @@ bool MainWindow::Init() {
|
|||
|
||||
// Initialize Discord RPC
|
||||
if (Config::getEnableDiscordRPC()) {
|
||||
DiscordRPCHandler::RPC::getInstance().init();
|
||||
DiscordRPCHandler::RPC::getInstance().setStatusIdling();
|
||||
auto* rpc = Common::Singleton<DiscordRPCHandler::RPC>::Instance();
|
||||
rpc->init();
|
||||
rpc->setStatusIdling();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -154,11 +154,12 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
|
|||
|
||||
connect(ui->discordRPCCheckbox, &QCheckBox::stateChanged, this, [](int val) {
|
||||
Config::setEnableDiscordRPC(val);
|
||||
if (val) {
|
||||
DiscordRPCHandler::RPC::getInstance().init();
|
||||
DiscordRPCHandler::RPC::getInstance().setStatusIdling();
|
||||
auto* rpc = Common::Singleton<DiscordRPCHandler::RPC>::Instance();
|
||||
if (val == Qt::Checked) {
|
||||
rpc->init();
|
||||
rpc->setStatusIdling();
|
||||
} else {
|
||||
DiscordRPCHandler::RPC::getInstance().shutdown();
|
||||
rpc->shutdown();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue