Compare commits

...

12 Commits

Author SHA1 Message Date
Laurent Trinques 2cc5de6f7c Merge pull request #327 from plc-user/master
set config- and data-dir to system-specific paths
2025-01-24 13:48:11 +01:00
plc-user 661530030a Update machine_info.cpp
second try to resolve PR-conflict
2025-01-24 13:28:52 +01:00
plc-user 620aa665f2 Update machine_info.cpp
try to resolve PR-conflict
2025-01-24 13:25:57 +01:00
Laurent Trinques 8f23a3d94d Improve logs in machine info 2025-01-24 11:49:53 +01:00
Laurent Trinques c343df3fc9 Minor 2025-01-24 11:12:36 +01:00
plc-user d7ac2af4d6 use QETApp::dataDir() instead of QStamdardPaths 2025-01-24 08:35:03 +01:00
plc-user ec7ba05ec1 adjust info-text 2025-01-24 07:19:36 +01:00
plc-user 600cba6a8f update comment 2025-01-24 07:10:36 +01:00
plc-user 4221bb84fb create "AppDataLocation" if not present 2025-01-24 07:02:57 +01:00
plc-user b6d29fbbf0 update comment 2025-01-24 06:56:04 +01:00
plc-user 635af67100 "writableLocation" is a QString 2025-01-23 20:20:17 +01:00
plc-user ba9cd71816 set config- and data-dir to system-specific paths 2025-01-23 18:47:10 +01:00
7 changed files with 58 additions and 49 deletions
+2 -8
View File
@@ -17,11 +17,11 @@
*/ */
#include "dxftoelmt.h" #include "dxftoelmt.h"
#include "../ui/thirdpartybinaryinstalldialog.h" #include "../ui/thirdpartybinaryinstalldialog.h"
#include "../qetapp.h"
#include <QFile> #include <QFile>
#include <QProcess> #include <QProcess>
#include <QMessageBox> #include <QMessageBox>
#include <QDir>
/** /**
* @brief dxftoElmt * @brief dxftoElmt
@@ -71,13 +71,7 @@ QByteArray dxfToElmt(const QString &file_path)
QString dxf2ElmtDirPath() QString dxf2ElmtDirPath()
{ {
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) return QETApp::dataDir() + "/binary";
return (QDir::homePath() + QStringLiteral("/Application Data/qet/binary"));
#elif defined(Q_OS_MACOS)
return (QDir::homePath() + QStringLiteral("/.qet/binary"));
#else
return (QDir::homePath() + QStringLiteral("/.qet/binary"));
#endif
} }
/** /**
+8 -6
View File
@@ -156,13 +156,15 @@ void MachineInfo::send_info_to_debug()
qInfo()<< " Custom TitleBlock Templates Dir:"<< QString(QETApp::customTitleBlockTemplatesDir().toLatin1()); qInfo()<< " Custom TitleBlock Templates Dir:"<< QString(QETApp::customTitleBlockTemplatesDir().toLatin1());
qInfo()<< " Company Elements Dir:"<< QString(QETApp::companyElementsDir().toLatin1()); qInfo()<< " Company Elements Dir:"<< QString(QETApp::companyElementsDir().toLatin1());
qInfo()<< " Company TitleBlock Templates Dir:"<< QString(QETApp::companyTitleBlockTemplatesDir().toLatin1()); qInfo()<< " Company TitleBlock Templates Dir:"<< QString(QETApp::companyTitleBlockTemplatesDir().toLatin1());
qInfo()<< " User Location:"<< QString(QETApp::configDir().toLatin1());
qInfo()<< " Standard Location :"<< QStringList(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation));
qInfo()<< " App Data Location:"<< QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); qInfo()<< " Config Location :"<< QStringList(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation));
qInfo()<< " App Local DataLocation:"<< QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation); qInfo()<< " Project stalefiles Location:"<< QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
qInfo()<< " Home Location:"<< QStandardPaths::writableLocation(QStandardPaths::HomeLocation); //qInfo()<< " App Local DataLocation:"<< QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation);
qInfo()<< " Runtime Location:"<< QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); // qInfo()<< " Home Location:"<< QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
qInfo()<< " Cache Location:"<< QStandardPaths::writableLocation(QStandardPaths::CacheLocation); // qInfo()<< " Runtime Location:"<< QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
// qInfo()<< " Cache Location:"<< QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
+3 -2
View File
@@ -112,7 +112,8 @@ void myMessageOutput(QtMsgType type,
txt+= context.function ? context.function : ""; txt+= context.function ? context.function : "";
txt+=")\n"; txt+=")\n";
} }
QFile outFile(QETApp::configDir() QFile outFile(QETApp::dataDir()
+"/"
+QDate::currentDate().toString("yyyyMMdd") +QDate::currentDate().toString("yyyyMMdd")
+".log"); +".log");
if(outFile.open(QIODevice::WriteOnly | QIODevice::Append)) if(outFile.open(QIODevice::WriteOnly | QIODevice::Append))
@@ -131,7 +132,7 @@ void myMessageOutput(QtMsgType type,
void delete_old_log_files(int days) void delete_old_log_files(int days)
{ {
const QDate today = QDate::currentDate(); const QDate today = QDate::currentDate();
const QString path = QETApp::configDir() + "/"; const QString path = QETApp::dataDir() + "/";
QString filter("%1%1%1%1%1%1%1%1.log"); // pattern QString filter("%1%1%1%1%1%1%1%1.log"); // pattern
filter = filter.arg("[0123456789]"); // valid characters filter = filter.arg("[0123456789]"); // valid characters
@@ -17,12 +17,12 @@
*/ */
#include "qet_elementscaler.h" #include "qet_elementscaler.h"
#include "../ui/thirdpartybinaryinstalldialog.h" #include "../ui/thirdpartybinaryinstalldialog.h"
#include "../qetapp.h"
#include <QFile> #include <QFile>
#include <QProcess> #include <QProcess>
#include <QInputDialog> #include <QInputDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QDir>
/** /**
* @brief QET_ElementScaler * @brief QET_ElementScaler
@@ -113,13 +113,7 @@ QByteArray ElementScaler(const QString &file_path, QWidget *parent)
QString ElementScalerDirPath() QString ElementScalerDirPath()
{ {
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) return QETApp::dataDir() + "/binary";
return (QDir::homePath() + QStringLiteral("/Application Data/qet/binary"));
#elif defined(Q_OS_MACOS)
return (QDir::homePath() + QStringLiteral("/.qet/binary"));
#else
return (QDir::homePath() + QStringLiteral("/.qet/binary"));
#endif
} }
/** /**
+41 -24
View File
@@ -121,7 +121,7 @@ QETApp::QETApp() :
tr("Chargement... Initialisation du cache des collections d'éléments", tr("Chargement... Initialisation du cache des collections d'éléments",
"splash screen caption")); "splash screen caption"));
if (!collections_cache_) { if (!collections_cache_) {
QString cache_path = QETApp::configDir() + "/elements_cache.sqlite"; QString cache_path = QETApp::dataDir() + "/elements_cache.sqlite";
collections_cache_ = new ElementsCollectionCache(cache_path, this); collections_cache_ = new ElementsCollectionCache(cache_path, this);
collections_cache_->setLocale(langFromSetting()); collections_cache_->setLocale(langFromSetting());
@@ -620,7 +620,7 @@ QString QETApp::customElementsDir()
} }
} }
m_custom_element_dir = configDir() + "elements/"; m_custom_element_dir = dataDir() + "/elements/";
return m_custom_element_dir; return m_custom_element_dir;
} }
} }
@@ -657,7 +657,7 @@ QString QETApp::companyElementsDir()
} }
} }
m_company_element_dir = configDir() + "elements-company/"; m_company_element_dir = dataDir() + "/elements-company/";
return m_company_element_dir; return m_company_element_dir;
} }
} }
@@ -780,7 +780,7 @@ QString QETApp::companyTitleBlockTemplatesDir()
return m_user_company_tbt_dir; return m_user_company_tbt_dir;
} }
return(configDir() + "titleblocks-company/"); return(dataDir() + "/titleblocks-company/");
} }
/** /**
@@ -813,7 +813,7 @@ QString QETApp::customTitleBlockTemplatesDir()
return m_user_custom_tbt_dir; return m_user_custom_tbt_dir;
} }
return(configDir() + "titleblocks/"); return(dataDir() + "/titleblocks/");
} }
/** /**
@@ -821,17 +821,17 @@ QString QETApp::customTitleBlockTemplatesDir()
Return the QET configuration folder, i.e. the path to the folder in Return the QET configuration folder, i.e. the path to the folder in
which QET will read configuration and customization information which QET will read configuration and customization information
specific to the current user. This file is generally specific to the current user. This file is generally
C:\\Documents And Settings\\user\\Application Data\ qet C:/Users/<USER>/AppData/Local/<APPNAME>
on Windows and on Windows and
~/.qet ~/.config/<APPNAME>
under UNIX-like systems. under UNIX-like systems.
\~French Renvoie le dossier de configuration de QET, \~French Renvoie le dossier de configuration de QET,
c-a-d le chemin du dossier dans lequel QET lira les informations c-a-d le chemin du dossier dans lequel QET lira les informations
de configuration et de personnalisation propres a l'utilisateur courant. de configuration et de personnalisation propres a l'utilisateur courant.
Ce dossier est generalement Ce dossier est generalement
C:\\Documents And Settings\\utilisateur\\Application Data\\qet C:/Users/<USER>/AppData/Local/<APPNAME>
sous Windows et sous Windows et
~/.qet ~/.config/<APPNAME>
sous les systemes type UNIX. sous les systemes type UNIX.
\~ @return The path of the QElectroTech configuration folder \~ @return The path of the QElectroTech configuration folder
\~French Le chemin du dossier de configuration de QElectroTech \~French Le chemin du dossier de configuration de QElectroTech
@@ -841,21 +841,32 @@ QString QETApp::configDir()
#ifdef QET_ALLOW_OVERRIDE_CD_OPTION #ifdef QET_ALLOW_OVERRIDE_CD_OPTION
if (config_dir != QString()) return(config_dir); if (config_dir != QString()) return(config_dir);
#endif #endif
#ifdef Q_OS_WIN32 QString configdir = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
// recupere l'emplacement du dossier Application Data if (configdir.endsWith('/')) {
// char *app_data_env = getenv("APPDATA"); configdir.remove(configdir.length()-1, 1);
// QString app_data_str(app_data_env);
QProcess * process = new QProcess();
QString app_data_str = (process->processEnvironment()).value("APPDATA");
// delete app_data_env;
delete process;
if (app_data_str.isEmpty()) {
app_data_str = QDir::homePath() + "/Application Data";
} }
return(app_data_str + "/qet/"); return configdir;
#else }
return(QDir::homePath() + "/.qet/");
#endif /**
@brief QETApp::dataDir
Return the QET data folder, i.e. the path to the folder in
which QET will save log-files and elements-cache and where
to find user-collections and user-titleblocks by default
specific to the current user. This directory is generally
C:/Users/<USER>/AppData/Roaming/<APPNAME>
on Windows and
~/.local/share/<APPNAME>
under UNIX-like systems.
\~ @return The path of the QElectroTech data-folder
*/
QString QETApp::dataDir()
{
QString datadir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
if (datadir.endsWith('/')) {
datadir.remove(datadir.length()-1, 1);
}
return datadir;
} }
/** /**
@@ -1536,7 +1547,7 @@ void QETApp::useSystemPalette(bool use) {
"}" "}"
); );
} else { } else {
QFile file(configDir() + "style.css"); QFile file(configDir() + "/style.css");
file.open(QFile::ReadOnly); file.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(file.readAll()); QString styleSheet = QLatin1String(file.readAll());
qApp->setStyleSheet(styleSheet); qApp->setStyleSheet(styleSheet);
@@ -2044,6 +2055,12 @@ void QETApp::initConfiguration()
QDir config_dir(QETApp::configDir()); QDir config_dir(QETApp::configDir());
if (!config_dir.exists()) config_dir.mkpath(QETApp::configDir()); if (!config_dir.exists()) config_dir.mkpath(QETApp::configDir());
// we definitely need the dataDir for log files and element cache
// Nous avons absolument besoin du répertoire dataDir pour
// les fichiers journaux et le cache des éléments.
QDir data_dir(QETApp::dataDir());
if (!data_dir.exists()) data_dir.mkpath(QETApp::dataDir());
QDir custom_elements_dir(QETApp::customElementsDir()); QDir custom_elements_dir(QETApp::customElementsDir());
if (!custom_elements_dir.exists()) if (!custom_elements_dir.exists())
custom_elements_dir.mkpath(QETApp::customElementsDir()); custom_elements_dir.mkpath(QETApp::customElementsDir());
+1
View File
@@ -97,6 +97,7 @@ class QETApp : public QObject
static QETProject *project(const uint &); static QETProject *project(const uint &);
static int projectId(const QETProject *); static int projectId(const QETProject *);
static QString configDir(); static QString configDir();
static QString dataDir();
static QString languagesPath(); static QString languagesPath();
static QString realPath(const QString &); static QString realPath(const QString &);
static QString symbolicPath(const QString &); static QString symbolicPath(const QString &);
+1 -1
View File
@@ -208,7 +208,7 @@ void AboutQETDialog::setLicence()
*/ */
void AboutQETDialog::setLoginfo() void AboutQETDialog::setLoginfo()
{ {
const QString path = QETApp::configDir() + "/"; const QString path = QETApp::dataDir() + "/";
QString filter("%1%1%1%1%1%1%1%1.log"); // pattern QString filter("%1%1%1%1%1%1%1%1.log"); // pattern
filter = filter.arg("[0123456789]"); // valid characters filter = filter.arg("[0123456789]"); // valid characters
Q_FOREACH (auto fileInfo, Q_FOREACH (auto fileInfo,