Rename, move some functions.
This commit is contained in:
parent
ee6430988b
commit
2f7337336e
7 changed files with 41 additions and 39 deletions
|
@ -53,10 +53,10 @@ void FormAbout::loadSettingsAndPaths() {
|
|||
m_ui->m_txtPathsSettingsType->setText(tr("FULLY portable"));
|
||||
}
|
||||
else {
|
||||
m_ui->m_txtPathsSettingsType->setText(tr("PARTIALLY portable"));
|
||||
m_ui->m_txtPathsSettingsType->setText(tr("NOT portable"));
|
||||
}
|
||||
|
||||
m_ui->m_txtPathsDatabaseRoot->setText(QDir::toNativeSeparators(qApp->settings()->userSettingsRootFolder() +
|
||||
m_ui->m_txtPathsDatabaseRoot->setText(QDir::toNativeSeparators(qApp->getUserDataPath() +
|
||||
QDir::separator() +
|
||||
QString(APP_DB_SQLITE_PATH)));
|
||||
m_ui->m_txtPathsSettingsFile->setText(QDir::toNativeSeparators(qApp->settings()->fileName()));
|
||||
|
|
|
@ -190,6 +190,33 @@ QString Application::getConfigHomePath() {
|
|||
return IOFactory::getSystemFolder(QStandardPaths::ConfigLocation);
|
||||
}
|
||||
|
||||
QString Application::getUserDataAppPath() {
|
||||
// In "app" folder, we would like to separate all user data into own subfolder,
|
||||
// therefore stick to "data" folder in this mode.
|
||||
return applicationDirPath() + QDir::separator() + QSL("data");
|
||||
}
|
||||
|
||||
QString Application::getUserDataPath() {
|
||||
if (settings()->type() == SettingsProperties::Portable) {
|
||||
return getUserDataAppPath();
|
||||
}
|
||||
else {
|
||||
return getUserDataHomePath();
|
||||
}
|
||||
}
|
||||
|
||||
QString Application::getUserDataHomePath() {
|
||||
// Fallback folder.
|
||||
const QString home_folder = getHomeFolderPath() + QDir::separator() + QSL(APP_LOW_H_NAME) + QDir::separator() + QSL("data");
|
||||
|
||||
if (QDir().exists(home_folder)) {
|
||||
return home_folder;
|
||||
}
|
||||
else {
|
||||
return getConfigHomePath() + QDir::separator() + QSL(APP_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
QString Application::getTempFolderPath() {
|
||||
return IOFactory::getSystemFolder(QStandardPaths::TempLocation);
|
||||
}
|
||||
|
|
|
@ -85,6 +85,14 @@ class Application : public QtSingleApplication {
|
|||
QString getHomeFolderPath();
|
||||
QString getConfigHomePath();
|
||||
|
||||
// These return user ready folders.
|
||||
QString getUserDataAppPath();
|
||||
QString getUserDataHomePath();
|
||||
|
||||
// Returns the base folder to which store user data, the "data" folder.
|
||||
// NOTE: Use this to get correct path under which store user data.
|
||||
QString getUserDataPath();
|
||||
|
||||
void setMainForm(FormMain *main_form);
|
||||
|
||||
void backupDatabaseSettings(bool backup_database, bool backup_settings,
|
||||
|
|
|
@ -187,7 +187,7 @@ void DatabaseFactory::finishRestoration() {
|
|||
}
|
||||
|
||||
void DatabaseFactory::sqliteAssemblyDatabaseFilePath() {
|
||||
m_sqliteDatabaseFilePath = qApp->settings()->userSettingsRootFolder() + QDir::separator() + QString(APP_DB_SQLITE_PATH);
|
||||
m_sqliteDatabaseFilePath = qApp->getUserDataPath() + QDir::separator() + QString(APP_DB_SQLITE_PATH);
|
||||
}
|
||||
|
||||
QSqlDatabase DatabaseFactory::sqliteInitializeInMemoryDatabase() {
|
||||
|
|
|
@ -275,15 +275,6 @@ Settings::Settings(const QString &file_name, Format format, const SettingsProper
|
|||
Settings::~Settings() {
|
||||
}
|
||||
|
||||
QString Settings::userSettingsRootFolder() const {
|
||||
if (qApp->settings()->type() == SettingsProperties::Portable) {
|
||||
return getAppPathUserFolder();
|
||||
}
|
||||
else {
|
||||
return getHomeUserFolder();
|
||||
}
|
||||
}
|
||||
|
||||
QString Settings::pathName() const {
|
||||
return QFileInfo(fileName()).absolutePath();
|
||||
}
|
||||
|
@ -318,24 +309,6 @@ void Settings::finishRestoration(const QString &desired_settings_file_path) {
|
|||
}
|
||||
}
|
||||
|
||||
QString Settings::getAppPathUserFolder() {
|
||||
// In "app" folder, we would like to separate all user data into own subfolder,
|
||||
// therefore stick to "data" folder in this mode.
|
||||
return qApp->applicationDirPath() + QDir::separator() + QSL("data");
|
||||
}
|
||||
|
||||
QString Settings::getHomeUserFolder() {
|
||||
// Fallback folder.
|
||||
const QString home_folder = qApp->getHomeFolderPath() + QDir::separator() + QSL(APP_LOW_H_NAME) + QDir::separator() + QSL("data");
|
||||
|
||||
if (QDir().exists(home_folder)) {
|
||||
return home_folder;
|
||||
}
|
||||
else {
|
||||
return qApp->getConfigHomePath() + QDir::separator() + QSL(APP_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
Settings *Settings::setupSettings(QObject *parent) {
|
||||
Settings *new_settings;
|
||||
|
||||
|
@ -366,8 +339,8 @@ SettingsProperties Settings::determineProperties() {
|
|||
properties.m_settingsSuffix = QDir::separator() + QString(APP_CFG_PATH) + QDir::separator() + QString(APP_CFG_FILE);
|
||||
|
||||
const QString exe_path = qApp->applicationDirPath();
|
||||
const QString app_path = getAppPathUserFolder();
|
||||
const QString home_path = getHomeUserFolder();
|
||||
const QString app_path = qApp->getUserDataAppPath();
|
||||
const QString home_path = qApp->getUserDataHomePath();
|
||||
const QString home_path_file = home_path + properties.m_settingsSuffix;
|
||||
|
||||
const bool portable_settings_available = IOFactory::isFolderWritable(exe_path);
|
||||
|
|
|
@ -312,9 +312,6 @@ class Settings : public QSettings {
|
|||
return m_initializationStatus;
|
||||
}
|
||||
|
||||
// Returns the base folder to which store user data, the "data" folder.
|
||||
QString userSettingsRootFolder() const;
|
||||
|
||||
// Getters/setters for settings values.
|
||||
inline QVariant value(const QString §ion, const QString &key, const QVariant &default_value = QVariant()) const {
|
||||
return QSettings::value(QString("%1/%2").arg(section, key), default_value);
|
||||
|
@ -345,9 +342,6 @@ class Settings : public QSettings {
|
|||
bool initiateRestoration(const QString &settings_backup_file_path);
|
||||
static void finishRestoration(const QString &desired_settings_file_path);
|
||||
|
||||
static QString getAppPathUserFolder();
|
||||
static QString getHomeUserFolder();
|
||||
|
||||
// Creates settings file in correct location.
|
||||
static Settings *setupSettings(QObject *parent);
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ void SkinFactory::setCurrentSkinName(const QString &skin_name) {
|
|||
}
|
||||
|
||||
QString SkinFactory::getUserSkinBaseFolder() const {
|
||||
return qApp->settings()->userSettingsRootFolder() + QDir::separator() + APP_SKIN_USER_FOLDER;
|
||||
return qApp->getUserDataPath() + QDir::separator() + APP_SKIN_USER_FOLDER;
|
||||
}
|
||||
|
||||
QString SkinFactory::selectedSkinName() const {
|
||||
|
|
Loading…
Add table
Reference in a new issue