diff --git a/sources/awesome-widget/plugin/awformatterconfig.cpp b/sources/awesome-widget/plugin/awformatterconfig.cpp index b7ab3ed..aa52bcb 100644 --- a/sources/awesome-widget/plugin/awformatterconfig.cpp +++ b/sources/awesome-widget/plugin/awformatterconfig.cpp @@ -140,7 +140,7 @@ void AWFormatterConfig::execDialog() case 1: default: m_helper->writeFormatters(data); - m_helper->writeFormatters(data.keys()); + m_helper->removeUnusedFormatters(data.keys()); break; } } diff --git a/sources/awesome-widget/plugin/awformatterhelper.cpp b/sources/awesome-widget/plugin/awformatterhelper.cpp index 6a8f7f7..147588c 100644 --- a/sources/awesome-widget/plugin/awformatterhelper.cpp +++ b/sources/awesome-widget/plugin/awformatterhelper.cpp @@ -37,6 +37,7 @@ AWFormatterHelper::AWFormatterHelper(QWidget *parent) { qCDebug(LOG_AW) << __PRETTY_FUNCTION__; + m_filePath = QString("awesomewidgets/formatters/formatters.ini"); initItems(); } @@ -92,13 +93,14 @@ QStringList AWFormatterHelper::knownFormatters() const } -bool AWFormatterHelper::writeFormatters(const QStringList keys) const +bool AWFormatterHelper::removeUnusedFormatters(const QStringList keys) const { qCDebug(LOG_AW) << "Remove formatters" << keys; - QString fileName = QString("%1/awesomewidgets/formatters/formatters.ini") + QString fileName = QString("%1/%2") .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericDataLocation)); + QStandardPaths::GenericDataLocation)) + .arg(m_filePath); QSettings settings(fileName, QSettings::IniFormat); qCInfo(LOG_AW) << "Configuration file" << fileName; @@ -122,9 +124,10 @@ bool AWFormatterHelper::writeFormatters( { qCDebug(LOG_AW) << "Write configuration" << configuration; - QString fileName = QString("%1/awesomewidgets/formatters/formatters.ini") + QString fileName = QString("%1/%2") .arg(QStandardPaths::writableLocation( - QStandardPaths::GenericDataLocation)); + QStandardPaths::GenericDataLocation)) + .arg(m_filePath); QSettings settings(fileName, QSettings::IniFormat); qCInfo(LOG_AW) << "Configuration file" << fileName; @@ -227,8 +230,7 @@ void AWFormatterHelper::initKeys() m_formatters.clear(); QStringList configs = QStandardPaths::locateAll( - QStandardPaths::GenericDataLocation, - QString("awesomewidgets/formatters/formatters.ini")); + QStandardPaths::GenericDataLocation, m_filePath); for (auto fileName : configs) { QSettings settings(fileName, QSettings::IniFormat); diff --git a/sources/awesome-widget/plugin/awformatterhelper.h b/sources/awesome-widget/plugin/awformatterhelper.h index 5ba16d6..42339d4 100644 --- a/sources/awesome-widget/plugin/awformatterhelper.h +++ b/sources/awesome-widget/plugin/awformatterhelper.h @@ -38,7 +38,7 @@ public: QHash getFormatters() const; QList items() const; QStringList knownFormatters() const; - bool writeFormatters(const QStringList keys) const; + bool removeUnusedFormatters(const QStringList keys) const; bool writeFormatters(const QHash configuration) const; public slots: @@ -58,6 +58,7 @@ private: void initItems(); // properties QStringList m_directories; + QString m_filePath; QHash m_formatters; QHash m_formattersClasses; };