mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
small refactoring
* change `writeFormatters` method to more intuitive `removeUnusedFormatters` * use class property as filename
This commit is contained in:
parent
ee6cf60aa4
commit
877f58784b
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
QHash<QString, QString> getFormatters() const;
|
||||
QList<AbstractExtItem *> items() const;
|
||||
QStringList knownFormatters() const;
|
||||
bool writeFormatters(const QStringList keys) const;
|
||||
bool removeUnusedFormatters(const QStringList keys) const;
|
||||
bool writeFormatters(const QHash<QString, QString> configuration) const;
|
||||
|
||||
public slots:
|
||||
@ -58,6 +58,7 @@ private:
|
||||
void initItems();
|
||||
// properties
|
||||
QStringList m_directories;
|
||||
QString m_filePath;
|
||||
QHash<QString, AWAbstractFormatter *> m_formatters;
|
||||
QHash<QString, AWAbstractFormatter *> m_formattersClasses;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user