From b636a7376e34df5dd4cf653a7c84d68cb3fcca6d Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 14 Sep 2016 08:14:00 +0200 Subject: [PATCH] Changed: Disable button if executable not found, see #279 --- .../client/ryzom_installer/src/mainwindow.cpp | 26 +++++++++++++++++++ .../client/ryzom_installer/src/mainwindow.h | 1 + 2 files changed, 27 insertions(+) diff --git a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp index 55aa3b5bc..a36ed9b59 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp @@ -60,6 +60,7 @@ CMainWindow::CMainWindow():QMainWindow() setFixedHeight(height()); updateProfiles(); + updateButtons(); } CMainWindow::~CMainWindow() @@ -83,6 +84,28 @@ void CMainWindow::updateProfiles() profilesComboBox->setModel(new CProfilesModel(this)); } +void CMainWindow::updateButtons() +{ + int profileIndex = profilesComboBox->currentIndex(); + + if (profileIndex < 0) return; + + CConfigFile *config = CConfigFile::getInstance(); + + const CProfile &profile = config->getProfile(profileIndex); + const CServer &server = config->getServer(profile.server); + + // get full path of client executable + QString executable = profile.getClientFullPath(); + + playButton->setEnabled(!executable.isEmpty() && QFile::exists(executable)); + + // get full path of configuration executable + executable = server.getConfigurationFullPath(); + + configureButton->setEnabled(!executable.isEmpty() && QFile::exists(executable)); +} + void CMainWindow::onPlayClicked() { int profileIndex = profilesComboBox->currentIndex(); @@ -123,6 +146,7 @@ void CMainWindow::onConfigureClicked() const CProfile &profile = config->getProfile(profileIndex); const CServer &server = config->getServer(profile.server); + // get full path of configuration executable QString executable = server.getConfigurationFullPath(); if (executable.isEmpty() || !QFile::exists(executable)) return; @@ -262,4 +286,6 @@ void CMainWindow::onProfileChanged(int profileIndex) // load changelog m_downloader->getHtmlPageContent(config->expandVariables(server.displayUrl)); + + updateButtons(); } diff --git a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.h b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.h index 0f7d88138..7449b2039 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.h +++ b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.h @@ -61,6 +61,7 @@ protected: void closeEvent(QCloseEvent *e); void updateProfiles(); + void updateButtons(); QWinTaskbarButton *m_button; CDownloader *m_downloader;