Qt: Allow to drop RAP&PKG together

This commit is contained in:
Eladash 2023-06-23 19:06:13 +03:00 committed by Ivan
commit 2da78c6591
2 changed files with 6 additions and 36 deletions

View file

@ -3255,21 +3255,21 @@ main_window::drop_type main_window::IsValidFile(const QMimeData& md, QStringList
} }
else if (info.suffix().toLower() == "pkg") else if (info.suffix().toLower() == "pkg")
{ {
if (drop_type != drop_type::drop_pkg && drop_type != drop_type::drop_error) if (drop_type != drop_type::drop_rap_edat_pkg && drop_type != drop_type::drop_error)
{ {
return drop_type::drop_error; return drop_type::drop_error;
} }
drop_type = drop_type::drop_pkg; drop_type = drop_type::drop_rap_edat_pkg;
} }
else if (info.suffix().toLower() == "rap" || info.suffix().toLower() == "edat") else if (info.suffix().toLower() == "rap" || info.suffix().toLower() == "edat")
{ {
if (info.size() < 0x10 || (drop_type != drop_type::drop_rap_edat && drop_type != drop_type::drop_error)) if (info.size() < 0x10 || (drop_type != drop_type::drop_rap_edat_pkg && drop_type != drop_type::drop_error))
{ {
return drop_type::drop_error; return drop_type::drop_error;
} }
drop_type = drop_type::drop_rap_edat; drop_type = drop_type::drop_rap_edat_pkg;
} }
else if (list.size() == 1) else if (list.size() == 1)
{ {
@ -3309,7 +3309,7 @@ void main_window::dropEvent(QDropEvent* event)
event->ignore(); event->ignore();
break; break;
} }
case drop_type::drop_pkg: // install the packages case drop_type::drop_rap_edat_pkg: // install the packages
{ {
InstallPackages(drop_paths); InstallPackages(drop_paths);
break; break;
@ -3319,35 +3319,6 @@ void main_window::dropEvent(QDropEvent* event)
InstallPup(drop_paths.first()); InstallPup(drop_paths.first());
break; break;
} }
case drop_type::drop_rap_edat: // import rap files to exdata dir
{
int installed_count = 0;
for (const auto& path : drop_paths)
{
const QFileInfo file_info = path;
const std::string extension = file_info.suffix().toLower().toStdString();
const std::string filename = sstr(file_info.fileName());
if (InstallFileInExData(extension, path, filename))
{
gui_log.success("Successfully copied %s file by drop: %s", extension, filename);
installed_count++;
}
else
{
gui_log.error("Could not copy %s file by drop: %s", extension, filename);
}
}
if (installed_count > 0)
{
// Refresh game list since we probably unlocked some games now.
m_game_list_frame->Refresh(true);
}
break;
}
case drop_type::drop_psf: // Display PARAM.SFO content case drop_type::drop_psf: // Display PARAM.SFO content
{ {
for (const auto& psf : drop_paths) for (const auto& psf : drop_paths)

View file

@ -71,9 +71,8 @@ class main_window : public QMainWindow
enum class drop_type enum class drop_type
{ {
drop_error, drop_error,
drop_pkg, drop_rap_edat_pkg,
drop_pup, drop_pup,
drop_rap_edat,
drop_psf, drop_psf,
drop_dir, drop_dir,
drop_game, drop_game,