mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
re-enable the possibility to define the path of elements collections.
Add variables for common and custom elements collections, to avoid multiple access to QSettings and so reduce the loading of collections. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5462 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -58,6 +58,8 @@ uint QETApp::next_project_id = 0;
|
|||||||
RecentFiles *QETApp::m_projects_recent_files = nullptr;
|
RecentFiles *QETApp::m_projects_recent_files = nullptr;
|
||||||
RecentFiles *QETApp::m_elements_recent_files = nullptr;
|
RecentFiles *QETApp::m_elements_recent_files = nullptr;
|
||||||
TitleBlockTemplate *QETApp::default_titleblock_template_ = nullptr;
|
TitleBlockTemplate *QETApp::default_titleblock_template_ = nullptr;
|
||||||
|
QString QETApp::m_user_common_elements_dir = QString();
|
||||||
|
QString QETApp::m_user_custom_elements_dir = QString();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -463,17 +465,26 @@ QString QETApp::userName() {
|
|||||||
*/
|
*/
|
||||||
QString QETApp::commonElementsDir()
|
QString QETApp::commonElementsDir()
|
||||||
{
|
{
|
||||||
//@todo: fix me " Load time from elements is very slow "
|
if (m_user_common_elements_dir.isEmpty())
|
||||||
|
{
|
||||||
// QSettings settings;
|
QSettings settings;
|
||||||
// QString path = settings.value("elements-collections/common-collection-path", "default").toString();
|
QString path = settings.value("elements-collections/common-collection-path", "default").toString();
|
||||||
// if (path != "default" && !path.isEmpty())
|
if (path != "default" && !path.isEmpty())
|
||||||
// {
|
{
|
||||||
// QDir dir(path);
|
QDir dir(path);
|
||||||
// if (dir.exists()) {
|
if (dir.exists())
|
||||||
// return path;
|
{
|
||||||
// }
|
m_user_common_elements_dir = path;
|
||||||
// }
|
return m_user_common_elements_dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_user_common_elements_dir = "default";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_user_common_elements_dir != "default") {
|
||||||
|
return m_user_common_elements_dir;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
|
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
|
||||||
if (common_elements_dir != QString()) return(common_elements_dir);
|
if (common_elements_dir != QString()) return(common_elements_dir);
|
||||||
@@ -498,17 +509,26 @@ QString QETApp::commonElementsDir()
|
|||||||
*/
|
*/
|
||||||
QString QETApp::customElementsDir()
|
QString QETApp::customElementsDir()
|
||||||
{
|
{
|
||||||
//@todo: fix me " Load time from elements is very slow "
|
if (m_user_custom_elements_dir.isEmpty())
|
||||||
|
{
|
||||||
// QSettings settings;
|
QSettings settings;
|
||||||
// QString path = settings.value("elements-collections/custom-collection-path", "default").toString();
|
QString path = settings.value("elements-collections/custom-collection-path", "default").toString();
|
||||||
// if (path != "default" && !path.isEmpty())
|
if (path != "default" && !path.isEmpty())
|
||||||
// {
|
{
|
||||||
// QDir dir(path);
|
QDir dir(path);
|
||||||
// if (dir.exists()) {
|
if (dir.exists())
|
||||||
// return path;
|
{
|
||||||
// }
|
m_user_custom_elements_dir = path;
|
||||||
// }
|
return m_user_custom_elements_dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_user_custom_elements_dir = "default";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_user_custom_elements_dir != "default") {
|
||||||
|
return m_user_custom_elements_dir;
|
||||||
|
}
|
||||||
|
|
||||||
return(configDir() + "elements/");
|
return(configDir() + "elements/");
|
||||||
}
|
}
|
||||||
@@ -537,6 +557,17 @@ QString QETApp::customElementsDirN()
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QETApp::resetUserElementsDir
|
||||||
|
* Reset the path of the user common and custom elements dir.
|
||||||
|
* Use this function when the user path (common and/or custom) change.
|
||||||
|
*/
|
||||||
|
void QETApp::resetUserElementsDir()
|
||||||
|
{
|
||||||
|
m_user_common_elements_dir.clear();
|
||||||
|
m_user_custom_elements_dir.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return the path of the directory containing the common title block
|
@return the path of the directory containing the common title block
|
||||||
templates collection.
|
templates collection.
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ class QETApp : public QETSingleApplication
|
|||||||
static QString customElementsDir();
|
static QString customElementsDir();
|
||||||
static QString commonElementsDirN();
|
static QString commonElementsDirN();
|
||||||
static QString customElementsDirN();
|
static QString customElementsDirN();
|
||||||
|
static void resetUserElementsDir();
|
||||||
static QString commonTitleBlockTemplatesDir();
|
static QString commonTitleBlockTemplatesDir();
|
||||||
static QString customTitleBlockTemplatesDir();
|
static QString customTitleBlockTemplatesDir();
|
||||||
static bool registerProject(QETProject *);
|
static bool registerProject(QETProject *);
|
||||||
@@ -185,6 +186,8 @@ class QETApp : public QETSingleApplication
|
|||||||
static RecentFiles *m_projects_recent_files;
|
static RecentFiles *m_projects_recent_files;
|
||||||
static RecentFiles *m_elements_recent_files;
|
static RecentFiles *m_elements_recent_files;
|
||||||
static TitleBlockTemplate *default_titleblock_template_;
|
static TitleBlockTemplate *default_titleblock_template_;
|
||||||
|
static QString m_user_common_elements_dir;
|
||||||
|
static QString m_user_custom_elements_dir;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void systray(QSystemTrayIcon::ActivationReason);
|
void systray(QSystemTrayIcon::ActivationReason);
|
||||||
|
|||||||
@@ -80,11 +80,6 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
fillLang();
|
fillLang();
|
||||||
|
|
||||||
//@todo: fix me " Load time from elements is very slow " -> Disable dialog buttons for define the file system path of the common and custom elements
|
|
||||||
ui->m_common_elmt_path_cb ->setDisabled(true);
|
|
||||||
ui->m_custom_elmt_path_cb ->setDisabled(true);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneralConfigurationPage::~GeneralConfigurationPage()
|
GeneralConfigurationPage::~GeneralConfigurationPage()
|
||||||
@@ -121,6 +116,7 @@ void GeneralConfigurationPage::applyConf()
|
|||||||
settings.setValue("nomenclature/terminal-exportlist",ui->m_export_terminal->isChecked());
|
settings.setValue("nomenclature/terminal-exportlist",ui->m_export_terminal->isChecked());
|
||||||
settings.setValue("diagrameditor/autosave-interval", ui->m_autosave_sb->value());
|
settings.setValue("diagrameditor/autosave-interval", ui->m_autosave_sb->value());
|
||||||
|
|
||||||
|
QString path = settings.value("elements-collections/common-collection-path").toString();
|
||||||
if (ui->m_common_elmt_path_cb->currentIndex() == 1)
|
if (ui->m_common_elmt_path_cb->currentIndex() == 1)
|
||||||
{
|
{
|
||||||
QString path = ui->m_common_elmt_path_cb->currentText();
|
QString path = ui->m_common_elmt_path_cb->currentText();
|
||||||
@@ -131,7 +127,11 @@ void GeneralConfigurationPage::applyConf()
|
|||||||
else {
|
else {
|
||||||
settings.setValue("elements-collections/common-collection-path", "default");
|
settings.setValue("elements-collections/common-collection-path", "default");
|
||||||
}
|
}
|
||||||
|
if (path != settings.value("elements-collections/common-collection-path").toString()) {
|
||||||
|
QETApp::resetUserElementsDir();
|
||||||
|
}
|
||||||
|
|
||||||
|
path = settings.value("elements-collections/custom-collection-path").toString();
|
||||||
if (ui->m_custom_elmt_path_cb->currentIndex() == 1)
|
if (ui->m_custom_elmt_path_cb->currentIndex() == 1)
|
||||||
{
|
{
|
||||||
QString path = ui->m_custom_elmt_path_cb->currentText();
|
QString path = ui->m_custom_elmt_path_cb->currentText();
|
||||||
@@ -142,6 +142,9 @@ void GeneralConfigurationPage::applyConf()
|
|||||||
else {
|
else {
|
||||||
settings.setValue("elements-collections/custom-collection-path", "default");
|
settings.setValue("elements-collections/custom-collection-path", "default");
|
||||||
}
|
}
|
||||||
|
if (path != settings.value("elements-collections/custom-collection-path").toString()) {
|
||||||
|
QETApp::resetUserElementsDir();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user