Skip to content

Commit

Permalink
refactor: add missing std::as_const
Browse files Browse the repository at this point in the history
  • Loading branch information
sithlord48 committed Aug 4, 2024
1 parent ba6a746 commit 976220e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/blackchocobo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void BlackChocobo::detectTranslations()
QMap<QString, QTranslator *> app_translations;
QDir dir (QStringLiteral("%1").arg(BCSettings::value(SETTINGS::LANGPATH).toString()));
QStringList langList = dir.entryList(nameFilter,QDir::Files, QDir::Name);
for (const QString &translation : langList) {
for (const QString &translation : std::as_const(langList)) {
QTranslator *translator = new QTranslator;
std::ignore = translator->load(translation, dir.absolutePath());
QString lang = translation.mid(13, 2);
Expand Down Expand Up @@ -335,7 +335,7 @@ void BlackChocobo::init_style()
ui->slideWorldX->setStyleSheet(QStringLiteral("::handle{image: url(:/icons/common/map-slide-up);}"));
if (style()->name() == "fusion") {
auto cboxes = findChildren<QComboBox*>(QString(), Qt::FindChildrenRecursively);
for (auto box : cboxes) {
for (auto box : std::as_const(cboxes)) {
box->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
box->setStyleSheet(QStringLiteral("QComboBox { combobox-popup: 0;}"));
}
Expand Down Expand Up @@ -717,7 +717,7 @@ void BlackChocobo::changeEvent(QEvent *e)
if (e->type() == QEvent::PaletteChange) {
QPalette palette = BCSettings::paletteForSetting();
QList<QWidget*> widgets = findChildren<QWidget *>(QString(), Qt::FindChildrenRecursively);
for (QWidget * widget : widgets)
for (QWidget * widget : std::as_const(widgets))
widget->setPalette(palette);
hexEditor->setAddressAreaColor(palette.alternateBase().color());
QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() << QStringLiteral(":/icons"));
Expand Down Expand Up @@ -1150,11 +1150,14 @@ void BlackChocobo::changeLanguage(const QVariant &data)
if(!m_translations.contains(data.toString()))
detectTranslations();

for(auto translation : m_translations.value(BCSettings::value(SETTINGS::LANG).toString()))
const auto translations = m_translations.value(BCSettings::value(SETTINGS::LANG).toString());
for(auto translation : std::as_const(translations))
QApplication::removeTranslator(translation);

BCSettings::setValue(SETTINGS::LANG, data);
for(auto translation : m_translations.value(data.toString()))

const auto translation_values = m_translations.value(data.toString());
for(auto translation : translation_values)
QApplication::installTranslator(translation);
}

Expand Down

0 comments on commit 976220e

Please sign in to comment.