Changed: Renamed configurations to profiles

This commit is contained in:
kervala 2016-02-27 18:43:14 +01:00
parent 7299c7d414
commit c149714559
8 changed files with 94 additions and 94 deletions

View file

@ -338,7 +338,7 @@ bool CArchive::copyServerFiles()
return copyFiles(files); return copyFiles(files);
} }
bool CArchive::copyConfigurationFiles() bool CArchive::copyProfileFiles()
{ {
emit extractPrepare(); emit extractPrepare();
@ -372,7 +372,7 @@ bool CArchive::copyServerFiles(const QString &src, const QString &dst)
return true; return true;
} }
bool CArchive::copyConfigurationFiles(const QString &src, const QString &dst) bool CArchive::copyProfileFiles(const QString &src, const QString &dst)
{ {
if (src.isEmpty() || dst.isEmpty()) return false; if (src.isEmpty() || dst.isEmpty()) return false;
@ -382,7 +382,7 @@ bool CArchive::copyConfigurationFiles(const QString &src, const QString &dst)
// create destination directory // create destination directory
QDir().mkpath(dst); QDir().mkpath(dst);
QFuture<bool> future = QtConcurrent::run(this, &CArchive::copyConfigurationFiles); QFuture<bool> future = QtConcurrent::run(this, &CArchive::copyProfileFiles);
return true; return true;
} }

View file

@ -33,7 +33,7 @@ public:
bool extract(const QString &filename, const QString &dest); bool extract(const QString &filename, const QString &dest);
bool copyServerFiles(const QString &src, const QString &dst); bool copyServerFiles(const QString &src, const QString &dst);
bool copyConfigurationFiles(const QString &src, const QString &dst); bool copyProfileFiles(const QString &src, const QString &dst);
void stop(); void stop();
bool mustStop(); bool mustStop();
@ -80,7 +80,7 @@ protected:
bool progress(const std::string &filename, uint32 currentFile, uint32 totalFiles); bool progress(const std::string &filename, uint32 currentFile, uint32 totalFiles);
bool copyServerFiles(); bool copyServerFiles();
bool copyConfigurationFiles(); bool copyProfileFiles();
bool copyFiles(const FilesToCopy &files); bool copyFiles(const FilesToCopy &files);
static void getFilesList(const QString &srcDir, const QString &dstDir, const QStringList &filter, FilesToCopy &files); static void getFilesList(const QString &srcDir, const QString &dstDir, const QStringList &filter, FilesToCopy &files);

View file

@ -25,11 +25,11 @@
#endif #endif
const CServer NoServer; const CServer NoServer;
const CConfiguration NoConfiguration; const CProfile NoProfile;
CConfigFile *CConfigFile::s_instance = NULL; CConfigFile *CConfigFile::s_instance = NULL;
CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_defaultServer(0), m_defaultConfiguration(0), m_use64BitsClient(false) CConfigFile::CConfigFile(QObject *parent):QObject(parent), m_defaultServer(0), m_defaultProfile(0), m_use64BitsClient(false)
{ {
s_instance = this; s_instance = this;
@ -92,26 +92,26 @@ bool CConfigFile::load(const QString &filename)
settings.endGroup(); settings.endGroup();
} }
settings.beginGroup("configurations"); settings.beginGroup("profiles");
int configurationsCounts = settings.value("size").toInt(); int profilesCounts = settings.value("size").toInt();
m_defaultConfiguration = settings.value("default").toInt(); m_defaultProfile = settings.value("default").toInt();
settings.endGroup(); settings.endGroup();
m_configurations.resize(configurationsCounts); m_profiles.resize(profilesCounts);
for(int i = 0; i < configurationsCounts; ++i) for(int i = 0; i < profilesCounts; ++i)
{ {
CConfiguration &configuration = m_configurations[i]; CProfile &profile = m_profiles[i];
settings.beginGroup(QString("configuration_%1").arg(i)); settings.beginGroup(QString("profile_%1").arg(i));
configuration.id = settings.value("id").toInt(); profile.id = settings.value("id").toInt();
configuration.name = settings.value("name").toString(); profile.name = settings.value("name").toString();
configuration.account = settings.value("account").toString(); profile.account = settings.value("account").toString();
configuration.server = settings.value("server").toString(); profile.server = settings.value("server").toString();
configuration.executable = settings.value("executable").toString(); profile.executable = settings.value("executable").toString();
configuration.parameters = settings.value("parameters").toString(); profile.parameters = settings.value("parameters").toString();
configuration.comments = settings.value("comments").toString(); profile.comments = settings.value("comments").toString();
settings.endGroup(); settings.endGroup();
} }
@ -162,24 +162,24 @@ bool CConfigFile::save() const
settings.endGroup(); settings.endGroup();
} }
settings.beginGroup("configurations"); settings.beginGroup("profiles");
settings.setValue("size", m_configurations.size()); settings.setValue("size", m_profiles.size());
settings.setValue("default", m_defaultConfiguration); settings.setValue("default", m_defaultProfile);
settings.endGroup(); settings.endGroup();
for(int i = 0; i < m_configurations.size(); ++i) for(int i = 0; i < m_profiles.size(); ++i)
{ {
const CConfiguration &configuration = m_configurations[i]; const CProfile &profile = m_profiles[i];
settings.beginGroup(QString("configuration_%1").arg(i)); settings.beginGroup(QString("profile_%1").arg(i));
settings.setValue("id", configuration.id); settings.setValue("id", profile.id);
settings.setValue("name", configuration.name); settings.setValue("name", profile.name);
settings.setValue("account", configuration.account); settings.setValue("account", profile.account);
settings.setValue("server", configuration.server); settings.setValue("server", profile.server);
settings.setValue("executable", configuration.executable); settings.setValue("executable", profile.executable);
settings.setValue("parameters", configuration.parameters); settings.setValue("parameters", profile.parameters);
settings.setValue("comments", configuration.comments); settings.setValue("comments", profile.comments);
settings.endGroup(); settings.endGroup();
} }
@ -217,37 +217,37 @@ const CServer& CConfigFile::getServer(const QString &id) const
return getServer(); return getServer();
} }
int CConfigFile::getConfigurationsCount() const int CConfigFile::getProfilesCount() const
{ {
return m_configurations.size(); return m_profiles.size();
} }
CConfiguration CConfigFile::getConfiguration(int i) const CProfile CConfigFile::getProfile(int i) const
{ {
if (i < 0) i = m_defaultConfiguration; if (i < 0) i = m_defaultProfile;
if (i >= m_configurations.size()) return NoConfiguration; if (i >= m_profiles.size()) return NoProfile;
return m_configurations.at(i); return m_profiles.at(i);
} }
void CConfigFile::setConfiguration(int i, const CConfiguration &configuration) void CConfigFile::setProfile(int i, const CProfile &profile)
{ {
m_configurations[i] = configuration; m_profiles[i] = profile;
} }
int CConfigFile::addConfiguration(const CConfiguration &configuration) int CConfigFile::addProfile(const CProfile &profile)
{ {
m_configurations.append(configuration); m_profiles.append(profile);
return m_configurations.size()-1; return m_profiles.size()-1;
} }
void CConfigFile::removeConfiguration(int i) void CConfigFile::removeProfile(int i)
{ {
m_configurations.removeAt(i); m_profiles.removeAt(i);
// TODO: decalle all configurations and move files // TODO: decalle all profiles and move files
} }
bool CConfigFile::has64bitsOS() bool CConfigFile::has64bitsOS()
@ -255,9 +255,9 @@ bool CConfigFile::has64bitsOS()
return QSysInfo::currentCpuArchitecture() == "x86_64"; return QSysInfo::currentCpuArchitecture() == "x86_64";
} }
int CConfigFile::getDefaultConfiguration() const int CConfigFile::getDefaultProfile() const
{ {
return m_defaultConfiguration; return m_defaultProfile;
} }
int CConfigFile::getDefaultServer() const int CConfigFile::getDefaultServer() const
@ -267,7 +267,7 @@ int CConfigFile::getDefaultServer() const
bool CConfigFile::isRyzomInstallerConfigured() const bool CConfigFile::isRyzomInstallerConfigured() const
{ {
return m_configurations.size() > 0; return m_profiles.size() > 0;
} }
QString CConfigFile::getInstallationDirectory() const QString CConfigFile::getInstallationDirectory() const
@ -290,12 +290,12 @@ void CConfigFile::setSrcServerDirectory(const QString &directory)
m_srcDirectory = directory; m_srcDirectory = directory;
} }
QString CConfigFile::getConfigurationDirectory() const QString CConfigFile::getProfileDirectory() const
{ {
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
} }
QString CConfigFile::getSrcConfigurationDirectory() const QString CConfigFile::getSrcProfileDirectory() const
{ {
if (QFile::exists(getSrcServerDirectory() + "/client.cfg")) return getSrcServerDirectory(); if (QFile::exists(getSrcServerDirectory() + "/client.cfg")) return getSrcServerDirectory();
@ -425,7 +425,7 @@ bool CConfigFile::isRyzomClientInstalledIn(const QString &directory) const
QString CConfigFile::getClientFullPath() const QString CConfigFile::getClientFullPath() const
{ {
QString path = getConfiguration().executable; QString path = getProfile().executable;
if (!path.isEmpty()) return path; if (!path.isEmpty()) return path;
@ -439,13 +439,13 @@ QString CConfigFile::getSrcServerClientBNPFullPath() const
CConfigFile::InstallationStep CConfigFile::getNextStep() const CConfigFile::InstallationStep CConfigFile::getNextStep() const
{ {
// get last used configuration // get last used profile
const CConfiguration &configuration = getConfiguration(); const CProfile &profile = getProfile();
// get server used by it or default server // get server used by it or default server
CServer server = getServer(configuration.server); CServer server = getServer(profile.server);
// no or wrong configuration // no or wrong profile
if (server.id.isEmpty()) if (server.id.isEmpty())
{ {
// get last used server // get last used server
@ -542,16 +542,16 @@ CConfigFile::InstallationStep CConfigFile::getNextStep() const
} }
} }
// no default configuration // no default profile
if (configuration.id < 0) if (profile.id < 0)
{ {
return CreateConfiguration; return CreateProfile;
} }
// migration configuration // migration profile
if (!getSrcServerDirectory().isEmpty() && QFile::exists(getSrcConfigurationDirectory() + "/client.cfg") && !QFile::exists(QString("%1/%2/client.cfg").arg(getConfigurationDirectory()).arg(configuration.name))) if (!getSrcServerDirectory().isEmpty() && QFile::exists(getSrcProfileDirectory() + "/client.cfg") && !QFile::exists(QString("%1/%2/client.cfg").arg(getProfileDirectory()).arg(profile.name)))
{ {
return CopyConfigurationFiles; return CopyProfileFiles;
} }
if (!QFile::exists(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Ryzom.lnk")) if (!QFile::exists(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) + "/Ryzom.lnk"))

View file

@ -40,9 +40,9 @@ struct CServer
extern const CServer NoServer; extern const CServer NoServer;
struct CConfiguration struct CProfile
{ {
CConfiguration() CProfile()
{ {
id = -1; id = -1;
} }
@ -56,7 +56,7 @@ struct CConfiguration
QString comments; QString comments;
}; };
extern const CConfiguration NoConfiguration; extern const CProfile NoProfile;
/** /**
* Config file management and other stuff related to location of files/directories. * Config file management and other stuff related to location of files/directories.
@ -78,9 +78,9 @@ public:
DownloadClient, DownloadClient,
ExtractDownloadedClient, ExtractDownloadedClient,
CopyServerFiles, CopyServerFiles,
CopyConfigurationFiles, CopyProfileFiles,
ExtractBnpClient, ExtractBnpClient,
CreateConfiguration, CreateProfile,
CreateShortcuts, CreateShortcuts,
Done Done
}; };
@ -98,14 +98,14 @@ public:
const CServer& getServer(int i = -1) const; const CServer& getServer(int i = -1) const;
const CServer& getServer(const QString &id) const; const CServer& getServer(const QString &id) const;
int getConfigurationsCount() const; int getProfilesCount() const;
CConfiguration getConfiguration(int i = -1) const; CProfile getProfile(int i = -1) const;
void setConfiguration(int i, const CConfiguration &configuration); void setProfile(int i, const CProfile &profile);
int addConfiguration(const CConfiguration &configuration); int addProfile(const CProfile &profile);
void removeConfiguration(int i); void removeProfile(int i);
int getDefaultServer() const; int getDefaultServer() const;
int getDefaultConfiguration() const; int getDefaultProfile() const;
bool isRyzomInstallerConfigured() const; bool isRyzomInstallerConfigured() const;
@ -115,8 +115,8 @@ public:
QString getSrcServerDirectory() const; QString getSrcServerDirectory() const;
void setSrcServerDirectory(const QString &directory); void setSrcServerDirectory(const QString &directory);
QString getConfigurationDirectory() const; QString getProfileDirectory() const;
QString getSrcConfigurationDirectory() const; QString getSrcProfileDirectory() const;
static bool has64bitsOS(); static bool has64bitsOS();
@ -147,10 +147,10 @@ public:
private: private:
int m_defaultServer; int m_defaultServer;
int m_defaultConfiguration; int m_defaultProfile;
QVector<CServer> m_servers; QVector<CServer> m_servers;
QVector<CConfiguration> m_configurations; QVector<CProfile> m_profiles;
QString m_installationDirectory; QString m_installationDirectory;
QString m_srcDirectory; QString m_srcDirectory;

View file

@ -92,8 +92,8 @@ void CMainWindow::processNextStep()
// default server // default server
const CServer &server = config->getServer(); const CServer &server = config->getServer();
// default configuration // default profile
const CConfiguration &configuration = config->getConfiguration(); const CProfile &configuration = config->getProfile();
switch(CConfigFile::getInstance()->getNextStep()) switch(CConfigFile::getInstance()->getNextStep())
{ {
@ -126,9 +126,9 @@ void CMainWindow::processNextStep()
m_archive->copyServerFiles(config->getSrcServerDirectory(), config->getInstallationDirectory() + "/" + server.id); m_archive->copyServerFiles(config->getSrcServerDirectory(), config->getInstallationDirectory() + "/" + server.id);
break; break;
case CConfigFile::CopyConfigurationFiles: case CConfigFile::CopyProfileFiles:
displayProgressBar(); displayProgressBar();
m_archive->copyConfigurationFiles(config->getSrcConfigurationDirectory(), config->getConfigurationDirectory() + "/0"); m_archive->copyProfileFiles(config->getSrcProfileDirectory(), config->getProfileDirectory() + "/0");
break; break;
case CConfigFile::ExtractBnpClient: case CConfigFile::ExtractBnpClient:
@ -136,7 +136,7 @@ void CMainWindow::processNextStep()
m_archive->extract(config->getSrcServerClientBNPFullPath(), config->getInstallationDirectory() + "/" + server.id); m_archive->extract(config->getSrcServerClientBNPFullPath(), config->getInstallationDirectory() + "/" + server.id);
break; break;
case CConfigFile::CreateConfiguration: case CConfigFile::CreateProfile:
displayProgressBar(); displayProgressBar();
break; break;

View file

@ -15,22 +15,22 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h" #include "stdpch.h"
#include "configurationsdialog.h" #include "profilesdialog.h"
#ifdef DEBUG_NEW #ifdef DEBUG_NEW
#define new DEBUG_NEW #define new DEBUG_NEW
#endif #endif
CConfigurationsDialog::CConfigurationsDialog():QDialog() CProfilesDialog::CProfilesDialog():QDialog()
{ {
setupUi(this); setupUi(this);
} }
CConfigurationsDialog::~CConfigurationsDialog() CProfilesDialog::~CProfilesDialog()
{ {
} }
void CConfigurationsDialog::accept() void CProfilesDialog::accept()
{ {
// TODO: add save code // TODO: add save code

View file

@ -14,18 +14,18 @@
// You should have received a copy of the GNU Affero General Public License // 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/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CONFIGURATIONSDIALOG_H #ifndef PROFILESDIALOG_H
#define CONFIGURATIONSDIALOG_H #define PROFILESDIALOG_H
#include "ui_configurations.h" #include "ui_profiles.h"
class CConfigurationsDialog : public QDialog, public Ui::ConfigurationsDialog class CProfilesDialog : public QDialog, public Ui::ConfigurationsDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
CConfigurationsDialog(); CProfilesDialog();
virtual ~CConfigurationsDialog(); virtual ~CProfilesDialog();
private slots: private slots:
void accept(); void accept();