let user define the file system path of the common and custom elements collections

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5452 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2018-07-25 17:34:50 +00:00
parent b97b01d63c
commit 1ec4334308
4 changed files with 163 additions and 13 deletions

View File

@@ -59,6 +59,7 @@ RecentFiles *QETApp::m_projects_recent_files = nullptr;
RecentFiles *QETApp::m_elements_recent_files = nullptr;
TitleBlockTemplate *QETApp::default_titleblock_template_ = nullptr;
/**
Constructeur
@param argc Nombre d'arguments passes a l'application
@@ -455,12 +456,23 @@ QString QETApp::userName() {
#endif
}
/**
Renvoie le dossier des elements communs, c-a-d le chemin du dossier dans
lequel QET doit chercher les definitions XML des elements de la collection QET.
@return Le chemin du dossier des elements communs
* @brief QETApp::commonElementsDir
* @return the dir path of the common elements collection.
*/
QString QETApp::commonElementsDir() {
QString QETApp::commonElementsDir()
{
QSettings settings;
QString path = settings.value("elements-collections/common-collection-path", "default").toString();
if (path != "default" && !path.isEmpty())
{
QDir dir(path);
if (dir.exists()) {
return path;
}
}
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
if (common_elements_dir != QString()) return(common_elements_dir);
#endif
@@ -479,12 +491,21 @@ QString QETApp::commonElementsDir() {
}
/**
Renvoie le dossier des elements de l'utilisateur, c-a-d le chemin du dossier
dans lequel QET chercher les definitions XML des elements propres a
l'utilisateur.
@return Le chemin du dossier des elements persos
* @brief QETApp::customElementsDir
* @return the dir path of user elements collection
*/
QString QETApp::customElementsDir() {
QString QETApp::customElementsDir()
{
QSettings settings;
QString path = settings.value("elements-collections/custom-collection-path", "default").toString();
if (path != "default" && !path.isEmpty())
{
QDir dir(path);
if (dir.exists()) {
return path;
}
}
return(configDir() + "elements/");
}

View File

@@ -61,6 +61,24 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
ui->m_highlight_integrated_elements->setChecked(settings.value("diagrameditor/highlight-integrated-elements", true).toBool());
ui->m_default_elements_info->setPlainText(settings.value("elementeditor/default-informations", "").toString());
QString path = settings.value("elements-collections/common-collection-path", "default").toString();
if (path != "default")
{
ui->m_common_elmt_path_cb->blockSignals(true);
ui->m_common_elmt_path_cb->setCurrentIndex(1);
ui->m_common_elmt_path_cb->setItemData(1, path, Qt::DisplayRole);
ui->m_common_elmt_path_cb->blockSignals(false);
}
path = settings.value("elements-collections/custom-collection-path", "default").toString();
if (path != "default")
{
ui->m_custom_elmt_path_cb->blockSignals(true);
ui->m_custom_elmt_path_cb->setCurrentIndex(1);
ui->m_custom_elmt_path_cb->setItemData(1, path, Qt::DisplayRole);
ui->m_custom_elmt_path_cb->blockSignals(false);
}
fillLang();
}
@@ -97,6 +115,28 @@ void GeneralConfigurationPage::applyConf()
settings.setValue("genericpanel/folio",ui->m_use_folio_label->isChecked());
settings.setValue("nomenclature/terminal-exportlist",ui->m_export_terminal->isChecked());
settings.setValue("diagrameditor/autosave-interval", ui->m_autosave_sb->value());
if (ui->m_common_elmt_path_cb->currentIndex() == 1)
{
QString path = ui->m_common_elmt_path_cb->currentText();
QDir dir(path);
settings.setValue("elements-collections/common-collection-path",
dir.exists() ? path : "default");
}
else {
settings.setValue("elements-collections/common-collection-path", "default");
}
if (ui->m_custom_elmt_path_cb->currentIndex() == 1)
{
QString path = ui->m_custom_elmt_path_cb->currentText();
QDir dir(path);
settings.setValue("elements-collections/custom-collection-path",
dir.exists() ? path : "default");
}
else {
settings.setValue("elements-collections/custom-collection-path", "default");
}
}
/**
@@ -202,3 +242,32 @@ void GeneralConfigurationPage::on_m_folio_list_pb_clicked()
ui->m_folio_list_pb->setText(fontInfos);
}
}
#include <QFileDialog>
void GeneralConfigurationPage::on_m_common_elmt_path_cb_currentIndexChanged(int index)
{
if (index == 1)
{
QString path = QFileDialog::getExistingDirectory(this, tr("Chemin de la collection commune"), QDir::homePath());
if (!path.isEmpty()) {
ui->m_common_elmt_path_cb->setItemData(1, path, Qt::DisplayRole);
}
else {
ui->m_common_elmt_path_cb->setCurrentIndex(0);
}
}
}
void GeneralConfigurationPage::on_m_custom_elmt_path_cb_currentIndexChanged(int index)
{
if (index == 1)
{
QString path = QFileDialog::getExistingDirectory(this, tr("Chemin de la collection utilisateur"), QDir::homePath());
if (!path.isEmpty()) {
ui->m_custom_elmt_path_cb->setItemData(1, path, Qt::DisplayRole);
}
else {
ui->m_custom_elmt_path_cb->setCurrentIndex(0);
}
}
}

View File

@@ -40,6 +40,8 @@ class GeneralConfigurationPage : public ConfigPage
private slots:
void on_m_font_pb_clicked();
void on_m_folio_list_pb_clicked();
void on_m_common_elmt_path_cb_currentIndexChanged(int index);
void on_m_custom_elmt_path_cb_currentIndexChanged(int index);
private:
void fillLang();

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>916</width>
<height>747</height>
<width>827</width>
<height>779</height>
</rect>
</property>
<property name="windowTitle">
@@ -44,6 +44,64 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_5">
<property name="title">
<string>Collections d'éléments</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Chemin de la collection utilisateur</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Chemin de la collection commune</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="m_common_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="1" 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="2" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string>(Recharger les collections d'éléments pour appliquer les changements)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">