mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +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:
|
case 1:
|
||||||
default:
|
default:
|
||||||
m_helper->writeFormatters(data);
|
m_helper->writeFormatters(data);
|
||||||
m_helper->writeFormatters(data.keys());
|
m_helper->removeUnusedFormatters(data.keys());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ AWFormatterHelper::AWFormatterHelper(QWidget *parent)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||||
|
|
||||||
|
m_filePath = QString("awesomewidgets/formatters/formatters.ini");
|
||||||
initItems();
|
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;
|
qCDebug(LOG_AW) << "Remove formatters" << keys;
|
||||||
|
|
||||||
QString fileName = QString("%1/awesomewidgets/formatters/formatters.ini")
|
QString fileName = QString("%1/%2")
|
||||||
.arg(QStandardPaths::writableLocation(
|
.arg(QStandardPaths::writableLocation(
|
||||||
QStandardPaths::GenericDataLocation));
|
QStandardPaths::GenericDataLocation))
|
||||||
|
.arg(m_filePath);
|
||||||
QSettings settings(fileName, QSettings::IniFormat);
|
QSettings settings(fileName, QSettings::IniFormat);
|
||||||
qCInfo(LOG_AW) << "Configuration file" << fileName;
|
qCInfo(LOG_AW) << "Configuration file" << fileName;
|
||||||
|
|
||||||
@ -122,9 +124,10 @@ bool AWFormatterHelper::writeFormatters(
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Write configuration" << configuration;
|
qCDebug(LOG_AW) << "Write configuration" << configuration;
|
||||||
|
|
||||||
QString fileName = QString("%1/awesomewidgets/formatters/formatters.ini")
|
QString fileName = QString("%1/%2")
|
||||||
.arg(QStandardPaths::writableLocation(
|
.arg(QStandardPaths::writableLocation(
|
||||||
QStandardPaths::GenericDataLocation));
|
QStandardPaths::GenericDataLocation))
|
||||||
|
.arg(m_filePath);
|
||||||
QSettings settings(fileName, QSettings::IniFormat);
|
QSettings settings(fileName, QSettings::IniFormat);
|
||||||
qCInfo(LOG_AW) << "Configuration file" << fileName;
|
qCInfo(LOG_AW) << "Configuration file" << fileName;
|
||||||
|
|
||||||
@ -227,8 +230,7 @@ void AWFormatterHelper::initKeys()
|
|||||||
m_formatters.clear();
|
m_formatters.clear();
|
||||||
|
|
||||||
QStringList configs = QStandardPaths::locateAll(
|
QStringList configs = QStandardPaths::locateAll(
|
||||||
QStandardPaths::GenericDataLocation,
|
QStandardPaths::GenericDataLocation, m_filePath);
|
||||||
QString("awesomewidgets/formatters/formatters.ini"));
|
|
||||||
|
|
||||||
for (auto fileName : configs) {
|
for (auto fileName : configs) {
|
||||||
QSettings settings(fileName, QSettings::IniFormat);
|
QSettings settings(fileName, QSettings::IniFormat);
|
||||||
|
@ -38,7 +38,7 @@ public:
|
|||||||
QHash<QString, QString> getFormatters() const;
|
QHash<QString, QString> getFormatters() const;
|
||||||
QList<AbstractExtItem *> items() const;
|
QList<AbstractExtItem *> items() const;
|
||||||
QStringList knownFormatters() const;
|
QStringList knownFormatters() const;
|
||||||
bool writeFormatters(const QStringList keys) const;
|
bool removeUnusedFormatters(const QStringList keys) const;
|
||||||
bool writeFormatters(const QHash<QString, QString> configuration) const;
|
bool writeFormatters(const QHash<QString, QString> configuration) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -58,6 +58,7 @@ private:
|
|||||||
void initItems();
|
void initItems();
|
||||||
// properties
|
// properties
|
||||||
QStringList m_directories;
|
QStringList m_directories;
|
||||||
|
QString m_filePath;
|
||||||
QHash<QString, AWAbstractFormatter *> m_formatters;
|
QHash<QString, AWAbstractFormatter *> m_formatters;
|
||||||
QHash<QString, AWAbstractFormatter *> m_formattersClasses;
|
QHash<QString, AWAbstractFormatter *> m_formattersClasses;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user