示例#1
0
static inline bool detectWebBrowser(const QByteArray &desktop,
                                    bool checkBrowserVariable,
                                    QString *browser)
{
    const char *browsers[] = {"google-chrome", "firefox", "mozilla", "opera"};

    browser->clear();
    if (checkExecutable(QStringLiteral("xdg-open"), browser))
        return true;

    if (checkBrowserVariable) {
        QByteArray browserVariable = qgetenv("DEFAULT_BROWSER");
        if (browserVariable.isEmpty())
            browserVariable = qgetenv("BROWSER");
        if (!browserVariable.isEmpty() && checkExecutable(QString::fromLocal8Bit(browserVariable), browser))
            return true;
    }

    if (desktop == QByteArray("KDE")) {
        // Konqueror launcher
        if (checkExecutable(QStringLiteral("kfmclient"), browser)) {
            browser->append(QStringLiteral(" exec"));
            return true;
        }
    } else if (desktop == QByteArray("GNOME")) {
        if (checkExecutable(QStringLiteral("gnome-open"), browser))
            return true;
    }

    for (size_t i = 0; i < sizeof(browsers)/sizeof(char *); ++i)
        if (checkExecutable(QLatin1String(browsers[i]), browser))
            return true;
    return false;
}
示例#2
0
bool R3DExternalPrograms::initialize()
{
	if(!initialized_)
	{
		wxFileName exeFN(wxStandardPaths::Get().GetExecutablePath());
		exeFN.SetFullName(wxEmptyString);

		wxString configExePath = Regard3DSettings::getInstance().getExternalEXEPath();
		if(!configExePath.IsEmpty())
			exeFN.SetPath(configExePath);

		wxString executableExtension;
#if defined(R3D_WIN32)
		executableExtension = wxT("exe");
#endif
		bool isOK = true;
		allPaths_.Clear();
		wxFileName pmvsFN(exeFN);
		pmvsFN.AppendDir(wxT("pmvs"));
		if(pmvsFN.DirExists())
		{
			allPaths_.Add(pmvsFN.GetPath(wxPATH_GET_VOLUME));
			isOK &= checkExecutable(pmvsFN.GetPath(wxPATH_GET_VOLUME), wxT("pmvs2"), executableExtension, pmvsPath_);
			isOK &= checkExecutable(pmvsFN.GetPath(wxPATH_GET_VOLUME), wxT("cmvs"), executableExtension, cmvsPath_);
			isOK &= checkExecutable(pmvsFN.GetPath(wxPATH_GET_VOLUME), wxT("genOption"), executableExtension, genOptionPath_);
		}
		else
			isOK = false;

		wxFileName poissonFN(exeFN);
		poissonFN.AppendDir(wxT("poisson"));
		if(poissonFN.DirExists())
		{
			allPaths_.Add(poissonFN.GetPath(wxPATH_GET_VOLUME));
			isOK &= checkExecutable(poissonFN.GetPath(wxPATH_GET_VOLUME), wxT("PoissonRecon"), executableExtension, poissonReconPath_);
			isOK &= checkExecutable(poissonFN.GetPath(wxPATH_GET_VOLUME), wxT("SurfaceTrimmer"), executableExtension, surfaceTrimmerPath_);
		}
		else
			isOK = false;

		wxFileName mveFN(exeFN);
		mveFN.AppendDir(wxT("mve"));
		if(mveFN.DirExists())
		{
			allPaths_.Add(mveFN.GetPath(wxPATH_GET_VOLUME));
			isOK &= checkExecutable(mveFN.GetPath(wxPATH_GET_VOLUME), wxT("makescene"), executableExtension, makescenePath_);
			isOK &= checkExecutable(mveFN.GetPath(wxPATH_GET_VOLUME), wxT("texrecon"), executableExtension, texreconPath_);
			isOK &= checkExecutable(mveFN.GetPath(wxPATH_GET_VOLUME), wxT("dmrecon"), executableExtension, dmreconPath_);
			isOK &= checkExecutable(mveFN.GetPath(wxPATH_GET_VOLUME), wxT("scene2pset"), executableExtension, scene2psetPath_);
			isOK &= checkExecutable(mveFN.GetPath(wxPATH_GET_VOLUME), wxT("fssrecon"), executableExtension, fssreconPath_);
			isOK &= checkExecutable(mveFN.GetPath(wxPATH_GET_VOLUME), wxT("meshclean"), executableExtension, meshcleanPath_);
			isOK &= checkExecutable(mveFN.GetPath(wxPATH_GET_VOLUME), wxT("smvsrecon"), executableExtension, smvsreconPath_);
			isOK &= checkExecutable(mveFN.GetPath(wxPATH_GET_VOLUME), wxT("smvsrecon_SSE41"), executableExtension, smvsreconSSE41Path);
		}
		else
			isOK = false;

		wxFileName cmpmvsFN(exeFN);
		cmpmvsFN.AppendDir(wxT("cmpmvs"));
		if(cmpmvsFN.DirExists())
		{
			allPaths_.Add(cmpmvsFN.GetPath(wxPATH_GET_VOLUME));
			checkExecutable(mveFN.GetPath(wxPATH_GET_VOLUME), wxT("CMPMVS"), executableExtension, cmpmvsPath_);
		}

		if(!isOK)
		{
			wxMessageBox(wxT("Third-party executables not found.\nPlease put them where the executable is located."),
				wxT("Third party executables not found"), wxICON_ERROR | wxOK, NULL);
		}

		initialized_ = true;
	}

	return true;
}