Fix QuickPlay on Linux, add more robust executable validation
This commit is contained in:
parent
7819b07df5
commit
cd9601d6aa
|
@ -19,7 +19,7 @@ public:
|
||||||
static bool PathValid(const QString& kPath)
|
static bool PathValid(const QString& kPath)
|
||||||
{
|
{
|
||||||
QFileInfo FileInfo(kPath);
|
QFileInfo FileInfo(kPath);
|
||||||
return FileInfo.exists() && FileInfo.suffix() == "exe";
|
return FileInfo.exists() && FileInfo.isExecutable();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ CQuickplayPropertyEditor::~CQuickplayPropertyEditor()
|
||||||
|
|
||||||
void CQuickplayPropertyEditor::BrowseForDolphin()
|
void CQuickplayPropertyEditor::BrowseForDolphin()
|
||||||
{
|
{
|
||||||
QString Path = UICommon::OpenFileDialog(this, "Open Dolphin", "Dolphin.exe");
|
QString Path = UICommon::OpenFileDialog(this, "Open Dolphin", "Dolphin");
|
||||||
|
|
||||||
if (!Path.isEmpty())
|
if (!Path.isEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,7 +41,6 @@ void CQuickplayRelay::QuickplayStarted()
|
||||||
void CQuickplayRelay::QuickplayFinished(int ReturnCode)
|
void CQuickplayRelay::QuickplayFinished(int ReturnCode)
|
||||||
{
|
{
|
||||||
debugf("Quickplay session finished.");
|
debugf("Quickplay session finished.");
|
||||||
|
|
||||||
disconnect(gpDolphinProcess, 0, this, 0);
|
disconnect(gpDolphinProcess, 0, this, 0);
|
||||||
CleanupQuickplayFiles(gpQuickplayProject);
|
CleanupQuickplayFiles(gpQuickplayProject);
|
||||||
gpDolphinProcess->waitForFinished();
|
gpDolphinProcess->waitForFinished();
|
||||||
|
@ -95,7 +94,7 @@ EQuickplayLaunchResult LaunchQuickplay(QWidget* pParentWidget,
|
||||||
if (Path.isEmpty())
|
if (Path.isEmpty())
|
||||||
{
|
{
|
||||||
// Allow the user to select the Dolphin exe.
|
// Allow the user to select the Dolphin exe.
|
||||||
Path = UICommon::OpenFileDialog(pParentWidget, "Open Dolphin", "Dolphin.exe");
|
Path = UICommon::OpenFileDialog(pParentWidget, "Open Dolphin", "Dolphin");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool bGotDolphin = (!Path.isEmpty() && SetDolphinPath(pParentWidget, Path, true));
|
bool bGotDolphin = (!Path.isEmpty() && SetDolphinPath(pParentWidget, Path, true));
|
||||||
|
@ -254,15 +253,46 @@ bool SetDolphinPath(QWidget* pParentWidget, const QString& kDolphinPath, bool bS
|
||||||
//@todo Validate the build version to make sure the build supports quickplay? Necessary?
|
//@todo Validate the build version to make sure the build supports quickplay? Necessary?
|
||||||
QFileInfo DolphinFile(kDolphinPath);
|
QFileInfo DolphinFile(kDolphinPath);
|
||||||
|
|
||||||
if (!DolphinFile.exists() || DolphinFile.suffix() != "exe")
|
if (!DolphinFile.exists() || !DolphinFile.isExecutable())
|
||||||
{
|
{
|
||||||
if (!bSilent)
|
if (!bSilent)
|
||||||
{
|
{
|
||||||
UICommon::ErrorMsg(pParentWidget, "The selected file is not a Dolphin exe!");
|
UICommon::ErrorMsg(pParentWidget, "The selected file is not a Dolphin executable!");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to obtain the version from Dolphin
|
||||||
|
QProcess DolphinProcess;
|
||||||
|
DolphinProcess.start(kDolphinPath, QStringList() << "--version");
|
||||||
|
DolphinProcess.waitForFinished();
|
||||||
|
QString VersionString = DolphinProcess.readLine().trimmed();
|
||||||
|
|
||||||
|
// Make sure we have a valid string
|
||||||
|
if (VersionString.isNull())
|
||||||
|
{
|
||||||
|
if (!bSilent)
|
||||||
|
{
|
||||||
|
UICommon::ErrorMsg(pParentWidget, "Unable to validate version string, the selected file is likely not a Dolphin executable");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dolphin's version string is broken into two parts, the first part is the name the second is the version
|
||||||
|
// Dolphin unfortunately collide's with KDE Plasma's file manager which also happens to be named "Dolphin"
|
||||||
|
// Fortunately the latter uses a lowercase name so we can differentiate.
|
||||||
|
QStringList VersionParts = VersionString.split(' ');
|
||||||
|
if (VersionParts.count() != 2 || VersionParts[0] != "Dolphin")
|
||||||
|
{
|
||||||
|
if (!bSilent)
|
||||||
|
{
|
||||||
|
UICommon::ErrorMsg(pParentWidget, "The selected file is not a Dolphin executable!");
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
debugf("Found dolphin version %s", *TO_TSTRING(VersionParts[1]));
|
||||||
|
|
||||||
// Build is legit, stash it
|
// Build is legit, stash it
|
||||||
QSettings Settings;
|
QSettings Settings;
|
||||||
Settings.setValue(gkDolphinPathSetting, kDolphinPath);
|
Settings.setValue(gkDolphinPathSetting, kDolphinPath);
|
||||||
|
|
Loading…
Reference in New Issue