mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-30 07:35:59 +00:00
Changed: Disable button if executable not found, see #279
This commit is contained in:
parent
86546c56dc
commit
b636a7376e
2 changed files with 27 additions and 0 deletions
|
@ -60,6 +60,7 @@ CMainWindow::CMainWindow():QMainWindow()
|
||||||
setFixedHeight(height());
|
setFixedHeight(height());
|
||||||
|
|
||||||
updateProfiles();
|
updateProfiles();
|
||||||
|
updateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
CMainWindow::~CMainWindow()
|
CMainWindow::~CMainWindow()
|
||||||
|
@ -83,6 +84,28 @@ void CMainWindow::updateProfiles()
|
||||||
profilesComboBox->setModel(new CProfilesModel(this));
|
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()
|
void CMainWindow::onPlayClicked()
|
||||||
{
|
{
|
||||||
int profileIndex = profilesComboBox->currentIndex();
|
int profileIndex = profilesComboBox->currentIndex();
|
||||||
|
@ -123,6 +146,7 @@ void CMainWindow::onConfigureClicked()
|
||||||
const CProfile &profile = config->getProfile(profileIndex);
|
const CProfile &profile = config->getProfile(profileIndex);
|
||||||
const CServer &server = config->getServer(profile.server);
|
const CServer &server = config->getServer(profile.server);
|
||||||
|
|
||||||
|
// get full path of configuration executable
|
||||||
QString executable = server.getConfigurationFullPath();
|
QString executable = server.getConfigurationFullPath();
|
||||||
|
|
||||||
if (executable.isEmpty() || !QFile::exists(executable)) return;
|
if (executable.isEmpty() || !QFile::exists(executable)) return;
|
||||||
|
@ -262,4 +286,6 @@ void CMainWindow::onProfileChanged(int profileIndex)
|
||||||
|
|
||||||
// load changelog
|
// load changelog
|
||||||
m_downloader->getHtmlPageContent(config->expandVariables(server.displayUrl));
|
m_downloader->getHtmlPageContent(config->expandVariables(server.displayUrl));
|
||||||
|
|
||||||
|
updateButtons();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ protected:
|
||||||
void closeEvent(QCloseEvent *e);
|
void closeEvent(QCloseEvent *e);
|
||||||
|
|
||||||
void updateProfiles();
|
void updateProfiles();
|
||||||
|
void updateButtons();
|
||||||
|
|
||||||
QWinTaskbarButton *m_button;
|
QWinTaskbarButton *m_button;
|
||||||
CDownloader *m_downloader;
|
CDownloader *m_downloader;
|
||||||
|
|
Loading…
Reference in a new issue