mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-01 16:05:56 +00:00
add formatters configuration to ui
This commit is contained in:
@ -90,6 +90,31 @@ QStringList AWFormatterHelper::knownFormatters() const
|
||||
}
|
||||
|
||||
|
||||
bool AWFormatterHelper::writeFormatters(const QStringList keys) const
|
||||
{
|
||||
qCDebug(LOG_AW) << "Remove formatters" << keys;
|
||||
|
||||
QString fileName = QString("%1/awesomewidgets/formatters/formatters.ini")
|
||||
.arg(QStandardPaths::writableLocation(
|
||||
QStandardPaths::GenericDataLocation));
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
qCInfo(LOG_AW) << "Configuration file" << fileName;
|
||||
|
||||
settings.beginGroup(QString("Formatters"));
|
||||
QStringList foundKeys = settings.childKeys();
|
||||
for (auto key : foundKeys) {
|
||||
if (keys.contains(key))
|
||||
continue;
|
||||
settings.remove(key);
|
||||
}
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
|
||||
return (settings.status() == QSettings::NoError);
|
||||
}
|
||||
|
||||
|
||||
bool AWFormatterHelper::writeFormatters(
|
||||
const QHash<QString, QString> configuration) const
|
||||
{
|
||||
@ -112,6 +137,14 @@ bool AWFormatterHelper::writeFormatters(
|
||||
}
|
||||
|
||||
|
||||
void AWFormatterHelper::editItems()
|
||||
{
|
||||
repaintList();
|
||||
int ret = exec();
|
||||
qCInfo(LOG_AW) << "Dialog returns" << ret;
|
||||
}
|
||||
|
||||
|
||||
AWFormatterHelper::FormatterClass
|
||||
AWFormatterHelper::defineFormatterClass(const QString stringType) const
|
||||
{
|
||||
@ -193,9 +226,14 @@ void AWFormatterHelper::initKeys()
|
||||
QString name = settings.value(key).toString();
|
||||
qCInfo(LOG_AW) << "Found formatter" << name << "for key" << key
|
||||
<< "in" << settings.fileName();
|
||||
if (name.isEmpty()) {
|
||||
qCInfo(LOG_AW) << "Skip empty formatter for" << key;
|
||||
continue;
|
||||
}
|
||||
if (!m_formattersClasses.contains(name)) {
|
||||
qCWarning(LOG_AW) << "Invalid formatter" << name << "found in"
|
||||
<< key;
|
||||
continue;
|
||||
}
|
||||
m_formatters[key] = m_formattersClasses[name];
|
||||
}
|
||||
|
Reference in New Issue
Block a user