added folder "company-titleblocks" \(incl. language-files\)

This commit is contained in:
plc-user
2023-12-16 09:32:44 +01:00
parent a4495d50d1
commit f12b11bee3
65 changed files with 39625 additions and 27212 deletions

View File

@@ -232,6 +232,14 @@ void ElementsPanel::reload()
common_tbt_collection_item_ -> setWhatsThis(0, tr("Ceci est la collection de cartouches fournie avec QElectroTech. Installée en tant que composant système, vous ne pouvez normalement pas la personnaliser.", "\"What's this\" tip"));
if (first_reload_) common_tbt_collection_item_ -> setExpanded(true);
// load the company title block templates collection
TitleBlockTemplatesCollection *company_tbt_collection = QETApp::companyTitleBlockTemplatesCollection();
company_tbt_collection_item_ = addTemplatesCollection(company_tbt_collection, invisibleRootItem());
company_tbt_collection_item_ -> setIcon(0, company_icon);
company_tbt_collection_item_ -> setStatusTip(0, tr("Double-cliquez pour réduire ou développer la collection company de cartouches", "Status tip"));
company_tbt_collection_item_ -> setWhatsThis(0, tr("Ceci est la collection company de cartouches -- utilisez-la pour créer, stocker et éditer vos propres cartouches.", "\"What's this\" tip"));
if (first_reload_) company_tbt_collection_item_ -> setExpanded(true);
// load the custom title block templates collection
TitleBlockTemplatesCollection *custom_tbt_collection = QETApp::customTitleBlockTemplatesCollection();
custom_tbt_collection_item_ = addTemplatesCollection(custom_tbt_collection, invisibleRootItem());

View File

@@ -64,6 +64,7 @@ QString QETApp::config_dir = QString();
QString QETApp::lang_dir = QString();
TitleBlockTemplatesFilesCollection *QETApp::m_common_tbt_collection;
TitleBlockTemplatesFilesCollection *QETApp::m_company_tbt_collection;
TitleBlockTemplatesFilesCollection *QETApp::m_custom_tbt_collection;
ElementsCollectionCache *QETApp::collections_cache_ = nullptr;
QMap<uint, QETProject *> QETApp::registered_projects_ = QMap<uint, QETProject *>();
@@ -81,7 +82,10 @@ bool QETApp::m_company_element_dir_is_set = false;
QString QETApp::m_custom_element_dir = QString();
bool QETApp::m_custom_element_dir_is_set = false;
QString QETApp::m_user_company_tbt_dir = QString();
QString QETApp::m_user_custom_tbt_dir = QString();
QETApp *QETApp::m_qetapp = nullptr;
bool lang_is_set = false;
@@ -158,6 +162,8 @@ QETApp::~QETApp()
if (m_custom_tbt_collection)
delete m_custom_tbt_collection;
if (m_company_tbt_collection)
delete m_company_tbt_collection;
if (m_common_tbt_collection)
delete m_common_tbt_collection;
@@ -436,6 +442,27 @@ TitleBlockTemplatesFilesCollection *QETApp::commonTitleBlockTemplatesCollection(
return(m_common_tbt_collection);
}
/**
@brief QETApp::companyTitleBlockTemplatesCollection
@return the company's title block templates collection,
i.e. the one managed by the admin
*/
TitleBlockTemplatesFilesCollection *QETApp::companyTitleBlockTemplatesCollection()
{
if (!m_company_tbt_collection) {
m_company_tbt_collection =
new TitleBlockTemplatesFilesCollection(
QETApp::companyTitleBlockTemplatesDir());
m_company_tbt_collection -> setTitle(
tr("Cartouches company",
"title of the company's \
title block templates collection"));
m_company_tbt_collection -> setProtocol(QETAPP_COMPANY_TBT_PROTOCOL);
m_company_tbt_collection -> setCollection(QET::QetCollection::Company);
}
return(m_company_tbt_collection);
}
/**
@brief QETApp::customTitleBlockTemplatesCollection
@return the custom title block templates collection,
@@ -466,6 +493,7 @@ QList<TitleBlockTemplatesCollection *> QETApp::availableTitleBlockTemplatesColle
QList<TitleBlockTemplatesCollection *> collections_list;
collections_list << commonTitleBlockTemplatesCollection();
collections_list << companyTitleBlockTemplatesCollection();
collections_list << customTitleBlockTemplatesCollection();
foreach(QETProject *opened_project, registered_projects_) {
@@ -485,6 +513,8 @@ TitleBlockTemplatesCollection *QETApp::titleBlockTemplatesCollection(
const QString &protocol) {
if (protocol == QETAPP_COMMON_TBT_PROTOCOL) {
return(m_common_tbt_collection);
} else if (protocol == QETAPP_COMPANY_TBT_PROTOCOL) {
return(m_company_tbt_collection);
} else if (protocol == QETAPP_CUSTOM_TBT_PROTOCOL) {
return(m_custom_tbt_collection);
} else {
@@ -685,6 +715,8 @@ void QETApp::resetCollectionsPath()
m_custom_element_dir.clear();
m_custom_element_dir_is_set = false;
m_user_company_tbt_dir.clear();
m_user_custom_tbt_dir.clear();
}
@@ -718,6 +750,39 @@ QString QETApp::commonTitleBlockTemplatesDir()
#endif
}
/**
@brief QETApp::companyTitleBlockTemplatesDir
@return the path of the directory containing the company title block
templates collection.
*/
QString QETApp::companyTitleBlockTemplatesDir()
{
if (m_user_company_tbt_dir.isEmpty())
{
QSettings settings;
QString path = settings.value(
"elements-collections/company-tbt-path",
"default").toString();
if (path != "default" && !path.isEmpty())
{
QDir dir(path);
if (dir.exists())
{
m_user_company_tbt_dir = path;
return m_user_company_tbt_dir;
}
}
else {
m_user_company_tbt_dir = "default";
}
}
else if (m_user_company_tbt_dir != "default") {
return m_user_company_tbt_dir;
}
return(configDir() + "titleblocks-company/");
}
/**
@brief QETApp::customTitleBlockTemplatesDir
@return the path of the directory containing the custom title block
@@ -813,14 +878,16 @@ QString QETApp::realPath(const QString &sym_path) {
QString directory;
if (sym_path.startsWith("common://")) {
directory = commonElementsDir();
} else if (sym_path.startsWith("company://")) {
directory = companyElementsDir();
} else if (sym_path.startsWith("company://")) {
directory = companyElementsDir();
} else if (sym_path.startsWith("custom://")) {
directory = customElementsDir();
} else if (sym_path.startsWith(QETAPP_COMMON_TBT_PROTOCOL "://")) {
} else if (sym_path.startsWith("company://")) {
directory = companyElementsDir();
} else if (sym_path.startsWith("company://")) {
directory = companyElementsDir();
} else if (sym_path.startsWith("custom://")) {
directory = customElementsDir();
} else if (sym_path.startsWith(QETAPP_COMMON_TBT_PROTOCOL "://")) {
directory = commonTitleBlockTemplatesDir();
} else if (sym_path.startsWith(QETAPP_COMPANY_TBT_PROTOCOL "://")) {
directory = companyTitleBlockTemplatesDir();
} else if (sym_path.startsWith(QETAPP_CUSTOM_TBT_PROTOCOL "://")) {
directory = customTitleBlockTemplatesDir();
} else return(QString());
@@ -1985,9 +2052,13 @@ void QETApp::initConfiguration()
if (!company_elements_dir.exists())
company_elements_dir.mkpath(QETApp::companyElementsDir());
QDir company_tbt_dir(QETApp::companyTitleBlockTemplatesDir());
if (!company_tbt_dir.exists())
company_tbt_dir.mkpath(QETApp::companyTitleBlockTemplatesDir());
QDir custom_tbt_dir(QETApp::customTitleBlockTemplatesDir());
if (!custom_tbt_dir.exists())
custom_tbt_dir.mkpath(QETApp::customTitleBlockTemplatesDir());
if (!custom_tbt_dir.exists())
custom_tbt_dir.mkpath(QETApp::customTitleBlockTemplatesDir());
/* recent files
* note:

View File

@@ -33,6 +33,7 @@ class QAction;
class QMainWindow;
#define QETAPP_COMMON_TBT_PROTOCOL "commontbt"
#define QETAPP_COMPANY_TBT_PROTOCOL "companytbt"
#define QETAPP_CUSTOM_TBT_PROTOCOL "customtbt"
class AboutQET;
@@ -75,6 +76,7 @@ class QETApp : public QObject
static ElementsCollectionCache *collectionCache();
static TitleBlockTemplatesFilesCollection *commonTitleBlockTemplatesCollection();
static TitleBlockTemplatesFilesCollection *companyTitleBlockTemplatesCollection();
static TitleBlockTemplatesFilesCollection *customTitleBlockTemplatesCollection();
static QList<TitleBlockTemplatesCollection *> availableTitleBlockTemplatesCollections();
static TitleBlockTemplatesCollection *titleBlockTemplatesCollection(const QString &);
@@ -87,6 +89,7 @@ class QETApp : public QObject
static QString customElementsDirN();
static void resetCollectionsPath();
static QString commonTitleBlockTemplatesDir();
static QString companyTitleBlockTemplatesDir();
static QString customTitleBlockTemplatesDir();
static bool registerProject(QETProject *);
static bool unregisterProject(QETProject *);
@@ -204,6 +207,7 @@ class QETApp : public QObject
QPalette initial_palette_; ///< System color palette
static TitleBlockTemplatesFilesCollection *m_common_tbt_collection;
static TitleBlockTemplatesFilesCollection *m_company_tbt_collection;
static TitleBlockTemplatesFilesCollection *m_custom_tbt_collection;
static ElementsCollectionCache *collections_cache_;
static QMap<uint, QETProject *> registered_projects_;
@@ -221,6 +225,7 @@ class QETApp : public QObject
static QString m_custom_element_dir;
static bool m_custom_element_dir_is_set;
static QString m_user_company_tbt_dir;
static QString m_user_custom_tbt_dir;

View File

@@ -147,6 +147,15 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
ui->m_company_elmt_path_cb->blockSignals(false);
}
path = settings.value("elements-collections/company-tbt-path", "default").toString();
if (path != "default")
{
ui->m_company_tbt_path_cb->blockSignals(true);
ui->m_company_tbt_path_cb->setCurrentIndex(1);
ui->m_company_tbt_path_cb->setItemData(1, path, Qt::DisplayRole);
ui->m_company_tbt_path_cb->blockSignals(false);
}
path = settings.value("elements-collections/custom-collection-path", "default").toString();
if (path != "default")
{
@@ -280,6 +289,21 @@ void GeneralConfigurationPage::applyConf()
QETApp::resetCollectionsPath();
}
path = settings.value("elements-collections/company-tbt-path").toString();
if (ui->m_company_tbt_path_cb->currentIndex() == 1)
{
QString path = ui->m_company_tbt_path_cb->currentText();
QDir dir(path);
settings.setValue("elements-collections/company-tbt-path",
dir.exists() ? path : "default");
}
else {
settings.setValue("elements-collections/company-tbt-path", "default");
}
if (path != settings.value("elements-collections/company-tbt-path").toString()) {
QETApp::resetCollectionsPath();
}
path = settings.value("elements-collections/custom-tbt-path").toString();
if (ui->m_custom_tbt_path_cb->currentIndex() == 1)
{
@@ -450,6 +474,20 @@ void GeneralConfigurationPage::on_m_custom_elmt_path_cb_currentIndexChanged(int
}
}
void GeneralConfigurationPage::on_m_company_tbt_path_cb_currentIndexChanged(int index)
{
if (index == 1)
{
QString path = QFileDialog::getExistingDirectory(this, tr("Chemin des cartouches company"), QDir::homePath());
if (!path.isEmpty()) {
ui->m_company_tbt_path_cb->setItemData(1, path, Qt::DisplayRole);
}
else {
ui->m_company_tbt_path_cb->setCurrentIndex(0);
}
}
}
void GeneralConfigurationPage::on_m_custom_tbt_path_cb_currentIndexChanged(int index)
{
if (index == 1)

View File

@@ -44,6 +44,7 @@ class GeneralConfigurationPage : public ConfigPage
void on_m_common_elmt_path_cb_currentIndexChanged(int index);
void on_m_company_elmt_path_cb_currentIndexChanged(int index);
void on_m_custom_elmt_path_cb_currentIndexChanged(int index);
void on_m_company_tbt_path_cb_currentIndexChanged(int index);
void on_m_custom_tbt_path_cb_currentIndexChanged(int index);
void on_m_indi_text_font_pb_clicked();
void on_MaxPartsElementEditorList_sb_valueChanged(int value);

View File

@@ -264,14 +264,14 @@
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_8">
<widget class="QLabel" name="label_17">
<property name="text">
<string>Répertoire de la collection utilisateur</string>
<string>Répertoire des cartouches company</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="m_custom_elmt_path_cb">
<widget class="QComboBox" name="m_company_tbt_path_cb">
<item>
<property name="text">
<string>Par defaut</string>
@@ -285,13 +285,34 @@
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Répertoire de la collection utilisateur</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="m_custom_elmt_path_cb">
<item>
<property name="text">
<string>Par defaut</string>
</property>
</item>
<item>
<property name="text">
<string>Parcourir...</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Répertoire des cartouches utilisateur</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QComboBox" name="m_custom_tbt_path_cb">
<item>
<property name="text">
@@ -305,7 +326,7 @@
</item>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string>(Recharger les collections d'éléments pour appliquer les changements)</string>