Changed: Read version from client and display it

--HG--
branch : feature-ryzom-installer
feature/pipeline-tools
kervala 9 years ago
parent a1ceaf0c5e
commit 0d06721689

@ -93,6 +93,10 @@ void CProfilesDialog::displayProfile(int index)
argumentsEdit->setText(profile.arguments);
commentsEdit->setPlainText(profile.comments);
directoryPathLabel->setText(CConfigFile::getInstance()->getProfileDirectory());
desktopShortcutCheckBox->setChecked(profile.desktopShortcut);
menuShortcutCheckBox->setChecked(profile.menuShortcut);
updateExecutableVersion(index);
m_currentProfileIndex = index;
}
@ -123,39 +127,68 @@ void CProfilesDialog::addProfile()
// TODO: browse all folders in AppData/Roaming/Ryzom
}
void CProfilesDialog::onExecutableBrowseClicked()
void CProfilesDialog::updateExecutableVersion(int index)
{
if (m_currentProfileIndex < 0) return;
if (index < 0) return;
CProfile &profile = m_model->getProfiles()[m_currentProfileIndex];
const CProfile &profile = m_model->getProfiles()[index];
QString file = QFileDialog::getOpenFileName(this, tr("Please choose Ryzom client executable to launch"), profile.executable, tr("Executables (*.exe)"));
QString executable = profile.executable;
if (file.isEmpty()) return;
profile.executable = file;
// file empty, use default one
if (executable.isEmpty())
{
executable = CConfigFile::getInstance()->getInstallationDirectory() + "/" + profile.server + "/";
#if defined(Q_OS_WIN32)
executable += "ryzom_client_r.exe";
#elif defined(Q_OS_APPLE)
executable += "Ryzom.app/Contents/MacOS/Ryzom";
#else
executable += "ryzom_client";
#endif
}
executablePathLabel->setText(QFileInfo(profile.executable).fileName());
// file doesn't exist
if (!QFile::exists(executable)) return;
// launch executable with --version argument
QProcess process;
process.setProcessChannelMode(QProcess::MergedChannels);
process.start(profile.executable, QStringList() << "--version", QIODevice::ReadWrite);
process.start(executable, QStringList() << "--version", QIODevice::ReadWrite);
if (!process.waitForStarted()) return;
QByteArray data;
// read all output
while (process.waitForReadyRead()) data.append(process.readAll());
// convert output to string
QString versionString = QString::fromUtf8(data);
// parse version from output
QRegExp reg("([A-Za-z0-1_.]+) ((DEV|FV) ([0-9.]+))");
if (reg.indexIn(versionString) > -1)
{
executableVersionLabel->setText(reg.cap(2));
}
}
void CProfilesDialog::onExecutableBrowseClicked()
{
if (m_currentProfileIndex < 0) return;
CProfile &profile = m_model->getProfiles()[m_currentProfileIndex];
QString file = QFileDialog::getOpenFileName(this, tr("Please choose Ryzom client executable to launch"), profile.executable, tr("Executables (*.exe)"));
if (file.isEmpty()) return;
profile.executable = file;
executablePathLabel->setText(QFileInfo(profile.executable).fileName());
// ryzom_client_dev_d.exe DEV 0.12.0.7331 (built on 2016-02-25 22:16:50)
// Copyright (C) 2004-2016 Winchgate and The Ryzom Core Community
updateExecutableVersion(m_currentProfileIndex);
}

@ -48,6 +48,8 @@ private slots:
void deleteProfile(int index);
void addProfile();
void updateExecutableVersion(int index);
void onExecutableBrowseClicked();
private:

Loading…
Cancel
Save