From 1f999fc420fd7260792c44ca952b68ff080253f9 Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 12 Mar 2016 21:58:53 +0100 Subject: [PATCH] Changed: Read version from client and display it --- .../ryzom_installer/src/profilesdialog.cpp | 75 +++++++++++++------ .../ryzom_installer/src/profilesdialog.h | 2 + 2 files changed, 56 insertions(+), 21 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp index 9632c69fe..5134902fc 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp @@ -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,6 +127,55 @@ void CProfilesDialog::addProfile() // TODO: browse all folders in AppData/Roaming/Ryzom } +void CProfilesDialog::updateExecutableVersion(int index) +{ + if (index < 0) return; + + const CProfile &profile = m_model->getProfiles()[index]; + + QString executable = profile.executable; + + // 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 + } + + // file doesn't exist + if (!QFile::exists(executable)) return; + + // launch executable with --version argument + QProcess process; + process.setProcessChannelMode(QProcess::MergedChannels); + 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; @@ -137,25 +190,5 @@ void CProfilesDialog::onExecutableBrowseClicked() executablePathLabel->setText(QFileInfo(profile.executable).fileName()); - QProcess process; - process.setProcessChannelMode(QProcess::MergedChannels); - process.start(profile.executable, QStringList() << "--version", QIODevice::ReadWrite); - - if (!process.waitForStarted()) return; - - QByteArray data; - - while (process.waitForReadyRead()) data.append(process.readAll()); - - QString versionString = QString::fromUtf8(data); - - QRegExp reg("([A-Za-z0-1_.]+) ((DEV|FV) ([0-9.]+))"); - - if (reg.indexIn(versionString) > -1) - { - executableVersionLabel->setText(reg.cap(2)); - } - - // 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); } diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.h b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.h index 78fe14bbc..231ab554a 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.h +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.h @@ -48,6 +48,8 @@ private slots: void deleteProfile(int index); void addProfile(); + void updateExecutableVersion(int index); + void onExecutableBrowseClicked(); private: