Merge with develop

--HG--
branch : compatibility-develop
This commit is contained in:
kervala 2016-09-14 08:18:14 +02:00
commit 0e3320554a
7 changed files with 85 additions and 6 deletions

View file

@ -27,7 +27,8 @@
CConfigFile *CConfigFile::s_instance = NULL;
CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_version(-1),
m_defaultServerIndex(0), m_defaultProfileIndex(0), m_use64BitsClient(false), m_shouldUninstallOldClient(true)
m_defaultServerIndex(0), m_defaultProfileIndex(0), m_use64BitsClient(false), m_shouldUninstallOldClient(true),
m_uninstallingOldClient(false)
{
s_instance = this;
@ -461,6 +462,16 @@ void CConfigFile::setShouldUninstallOldClient(bool on)
m_shouldUninstallOldClient = on;
}
bool CConfigFile::uninstallingOldClient() const
{
return m_uninstallingOldClient;
}
void CConfigFile::setUninstallingOldClient(bool on)
{
m_uninstallingOldClient = on;
}
QString CConfigFile::expandVariables(const QString &str) const
{
QString res = str;
@ -972,7 +983,7 @@ OperationStep CConfigFile::getInstallNextStep() const
if (!settings.contains("InstallLocation")) return CreateAddRemoveEntry;
#endif
if (m_shouldUninstallOldClient && !getSrcServerDirectory().isEmpty() && QFile::exists(getSrcServerDirectory() + "/Uninstall.exe"))
if (!m_uninstallingOldClient && m_shouldUninstallOldClient && !getSrcServerDirectory().isEmpty() && QFile::exists(getSrcServerDirectory() + "/Uninstall.exe"))
{
return UninstallOldClient;
}

View file

@ -109,6 +109,9 @@ public:
bool shouldUninstallOldClient() const;
void setShouldUninstallOldClient(bool on);
bool uninstallingOldClient() const;
void setUninstallingOldClient(bool on);
QString expandVariables(const QString &str) const;
QString getClientArch() const;
@ -147,6 +150,7 @@ private:
QString m_srcDirectory;
bool m_use64BitsClient;
bool m_shouldUninstallOldClient;
bool m_uninstallingOldClient;
QString m_language;
QString m_defaultConfigPath;

View file

@ -86,6 +86,11 @@ int main(int argc, char *argv[])
_CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
#ifdef Q_OS_WIN
// to fix the bug with QFileDialog::getExistingDirectory hanging under Windows
CoInitialize(NULL);
#endif
NLMISC::CApplicationContext appContext;
QApplication app(argc, argv);
@ -218,8 +223,10 @@ int main(int argc, char *argv[])
if (step == Done)
{
#if defined(Q_OS_WIN) && !defined(_DEBUG)
// restart Installer, so it could be copied in TEMP and allowed to update itself
if (QProcess::startDetached(QApplication::applicationFilePath(), QApplication::arguments())) return 0;
#endif
}
}

View file

@ -41,6 +41,11 @@ CMainWindow::CMainWindow():QMainWindow()
connect(m_downloader, SIGNAL(htmlPageContent(QString)), SLOT(onHtmlPageContent(QString)));
connect(actionProfiles, SIGNAL(triggered()), SLOT(onProfiles()));
// remove debug options
actionSettings->setVisible(false);
actionUninstall->setVisible(false);
connect(actionSettings, SIGNAL(triggered()), SLOT(onSettings()));
connect(actionUninstall, SIGNAL(triggered()), SLOT(onUninstall()));
connect(actionQuit, SIGNAL(triggered()), SLOT(onQuit()));
@ -60,6 +65,7 @@ CMainWindow::CMainWindow():QMainWindow()
setFixedHeight(height());
updateProfiles();
updateButtons();
}
CMainWindow::~CMainWindow()
@ -83,6 +89,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 +151,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 +291,6 @@ void CMainWindow::onProfileChanged(int profileIndex)
// load changelog
m_downloader->getHtmlPageContent(config->expandVariables(server.displayUrl));
updateButtons();
}

View file

@ -61,6 +61,7 @@ protected:
void closeEvent(QCloseEvent *e);
void updateProfiles();
void updateButtons();
QWinTaskbarButton *m_button;
CDownloader *m_downloader;

View file

@ -92,7 +92,7 @@ void COperationDialog::processNextStep()
{
if (operationShouldStop())
{
reject();
rejectDelayed();
return;
}
@ -184,7 +184,7 @@ void COperationDialog::processInstallNextStep()
break;
case Done:
accept();
acceptDelayed();
break;
default:
@ -253,6 +253,8 @@ void COperationDialog::updateAddRemoveComponents()
void COperationDialog::processUpdateProfilesNextStep()
{
m_currentOperation = tr("Update profiles");
// for "update profiles" operations, we set installer to false when components are updated,
// since we're not using this variable
if (m_addComponents.installer && m_removeComponents.installer)
@ -344,6 +346,8 @@ void COperationDialog::processUpdateProfilesNextStep()
}
updateAddRemoveEntry();
acceptDelayed();
}
void COperationDialog::processUninstallNextStep()
@ -369,7 +373,7 @@ void COperationDialog::processUninstallNextStep()
else
{
// done
accept();
acceptDelayed();
}
}
@ -460,7 +464,7 @@ void COperationDialog::onProgressStop()
m_button->progress()->hide();
#endif
reject();
rejectDelayed();
}
void COperationDialog::onProgressProgress(qint64 current, const QString &filename)
@ -789,9 +793,14 @@ void COperationDialog::uninstallOldClient()
if (button == QMessageBox::Yes)
{
// remember the choice
CConfigFile::getInstance()->setShouldUninstallOldClient(true);
// launch old uninstaller
QDesktopServices::openUrl(QUrl::fromLocalFile(uninstaller));
// to not ask twice
CConfigFile::getInstance()->setUninstallingOldClient(true);
}
else
{
@ -1247,3 +1256,15 @@ void COperationDialog::renamePartFile()
QFile::rename(partFile, finalFile);
}
}
void COperationDialog::acceptDelayed()
{
// wait 500ms before to call accept()
QTimer::singleShot(500, this, SLOT(accept()));
}
void COperationDialog::rejectDelayed()
{
// wait 500ms before to call reject()
QTimer::singleShot(500, this, SLOT(reject()));
}

View file

@ -133,6 +133,10 @@ protected:
void renamePartFile();
// hacks to prevent an infinite loop
void acceptDelayed();
void rejectDelayed();
QWinTaskbarButton *m_button;
CDownloader *m_downloader;