When calling arg() on a QString constructed from a literal, use QStringLiteral.

This commit is contained in:
Mat Sutcliffe
2018-12-20 21:32:39 +00:00
parent ace7650ebe
commit 6c05c5249d
99 changed files with 227 additions and 291 deletions

View File

@@ -155,7 +155,7 @@ namespace BlackGui
m_currentDataSource = dataSource;
ui->le_modelString->setCompleter(new QCompleter(modelStrings, this));
ui->le_modelString->setPlaceholderText(QString("model strings (%1/%2)").arg(modelStrings.size()).arg(simInfo));
ui->le_modelString->setPlaceholderText(QStringLiteral("model strings (%1/%2)").arg(modelStrings.size()).arg(simInfo));
}
void CAircraftModelStringCompleter::onTextChanged()

View File

@@ -430,8 +430,7 @@ namespace BlackGui
}
else
{
static const QString item("swift %1 (%2)");
ui->cb_OtherVersions->addItem(item.arg(info.getVersionString(), info.getPlatform()));
ui->cb_OtherVersions->addItem(QStringLiteral("swift %1 (%2)").arg(info.getVersionString(), info.getPlatform()));
}
m_otherVersionDirs.push_back(pair.first);
}

View File

@@ -86,7 +86,7 @@ namespace BlackGui
if (this->readDataFile(thisVersionModelSetFile, otherSet, otherVersion, simulator) && !otherSet.isEmpty())
{
CApplication::processEventsFor(250);
if (this->confirmOverride(QString("Override model set for '%1'").arg(simulator.toQString())))
if (this->confirmOverride(QStringLiteral("Override model set for '%1'").arg(simulator.toQString())))
{
m_modelSetCaches.setModelsForSimulator(otherSet, simulator);
}
@@ -105,7 +105,7 @@ namespace BlackGui
if (this->readDataFile(thisVersionModelCacheFile, otherCache, otherVersion, simulator) && !otherCache.isEmpty())
{
CApplication::processEventsFor(250);
if (this->confirmOverride(QString("Override model cache for '%1'").arg(simulator.toQString())))
if (this->confirmOverride(QStringLiteral("Override model cache for '%1'").arg(simulator.toQString())))
{
m_modelCaches.setModelsForSimulator(otherCache, simulator);
}
@@ -136,8 +136,7 @@ namespace BlackGui
const QFileInfo fiOtherModelFile(otherModelFile);
if (!fiOtherModelFile.exists())
{
static const QString noSet("No models here: '%1'");
ui->le_Status->setText(noSet.arg(fiOtherModelFile.absoluteFilePath()));
ui->le_Status->setText(QStringLiteral("No models here: '%1'").arg(fiOtherModelFile.absoluteFilePath()));
return false;
}
@@ -148,18 +147,15 @@ namespace BlackGui
{
models = CAircraftModelList::fromMultipleJsonFormats(jsonString);
ui->tvp_AircraftModels->updateContainerAsync(models);
static const QString importSet("Imported models: '%1'");
ui->le_Status->setText(importSet.arg(fiOtherModelFile.absoluteFilePath()));
ui->le_Status->setText(QStringLiteral("Imported models: '%1'").arg(fiOtherModelFile.absoluteFilePath()));
}
catch (const CJsonException &ex)
{
static const QString m("JSON format error. '%1'");
this->showOverlayMessage(ex.toStatusMessage(this, m.arg(fiOtherModelFile.absoluteFilePath())));
this->showOverlayMessage(ex.toStatusMessage(this, QStringLiteral("JSON format error. '%1'").arg(fiOtherModelFile.absoluteFilePath())));
return false;
}
static const QString importSet("Imported %1 models '%2' for %3");
ui->le_Status->setText(importSet.arg(models.size()).arg(fiOtherModelFile.fileName(), sim.toQString()));
ui->le_Status->setText(QStringLiteral("Imported %1 models '%2' for %3").arg(models.size()).arg(fiOtherModelFile.fileName(), sim.toQString()));
return true;
}

View File

@@ -469,9 +469,7 @@ namespace BlackGui
QString CCopySettingsAndCachesComponent::checkBoxText(const QString &text, bool setting)
{
static const QString s("%1 [setting]");
static const QString c("%1 [cache]");
return setting ? s.arg(text) : c.arg(text);
return setting ? QStringLiteral("%1 [setting]").arg(text) : QStringLiteral("%1 [cache]").arg(text);
}
void CCopySettingsAndCachesWizardPage::initializePage()

View File

@@ -50,7 +50,7 @@ namespace BlackGui
{
// this removes previously stashed models
this->getMappingComponent()->replaceStashedModelsUnvalidated(m_modelsToStash);
const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QString("Stashed %1 models").arg(m_modelsToStash.size()));
const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QStringLiteral("Stashed %1 models").arg(m_modelsToStash.size()));
this->addStatusMessage(stashedMsg);
m_modelsToStash.clear();
}

View File

@@ -89,7 +89,7 @@ namespace BlackGui
{
this->currentModelView()->removeModelsWithModelString(m_modelsToStash);
}
const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QString("Auto stashed %1 models").arg(m_modelsToStash.size()));
const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QStringLiteral("Auto stashed %1 models").arg(m_modelsToStash.size()));
this->addStatusMessage(stashedMsg);
m_modelsToStash.clear();
}
@@ -285,7 +285,7 @@ namespace BlackGui
this->updateProgressIndicator(100);
sGui->processEventsToRefreshGui();
const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QString("Ready to auto stash %1 models").arg(autoStashed.size()));
const CStatusMessage stashedMsg(this, CStatusMessage::SeverityInfo, QStringLiteral("Ready to auto stash %1 models").arg(autoStashed.size()));
this->addStatusMessage(stashedMsg);
m_modelsToStash = autoStashed;
m_state = Completed;

View File

@@ -232,8 +232,7 @@ namespace BlackGui
QString CDbOwnModelsComponent::directorySelector(const CSimulatorInfo &simulatorInfo)
{
QString dir = m_directorySettings.get().getLastModelDirectoryOrDefault();
const QString text("Open directory (%1)");
dir = QFileDialog::getExistingDirectory(this, text.arg(simulatorInfo.toQString()), dir,
dir = QFileDialog::getExistingDirectory(this, QStringLiteral("Open directory (%1)").arg(simulatorInfo.toQString()), dir,
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
const QDir d(dir);
if (d.exists())

View File

@@ -267,9 +267,8 @@ namespace BlackGui
ui->pb_SaveAsSetForSimulator->setEnabled(canSave);
if (canSave)
{
static const QString ss("save %1");
this->setSaveFileName(this->getModelSetSimulator());
ui->pb_SaveAsSetForSimulator->setText(ss.arg(this->getModelSetSimulator().toQString(true)));
ui->pb_SaveAsSetForSimulator->setText(QStringLiteral("save %1").arg(this->getModelSetSimulator().toQString(true)));
}
else
{

View File

@@ -283,7 +283,7 @@ namespace BlackGui
if (validModels.size() > MaxModelPublished)
{
validModels.truncate(MaxModelPublished);
msgs.push_back(CStatusMessage(validationCategories(), CStatusMessage::SeverityWarning, QString("More than %1 values, values skipped").arg(MaxModelPublished)));
msgs.push_back(CStatusMessage(validationCategories(), CStatusMessage::SeverityWarning, QStringLiteral("More than %1 values, values skipped").arg(MaxModelPublished)));
}
msgs.push_back(sGui->getWebDataServices()->asyncPublishModels(validModels));
@@ -340,7 +340,7 @@ namespace BlackGui
{
return CStatusMessageList(
{
CStatusMessage(validationCategories(), CStatusMessage::SeverityInfo, QString("No errors in %1 model(s)").arg(models.size()))
CStatusMessage(validationCategories(), CStatusMessage::SeverityInfo, QStringLiteral("No errors in %1 model(s)").arg(models.size()))
});
}
else

View File

@@ -303,10 +303,9 @@ namespace BlackGui
void CDownloadComponent::showStartedFileMessage(const CRemoteFile &rf)
{
static const QString of("%1/%2");
const int current = m_remoteFiles.size() - m_waitingForDownload.size();
ui->le_Started->setText(rf.getName());
ui->le_StartedNumber->setText(of.arg(current).arg(m_remoteFiles.size()));
ui->le_StartedNumber->setText(QStringLiteral("%1/%2").arg(current).arg(m_remoteFiles.size()));
ui->le_StartedUrl->setText(rf.getUrl().getFullUrl());
ui->prb_Total->setMaximum(m_remoteFiles.size());
ui->prb_Total->setValue(current - 1);
@@ -314,10 +313,9 @@ namespace BlackGui
void CDownloadComponent::showCompletedFileMessage(const CRemoteFile &rf)
{
static const QString of("%1/%2");
const int current = m_remoteFiles.size() - m_waitingForDownload.size();
ui->le_Completed->setText(rf.getName());
ui->le_CompletedNumber->setText(of.arg(current).arg(m_remoteFiles.size()));
ui->le_CompletedNumber->setText(QStringLiteral("%1/%2").arg(current).arg(m_remoteFiles.size()));
ui->le_CompletedUrl->setText(rf.getUrl().getFullUrl());
ui->prb_Total->setMaximum(m_remoteFiles.size());
ui->prb_Total->setValue(current);
@@ -336,8 +334,7 @@ namespace BlackGui
void CDownloadComponent::showFileInfo()
{
static const QString info("Files: %1 size: %2");
ui->le_Info->setText(info.arg(m_remoteFiles.size()).arg(m_remoteFiles.getTotalFileSizeHumanReadable()));
ui->le_Info->setText(QStringLiteral("Files: %1 size: %2").arg(m_remoteFiles.size()).arg(m_remoteFiles.getTotalFileSizeHumanReadable()));
}
} // ns
} // ns

View File

@@ -232,7 +232,7 @@ namespace BlackGui
ui->led_MapperReady->setOn(on);
if (on)
{
const QString m = QString("Mapper with %1 models").arg(models);
const QString m = QStringLiteral("Mapper with %1 models").arg(models);
ui->led_MapperReady->setToolTip(m);
}
}

View File

@@ -189,9 +189,8 @@ namespace BlackGui
void CInterpolationLogDisplay::onSliderChanged(int timeSecs)
{
static const QString time("%1secs");
m_updateTimer.setInterval(timeSecs * 1000);
ui->le_UpdateTime->setText(time.arg(timeSecs));
ui->le_UpdateTime->setText(QStringLiteral("%1secs").arg(timeSecs));
}
void CInterpolationLogDisplay::onCallsignEntered()

View File

@@ -311,8 +311,7 @@ namespace BlackGui
if (msg.isSuccess())
{
Q_ASSERT_X(currentServer.isValidForLogin(), Q_FUNC_INFO, "invalid server");
static const QString extraInfo("[%1]");
sGui->setExtraWindowTitle(extraInfo.arg(ownAircraft.getCallsignAsString()));
sGui->setExtraWindowTitle(QStringLiteral("[%1]").arg(ownAircraft.getCallsignAsString()));
sGui->crashAndLogInfoUserName(currentServer.getUser().getRealNameAndId());
sGui->crashAndLogInfoFlightNetwork(currentServer.getEcosystem().toQString(true));
sGui->crashAndLogAppendInfo(currentServer.getServerSessionId());
@@ -770,8 +769,7 @@ namespace BlackGui
color = warning;
}
}
static const QString sheet("background-color: %1;");
ui->le_SimulatorModel->setStyleSheet(sheet.arg(color));
ui->le_SimulatorModel->setStyleSheet(QStringLiteral("background-color: %1;").arg(color));
}
bool CLoginComponent::isVatsimNetworkTabSelected() const

View File

@@ -236,8 +236,7 @@ namespace BlackGui
QString CRawFsdMessagesComponent::rawFsdMessageToString(const CRawFsdMessage &rawFsdMessage)
{
static const QString s("%1 %2");
return s.arg(rawFsdMessage.getFormattedUtcTimestampHmsz(), rawFsdMessage.getRawMessage());
return QStringLiteral("%1 %2").arg(rawFsdMessage.getFormattedUtcTimestampHmsz(), rawFsdMessage.getRawMessage());
}
}
} // namespace

View File

@@ -35,10 +35,9 @@ namespace BlackGui
ui->hs_Factor->setMaximum(max);
ui->le_Factor->setValidator(new QIntValidator(min, max, ui->le_Factor));
static const QString info("%1-%2");
ui->le_Factor->setToolTip(info.arg(min).arg(max));
ui->le_Factor->setPlaceholderText(info.arg(min).arg(max));
ui->hs_Factor->setToolTip(info.arg(min, max));
ui->le_Factor->setToolTip(QStringLiteral("%1-%2").arg(min).arg(max));
ui->le_Factor->setPlaceholderText(QStringLiteral("%1-%2").arg(min).arg(max));
ui->hs_Factor->setToolTip(QStringLiteral("%1-%2").arg(min, max));
const int v = (min + max) / 2;
ui->hs_Factor->setValue(v);

View File

@@ -145,7 +145,7 @@ namespace BlackGui
if (!conflicts.isEmpty())
{
QString message = QString("The selected combination conflicts with the following %1 combination(s):\n\n").arg(conflicts.size());
QString message = QStringLiteral("The selected combination conflicts with the following %1 combination(s):\n\n").arg(conflicts.size());
for (const CActionHotkey &conflict : conflicts)
{
message += conflict.toQString();

View File

@@ -183,7 +183,7 @@ namespace BlackGui
void CSetupLoadingDialog::displayOtherVersionsInfo()
{
const int other = CDirectoryUtils::applicationDataDirectoriesCount() - 1 ;
ui->le_OtherSwiftVersions->setText(QString("There is/are %1 other swift version(s) installed").arg(other));
ui->le_OtherSwiftVersions->setText(QStringLiteral("There is/are %1 other swift version(s) installed").arg(other));
ui->pb_CopyFromSwift->setEnabled(other > 0);
}

View File

@@ -22,7 +22,7 @@ namespace BlackGui
QString CTransponderCodeSpinBox::textFromValue(int value) const
{
/* 4 - number of digits, 10 - base of number, '0' - pad character*/
return QString("%1").arg(value, 4 , 10, QChar('0'));
return QStringLiteral("%1").arg(value, 4 , 10, QChar('0'));
}
} // ns
} // ns

View File

@@ -41,8 +41,8 @@ namespace BlackGui
const QMessageBox::StandardButton reply =
QMessageBox::question(parent, "Copy XSwiftBus",
QString("Copy XSwiftBus from build directory '%1' to plugin directory '%2'?").arg(CDirectoryUtils::getXSwiftBusBuildDirectory(), CXPlaneUtil::xswiftbusPluginDir(xplaneRootDir)),
QMessageBox::Yes | QMessageBox::No);
QStringLiteral("Copy XSwiftBus from build directory '%1' to plugin directory '%2'?").arg(CDirectoryUtils::getXSwiftBusBuildDirectory(), CXPlaneUtil::xswiftbusPluginDir(xplaneRootDir)),
QMessageBox::Yes | QMessageBox::No);
if (reply != QMessageBox::Yes) { return 0; }
return CXPlaneUtil::copyXSwiftBusBuildFiles(xplaneRootDir);
} // ns

View File

@@ -982,10 +982,9 @@ namespace BlackGui
QString CGuiApplication::getFontInfo() const
{
static const QString info("Family: '%1', average width: %2");
const QWidget *w = this->mainApplicationWidget();
if (!w) { return QStringLiteral("Font info not available"); }
return info.
return QStringLiteral("Family: '%1', average width: %2").
arg(w->font().family()).
arg(w->fontMetrics().averageCharWidth());
}

View File

@@ -414,8 +414,7 @@ namespace BlackGui
QString CGuiUtility::marginsToString(const QMargins &margins)
{
const QString s("%1:%2:%3:%4");
return s.arg(margins.left()).arg(margins.top()).arg(margins.right()).arg(margins.bottom());
return QStringLiteral("%1:%2:%3:%4").arg(margins.left()).arg(margins.top()).arg(margins.right()).arg(margins.bottom());
}
QMargins CGuiUtility::stringToMargins(const QString &str)
@@ -580,8 +579,8 @@ namespace BlackGui
{
// const QSize sd = QApplication::desktop()->screenGeometry().size();
const QSize sd = QApplication::desktop()->screenGeometry(mainWidget).size();
desktop = QString("Desktop w%1 w%2").arg(sd.width()).arg(sd.height());
ratio = QString("ratio: %1").arg(mainWidget->devicePixelRatioF());
desktop = QStringLiteral("Desktop w%1 w%2").arg(sd.width()).arg(sd.height());
ratio = QStringLiteral("ratio: %1").arg(mainWidget->devicePixelRatioF());
}
return s.
arg(desktop).
@@ -620,11 +619,8 @@ namespace BlackGui
if (!icon.hasFileResourcePath()) return {};
const QString p = icon.getFileResourcePath();
static const QString htmlNoWidth("<img src=\"%1\">");
static const QString htmlWidth("<img src=\"%1\" width=%2>");
if (width < 0) { return htmlNoWidth.arg(p); }
return htmlWidth.arg(p, QString::number(width));
if (width < 0) { return QStringLiteral("<img src=\"%1\">").arg(p); }
return QStringLiteral("<img src=\"%1\" width=%2>").arg(p, QString::number(width));
}
QString CGuiUtility::asSimpleHtmlImageHeight(const CIcon &icon, int height)
@@ -633,7 +629,6 @@ namespace BlackGui
if (!icon.hasFileResourcePath()) return {};
const QString p = icon.getFileResourcePath();
static const QString htmlHeight("<img src=\"%1\" height=%2>");
return htmlHeight.arg(p, QString::number(height));
return QStringLiteral("<img src=\"%1\" height=%2>").arg(p, QString::number(height));
}
} // ns

View File

@@ -87,7 +87,7 @@ namespace BlackGui
{
menu->addAction(CIcons::dockTop16(), "Dock all", this, &CInfoArea::dockAllWidgets);
menu->addAction(CIcons::floatAll16(), "Float all", this, &CInfoArea::floatAllWidgets);
menu->addAction(CIcons::floatOne16(), QString("Dock / float '%1'").arg(this->windowTitle()), this, &CInfoArea::toggleFloatingWholeInfoArea);
menu->addAction(CIcons::floatOne16(), QStringLiteral("Dock / float '%1'").arg(this->windowTitle()), this, &CInfoArea::toggleFloatingWholeInfoArea);
QAction *lockTabBarMenuAction = new QAction(menu);
lockTabBarMenuAction->setObjectName(this->objectName().append("LockTabBar"));
lockTabBarMenuAction->setIconText("Lock tab bar");
@@ -217,8 +217,7 @@ namespace BlackGui
action->setObjectName(this->objectName().append(":getInfoAreaSelectActions:").append(wt));
if (withShortcut && i < keys.length())
{
static const QString ks("Ctrl+%1"); // Qt::CTRL
action->setShortcut(QKeySequence(ks.arg(keys.at(i))));
action->setShortcut(QKeySequence(QStringLiteral("Ctrl+%1").arg(keys.at(i))));
}
connect(action, &QAction::triggered, this, &CInfoArea::selectAreaByAction);

View File

@@ -268,8 +268,7 @@ namespace BlackGui
{
if (dataCVariant.canConvert<QString>()) { return dataCVariant; }
if (!dataCVariant.isValid()) { static const CVariant iv("invalid"); return iv; }
static const QString s("Invalid type: '%1'");
return CVariant::from(s.arg(dataCVariant.typeName()));
return CVariant::from(QStringLiteral("Invalid type: '%1'").arg(dataCVariant.typeName()));
}
Qt::ItemFlags CDelegateFormatter::flags(Qt::ItemFlags flags, bool editable) const

View File

@@ -48,8 +48,7 @@ namespace BlackGui
QString CGeneralGuiSettings::convertToQString(bool i18n) const
{
Q_UNUSED(i18n);
static const QString s("Widget style: %1");
return s.arg(this->m_widgetStyle);
return QStringLiteral("Widget style: %1").arg(this->m_widgetStyle);
}
BlackMisc::CVariant CGeneralGuiSettings::propertyByIndex(const BlackMisc::CPropertyIndex &index) const

View File

@@ -65,8 +65,7 @@ namespace BlackGui
QString CTextMessageSettings::convertToQString(bool i18n) const
{
Q_UNUSED(i18n);
static const QString s("Private: %1 supervisor: %2 frequency: %3 all: %4");
return s.arg(
return QStringLiteral("Private: %1 supervisor: %2 frequency: %3 all: %4").arg(
boolToOnOff(this->getPopupPrivateMessages()),
boolToOnOff(this->getPopupSupervisorMessages()),
boolToOnOff(this->getPopupFrequencyMessages()),

View File

@@ -103,7 +103,6 @@ namespace BlackGui
const QString CShortcut::toParenthesisString(const QKeySequence &sequence)
{
static const QString s("(%1)");
return s.arg(sequence.toString());
return QStringLiteral("(%1)").arg(sequence.toString());
}
} // ns

View File

@@ -116,7 +116,7 @@ namespace BlackGui
const QFont f = widget->font();
return CStyleSheetUtility::asStylesheet(
f.family(),
QString("%1pt").arg(pointSize < 0 ? f.pointSize() : pointSize),
QStringLiteral("%1pt").arg(pointSize < 0 ? f.pointSize() : pointSize),
CStyleSheetUtility::fontStyleAsString(f),
CStyleSheetUtility::fontWeightAsString(f)
);

View File

@@ -790,7 +790,7 @@ namespace BlackGui
if (dockWidget)
{
if (!menu.isEmpty()) { menu.addSeparator(); }
const QString mm = QString("Dock widget '%1'").arg(dockWidget->windowTitleOrBackup());
const QString mm = QStringLiteral("Dock widget '%1'").arg(dockWidget->windowTitleOrBackup());
QMenu *dockWidgetSubMenu = menu.addMenu(CIcons::text16(), mm);
dockWidget->addToContextMenu(dockWidgetSubMenu);
}