diff --git a/src/options/opt_iconset.cpp b/src/options/opt_iconset.cpp
index 1f7935a52..e07d9e841 100644
--- a/src/options/opt_iconset.cpp
+++ b/src/options/opt_iconset.cpp
@@ -1451,17 +1451,16 @@ bool OptionsTabIconsetRoster::event(QEvent *e)
while (*it) {
QTreeWidgetItem *i = *it;
if (!i->data(0, ServiceRole).toString().isEmpty()) {
- Iconset *iss
- = PsiIconset::instance()->roster[PsiOptions::instance()
- ->getOption(PsiOptions::instance()->mapLookup(
- "options.iconsets.service-status",
- i->data(0, ServiceRole).toString())
- + ".iconset")
- .toString()];
- if (iss) {
- i->setText(1, iss->name());
- QFileInfo fi(iss->fileName());
- i->setData(0, IconsetRole, fi.fileName());
+ auto mapPath = PsiOptions::instance()->mapLookup("options.iconsets.service-status",
+ i->data(0, ServiceRole).toString());
+ if (mapPath.has_value()) {
+ Iconset *iss = PsiIconset::instance()->roster.value(
+ PsiOptions::instance()->getOption(*mapPath + ".iconset").toString());
+ if (iss) {
+ i->setText(1, iss->name());
+ QFileInfo fi(iss->fileName());
+ i->setData(0, IconsetRole, fi.fileName());
+ }
}
}
++it;
diff --git a/src/psi_profiles.cpp b/src/psi_profiles.cpp
index 47ee00f74..d4908e75b 100644
--- a/src/psi_profiles.cpp
+++ b/src/psi_profiles.cpp
@@ -240,7 +240,7 @@ void UserAccount::fromOptions(OptionsTree *o, QString base)
QVariantList states = o->mapKeyList(base + ".group-state");
for (const QVariant &k : states) {
GroupData gd;
- QString sbase = o->mapLookup(base + ".group-state", k);
+ QString sbase = *o->mapLookup(base + ".group-state", k);
gd.open = o->getOption(sbase + ".open").toBool();
gd.rank = o->getOption(sbase + ".rank").toInt();
groupState.insert(k.toString(), gd);
diff --git a/src/psiaccount.cpp b/src/psiaccount.cpp
index 73b7e4ea2..764616564 100644
--- a/src/psiaccount.cpp
+++ b/src/psiaccount.cpp
@@ -1314,10 +1314,10 @@ void PsiAccount::setEnabled(bool e)
return;
}
if (isActive()) {
- if (QMessageBox::information(nullptr, tr("Disable Account"),
- tr("The account is currently active.\nDo you want to log out ?"),
- QMessageBox::Yes, QMessageBox::No | QMessageBox::Default | QMessageBox::Escape,
- QMessageBox::NoButton)
+ if (QMessageBox::information(
+ nullptr, tr("Disable Account"), tr("The account is currently active.\nDo you want to log out ?"),
+ QMessageBox::Yes,
+ QMessageBox::No | QMessageBox::Default | QMessageBox::Escape | QMessageBox::NoButton)
== QMessageBox::Yes) {
logout(false, loggedOutStatus());
} else {
diff --git a/src/psicon.cpp b/src/psicon.cpp
index 638e353a7..ef4c153a8 100644
--- a/src/psicon.cpp
+++ b/src/psicon.cpp
@@ -1513,7 +1513,7 @@ void PsiCon::slotApplyOptions()
QMessageBox::warning(nullptr, tr("Warning"),
tr("You can not disable all toolbars and the menubar. If you do so, you "
"will be unable to enable them back, when you'll change your mind."),
- tr("I understand"));
+ QMessageBox::Ok);
o->setOption("options.ui.contactlist.show-menubar", true);
}
}
diff --git a/src/psiiconset.cpp b/src/psiiconset.cpp
index 2e52dd3d2..8f8d66414 100644
--- a/src/psiiconset.cpp
+++ b/src/psiiconset.cpp
@@ -407,7 +407,7 @@ bool PsiIconset::loadRoster()
const auto &services = PsiOptions::instance()->mapKeyList("options.iconsets.service-status");
for (const QVariant &service : services) {
QString val = PsiOptions::instance()
- ->getOption(PsiOptions::instance()->mapLookup("options.iconsets.service-status", service)
+ ->getOption(*PsiOptions::instance()->mapLookup("options.iconsets.service-status", service)
+ ".iconset")
.toString();
if (val.isEmpty())
@@ -630,20 +630,18 @@ void PsiIconset::loadStatusIconDefinitions()
find = false;
if (find) {
- item.iconset = PsiOptions::instance()
- ->getOption(PsiOptions::instance()->mapLookup("options.iconsets.service-status", service)
- + ".iconset")
- .toString();
- d->status_icons.list.append(item);
+ auto mapPath = PsiOptions::instance()->mapLookup("options.iconsets.service-status", service);
+ if (mapPath) {
+ item.iconset = PsiOptions::instance()->getOption(*mapPath + ".iconset").toString();
+ d->status_icons.list.append(item);
+ }
}
}
// default transport icon set
- if (PsiOptions::instance()->mapKeyList("options.iconsets.service-status").contains("transport")) {
+ auto trnasportMapOptionsPath = PsiOptions::instance()->mapLookup("options.iconsets.service-status", "transport");
+ if (trnasportMapOptionsPath) {
PsiIconset::Private::StatusIconsets::IconsetItem item;
- item.iconset = PsiOptions::instance()
- ->getOption(PsiOptions::instance()->mapLookup("options.iconsets.service-status", "transport")
- + ".iconset")
- .toString();
+ item.iconset = PsiOptions::instance()->getOption(*trnasportMapOptionsPath + ".iconset").toString();
d->status_icons.list.append(item);
}
// custom icon sets
@@ -730,7 +728,7 @@ void PsiIconset::reloadRoster()
const auto &services = PsiOptions::instance()->mapKeyList("options.iconsets.service-status");
for (const QVariant &service : services) {
QString val = PsiOptions::instance()
- ->getOption(PsiOptions::instance()->mapLookup("options.iconsets.service-status", service)
+ ->getOption(*PsiOptions::instance()->mapLookup("options.iconsets.service-status", service)
+ ".iconset")
.toString();
if (val.isEmpty())
@@ -897,7 +895,7 @@ PsiIcon *PsiIconset::transportStatusPtr(QString name, int s)
if (serviceicons.contains(name)) {
const Iconset *is = roster.value(
PsiOptions::instance()
- ->getOption(PsiOptions::instance()->mapLookup("options.iconsets.service-status", name) + ".iconset")
+ ->getOption(*PsiOptions::instance()->mapLookup("options.iconsets.service-status", name) + ".iconset")
.toString());
if (is) {
icon = const_cast(is->icon(status2name(s)));
diff --git a/src/statusdlg.cpp b/src/statusdlg.cpp
index d4c7db2f4..fdc6254c5 100644
--- a/src/statusdlg.cpp
+++ b/src/statusdlg.cpp
@@ -311,7 +311,7 @@ void StatusSetDlg::chooseStatusPreset(int x)
if (x < 1)
return;
- QString base = PsiOptions::instance()->mapLookup("options.status.presets", d->cb_preset->itemText(x));
+ QString base = *PsiOptions::instance()->mapLookup("options.status.presets", d->cb_preset->itemText(x));
d->te->setPlainText(PsiOptions::instance()->getOption(base + ".message").toString());
if (PsiOptions::instance()->getOption(base + ".force-priority").toBool()) {
d->le_priority->setText(QString::number(PsiOptions::instance()->getOption(base + ".priority").toInt()));
diff --git a/src/statusmenu.cpp b/src/statusmenu.cpp
index 959d02fde..190a24c9b 100644
--- a/src/statusmenu.cpp
+++ b/src/statusmenu.cpp
@@ -164,7 +164,7 @@ void StatusMenu::presetActivated()
QAction *action = static_cast(sender());
QString name = action->property("preset").toString();
PsiOptions *o = PsiOptions::instance();
- QString base = o->mapLookup("options.status.presets", name);
+ QString base = *o->mapLookup("options.status.presets", name);
XMPP::Status status;
status.setType(o->getOption(base + ".status").toString());
status.setStatus(o->getOption(base + ".message").toString());
diff --git a/src/statuspreset.cpp b/src/statuspreset.cpp
index 54a4a7341..a5510f684 100644
--- a/src/statuspreset.cpp
+++ b/src/statuspreset.cpp
@@ -146,11 +146,13 @@ void StatusPreset::toOptions(OptionsTree *o)
void StatusPreset::fromOptions(OptionsTree *o, QString name)
{
- QString path = o->mapLookup("options.status.presets", name);
- name_ = name;
- bool forcePriority = o->getOption(path + ".force-priority").toBool();
- message_ = o->getOption(path + ".message").toString();
- status_ = XMPP::Status::txt2type(o->getOption(path + ".status").toString());
- if (forcePriority)
- priority_ = o->getOption(path + ".priority").toInt();
+ auto path = o->mapLookup("options.status.presets", name);
+ if (path) {
+ name_ = name;
+ bool forcePriority = o->getOption(*path + ".force-priority").toBool();
+ message_ = o->getOption(*path + ".message").toString();
+ status_ = XMPP::Status::txt2type(o->getOption(*path + ".status").toString());
+ if (forcePriority)
+ priority_ = o->getOption(*path + ".priority").toInt();
+ }
}
diff --git a/src/tools/optionstree/optionstree.cpp b/src/tools/optionstree/optionstree.cpp
index 35764021c..2b282ce47 100644
--- a/src/tools/optionstree/optionstree.cpp
+++ b/src/tools/optionstree/optionstree.cpp
@@ -133,21 +133,24 @@ bool OptionsTree::isValidName(const QString &name)
return true;
}
-QString OptionsTree::mapLookup(const QString &basename, const QVariant &key) const
+std::optional OptionsTree::mapLookup(const QString &basename, const QVariant &key) const
{
QStringList children = getChildOptionNames(basename, true, true);
for (const QString &path : children) {
- if (getOption(path + ".key") == key) {
+ if (getOption(path + QLatin1String(".key")) == key) {
return path;
}
}
- qWarning("Accessing missing key '%s' in option map '%s'", qPrintable(key.toString()), qPrintable(basename));
- return basename + "XXX";
+ return {};
}
QVariant OptionsTree::mapGet(const QString &basename, const QVariant &key, const QString &node) const
{
- return getOption(mapLookup(basename, key) + '.' + node);
+ auto opt = mapLookup(basename, key);
+ if (opt) {
+ return getOption(*opt + QLatin1Char('.') + node);
+ }
+ return {};
}
QVariant OptionsTree::mapGet(const QString &basename, const QVariant &key, const QString &node,
@@ -155,7 +158,7 @@ QVariant OptionsTree::mapGet(const QString &basename, const QVariant &key, const
{
QVariantList keys = mapKeyList(basename);
if (keys.contains(key)) {
- return getOption(mapLookup(basename, key) + '.' + node);
+ return getOption(*mapLookup(basename, key) + '.' + node);
} else {
return def;
}
diff --git a/src/tools/optionstree/optionstree.h b/src/tools/optionstree/optionstree.h
index 42482942d..94aa4fb65 100644
--- a/src/tools/optionstree/optionstree.h
+++ b/src/tools/optionstree/optionstree.h
@@ -55,8 +55,8 @@ class OptionsTree : public QObject {
static bool isValidName(const QString &name);
// Map helpers
- QString mapLookup(const QString &basename, const QVariant &key) const;
- QString mapPut(const QString &basename, const QVariant &key);
+ std::optional mapLookup(const QString &basename, const QVariant &key) const;
+ QString mapPut(const QString &basename, const QVariant &key);
void mapPut(const QString &basename, const QVariant &key, const QString &node, const QVariant &value);
QVariant mapGet(const QString &basename, const QVariant &key, const QString &node) const;
QVariant mapGet(const QString &basename, const QVariant &key, const QString &node, const QVariant &def) const;
diff --git a/src/widgets/psirichtext.cpp b/src/widgets/psirichtext.cpp
index 226c0039f..a2ed669ef 100644
--- a/src/widgets/psirichtext.cpp
+++ b/src/widgets/psirichtext.cpp
@@ -117,7 +117,7 @@ QSizeF TextIconHandler::intrinsicSize(QTextDocument *doc, int posInDocument, con
QSizeF ret;
auto icon = IconsetFactory::iconPtr(iconName);
if (!icon) {
- qWarning("invalid icon: %s", qPrintable(iconName));
+ // qWarning("invalid icon: %s", qPrintable(iconName));
ret = QSizeF();
} else if (htmlSize > 0) {
auto pxSize = pointToPixel(htmlSize);