Changed: CWizardDialog splitted to CMigrateWizard and CInstallWizard

This commit is contained in:
kervala 2016-05-25 23:23:48 +02:00
parent e3b09a2bd2
commit 9c23d64fab
11 changed files with 421 additions and 95 deletions

View file

@ -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;
}
}

View file

@ -80,7 +80,8 @@ public:
enum InstallationStep
{
DisplayNoServerError,
ShowWizard,
ShowInstallWizard,
ShowMigrateWizard,
DownloadData,
ExtractDownloadedData,
DownloadClient,

View file

@ -15,8 +15,9 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#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<std::string> 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);
}

View file

@ -14,10 +14,10 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#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;

View file

@ -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)
{

View file

@ -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"

View file

@ -0,0 +1,128 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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();
}

View file

@ -0,0 +1,49 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// 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 <http://www.gnu.org/licenses/>.
#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

View file

@ -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:

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WizardDialog</class>
<widget class="QDialog" name="WizardDialog">
<class>InstallWizardDialog</class>
<widget class="QDialog" name="InstallWizardDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
@ -10,7 +10,7 @@
<x>0</x>
<y>0</y>
<width>402</width>
<height>464</height>
<height>435</height>
</rect>
</property>
<property name="windowTitle">
@ -28,10 +28,13 @@
<property name="text">
<string>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.</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignTop</set>
</property>
@ -94,16 +97,6 @@ Just follow the different steps and make your choice between the different propo
<string>Files will be installed from:</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="currentDirectoryRadioButton">
<property name="text">
<string>Current directory</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="oldDirectoryRadioButton">
<property name="text">
@ -213,7 +206,6 @@ Just follow the different steps and make your choice between the different propo
</layout>
</widget>
<tabstops>
<tabstop>currentDirectoryRadioButton</tabstop>
<tabstop>oldDirectoryRadioButton</tabstop>
<tabstop>anotherLocationRadioButton</tabstop>
<tabstop>anotherLocationBrowseButton</tabstop>
@ -227,7 +219,7 @@ Just follow the different steps and make your choice between the different propo
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>WizardDialog</receiver>
<receiver>InstallWizardDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
@ -243,7 +235,7 @@ Just follow the different steps and make your choice between the different propo
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>WizardDialog</receiver>
<receiver>InstallWizardDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">

View file

@ -0,0 +1,183 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MigrateWizardDialog</class>
<widget class="QDialog" name="MigrateWizardDialog">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>402</width>
<height>331</height>
</rect>
</property>
<property name="windowTitle">
<string>Ryzom Installer</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0,0,0">
<item>
<widget class="QLabel" name="messageLabel">
<property name="text">
<string>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.</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="advancedLayout">
<item>
<spacer name="advancedHorizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="advancedCheckBox">
<property name="text">
<string>Show advanced parameters (expert)</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QFrame" name="advancedFrame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="advancedMainLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="destinationGroupBox">
<property name="title">
<string>Files will be installed to (requires 10 GiB):</string>
</property>
<layout class="QHBoxLayout" name="destinationLayout" stretch="1,0">
<item>
<widget class="QLabel" name="destinationLabel">
<property name="text">
<string>c:\</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="destinationBrowseButton">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="clientArchGroupBox">
<property name="title">
<string>Do you prefer to use a 64 or 32 bits client?</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="clientArch64RadioButton">
<property name="text">
<string>64 bits (recommended)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="clientArch32RadioButton">
<property name="text">
<string>32 bits</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="buttonsLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="continueButton">
<property name="text">
<string>Continue</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="quitButton">
<property name="text">
<string>Quit</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>destinationBrowseButton</tabstop>
<tabstop>clientArch64RadioButton</tabstop>
<tabstop>clientArch32RadioButton</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>