mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-23 07:36:16 +00:00
Merge with develop
This commit is contained in:
parent
89ab635693
commit
30ad6fa760
7 changed files with 85 additions and 6 deletions
|
@ -27,7 +27,8 @@
|
||||||
CConfigFile *CConfigFile::s_instance = NULL;
|
CConfigFile *CConfigFile::s_instance = NULL;
|
||||||
|
|
||||||
CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_version(-1),
|
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;
|
s_instance = this;
|
||||||
|
|
||||||
|
@ -461,6 +462,16 @@ void CConfigFile::setShouldUninstallOldClient(bool on)
|
||||||
m_shouldUninstallOldClient = 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 CConfigFile::expandVariables(const QString &str) const
|
||||||
{
|
{
|
||||||
QString res = str;
|
QString res = str;
|
||||||
|
@ -972,7 +983,7 @@ OperationStep CConfigFile::getInstallNextStep() const
|
||||||
if (!settings.contains("InstallLocation")) return CreateAddRemoveEntry;
|
if (!settings.contains("InstallLocation")) return CreateAddRemoveEntry;
|
||||||
#endif
|
#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;
|
return UninstallOldClient;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,9 @@ public:
|
||||||
bool shouldUninstallOldClient() const;
|
bool shouldUninstallOldClient() const;
|
||||||
void setShouldUninstallOldClient(bool on);
|
void setShouldUninstallOldClient(bool on);
|
||||||
|
|
||||||
|
bool uninstallingOldClient() const;
|
||||||
|
void setUninstallingOldClient(bool on);
|
||||||
|
|
||||||
QString expandVariables(const QString &str) const;
|
QString expandVariables(const QString &str) const;
|
||||||
|
|
||||||
QString getClientArch() const;
|
QString getClientArch() const;
|
||||||
|
@ -147,6 +150,7 @@ private:
|
||||||
QString m_srcDirectory;
|
QString m_srcDirectory;
|
||||||
bool m_use64BitsClient;
|
bool m_use64BitsClient;
|
||||||
bool m_shouldUninstallOldClient;
|
bool m_shouldUninstallOldClient;
|
||||||
|
bool m_uninstallingOldClient;
|
||||||
QString m_language;
|
QString m_language;
|
||||||
|
|
||||||
QString m_defaultConfigPath;
|
QString m_defaultConfigPath;
|
||||||
|
|
|
@ -86,6 +86,11 @@ int main(int argc, char *argv[])
|
||||||
_CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
_CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
// to fix the bug with QFileDialog::getExistingDirectory hanging under Windows
|
||||||
|
CoInitialize(NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
NLMISC::CApplicationContext appContext;
|
NLMISC::CApplicationContext appContext;
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
@ -218,8 +223,10 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (step == Done)
|
if (step == Done)
|
||||||
{
|
{
|
||||||
|
#if defined(Q_OS_WIN) && !defined(_DEBUG)
|
||||||
// restart Installer, so it could be copied in TEMP and allowed to update itself
|
// restart Installer, so it could be copied in TEMP and allowed to update itself
|
||||||
if (QProcess::startDetached(QApplication::applicationFilePath(), QApplication::arguments())) return 0;
|
if (QProcess::startDetached(QApplication::applicationFilePath(), QApplication::arguments())) return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,11 @@ CMainWindow::CMainWindow():QMainWindow()
|
||||||
connect(m_downloader, SIGNAL(htmlPageContent(QString)), SLOT(onHtmlPageContent(QString)));
|
connect(m_downloader, SIGNAL(htmlPageContent(QString)), SLOT(onHtmlPageContent(QString)));
|
||||||
|
|
||||||
connect(actionProfiles, SIGNAL(triggered()), SLOT(onProfiles()));
|
connect(actionProfiles, SIGNAL(triggered()), SLOT(onProfiles()));
|
||||||
|
|
||||||
|
// remove debug options
|
||||||
|
actionSettings->setVisible(false);
|
||||||
|
actionUninstall->setVisible(false);
|
||||||
|
|
||||||
connect(actionSettings, SIGNAL(triggered()), SLOT(onSettings()));
|
connect(actionSettings, SIGNAL(triggered()), SLOT(onSettings()));
|
||||||
connect(actionUninstall, SIGNAL(triggered()), SLOT(onUninstall()));
|
connect(actionUninstall, SIGNAL(triggered()), SLOT(onUninstall()));
|
||||||
connect(actionQuit, SIGNAL(triggered()), SLOT(onQuit()));
|
connect(actionQuit, SIGNAL(triggered()), SLOT(onQuit()));
|
||||||
|
@ -60,6 +65,7 @@ CMainWindow::CMainWindow():QMainWindow()
|
||||||
setFixedHeight(height());
|
setFixedHeight(height());
|
||||||
|
|
||||||
updateProfiles();
|
updateProfiles();
|
||||||
|
updateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
CMainWindow::~CMainWindow()
|
CMainWindow::~CMainWindow()
|
||||||
|
@ -83,6 +89,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 +151,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 +291,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;
|
||||||
|
|
|
@ -92,7 +92,7 @@ void COperationDialog::processNextStep()
|
||||||
{
|
{
|
||||||
if (operationShouldStop())
|
if (operationShouldStop())
|
||||||
{
|
{
|
||||||
reject();
|
rejectDelayed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ void COperationDialog::processInstallNextStep()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Done:
|
case Done:
|
||||||
accept();
|
acceptDelayed();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -253,6 +253,8 @@ void COperationDialog::updateAddRemoveComponents()
|
||||||
|
|
||||||
void COperationDialog::processUpdateProfilesNextStep()
|
void COperationDialog::processUpdateProfilesNextStep()
|
||||||
{
|
{
|
||||||
|
m_currentOperation = tr("Update profiles");
|
||||||
|
|
||||||
// for "update profiles" operations, we set installer to false when components are updated,
|
// for "update profiles" operations, we set installer to false when components are updated,
|
||||||
// since we're not using this variable
|
// since we're not using this variable
|
||||||
if (m_addComponents.installer && m_removeComponents.installer)
|
if (m_addComponents.installer && m_removeComponents.installer)
|
||||||
|
@ -344,6 +346,8 @@ void COperationDialog::processUpdateProfilesNextStep()
|
||||||
}
|
}
|
||||||
|
|
||||||
updateAddRemoveEntry();
|
updateAddRemoveEntry();
|
||||||
|
|
||||||
|
acceptDelayed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void COperationDialog::processUninstallNextStep()
|
void COperationDialog::processUninstallNextStep()
|
||||||
|
@ -369,7 +373,7 @@ void COperationDialog::processUninstallNextStep()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// done
|
// done
|
||||||
accept();
|
acceptDelayed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +464,7 @@ void COperationDialog::onProgressStop()
|
||||||
m_button->progress()->hide();
|
m_button->progress()->hide();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
reject();
|
rejectDelayed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void COperationDialog::onProgressProgress(qint64 current, const QString &filename)
|
void COperationDialog::onProgressProgress(qint64 current, const QString &filename)
|
||||||
|
@ -789,9 +793,14 @@ void COperationDialog::uninstallOldClient()
|
||||||
|
|
||||||
if (button == QMessageBox::Yes)
|
if (button == QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
|
// remember the choice
|
||||||
CConfigFile::getInstance()->setShouldUninstallOldClient(true);
|
CConfigFile::getInstance()->setShouldUninstallOldClient(true);
|
||||||
|
|
||||||
|
// launch old uninstaller
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(uninstaller));
|
QDesktopServices::openUrl(QUrl::fromLocalFile(uninstaller));
|
||||||
|
|
||||||
|
// to not ask twice
|
||||||
|
CConfigFile::getInstance()->setUninstallingOldClient(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1247,3 +1256,15 @@ void COperationDialog::renamePartFile()
|
||||||
QFile::rename(partFile, finalFile);
|
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()));
|
||||||
|
}
|
||||||
|
|
|
@ -133,6 +133,10 @@ protected:
|
||||||
|
|
||||||
void renamePartFile();
|
void renamePartFile();
|
||||||
|
|
||||||
|
// hacks to prevent an infinite loop
|
||||||
|
void acceptDelayed();
|
||||||
|
void rejectDelayed();
|
||||||
|
|
||||||
QWinTaskbarButton *m_button;
|
QWinTaskbarButton *m_button;
|
||||||
CDownloader *m_downloader;
|
CDownloader *m_downloader;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue