PIValueTreeEdit cut/copy/paste support
EMainWindow saveAs incorrect filename to recent fix QAD::loadTranslations now also look into standard translation location
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
#include <QLibraryInfo>
|
||||
#include <QTranslator>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
||||
# include <QStandardPaths>
|
||||
@@ -74,12 +75,22 @@ void QAD::loadTranslations(QString lang) {
|
||||
if (lang.isEmpty()) lang = QLocale().bcp47Name();
|
||||
QString short_lang = lang.left(2);
|
||||
QStringList dirs = resourcePaths("lang");
|
||||
QString std_dir = QDir::cleanPath(QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
bool has_std = false;
|
||||
for (const QString & d: dirs) {
|
||||
if (QDir::cleanPath(d) == std_dir) {
|
||||
has_std = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!has_std) dirs << std_dir;
|
||||
for (const QString & d: dirs) {
|
||||
QDirIterator dit(d);
|
||||
while (dit.hasNext()) {
|
||||
dit.next();
|
||||
if (!dit.filePath().endsWith(".qm")) continue;
|
||||
if (!dit.fileInfo().baseName().endsWith(lang) && !dit.fileInfo().baseName().endsWith(short_lang)) continue;
|
||||
if (dit.fileName() == QString("qt_%1.qm").arg(short_lang)) continue;
|
||||
QTranslator * tr = new QTranslator();
|
||||
if (tr->load(dit.filePath())) {
|
||||
qApp->installTranslator(tr);
|
||||
|
||||
Reference in New Issue
Block a user