forked from qt-creator/qt-creator
App/aggregation: Some modernization
Change-Id: I390e81122453d20a646af4a5bf08edf9de0d9db5 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -190,8 +190,7 @@ static inline int askMsgSendFailed()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// taken from utils/fileutils.cpp. We cannot use utils here since that depends app_version.h.
|
// taken from utils/fileutils.cpp. We cannot use utils here since that depends app_version.h.
|
||||||
static bool copyRecursively(const QString &srcFilePath,
|
static bool copyRecursively(const QString &srcFilePath, const QString &tgtFilePath)
|
||||||
const QString &tgtFilePath)
|
|
||||||
{
|
{
|
||||||
QFileInfo srcFileInfo(srcFilePath);
|
QFileInfo srcFileInfo(srcFilePath);
|
||||||
if (srcFileInfo.isDir()) {
|
if (srcFileInfo.isDir()) {
|
||||||
@@ -200,12 +199,11 @@ static bool copyRecursively(const QString &srcFilePath,
|
|||||||
if (!targetDir.mkdir(Utils::FilePath::fromString(tgtFilePath).fileName()))
|
if (!targetDir.mkdir(Utils::FilePath::fromString(tgtFilePath).fileName()))
|
||||||
return false;
|
return false;
|
||||||
QDir sourceDir(srcFilePath);
|
QDir sourceDir(srcFilePath);
|
||||||
QStringList fileNames = sourceDir.entryList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
|
const QStringList fileNames = sourceDir.entryList
|
||||||
foreach (const QString &fileName, fileNames) {
|
(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
|
||||||
const QString newSrcFilePath
|
for (const QString &fileName : fileNames) {
|
||||||
= srcFilePath + QLatin1Char('/') + fileName;
|
const QString newSrcFilePath = srcFilePath + '/' + fileName;
|
||||||
const QString newTgtFilePath
|
const QString newTgtFilePath = tgtFilePath + '/' + fileName;
|
||||||
= tgtFilePath + QLatin1Char('/') + fileName;
|
|
||||||
if (!copyRecursively(newSrcFilePath, newTgtFilePath))
|
if (!copyRecursively(newSrcFilePath, newTgtFilePath))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -300,8 +298,8 @@ static inline QSettings *userSettings()
|
|||||||
if (srcDir == destDir) // Nothing to copy and no settings yet
|
if (srcDir == destDir) // Nothing to copy and no settings yet
|
||||||
return settings;
|
return settings;
|
||||||
|
|
||||||
QStringList entries = srcDir.entryList();
|
const QStringList entries = srcDir.entryList();
|
||||||
foreach (const QString &file, entries) {
|
for (const QString &file : entries) {
|
||||||
const QString lowerFile = file.toLower();
|
const QString lowerFile = file.toLower();
|
||||||
if (lowerFile.startsWith(QLatin1String("profiles.xml"))
|
if (lowerFile.startsWith(QLatin1String("profiles.xml"))
|
||||||
|| lowerFile.startsWith(QLatin1String("toolchains.xml"))
|
|| lowerFile.startsWith(QLatin1String("toolchains.xml"))
|
||||||
@@ -349,7 +347,8 @@ void loadFonts()
|
|||||||
{
|
{
|
||||||
const QDir dir(resourcePath() + "/fonts/");
|
const QDir dir(resourcePath() + "/fonts/");
|
||||||
|
|
||||||
foreach (const QFileInfo &fileInfo, dir.entryInfoList(QStringList("*.ttf"), QDir::Files))
|
const QFileInfoList fonts = dir.entryInfoList(QStringList("*.ttf"), QDir::Files);
|
||||||
|
for (const QFileInfo &fileInfo : fonts)
|
||||||
QFontDatabase::addApplicationFont(fileInfo.absoluteFilePath());
|
QFontDatabase::addApplicationFont(fileInfo.absoluteFilePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -555,13 +554,12 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
QTranslator qtTranslator;
|
QTranslator qtTranslator;
|
||||||
QStringList uiLanguages;
|
QStringList uiLanguages = QLocale::system().uiLanguages();
|
||||||
uiLanguages = QLocale::system().uiLanguages();
|
|
||||||
QString overrideLanguage = settings->value(QLatin1String("General/OverrideLanguage")).toString();
|
QString overrideLanguage = settings->value(QLatin1String("General/OverrideLanguage")).toString();
|
||||||
if (!overrideLanguage.isEmpty())
|
if (!overrideLanguage.isEmpty())
|
||||||
uiLanguages.prepend(overrideLanguage);
|
uiLanguages.prepend(overrideLanguage);
|
||||||
const QString &creatorTrPath = resourcePath() + "/translations";
|
const QString &creatorTrPath = resourcePath() + "/translations";
|
||||||
foreach (QString locale, uiLanguages) {
|
for (QString locale : qAsConst(uiLanguages)) {
|
||||||
locale = QLocale(locale).name();
|
locale = QLocale(locale).name();
|
||||||
if (translator.load("qtcreator_" + locale, creatorTrPath)) {
|
if (translator.load("qtcreator_" + locale, creatorTrPath)) {
|
||||||
const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
const QString &qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
|
||||||
@@ -614,7 +612,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
const PluginSpecSet plugins = PluginManager::plugins();
|
const PluginSpecSet plugins = PluginManager::plugins();
|
||||||
PluginSpec *coreplugin = nullptr;
|
PluginSpec *coreplugin = nullptr;
|
||||||
foreach (PluginSpec *spec, plugins) {
|
for (PluginSpec *spec : plugins) {
|
||||||
if (spec->name() == QLatin1String(corePluginNameC)) {
|
if (spec->name() == QLatin1String(corePluginNameC)) {
|
||||||
coreplugin = spec;
|
coreplugin = spec;
|
||||||
break;
|
break;
|
||||||
|
@@ -207,7 +207,7 @@ Aggregate::~Aggregate()
|
|||||||
QList<QObject *> components;
|
QList<QObject *> components;
|
||||||
{
|
{
|
||||||
QWriteLocker locker(&lock());
|
QWriteLocker locker(&lock());
|
||||||
foreach (QObject *component, m_components) {
|
for (QObject *component : qAsConst(m_components)) {
|
||||||
disconnect(component, &QObject::destroyed, this, &Aggregate::deleteSelf);
|
disconnect(component, &QObject::destroyed, this, &Aggregate::deleteSelf);
|
||||||
aggregateMap().remove(component);
|
aggregateMap().remove(component);
|
||||||
}
|
}
|
||||||
|
@@ -48,7 +48,7 @@ public:
|
|||||||
|
|
||||||
template <typename T> T *component() {
|
template <typename T> T *component() {
|
||||||
QReadLocker locker(&lock());
|
QReadLocker locker(&lock());
|
||||||
foreach (QObject *component, m_components) {
|
for (QObject *component : qAsConst(m_components)) {
|
||||||
if (T *result = qobject_cast<T *>(component))
|
if (T *result = qobject_cast<T *>(component))
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ public:
|
|||||||
template <typename T> QList<T *> components() {
|
template <typename T> QList<T *> components() {
|
||||||
QReadLocker locker(&lock());
|
QReadLocker locker(&lock());
|
||||||
QList<T *> results;
|
QList<T *> results;
|
||||||
foreach (QObject *component, m_components) {
|
for (QObject *component : qAsConst(m_components)) {
|
||||||
if (T *result = qobject_cast<T *>(component)) {
|
if (T *result = qobject_cast<T *>(component)) {
|
||||||
results << result;
|
results << result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user