From 9c23d64fabbcb9867188fd7f917bacff4b24c472 Mon Sep 17 00:00:00 2001 From: kervala Date: Wed, 25 May 2016 23:23:48 +0200 Subject: [PATCH] Changed: CWizardDialog splitted to CMigrateWizard and CInstallWizard --- .../client/ryzom_installer/src/configfile.cpp | 19 +- .../client/ryzom_installer/src/configfile.h | 3 +- ...zarddialog.cpp => installwizarddialog.cpp} | 74 ++----- .../{wizarddialog.h => installwizarddialog.h} | 13 +- .../tools/client/ryzom_installer/src/main.cpp | 14 +- .../client/ryzom_installer/src/mainwindow.cpp | 1 - .../src/migratewizarddialog.cpp | 128 ++++++++++++ .../ryzom_installer/src/migratewizarddialog.h | 49 +++++ .../ryzom_installer/src/operationdialog.cpp | 6 +- .../ui/{wizard.ui => installwizard.ui} | 26 +-- .../ryzom_installer/ui/migratewizard.ui | 183 ++++++++++++++++++ 11 files changed, 421 insertions(+), 95 deletions(-) rename code/ryzom/tools/client/ryzom_installer/src/{wizarddialog.cpp => installwizarddialog.cpp} (68%) rename code/ryzom/tools/client/ryzom_installer/src/{wizarddialog.h => installwizarddialog.h} (85%) create mode 100644 code/ryzom/tools/client/ryzom_installer/src/migratewizarddialog.cpp create mode 100644 code/ryzom/tools/client/ryzom_installer/src/migratewizarddialog.h rename code/ryzom/tools/client/ryzom_installer/ui/{wizard.ui => installwizard.ui} (88%) create mode 100644 code/ryzom/tools/client/ryzom_installer/ui/migratewizard.ui diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 1aa5bad04..543c3a47c 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -525,7 +525,22 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const // only show wizard if installation directory undefined if (getInstallationDirectory().isEmpty()) { - return ShowWizard; + // if launched from current directory, it means we just patched files + QString currentDirectory = getCurrentDirectory(); + + if (!isRyzomInstalledIn(currentDirectory)) + { + // Ryzom is in the same directory as Ryzom Installer + currentDirectory = getApplicationDirectory(); + + if (!isRyzomInstalledIn(currentDirectory)) + { + currentDirectory.clear(); + } + } + + // install or migrate depending if Ryzom was found in current directory + return currentDirectory.isEmpty() ? ShowInstallWizard:ShowMigrateWizard; } QString serverDirectory = getInstallationDirectory() + "/" + server.id; @@ -575,7 +590,7 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const } else { - return ShowWizard; + return ShowInstallWizard; } } diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index 9fcced465..5cb0d77bb 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -80,7 +80,8 @@ public: enum InstallationStep { DisplayNoServerError, - ShowWizard, + ShowInstallWizard, + ShowMigrateWizard, DownloadData, ExtractDownloadedData, DownloadClient, diff --git a/code/ryzom/tools/client/ryzom_installer/src/wizarddialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/installwizarddialog.cpp similarity index 68% rename from code/ryzom/tools/client/ryzom_installer/src/wizarddialog.cpp rename to code/ryzom/tools/client/ryzom_installer/src/installwizarddialog.cpp index 0444487cd..aeeff44f8 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/wizarddialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/installwizarddialog.cpp @@ -15,8 +15,9 @@ // along with this program. If not, see . #include "stdpch.h" -#include "wizarddialog.h" +#include "installwizarddialog.h" #include "configfile.h" +#include "utils.h" #include "nel/misc/system_info.h" #include "nel/misc/common.h" @@ -25,63 +26,17 @@ #define new DEBUG_NEW #endif -QString qBytesToHumanReadable(qint64 bytes) -{ - static std::vector units; - - if (units.empty()) - { - units.push_back(QObject::tr("B").toUtf8().constData()); - units.push_back(QObject::tr("KiB").toUtf8().constData()); - units.push_back(QObject::tr("MiB").toUtf8().constData()); - units.push_back(QObject::tr("GiB").toUtf8().constData()); - units.push_back(QObject::tr("TiB").toUtf8().constData()); - units.push_back(QObject::tr("PiB").toUtf8().constData()); - } - - return QString::fromUtf8(NLMISC::bytesToHumanReadable(bytes).c_str()); -} - -CWizardDialog::CWizardDialog():QDialog() +CInstallWizardDialog::CInstallWizardDialog():QDialog() { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setupUi(this); - currentDirectoryRadioButton->setVisible(false); oldDirectoryRadioButton->setVisible(false); // enable download radio button by default internetRadioButton->setChecked(true); - // if launched from current directory, it means we just patched files - m_currentDirectory = CConfigFile::getInstance()->getCurrentDirectory(); - - if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory)) - { - // current directory is a child of Ryzom root directory - m_currentDirectory = CConfigFile::getInstance()->getParentDirectory(); - - if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory)) - { - // Ryzom is in the same directory as Ryzom Installer - m_currentDirectory = CConfigFile::getInstance()->getApplicationDirectory(); - - if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory)) - { - m_currentDirectory.clear(); - } - } - } - - // display found directory - if (!m_currentDirectory.isEmpty()) - { - currentDirectoryRadioButton->setText(tr("Current directory: %1").arg(m_currentDirectory)); - currentDirectoryRadioButton->setVisible(true); - currentDirectoryRadioButton->setChecked(true); - } - m_oldDirectory = CConfigFile::getInstance()->getOldInstallationDirectory(); // found a previous installation @@ -89,8 +44,7 @@ CWizardDialog::CWizardDialog():QDialog() { oldDirectoryRadioButton->setText(tr("Old installation: %1").arg(m_oldDirectory)); oldDirectoryRadioButton->setVisible(true); - - if (m_currentDirectory.isEmpty()) oldDirectoryRadioButton->setChecked(true); + oldDirectoryRadioButton->setChecked(true); } updateAnotherLocationText(); @@ -128,18 +82,18 @@ CWizardDialog::CWizardDialog():QDialog() connect(advancedCheckBox, SIGNAL(stateChanged(int)), SLOT(onShowAdvancedParameters(int))); } -CWizardDialog::~CWizardDialog() +CInstallWizardDialog::~CInstallWizardDialog() { } -void CWizardDialog::onShowAdvancedParameters(int state) +void CInstallWizardDialog::onShowAdvancedParameters(int state) { advancedFrame->setVisible(state != Qt::Unchecked); adjustSize(); } -void CWizardDialog::onAnotherLocationBrowseButtonClicked() +void CInstallWizardDialog::onAnotherLocationBrowseButtonClicked() { QString directory; @@ -162,7 +116,7 @@ void CWizardDialog::onAnotherLocationBrowseButtonClicked() updateAnotherLocationText(); } -void CWizardDialog::onDestinationBrowseButtonClicked() +void CInstallWizardDialog::onDestinationBrowseButtonClicked() { QString directory = QFileDialog::getExistingDirectory(this, tr("Please choose directory where to install Ryzom")); @@ -173,17 +127,17 @@ void CWizardDialog::onDestinationBrowseButtonClicked() updateDestinationText(); } -void CWizardDialog::updateAnotherLocationText() +void CInstallWizardDialog::updateAnotherLocationText() { anotherLocationRadioButton->setText(tr("Another location: %1").arg(m_anotherDirectory.isEmpty() ? tr("Undefined"):m_anotherDirectory)); } -void CWizardDialog::updateDestinationText() +void CInstallWizardDialog::updateDestinationText() { destinationLabel->setText(m_dstDirectory); } -void CWizardDialog::accept() +void CInstallWizardDialog::accept() { // check free disk space qint64 freeSpace = NLMISC::CSystemInfo::availableHDSpace(m_dstDirectory.toUtf8().constData()); @@ -196,11 +150,7 @@ void CWizardDialog::accept() return; } - if (currentDirectoryRadioButton->isChecked()) - { - CConfigFile::getInstance()->setSrcServerDirectory(m_currentDirectory); - } - else if (oldDirectoryRadioButton->isChecked()) + if (oldDirectoryRadioButton->isChecked()) { CConfigFile::getInstance()->setSrcServerDirectory(m_oldDirectory); } diff --git a/code/ryzom/tools/client/ryzom_installer/src/wizarddialog.h b/code/ryzom/tools/client/ryzom_installer/src/installwizarddialog.h similarity index 85% rename from code/ryzom/tools/client/ryzom_installer/src/wizarddialog.h rename to code/ryzom/tools/client/ryzom_installer/src/installwizarddialog.h index 8ac146184..317a24125 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/wizarddialog.h +++ b/code/ryzom/tools/client/ryzom_installer/src/installwizarddialog.h @@ -14,10 +14,10 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#ifndef WIZARDDIALOG_H -#define WIZARDDIALOG_H +#ifndef INSTALLWIZARDDIALOG_H +#define INSTALLWIZARDDIALOG_H -#include "ui_wizard.h" +#include "ui_installwizard.h" /** * Wizard displayed at first launch, that asks user to choose source and destination directories. @@ -25,13 +25,13 @@ * \author Cedric 'Kervala' OCHS * \date 2016 */ -class CWizardDialog : public QDialog, public Ui::WizardDialog +class CInstallWizardDialog : public QDialog, public Ui::InstallWizardDialog { Q_OBJECT public: - CWizardDialog(); - virtual ~CWizardDialog(); + CInstallWizardDialog(); + virtual ~CInstallWizardDialog(); private slots: void onShowAdvancedParameters(int state); @@ -44,7 +44,6 @@ private: void updateAnotherLocationText(); void updateDestinationText(); - QString m_currentDirectory; QString m_oldDirectory; QString m_anotherDirectory; QString m_dstDirectory; diff --git a/code/ryzom/tools/client/ryzom_installer/src/main.cpp b/code/ryzom/tools/client/ryzom_installer/src/main.cpp index 580defe49..4599f618c 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/main.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/main.cpp @@ -17,7 +17,8 @@ #include "stdpch.h" #include "mainwindow.h" #include "configfile.h" -#include "wizarddialog.h" +#include "migratewizarddialog.h" +#include "installwizarddialog.h" #include "operationdialog.h" #include "nel/misc/path.h" @@ -89,12 +90,19 @@ int main(int argc, char *argv[]) bool displayMainWindow = true; - if (step == CConfigFile::ShowWizard) + if (step == CConfigFile::ShowMigrateWizard) { - CWizardDialog dialog; + CMigrateWizardDialog dialog; if (!dialog.exec()) displayMainWindow = false; } + else if (step == CConfigFile::ShowInstallWizard) + { + CInstallWizardDialog dialog; + + if (!dialog.exec()) displayMainWindow = false; + } + if (displayMainWindow) { diff --git a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp index 5fd114d0f..d38de5b2e 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/mainwindow.cpp @@ -17,7 +17,6 @@ #include "stdpch.h" #include "mainwindow.h" #include "downloader.h" -#include "wizarddialog.h" #include "profilesdialog.h" #include "configfile.h" #include "config.h" diff --git a/code/ryzom/tools/client/ryzom_installer/src/migratewizarddialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/migratewizarddialog.cpp new file mode 100644 index 000000000..e3f521aaa --- /dev/null +++ b/code/ryzom/tools/client/ryzom_installer/src/migratewizarddialog.cpp @@ -0,0 +1,128 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "stdpch.h" +#include "migratewizarddialog.h" +#include "configfile.h" +#include "utils.h" + +#include "nel/misc/system_info.h" +#include "nel/misc/common.h" + +#ifdef DEBUG_NEW + #define new DEBUG_NEW +#endif + +CMigrateWizardDialog::CMigrateWizardDialog():QDialog() +{ + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + + setupUi(this); + + // if launched from current directory, it means we just patched files + m_currentDirectory = CConfigFile::getInstance()->getCurrentDirectory(); + + if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory)) + { + // Ryzom is in the same directory as Ryzom Installer + m_currentDirectory = CConfigFile::getInstance()->getApplicationDirectory(); + + if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory)) + { + m_currentDirectory.clear(); + } + } + + m_dstDirectory = CConfigFile::getNewInstallationDirectory(); + + updateDestinationText(); + + // check whether OS architecture is 32 or 64 bits + // TODO: 64 bits client only supported under Vista+ + if (CConfigFile::has64bitsOS()) + { + clientArchGroupBox->setVisible(true); + clientArch64RadioButton->setChecked(true); + } + else + { + clientArchGroupBox->setVisible(false); + clientArch32RadioButton->setChecked(true); + } + + const CServer &server = CConfigFile::getInstance()->getServer(); + + destinationGroupBox->setTitle(tr("Files will be installed to (requires %1):").arg(qBytesToHumanReadable(server.dataUncompressedSize))); + + connect(destinationBrowseButton, SIGNAL(clicked()), SLOT(onDestinationBrowseButtonClicked())); + connect(continueButton, SIGNAL(clicked()), SLOT(accept())); + connect(quitButton, SIGNAL(clicked()), SLOT(reject())); + + // TODO: if found a folder with initial data, get its total size and check if at least that size is free on the disk + + // by default, advanced parameters are hidden + onShowAdvancedParameters(Qt::Unchecked); + + connect(advancedCheckBox, SIGNAL(stateChanged(int)), SLOT(onShowAdvancedParameters(int))); +} + +CMigrateWizardDialog::~CMigrateWizardDialog() +{ +} + +void CMigrateWizardDialog::onShowAdvancedParameters(int state) +{ + advancedFrame->setVisible(state != Qt::Unchecked); + + adjustSize(); +} + +void CMigrateWizardDialog::onDestinationBrowseButtonClicked() +{ + QString directory = QFileDialog::getExistingDirectory(this, tr("Please choose directory where to install Ryzom")); + + if (directory.isEmpty()) return; + + m_dstDirectory = directory; + + updateDestinationText(); +} + +void CMigrateWizardDialog::updateDestinationText() +{ + destinationLabel->setText(m_dstDirectory); +} + +void CMigrateWizardDialog::accept() +{ + // check free disk space + qint64 freeSpace = NLMISC::CSystemInfo::availableHDSpace(m_dstDirectory.toUtf8().constData()); + + const CServer &server = CConfigFile::getInstance()->getServer(); + + if (freeSpace < server.dataUncompressedSize) + { + QMessageBox::StandardButton res = QMessageBox::warning(this, tr("Not enough free disk space"), tr("You don't have enough free space on this disk, please make more space or choose a directory on another disk.")); + return; + } + + CConfigFile::getInstance()->setSrcServerDirectory(m_currentDirectory); + CConfigFile::getInstance()->setInstallationDirectory(m_dstDirectory); + CConfigFile::getInstance()->setUse64BitsClient(clientArch64RadioButton->isChecked()); + CConfigFile::getInstance()->save(); + + QDialog::accept(); +} diff --git a/code/ryzom/tools/client/ryzom_installer/src/migratewizarddialog.h b/code/ryzom/tools/client/ryzom_installer/src/migratewizarddialog.h new file mode 100644 index 000000000..cbc7cdd91 --- /dev/null +++ b/code/ryzom/tools/client/ryzom_installer/src/migratewizarddialog.h @@ -0,0 +1,49 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#ifndef MIGRATEWIZARDDIALOG_H +#define MIGRATEWIZARDDIALOG_H + +#include "ui_migratewizard.h" + +/** + * Wizard displayed at first launch, that asks user to choose source and destination directories. + * + * \author Cedric 'Kervala' OCHS + * \date 2016 + */ +class CMigrateWizardDialog : public QDialog, public Ui::MigrateWizardDialog +{ + Q_OBJECT + +public: + CMigrateWizardDialog(); + virtual ~CMigrateWizardDialog(); + +private slots: + void onShowAdvancedParameters(int state); + void onDestinationBrowseButtonClicked(); + + void accept(); + +private: + void updateDestinationText(); + + QString m_currentDirectory; + QString m_dstDirectory; +}; + +#endif diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index 5c04fd790..50cbd9d78 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -17,7 +17,6 @@ #include "stdpch.h" #include "operationdialog.h" #include "downloader.h" -#include "wizarddialog.h" #include "profilesdialog.h" #include "configfile.h" #include "config.h" @@ -99,7 +98,10 @@ void COperationDialog::processNextStep() case CConfigFile::DisplayNoServerError: break; - case CConfigFile::ShowWizard: + case CConfigFile::ShowMigrateWizard: + break; + + case CConfigFile::ShowInstallWizard: break; case CConfigFile::DownloadData: diff --git a/code/ryzom/tools/client/ryzom_installer/ui/wizard.ui b/code/ryzom/tools/client/ryzom_installer/ui/installwizard.ui similarity index 88% rename from code/ryzom/tools/client/ryzom_installer/ui/wizard.ui rename to code/ryzom/tools/client/ryzom_installer/ui/installwizard.ui index b7b6475e0..07b0c7520 100644 --- a/code/ryzom/tools/client/ryzom_installer/ui/wizard.ui +++ b/code/ryzom/tools/client/ryzom_installer/ui/installwizard.ui @@ -1,7 +1,7 @@ - WizardDialog - + InstallWizardDialog + Qt::ApplicationModal @@ -10,7 +10,7 @@ 0 0 402 - 464 + 435 @@ -28,10 +28,13 @@ Welcome to Ryzom Installer! -This program will allow you to download, install, migrate, configure or manage Ryzom on your computer. +This program will allow you to download, install, configure or manage Ryzom on your computer. Just follow the different steps and make your choice between the different propositions. + + Qt::PlainText + Qt::AlignJustify|Qt::AlignTop @@ -94,16 +97,6 @@ Just follow the different steps and make your choice between the different propo Files will be installed from: - - - - Current directory - - - true - - - @@ -213,7 +206,6 @@ Just follow the different steps and make your choice between the different propo - currentDirectoryRadioButton oldDirectoryRadioButton anotherLocationRadioButton anotherLocationBrowseButton @@ -227,7 +219,7 @@ Just follow the different steps and make your choice between the different propo buttonBox accepted() - WizardDialog + InstallWizardDialog accept() @@ -243,7 +235,7 @@ Just follow the different steps and make your choice between the different propo buttonBox rejected() - WizardDialog + InstallWizardDialog reject() diff --git a/code/ryzom/tools/client/ryzom_installer/ui/migratewizard.ui b/code/ryzom/tools/client/ryzom_installer/ui/migratewizard.ui new file mode 100644 index 000000000..376d90c40 --- /dev/null +++ b/code/ryzom/tools/client/ryzom_installer/ui/migratewizard.ui @@ -0,0 +1,183 @@ + + + MigrateWizardDialog + + + Qt::ApplicationModal + + + + 0 + 0 + 402 + 331 + + + + Ryzom Installer + + + true + + + + + + Welcome to Ryzom Installer! + +This program will migrate Ryzom version 2.1 to 3.0. Your files will be updated, cleaned and moved to a new location. + +Just press Continue button and follow the different steps until everything is done. + + + Qt::PlainText + + + Qt::AlignJustify|Qt::AlignTop + + + true + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Show advanced parameters (expert) + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 6 + + + 0 + + + 9 + + + 0 + + + 0 + + + + + Files will be installed to (requires 10 GiB): + + + + + + c:\ + + + + + + + Browse... + + + + + + + + + + Do you prefer to use a 64 or 32 bits client? + + + + + + 64 bits (recommended) + + + true + + + + + + + 32 bits + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Continue + + + + + + + Quit + + + + + + + + + destinationBrowseButton + clientArch64RadioButton + clientArch32RadioButton + + + +