From 0d06721689fa06040412caa6e44e2dc1d8c0fee5 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 --HG-- branch : feature-ryzom-installer --- .../ryzom_installer/src/profilesdialog.cpp | 55 +++++++++++++++---- .../ryzom_installer/src/profilesdialog.h | 2 + 2 files changed, 46 insertions(+), 11 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,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); } 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: