Changed: Disable button if executable not found, see #279
--HG-- branch : develop
This commit is contained in:
parent
fb934818a7
commit
742f8ab2e4
2 changed files with 27 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ protected:
|
|||
void closeEvent(QCloseEvent *e);
|
||||
|
||||
void updateProfiles();
|
||||
void updateButtons();
|
||||
|
||||
QWinTaskbarButton *m_button;
|
||||
CDownloader *m_downloader;
|
||||
|
|
Loading…
Reference in a new issue