|
|
|
@ -144,37 +144,37 @@ void ConfigMgr::save() |
|
|
|
|
|
|
|
|
|
QString ConfigMgr::geometry(const QString& key) const |
|
|
|
|
{ |
|
|
|
|
const auto keystdstr = key.toStdString(); |
|
|
|
|
const auto& defaultValue = getDefault(defaultGeometry, keystdstr); |
|
|
|
|
return QString::fromStdString( ini.read("Geometry", keystdstr, defaultValue) ); |
|
|
|
|
return genericConfigGetter("Geometry", key, defaultGeometry); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString ConfigMgr::connection(const QString& key) const |
|
|
|
|
{ |
|
|
|
|
const auto keystdstr = key.toStdString(); |
|
|
|
|
const auto& defaultValue = getDefault(defaultConnection, keystdstr); |
|
|
|
|
return QString::fromStdString( ini.read("Connection", keystdstr, defaultValue) ); |
|
|
|
|
return genericConfigGetter("Connection", key, defaultConnection); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString ConfigMgr::common(const QString& key) const |
|
|
|
|
{ |
|
|
|
|
const auto keystdstr = key.toStdString(); |
|
|
|
|
const auto& defaultValue = getDefault(defaultCommon, keystdstr); |
|
|
|
|
return QString::fromStdString( ini.read("Common", keystdstr, defaultValue) ); |
|
|
|
|
return genericConfigGetter("Common", key, defaultCommon); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString ConfigMgr::color(const QString& key) const |
|
|
|
|
{ |
|
|
|
|
const auto keystdstr = key.toStdString(); |
|
|
|
|
const auto& defaultValue = getDefault(defaultColor, keystdstr); |
|
|
|
|
return QString::fromStdString( ini.read("Color", keystdstr, defaultValue) ); |
|
|
|
|
return genericConfigGetter("Color", key, defaultColor); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString ConfigMgr::window(const QString& key) const |
|
|
|
|
{ |
|
|
|
|
const auto keystdstr = key.toStdString(); |
|
|
|
|
const auto& defaultValue = getDefault(defaultColor, keystdstr); |
|
|
|
|
return QString::fromStdString( ini.read("Window", keystdstr, defaultValue) ); |
|
|
|
|
return genericConfigGetter("Window", key); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString ConfigMgr::logging(const QString& key) const |
|
|
|
|
{ |
|
|
|
|
return genericConfigGetter("Logging", key, defaultLogging); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString ConfigMgr::IRCv3(const QString& key) const |
|
|
|
|
{ |
|
|
|
|
return genericConfigGetter("IRCv3", key, defaultIRCv3); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::optional<QColor> ConfigMgr::prefixColor(const QChar& prefix) const |
|
|
|
@ -190,8 +190,8 @@ std::optional<QColor> ConfigMgr::prefixColor(const QChar& prefix) const |
|
|
|
|
QHash<QString, QString> ConfigMgr::color() const |
|
|
|
|
{ |
|
|
|
|
QHash<QString, QString> ret; |
|
|
|
|
const int sectSize = ini.count("Color"); |
|
|
|
|
for (int i = 0; i < sectSize; ++i) { |
|
|
|
|
const auto sectSize = ini.count("Color"); |
|
|
|
|
for (auto i = 0; i < sectSize; ++i) { |
|
|
|
|
const auto key = QString::fromStdString( ini.item("Color", i) ); |
|
|
|
|
const auto val = QString::fromStdString( ini.read("Color", i) ); |
|
|
|
|
ret.insert(key, val); |
|
|
|
@ -202,8 +202,8 @@ QHash<QString, QString> ConfigMgr::color() const |
|
|
|
|
QVector<std::pair<QChar, QColor> > ConfigMgr::prefixColor() const |
|
|
|
|
{ |
|
|
|
|
QVector<std::pair<QChar, QColor>> ret; |
|
|
|
|
const int sectSize = ini.count("PrefixColor"); |
|
|
|
|
for (int i = 0; i < sectSize; ++i) { |
|
|
|
|
const auto sectSize = ini.count("PrefixColor"); |
|
|
|
|
for (auto i = 0; i < sectSize; ++i) { |
|
|
|
|
const auto code = ini.item("PrefixColor", i); |
|
|
|
|
const auto first = std::stoi(code); |
|
|
|
|
const auto second = QString::fromStdString( ini.read("PrefixColor", i) ); |
|
|
|
@ -212,13 +212,6 @@ QVector<std::pair<QChar, QColor> > ConfigMgr::prefixColor() const |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString ConfigMgr::logging(const QString& key) const |
|
|
|
|
{ |
|
|
|
|
const auto keystdstr = key.toStdString(); |
|
|
|
|
const auto& defaultValue = getDefault(defaultLogging, keystdstr); |
|
|
|
|
return QString::fromStdString( ini.read("Logging", keystdstr, defaultValue) ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QStringList ConfigMgr::scripts() const |
|
|
|
|
{ |
|
|
|
|
QStringList ret; |
|
|
|
@ -230,14 +223,6 @@ QStringList ConfigMgr::scripts() const |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString ConfigMgr::IRCv3(const QString& key) const |
|
|
|
|
{ |
|
|
|
|
const auto keystdstr = key.toStdString(); |
|
|
|
|
const auto& defaultValue = getDefault(defaultIRCv3, keystdstr); |
|
|
|
|
return QString::fromStdString( ini.read("IRCv3", keystdstr, defaultValue) ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ConfigMgr::setGeometry(const QString& key, const QString& value) |
|
|
|
|
{ |
|
|
|
|
ini.write("Geometry", key.toStdString(), value.toStdString()); |
|
|
|
@ -263,6 +248,11 @@ void ConfigMgr::setLogging(const QString& key, const QString& value) |
|
|
|
|
ini.write("Logging", key.toStdString(), value.toStdString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ConfigMgr::setIRCv3(const QString& key, const QString& value) |
|
|
|
|
{ |
|
|
|
|
ini.write("IRCv3", key.toStdString(), value.toStdString()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ConfigMgr::setColorPalette(const QHash<QString, QString>& palette) |
|
|
|
|
{ |
|
|
|
|
QHashIterator<QString,QString> it(palette); |
|
|
|
@ -290,8 +280,8 @@ void ConfigMgr::addScript(const QString& path) |
|
|
|
|
* Find the highest available number and use that. |
|
|
|
|
*/ |
|
|
|
|
QStringList scripts; |
|
|
|
|
const int sectSize = ini.count("Scripts"); |
|
|
|
|
for (int i = 0; i < sectSize; ++i) { |
|
|
|
|
const auto sectSize = ini.count("Scripts"); |
|
|
|
|
for (auto i = 0; i < sectSize; ++i) { |
|
|
|
|
scripts << QString::fromStdString( ini.read("Scripts", i) ); |
|
|
|
|
} |
|
|
|
|
scripts << path; |
|
|
|
@ -308,8 +298,8 @@ void ConfigMgr::addScript(const QString& path) |
|
|
|
|
void ConfigMgr::delScript(const QString& path) |
|
|
|
|
{ |
|
|
|
|
std::string n; |
|
|
|
|
const int sectSize = ini.count("Scripts"); |
|
|
|
|
for (int i = 0; i < sectSize; ++i) { |
|
|
|
|
const auto sectSize = ini.count("Scripts"); |
|
|
|
|
for (auto i = 0; i < sectSize; ++i) { |
|
|
|
|
n = ini.item("Scripts", i); |
|
|
|
|
if (ini.read("Scripts", i) == path.toStdString()) |
|
|
|
|
break; |
|
|
|
@ -319,7 +309,17 @@ void ConfigMgr::delScript(const QString& path) |
|
|
|
|
ini.remove("Scripts", n); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ConfigMgr::setIRCv3(const QString& key, const QString& value) |
|
|
|
|
QString ConfigMgr::genericConfigGetter(const QString& section, const QString& key, const std::unordered_map<std::string,std::string>& defaults) const |
|
|
|
|
{ |
|
|
|
|
ini.write("IRCv3", key.toStdString(), value.toStdString()); |
|
|
|
|
const auto sectionstdstr = section.toStdString(); |
|
|
|
|
const auto keystdstr = key.toStdString(); |
|
|
|
|
const auto& defaultValue = getDefault(defaults, keystdstr); |
|
|
|
|
return QString::fromStdString( ini.read(sectionstdstr, keystdstr, defaultValue) ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QString ConfigMgr::genericConfigGetter(const QString& section, const QString& key) const |
|
|
|
|
{ |
|
|
|
|
const auto sectionstdstr = section.toStdString(); |
|
|
|
|
const auto keystdstr = key.toStdString(); |
|
|
|
|
return QString::fromStdString( ini.read(sectionstdstr, keystdstr) ); |
|
|
|
|
} |
|
|
|
|