Merge pull request #1612 from PolyMC/fix-qt-6-6-0-build
Fix build on Qt 6.6.0
This commit is contained in:
commit
c4d68b7ccf
@ -226,7 +226,9 @@ void TranslationsModel::indexReceived()
|
|||||||
reloadLocalFiles();
|
reloadLocalFiles();
|
||||||
|
|
||||||
auto language = d->m_system_locale;
|
auto language = d->m_system_locale;
|
||||||
if (!findLanguage(language))
|
auto languageIterator = findLanguage(language);
|
||||||
|
|
||||||
|
if (languageIterator == decltype(languageIterator){})
|
||||||
{
|
{
|
||||||
language = d->m_system_language;
|
language = d->m_system_language;
|
||||||
}
|
}
|
||||||
@ -488,7 +490,7 @@ int TranslationsModel::columnCount(const QModelIndex& parent) const
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
Language * TranslationsModel::findLanguage(const QString& key)
|
QVector<Language>::iterator TranslationsModel::findLanguage(const QString& key)
|
||||||
{
|
{
|
||||||
auto found = std::find_if(d->m_languages.begin(), d->m_languages.end(), [&](Language & lang)
|
auto found = std::find_if(d->m_languages.begin(), d->m_languages.end(), [&](Language & lang)
|
||||||
{
|
{
|
||||||
@ -496,7 +498,7 @@ Language * TranslationsModel::findLanguage(const QString& key)
|
|||||||
});
|
});
|
||||||
if(found == d->m_languages.end())
|
if(found == d->m_languages.end())
|
||||||
{
|
{
|
||||||
return nullptr;
|
return {};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -507,21 +509,21 @@ Language * TranslationsModel::findLanguage(const QString& key)
|
|||||||
bool TranslationsModel::selectLanguage(QString key)
|
bool TranslationsModel::selectLanguage(QString key)
|
||||||
{
|
{
|
||||||
QString &langCode = key;
|
QString &langCode = key;
|
||||||
auto langPtr = findLanguage(key);
|
auto langIterator = findLanguage(key);
|
||||||
|
|
||||||
if (langCode.isEmpty())
|
if (langCode.isEmpty())
|
||||||
{
|
{
|
||||||
d->no_language_set = true;
|
d->no_language_set = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!langPtr)
|
if (langIterator == decltype(langIterator){})
|
||||||
{
|
{
|
||||||
qWarning() << "Selected invalid language" << key << ", defaulting to" << defaultLangCode;
|
qWarning() << "Selected invalid language" << key << ", defaulting to" << defaultLangCode;
|
||||||
langCode = defaultLangCode;
|
langCode = defaultLangCode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
langCode = langPtr->key;
|
langCode = langIterator->key;
|
||||||
}
|
}
|
||||||
|
|
||||||
// uninstall existing translators if there are any
|
// uninstall existing translators if there are any
|
||||||
@ -573,7 +575,7 @@ bool TranslationsModel::selectLanguage(QString key)
|
|||||||
d->m_qt_translator.reset();
|
d->m_qt_translator.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(langPtr->localFileType == FileType::PO)
|
if(langIterator->localFileType == FileType::PO)
|
||||||
{
|
{
|
||||||
qDebug() << "Loading Application Language File for" << langCode.toLocal8Bit().constData() << "...";
|
qDebug() << "Loading Application Language File for" << langCode.toLocal8Bit().constData() << "...";
|
||||||
auto poTranslator = new POTranslator(FS::PathCombine(d->m_dir.path(), langCode + ".po"));
|
auto poTranslator = new POTranslator(FS::PathCombine(d->m_dir.path(), langCode + ".po"));
|
||||||
@ -596,7 +598,7 @@ bool TranslationsModel::selectLanguage(QString key)
|
|||||||
d->m_app_translator.reset();
|
d->m_app_translator.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(langPtr->localFileType == FileType::QM)
|
else if(langIterator->localFileType == FileType::QM)
|
||||||
{
|
{
|
||||||
d->m_app_translator.reset(new QTranslator());
|
d->m_app_translator.reset(new QTranslator());
|
||||||
if (d->m_app_translator->load("mmc_" + langCode, d->m_dir.path()))
|
if (d->m_app_translator->load("mmc_" + langCode, d->m_dir.path()))
|
||||||
@ -628,7 +630,7 @@ bool TranslationsModel::selectLanguage(QString key)
|
|||||||
QModelIndex TranslationsModel::selectedIndex()
|
QModelIndex TranslationsModel::selectedIndex()
|
||||||
{
|
{
|
||||||
auto found = findLanguage(d->m_selectedLanguage);
|
auto found = findLanguage(d->m_selectedLanguage);
|
||||||
if(found)
|
if(found != decltype(found){})
|
||||||
{
|
{
|
||||||
// QVector iterator freely converts to pointer to contained type
|
// QVector iterator freely converts to pointer to contained type
|
||||||
return index(found - d->m_languages.begin(), 0, QModelIndex());
|
return index(found - d->m_languages.begin(), 0, QModelIndex());
|
||||||
@ -666,7 +668,7 @@ void TranslationsModel::updateLanguage(QString key)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto found = findLanguage(key);
|
auto found = findLanguage(key);
|
||||||
if(!found)
|
if(found == decltype(found){})
|
||||||
{
|
{
|
||||||
qWarning() << "Cannot update invalid language" << key;
|
qWarning() << "Cannot update invalid language" << key;
|
||||||
return;
|
return;
|
||||||
@ -685,7 +687,7 @@ void TranslationsModel::downloadTranslation(QString key)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto lang = findLanguage(key);
|
auto lang = findLanguage(key);
|
||||||
if(!lang)
|
if(lang == decltype(lang){})
|
||||||
{
|
{
|
||||||
qWarning() << "Will not download an unknown translation" << key;
|
qWarning() << "Will not download an unknown translation" << key;
|
||||||
return;
|
return;
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
void downloadIndex();
|
void downloadIndex();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Language *findLanguage(const QString & key);
|
QVector<Language>::iterator findLanguage(const QString & key);
|
||||||
void reloadLocalFiles();
|
void reloadLocalFiles();
|
||||||
void downloadTranslation(QString key);
|
void downloadTranslation(QString key);
|
||||||
void downloadNext();
|
void downloadNext();
|
||||||
|
Loading…
Reference in New Issue
Block a user