Qt: simplify Boot options a bit (#4158)

This commit is contained in:
Megamouse 2018-02-28 15:53:39 +01:00 committed by Ivan
parent 6141bc5598
commit 2444385763
4 changed files with 35 additions and 93 deletions

View file

@ -492,17 +492,8 @@ void game_list_frame::doubleClickedSlot(const QModelIndex& index)
i = m_xgrid->item(index.row(), index.column())->data(Qt::ItemDataRole::UserRole).toInt();
}
if (1)
{
if (Boot(m_game_data[i].info))
{
LOG_SUCCESS(LOADER, "Boot from gamelist per doubleclick: done");
}
}
else
{
open_dir(m_game_data[i].info.path);
}
LOG_NOTICE(LOADER, "Booting from gamelist per doubleclick...");
Q_EMIT RequestBoot(m_game_data[i].info.path);
}
void game_list_frame::ShowContextMenu(const QPoint &pos)
@ -570,10 +561,8 @@ void game_list_frame::ShowSpecifiedContextMenu(const QPoint &pos, int row)
connect(boot, &QAction::triggered, [=]
{
if (Boot(currGame))
{
LOG_SUCCESS(LOADER, "Boot from gamelist per Boot: done");
}
LOG_NOTICE(LOADER, "Booting from gamelist per context menu...");
Q_EMIT RequestBoot(currGame.path);
});
connect(configure, &QAction::triggered, [=]
{
@ -671,27 +660,6 @@ void game_list_frame::ShowSpecifiedContextMenu(const QPoint &pos, int row)
myMenu.exec(globalPos);
}
bool game_list_frame::Boot(const GameInfo& game)
{
Q_EMIT RequestIconPathSet(game.path);
Emu.SetForceBoot(true);
Emu.Stop();
if (!Emu.BootGame(game.path))
{
QMessageBox::warning(this, tr("Warning!"), tr("Failed to boot ") + qstr(game.path));
LOG_ERROR(LOADER, "Failed to boot %s", game.path);
return false;
}
else
{
Q_EMIT RequestAddRecentGame(gui::Recent_Game(qstr(Emu.GetBoot()), qstr("[" + game.serial + "] " + game.name)));
Refresh(true);
return true;
}
}
void game_list_frame::RemoveCustomConfiguration(int row)
{
const std::string config_path = fs::get_config_dir() + "data/" + m_game_data[row].info.serial + "/config.yml";

View file

@ -209,8 +209,7 @@ private Q_SLOTS:
void doubleClickedSlot(const QModelIndex& index);
Q_SIGNALS:
void GameListFrameClosed();
void RequestIconPathSet(const std::string& path);
void RequestAddRecentGame(const q_string_pair& entry);
void RequestBoot(const std::string& path);
void RequestIconSizeChange(const int& val);
protected:
/** Override inherited method from Qt to allow signalling when close happened.*/
@ -219,7 +218,6 @@ protected:
bool eventFilter(QObject *object, QEvent *event) override;
private:
QPixmap PaintedPixmap(const QImage& img, bool paintConfigIcon = false);
bool Boot(const GameInfo& info);
void PopulateGameGrid(int maxCols, const QSize& image_size, const QColor& image_color);
void FilterData();
void SortGameList();

View file

@ -227,6 +227,25 @@ void main_window::SetAppIconFromPath(const std::string& path)
m_appIcon = QApplication::windowIcon();
}
void main_window::Boot(const std::string& path, bool direct, bool add_only, bool force_boot)
{
SetAppIconFromPath(path);
Emu.SetForceBoot(force_boot);
if (Emu.BootGame(path, add_only))
{
LOG_SUCCESS(LOADER, "Boot successful.");
const std::string serial = Emu.GetTitleID().empty() ? "" : "[" + Emu.GetTitleID() + "] ";
AddRecentAction(gui::Recent_Game(qstr(Emu.GetBoot()), qstr(serial + Emu.GetTitle())));
}
else
{
LOG_ERROR(GENERAL, "Boot failed: path=%s direct=%d add_only=%d force_boot=%d", path, direct, add_only, force_boot);
}
m_gameListFrame->Refresh(true);
}
void main_window::BootElf()
{
bool stopped = false;
@ -253,30 +272,14 @@ void main_window::BootElf()
return;
}
LOG_NOTICE(LOADER, "(S)ELF: booting...");
// If we resolved the filepath earlier we would end up setting the last opened dir to the unwanted
// game folder in case of having e.g. a Game Folder with collected links to elf files.
// Don't set last path earlier in case of cancelled dialog
guiSettings->SetValue(gui::fd_boot_elf, filePath);
const std::string path = sstr(QFileInfo(filePath).canonicalFilePath());
SetAppIconFromPath(path);
Emu.SetForceBoot(true);
Emu.Stop();
if (!Emu.BootGame(path, true))
{
LOG_ERROR(GENERAL, "PS3 executable not found at path (%s)", path);
}
else
{
LOG_SUCCESS(LOADER, "(S)ELF: boot done.");
const std::string serial = Emu.GetTitleID().empty() ? "" : "[" + Emu.GetTitleID() + "] ";
AddRecentAction(gui::Recent_Game(qstr(Emu.GetBoot()), qstr(serial + Emu.GetTitle())));
m_gameListFrame->Refresh(true);
}
LOG_NOTICE(LOADER, "Booting from BootElf...");
Boot(path, true);
}
void main_window::BootGame()
@ -298,24 +301,11 @@ void main_window::BootGame()
return;
}
Emu.SetForceBoot(true);
Emu.Stop();
guiSettings->SetValue(gui::fd_boot_game, QFileInfo(dirPath).path());
const std::string path = sstr(dirPath);
SetAppIconFromPath(path);
if (!Emu.BootGame(path))
{
LOG_ERROR(GENERAL, "PS3 executable not found in selected folder (%s)", path);
}
else
{
LOG_SUCCESS(LOADER, "Boot Game: boot done.");
const std::string serial = Emu.GetTitleID().empty() ? "" : "[" + Emu.GetTitleID() + "] ";
AddRecentAction(gui::Recent_Game(qstr(Emu.GetBoot()), qstr(serial + Emu.GetTitle())));
m_gameListFrame->Refresh(true);
}
LOG_NOTICE(LOADER, "Booting from BootGame...");
Boot(path);
}
void main_window::InstallPkg(const QString& dropPath)
@ -813,6 +803,7 @@ void main_window::BootRecentAction(const QAction* act)
}
const QString pth = act->data().toString();
const std::string path = sstr(pth);
QString nam;
bool containsPath = false;
@ -844,7 +835,7 @@ void main_window::BootRecentAction(const QAction* act)
guiSettings->SetValue(gui::rg_entries, guiSettings->List2Var(m_rg_entries));
LOG_ERROR(GENERAL, "Recent Game not valid, removed from Boot Recent list: %s", sstr(pth));
LOG_ERROR(GENERAL, "Recent Game not valid, removed from Boot Recent list: %s", path);
// refill menu with actions
for (int i = 0; i < m_recentGameActs.count(); i++)
@ -855,30 +846,15 @@ void main_window::BootRecentAction(const QAction* act)
}
LOG_WARNING(GENERAL, "Boot Recent list refreshed");
return;
}
LOG_ERROR(GENERAL, "Path invalid and not in m_rg_paths: %s", sstr(pth));
LOG_ERROR(GENERAL, "Path invalid and not in m_rg_paths: %s", path);
return;
}
SetAppIconFromPath(sstr(pth));
Emu.SetForceBoot(true);
Emu.Stop();
if (!Emu.BootGame(sstr(pth), true))
{
LOG_ERROR(LOADER, "Failed to boot %s", sstr(pth));
}
else
{
LOG_SUCCESS(LOADER, "Boot from Recent List: done");
AddRecentAction(gui::Recent_Game(qstr(Emu.GetBoot()), nam));
m_gameListFrame->Refresh(true);
}
LOG_NOTICE(LOADER, "Booting from recent games list...");
Boot(path, true);
};
QAction* main_window::CreateRecentAction(const q_string_pair& entry, const uint& sc_idx)
@ -1370,8 +1346,7 @@ void main_window::CreateDockWindows()
}
});
connect(m_gameListFrame, &game_list_frame::RequestIconPathSet, this, &main_window::SetAppIconFromPath);
connect(m_gameListFrame, &game_list_frame::RequestAddRecentGame, this, &main_window::AddRecentAction);
connect(m_gameListFrame, &game_list_frame::RequestBoot, [this](const std::string& path){ Boot(path); });
}
void main_window::ConfigureGuiFromSettings(bool configure_all)

View file

@ -85,6 +85,7 @@ public Q_SLOTS:
void RepaintGui();
private Q_SLOTS:
void Boot(const std::string& path, bool direct = false, bool add_only = false, bool force_boot = true);
void BootElf();
void BootGame();
void DecryptSPRXLibraries();