From 2ea853ba28e359fba7f98ba1286bc5c89a48105a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@qt.io> Date: Tue, 31 Jul 2018 12:48:24 +0200 Subject: [PATCH] Qt Designer: Fix clang-tidy warnings about Qt usage - Use multi-arg form of QString::arg() - Fix static method calls - Prefer QFileInfo::exists() - Use isEmpty() for containers instead of checking size() - Use QOverload Change-Id: I31e92f77d0fa377932c1369afe2503abc8ecceac Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> --- .../formeditor/formwindowmanager.cpp | 2 +- .../formeditor/qdesigner_resource.cpp | 5 +++-- .../components/lib/qdesigner_components.cpp | 4 ++-- .../propertyeditor/brushpropertymanager.cpp | 3 ++- .../designerpropertymanager.cpp | 5 +++-- .../propertyeditor/propertyeditor.cpp | 3 ++- .../signalsloteditor/connectdialog.cpp | 4 ++-- .../signalsloteditor/signalsloteditor.cpp | 2 +- src/designer/src/designer/main.cpp | 4 ++-- .../src/designer/qdesigner_actions.cpp | 4 ++-- .../designer/qdesigner_appearanceoptions.cpp | 4 +--- .../src/designer/qdesigner_formwindow.cpp | 2 +- .../src/designer/saveformastemplate.cpp | 6 ++++-- src/designer/src/lib/shared/codedialog.cpp | 6 ++++-- .../src/lib/shared/connectionedit.cpp | 4 ++-- src/designer/src/lib/shared/iconselector.cpp | 6 ++++-- .../lib/shared/qdesigner_propertycommand.cpp | 20 +++++++++++++------ .../lib/shared/qdesigner_propertysheet.cpp | 3 ++- .../src/lib/shared/qdesigner_stackedbox.cpp | 10 ++++++++-- .../src/lib/shared/qdesigner_utils.cpp | 12 ++++++++--- .../src/lib/shared/qdesigner_widgetbox.cpp | 6 +++--- .../src/lib/shared/qtresourceeditordialog.cpp | 13 +++++++++--- src/designer/src/lib/shared/widgetfactory.cpp | 8 +++++--- 23 files changed, 87 insertions(+), 49 deletions(-) diff --git a/src/designer/src/components/formeditor/formwindowmanager.cpp b/src/designer/src/components/formeditor/formwindowmanager.cpp index ecb348ade..410d9cad9 100644 --- a/src/designer/src/components/formeditor/formwindowmanager.cpp +++ b/src/designer/src/components/formeditor/formwindowmanager.cpp @@ -297,7 +297,7 @@ void FormWindowManager::removeFormWindow(QDesignerFormWindowInterface *w) setActiveFormWindow(0); // Make sure that widget box is enabled by default - if (m_formWindows.size() == 0 && m_core->widgetBox()) + if (m_formWindows.isEmpty() && m_core->widgetBox()) m_core->widgetBox()->setEnabled(true); } diff --git a/src/designer/src/components/formeditor/qdesigner_resource.cpp b/src/designer/src/components/formeditor/qdesigner_resource.cpp index e79f1897b..78882fdfa 100644 --- a/src/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/src/designer/src/components/formeditor/qdesigner_resource.cpp @@ -779,8 +779,9 @@ QWidget *QDesignerResource::create(DomUI *ui, QWidget *parentWidget) QWidget *QDesignerResource::create(DomWidget *ui_widget, QWidget *parentWidget) { const QString className = ui_widget->attributeClass(); - if (!m_isMainWidget && className == QStringLiteral("QWidget") && ui_widget->elementLayout().size() && - !ui_widget->hasAttributeNative()) { + if (!m_isMainWidget && className == QStringLiteral("QWidget") + && !ui_widget->elementLayout().isEmpty() + && !ui_widget->hasAttributeNative()) { // ### check if elementLayout.size() == 1 QDesignerContainerExtension *container = qt_extension<QDesignerContainerExtension*>(core()->extensionManager(), parentWidget); diff --git a/src/designer/src/components/lib/qdesigner_components.cpp b/src/designer/src/components/lib/qdesigner_components.cpp index 45724524e..a69bf8a66 100644 --- a/src/designer/src/components/lib/qdesigner_components.cpp +++ b/src/designer/src/components/lib/qdesigner_components.cpp @@ -186,14 +186,14 @@ QDesignerWidgetBoxInterface *QDesignerComponents::createWidgetBox(QDesignerFormE const QString userWidgetBoxFile = widgetBoxFileName(QT_VERSION, lang); widgetBox->setFileName(userWidgetBoxFile); - if (!QFileInfo(userWidgetBoxFile).exists()) { + if (!QFileInfo::exists(userWidgetBoxFile)) { // check previous version, that is, are we running the new version for the first time // If so, try to copy the old widget box file if (const int minv = qtMinorVersion(QT_VERSION)) { int oldVersion = QT_VERSION; setMinorVersion(minv - 1, &oldVersion); const QString oldWidgetBoxFile = widgetBoxFileName(oldVersion, lang); - if (QFileInfo(oldWidgetBoxFile).exists()) + if (QFileInfo::exists(oldWidgetBoxFile)) QFile::copy(oldWidgetBoxFile, userWidgetBoxFile); } } diff --git a/src/designer/src/components/propertyeditor/brushpropertymanager.cpp b/src/designer/src/components/propertyeditor/brushpropertymanager.cpp index 9adbfe612..895a6152c 100644 --- a/src/designer/src/components/propertyeditor/brushpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/brushpropertymanager.cpp @@ -265,7 +265,8 @@ bool BrushPropertyManager::valueText(const QtProperty *property, QString *text) return false; const QBrush &brush = brit.value(); const QString styleName = brushStyleIndexToString(brushStyleToIndex(brush.style())); - *text = QCoreApplication::translate("BrushPropertyManager", "[%1, %2]").arg(styleName).arg(QtPropertyBrowserUtils::colorValueText(brush.color())); + *text = QCoreApplication::translate("BrushPropertyManager", "[%1, %2]") + .arg(styleName, QtPropertyBrowserUtils::colorValueText(brush.color())); return true; } diff --git a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp index 193209b3a..0577709d6 100644 --- a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp @@ -767,7 +767,7 @@ void PixmapEditor::pasteActionActivated() QString text = clipboard->text(subtype); if (!text.isNull()) { QStringList list = text.split(QLatin1Char('\n')); - if (list.size() > 0) { + if (!list.isEmpty()) { text = list.at(0); if (m_iconThemeModeEnabled && QIcon::hasThemeIcon(text)) { setTheme(text); @@ -1531,7 +1531,8 @@ QString DesignerPropertyManager::valueText(const QtProperty *property) const } if (m_alignValues.contains(const_cast<QtProperty *>(property))) { const uint v = m_alignValues.value(const_cast<QtProperty *>(property)); - return tr("%1, %2").arg(indexHToString(alignToIndexH(v))).arg(indexVToString(alignToIndexV(v))); + return tr("%1, %2").arg(indexHToString(alignToIndexH(v)), + indexVToString(alignToIndexV(v))); } if (m_paletteValues.contains(const_cast<QtProperty *>(property))) { const PaletteData data = m_paletteValues.value(const_cast<QtProperty *>(property)); diff --git a/src/designer/src/components/propertyeditor/propertyeditor.cpp b/src/designer/src/components/propertyeditor/propertyeditor.cpp index ed1ae80c3..759e09eed 100644 --- a/src/designer/src/components/propertyeditor/propertyeditor.cpp +++ b/src/designer/src/components/propertyeditor/propertyeditor.cpp @@ -797,7 +797,8 @@ void PropertyEditor::updateToolBarLabel() classLabelText += className; m_classLabel->setText(classLabelText); - m_classLabel->setToolTip(tr("Object: %1\nClass: %2").arg(objectName).arg(className)); + m_classLabel->setToolTip(tr("Object: %1\nClass: %2") + .arg(objectName, className)); } void PropertyEditor::updateBrowserValue(QtVariantProperty *property, const QVariant &value) diff --git a/src/designer/src/components/signalsloteditor/connectdialog.cpp b/src/designer/src/components/signalsloteditor/connectdialog.cpp index c35ea9671..62d790c34 100644 --- a/src/designer/src/components/signalsloteditor/connectdialog.cpp +++ b/src/designer/src/components/signalsloteditor/connectdialog.cpp @@ -59,8 +59,8 @@ static QString realClassName(QDesignerFormEditorInterface *core, QWidget *widget static QString widgetLabel(QDesignerFormEditorInterface *core, QWidget *widget) { return QString::fromUtf8("%1 (%2)") - .arg(qdesigner_internal::realObjectName(core, widget)) - .arg(realClassName(core, widget)); + .arg(qdesigner_internal::realObjectName(core, widget), + realClassName(core, widget)); } namespace qdesigner_internal { diff --git a/src/designer/src/components/signalsloteditor/signalsloteditor.cpp b/src/designer/src/components/signalsloteditor/signalsloteditor.cpp index 7794e989a..cc0a7ad84 100644 --- a/src/designer/src/components/signalsloteditor/signalsloteditor.cpp +++ b/src/designer/src/components/signalsloteditor/signalsloteditor.cpp @@ -137,7 +137,7 @@ void SignalSlotConnection::updateVisibility() QString SignalSlotConnection::toString() const { return QCoreApplication::translate("SignalSlotConnection", "SENDER(%1), SIGNAL(%2), RECEIVER(%3), SLOT(%4)") - .arg(sender()).arg(signal()).arg(receiver()).arg(slot()); + .arg(sender(), signal(), receiver(), slot()); } SignalSlotConnection::State SignalSlotConnection::isValid(const QWidget *background) const diff --git a/src/designer/src/designer/main.cpp b/src/designer/src/designer/main.cpp index 54667c689..e5e31ca16 100644 --- a/src/designer/src/designer/main.cpp +++ b/src/designer/src/designer/main.cpp @@ -53,7 +53,7 @@ int main(int argc, char *argv[]) case QDesigner::ParseArgumentsHelpRequested: return 0; } - app.setQuitOnLastWindowClosed(false); + QGuiApplication::setQuitOnLastWindowClosed(false); - return app.exec(); + return QApplication::exec(); } diff --git a/src/designer/src/designer/qdesigner_actions.cpp b/src/designer/src/designer/qdesigner_actions.cpp index 9db4b0b98..60c8ffb4b 100644 --- a/src/designer/src/designer/qdesigner_actions.cpp +++ b/src/designer/src/designer/qdesigner_actions.cpp @@ -863,7 +863,7 @@ bool QDesignerActions::writeOutForm(QDesignerFormWindowInterface *fw, const QStr box.setInformativeText(tr("The file %1 could not be opened." "\nReason: %2" "\nWould you like to retry or select a different file?") - .arg(f.fileName()).arg(f.errorString())); + .arg(f.fileName(), f.errorString())); QPushButton *retryButton = box.addButton(QMessageBox::Retry); retryButton->setDefault(true); QPushButton *switchButton = box.addButton(tr("Select New File"), QMessageBox::AcceptRole); @@ -901,7 +901,7 @@ bool QDesignerActions::writeOutForm(QDesignerFormWindowInterface *fw, const QStr box.setWindowModality(Qt::WindowModal); box.setInformativeText(tr("It was not possible to write the entire file %1 to disk." "\nReason:%2\nWould you like to retry?") - .arg(f.fileName()).arg(f.errorString())); + .arg(f.fileName(), f.errorString())); box.setDefaultButton(QMessageBox::Retry); switch (box.exec()) { case QMessageBox::Retry: diff --git a/src/designer/src/designer/qdesigner_appearanceoptions.cpp b/src/designer/src/designer/qdesigner_appearanceoptions.cpp index fbdb4268a..04f3ab1d4 100644 --- a/src/designer/src/designer/qdesigner_appearanceoptions.cpp +++ b/src/designer/src/designer/qdesigner_appearanceoptions.cpp @@ -62,13 +62,11 @@ QDesignerAppearanceOptionsWidget::QDesignerAppearanceOptionsWidget(QWidget *pare m_ui(new Ui::AppearanceOptionsWidget), m_initialUIMode(NeutralMode) { - typedef void (QComboBox::*QComboIntSignal)(int); - m_ui->setupUi(this); m_ui->m_uiModeCombo->addItem(tr("Docked Window"), QVariant(DockedMode)); m_ui->m_uiModeCombo->addItem(tr("Multiple Top-Level Windows"), QVariant(TopLevelMode)); - connect(m_ui->m_uiModeCombo, static_cast<QComboIntSignal>(&QComboBox::currentIndexChanged), + connect(m_ui->m_uiModeCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &QDesignerAppearanceOptionsWidget::slotUiModeComboChanged); m_ui->m_fontPanel->setCheckable(true); diff --git a/src/designer/src/designer/qdesigner_formwindow.cpp b/src/designer/src/designer/qdesigner_formwindow.cpp index 1a109ed7b..9453115d1 100644 --- a/src/designer/src/designer/qdesigner_formwindow.cpp +++ b/src/designer/src/designer/qdesigner_formwindow.cpp @@ -205,7 +205,7 @@ void QDesignerFormWindow::updateWindowTitle(const QString &fileName) if (const QWidget *mc = m_editor->mainContainer()) { setWindowIcon(mc->windowIcon()); - setWindowTitle(tr("%1 - %2[*]").arg(mc->windowTitle()).arg(fileNameTitle)); + setWindowTitle(tr("%1 - %2[*]").arg(mc->windowTitle(), fileNameTitle)); } else { setWindowTitle(fileNameTitle); } diff --git a/src/designer/src/designer/saveformastemplate.cpp b/src/designer/src/designer/saveformastemplate.cpp index e83ca48c2..637d7a433 100644 --- a/src/designer/src/designer/saveformastemplate.cpp +++ b/src/designer/src/designer/saveformastemplate.cpp @@ -92,7 +92,8 @@ void SaveFormAsTemplate::accept() while (!file.open(QFile::WriteOnly)) { if (QMessageBox::information(m_formWindow, tr("Open Error"), - tr("There was an error opening template %1 for writing. Reason: %2").arg(name).arg(file.errorString()), + tr("There was an error opening template %1 for writing. Reason: %2") + .arg(name, file.errorString()), QMessageBox::Retry|QMessageBox::Cancel, QMessageBox::Cancel) == QMessageBox::Cancel) { return; } @@ -106,7 +107,8 @@ void SaveFormAsTemplate::accept() m_formWindow->setFileName(origName); while (file.write(ba) != ba.size()) { if (QMessageBox::information(m_formWindow, tr("Write Error"), - tr("There was an error writing the template %1 to disk. Reason: %2").arg(name).arg(file.errorString()), + tr("There was an error writing the template %1 to disk. Reason: %2") + .arg(name, file.errorString()), QMessageBox::Retry|QMessageBox::Cancel, QMessageBox::Cancel) == QMessageBox::Cancel) { file.close(); file.remove(); diff --git a/src/designer/src/lib/shared/codedialog.cpp b/src/designer/src/lib/shared/codedialog.cpp index 474ebe863..e01c75ac3 100644 --- a/src/designer/src/lib/shared/codedialog.cpp +++ b/src/designer/src/lib/shared/codedialog.cpp @@ -223,12 +223,14 @@ void CodeDialog::slotSaveAs() QFile file(fileName); if (!file.open(QIODevice::WriteOnly|QIODevice::Text)) { - warning(tr("The file %1 could not be opened: %2").arg(fileName).arg(file.errorString())); + warning(tr("The file %1 could not be opened: %2") + .arg(fileName, file.errorString())); continue; } file.write(code().toUtf8()); if (!file.flush()) { - warning(tr("The file %1 could not be written: %2").arg(fileName).arg(file.errorString())); + warning(tr("The file %1 could not be written: %2") + .arg(fileName, file.errorString())); continue; } file.close(); diff --git a/src/designer/src/lib/shared/connectionedit.cpp b/src/designer/src/lib/shared/connectionedit.cpp index cd8bedcc1..d02f96e91 100644 --- a/src/designer/src/lib/shared/connectionedit.cpp +++ b/src/designer/src/lib/shared/connectionedit.cpp @@ -1568,10 +1568,10 @@ void ConnectionEdit::createContextMenu(QMenu &menu) { // Select QAction *selectAllAction = menu.addAction(tr("Select All")); - selectAllAction->setEnabled(connectionList().size()); + selectAllAction->setEnabled(!connectionList().isEmpty()); connect(selectAllAction, &QAction::triggered, this, &ConnectionEdit::selectAll); QAction *deselectAllAction = menu.addAction(tr("Deselect All")); - deselectAllAction->setEnabled(selection().size()); + deselectAllAction->setEnabled(!selection().isEmpty()); connect(deselectAllAction, &QAction::triggered, this, &ConnectionEdit::selectNone); menu.addSeparator(); // Delete diff --git a/src/designer/src/lib/shared/iconselector.cpp b/src/designer/src/lib/shared/iconselector.cpp index 303a2e2a6..f84b30173 100644 --- a/src/designer/src/lib/shared/iconselector.cpp +++ b/src/designer/src/lib/shared/iconselector.cpp @@ -321,7 +321,8 @@ bool IconSelector::checkPixmap(const QString &fileName, CheckMode cm, QString *e QImageReader reader(fileName); if (!reader.canRead()) { if (errorMessage) - *errorMessage = tr("The file '%1' does not appear to be a valid pixmap file: %2").arg(fileName).arg(reader.errorString()); + *errorMessage = tr("The file '%1' does not appear to be a valid pixmap file: %2") + .arg(fileName, reader.errorString()); return false; } if (cm == CheckFast) @@ -330,7 +331,8 @@ bool IconSelector::checkPixmap(const QString &fileName, CheckMode cm, QString *e const QImage image = reader.read(); if (image.isNull()) { if (errorMessage) - *errorMessage = tr("The file '%1' could not be read: %2").arg(fileName).arg(reader.errorString()); + *errorMessage = tr("The file '%1' could not be read: %2") + .arg(fileName, reader.errorString()); return false; } return true; diff --git a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp index 6b40aec8c..5adab88a4 100644 --- a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp @@ -1250,7 +1250,8 @@ unsigned SetPropertyCommand::subPropertyMask(const QVariant &newValue, QObject * void SetPropertyCommand::setDescription() { if (propertyHelperList().size() == 1) { - setText(QApplication::translate("Command", "Changed '%1' of '%2'").arg(propertyName()).arg(propertyHelperList().at(0)->object()->objectName())); + setText(QApplication::translate("Command", "Changed '%1' of '%2'") + .arg(propertyName(), propertyHelperList().at(0)->object()->objectName())); } else { int count = propertyHelperList().size(); setText(QCoreApplication::translate("Command", "Changed '%1' of %n objects", "", count).arg(propertyName())); @@ -1349,7 +1350,8 @@ bool ResetPropertyCommand::init(const ObjectList &list, const QString &aproperty void ResetPropertyCommand::setDescription() { if (propertyHelperList().size() == 1) { - setText(QCoreApplication::translate("Command", "Reset '%1' of '%2'").arg(propertyName()).arg(propertyHelperList().at(0)->object()->objectName())); + setText(QCoreApplication::translate("Command", "Reset '%1' of '%2'") + .arg(propertyName(), propertyHelperList().at(0)->object()->objectName())); } else { int count = propertyHelperList().size(); setText(QCoreApplication::translate("Command", "Reset '%1' of %n objects", "", count).arg(propertyName())); @@ -1435,10 +1437,12 @@ void AddDynamicPropertyCommand::undo() void AddDynamicPropertyCommand::setDescription() { if (m_selection.size() == 1) { - setText(QApplication::translate("Command", "Add dynamic property '%1' to '%2'").arg(m_propertyName).arg(m_selection.first()->objectName())); + setText(QApplication::translate("Command", "Add dynamic property '%1' to '%2'") + .arg(m_propertyName, m_selection.first()->objectName())); } else { int count = m_selection.size(); - setText(QCoreApplication::translate("Command", "Add dynamic property '%1' to %n objects", "", count).arg(m_propertyName)); + setText(QCoreApplication::translate("Command", "Add dynamic property '%1' to %n objects", "", count) + .arg(m_propertyName)); } } @@ -1522,10 +1526,14 @@ void RemoveDynamicPropertyCommand::undo() void RemoveDynamicPropertyCommand::setDescription() { if (m_objectToValueAndChanged.size() == 1) { - setText(QApplication::translate("Command", "Remove dynamic property '%1' from '%2'").arg(m_propertyName).arg(m_objectToValueAndChanged.constBegin().key()->objectName())); + setText(QApplication::translate("Command", + "Remove dynamic property '%1' from '%2'") + .arg(m_propertyName, m_objectToValueAndChanged.constBegin().key()->objectName())); } else { int count = m_objectToValueAndChanged.size(); - setText(QApplication::translate("Command", "Remove dynamic property '%1' from %n objects", "", count).arg(m_propertyName)); + setText(QApplication::translate("Command", + "Remove dynamic property '%1' from %n objects", "", count) + .arg(m_propertyName)); } } diff --git a/src/designer/src/lib/shared/qdesigner_propertysheet.cpp b/src/designer/src/lib/shared/qdesigner_propertysheet.cpp index 31c88da1e..1f1348f29 100644 --- a/src/designer/src/lib/shared/qdesigner_propertysheet.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertysheet.cpp @@ -643,7 +643,8 @@ QDesignerPropertySheet::QDesignerPropertySheet(QObject *object, QObject *parent) } else { if (qobject_cast<const QMenuBar *>(d->m_object)) { // Keep the menu bar editable in the form even if a native menu bar is used. - const bool nativeMenuBarDefault = !qApp->testAttribute(Qt::AA_DontUseNativeMenuBar); + const bool nativeMenuBarDefault = + !QCoreApplication::testAttribute(Qt::AA_DontUseNativeMenuBar); createFakeProperty(QStringLiteral("nativeMenuBar"), QVariant(nativeMenuBarDefault)); } } diff --git a/src/designer/src/lib/shared/qdesigner_stackedbox.cpp b/src/designer/src/lib/shared/qdesigner_stackedbox.cpp index ac91b7ed9..da7d315bd 100644 --- a/src/designer/src/lib/shared/qdesigner_stackedbox.cpp +++ b/src/designer/src/lib/shared/qdesigner_stackedbox.cpp @@ -162,11 +162,17 @@ static inline QString stackedClassName(QStackedWidget *w) void QStackedWidgetPreviewEventFilter::updateButtonToolTip(QObject *o) { if (o == m_prev) { - const QString msg = tr("Go to previous page of %1 '%2' (%3/%4).").arg(stackedClassName(m_stackedWidget)).arg(m_stackedWidget->objectName()).arg(m_stackedWidget->currentIndex() + 1).arg(m_stackedWidget->count()); + const QString msg = tr("Go to previous page of %1 '%2' (%3/%4).") + .arg(stackedClassName(m_stackedWidget), m_stackedWidget->objectName()) + .arg(m_stackedWidget->currentIndex() + 1) + .arg(m_stackedWidget->count()); m_prev->setToolTip(msg); } else { if (o == m_next) { - const QString msg = tr("Go to next page of %1 '%2' (%3/%4).").arg(stackedClassName(m_stackedWidget)).arg(m_stackedWidget->objectName()).arg(m_stackedWidget->currentIndex() + 1).arg(m_stackedWidget->count()); + const QString msg = tr("Go to next page of %1 '%2' (%3/%4).") + .arg(stackedClassName(m_stackedWidget), m_stackedWidget->objectName()) + .arg(m_stackedWidget->currentIndex() + 1) + .arg(m_stackedWidget->count()); m_next->setToolTip(msg); } } diff --git a/src/designer/src/lib/shared/qdesigner_utils.cpp b/src/designer/src/lib/shared/qdesigner_utils.cpp index b706fa3bb..0c78fe8c8 100644 --- a/src/designer/src/lib/shared/qdesigner_utils.cpp +++ b/src/designer/src/lib/shared/qdesigner_utils.cpp @@ -157,12 +157,16 @@ namespace qdesigner_internal QString DesignerMetaEnum::messageToStringFailed(int value) const { - return QCoreApplication::translate("DesignerMetaEnum", "%1 is not a valid enumeration value of '%2'.").arg(value).arg(name()); + return QCoreApplication::translate("DesignerMetaEnum", + "%1 is not a valid enumeration value of '%2'.") + .arg(value).arg(name()); } QString DesignerMetaEnum::messageParseFailed(const QString &s) const { - return QCoreApplication::translate("DesignerMetaEnum", "'%1' could not be converted to an enumeration value of type '%2'.").arg(s).arg(name()); + return QCoreApplication::translate("DesignerMetaEnum", + "'%1' could not be converted to an enumeration value of type '%2'.") + .arg(s, name()); } // -------------- DesignerMetaFlags DesignerMetaFlags::DesignerMetaFlags(const QString &name, const QString &scope, const QString &separator) : @@ -237,7 +241,9 @@ namespace qdesigner_internal QString DesignerMetaFlags::messageParseFailed(const QString &s) const { - return QCoreApplication::translate("DesignerMetaFlags", "'%1' could not be converted to a flag value of type '%2'.").arg(s).arg(name()); + return QCoreApplication::translate("DesignerMetaFlags", + "'%1' could not be converted to a flag value of type '%2'.") + .arg(s, name()); } // ---------- PropertySheetEnumValue diff --git a/src/designer/src/lib/shared/qdesigner_widgetbox.cpp b/src/designer/src/lib/shared/qdesigner_widgetbox.cpp index 079c0ab00..f2e4cd5cc 100644 --- a/src/designer/src/lib/shared/qdesigner_widgetbox.cpp +++ b/src/designer/src/lib/shared/qdesigner_widgetbox.cpp @@ -215,15 +215,15 @@ DomUI *QDesignerWidgetBox::xmlToUi(const QString &name, const QString &xml, bool delete ui; *errorMessage = tr("A parse error occurred at line %1, column %2 of the XML code " "specified for the widget %3: %4\n%5") - .arg(reader.lineNumber()).arg(reader.columnNumber()).arg(name) - .arg(reader.errorString()).arg(xml); + .arg(reader.lineNumber()).arg(reader.columnNumber()) + .arg(name, reader.errorString(), xml); return 0; } if (!ui || !ui->elementWidget()) { delete ui; *errorMessage = tr("The XML code specified for the widget %1 does not contain " - "any widget elements.\n%2").arg(name).arg(xml); + "any widget elements.\n%2").arg(name, xml); return 0; } diff --git a/src/designer/src/lib/shared/qtresourceeditordialog.cpp b/src/designer/src/lib/shared/qtresourceeditordialog.cpp index 960313f49..05338c063 100644 --- a/src/designer/src/lib/shared/qtresourceeditordialog.cpp +++ b/src/designer/src/lib/shared/qtresourceeditordialog.cpp @@ -1863,7 +1863,10 @@ bool QtResourceEditorDialogPrivate::loadQrcFile(const QString &path, QtQrcFileDa QDomDocument doc; int errLine, errCol; if (!doc.setContent(dataArray, errorMessage, &errLine, &errCol)) { - *errorMessage = QCoreApplication::translate("QtResourceEditorDialog", "A parse error occurred at line %1, column %2 of %3:\n%4").arg(errLine).arg(errCol).arg(path).arg(*errorMessage); + *errorMessage = + QCoreApplication::translate("QtResourceEditorDialog", + "A parse error occurred at line %1, column %2 of %3:\n%4") + .arg(errLine).arg(errCol).arg(path, *errorMessage); return false; } @@ -1875,8 +1878,12 @@ bool QtResourceEditorDialogPrivate::saveQrcFile(const QtQrcFileData &qrcFileData QFile file(qrcFileData.qrcPath); while (!file.open(QIODevice::WriteOnly)) { QMessageBox msgBox(QMessageBox::Warning, - QCoreApplication::translate("QtResourceEditorDialog", "Save Resource File"), - QCoreApplication::translate("QtResourceEditorDialog", "Could not write %1: %2").arg(qrcFileData.qrcPath).arg(file.errorString()), + QCoreApplication::translate("QtResourceEditorDialog", + "Save Resource File"), + QCoreApplication::translate("QtResourceEditorDialog", + "Could not write %1: %2") + .arg(qrcFileData.qrcPath, + file.errorString()), QMessageBox::Cancel|QMessageBox::Ignore|QMessageBox::Retry); msgBox.setEscapeButton(QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Ignore); diff --git a/src/designer/src/lib/shared/widgetfactory.cpp b/src/designer/src/lib/shared/widgetfactory.cpp index 880f62a93..3fffe610d 100644 --- a/src/designer/src/lib/shared/widgetfactory.cpp +++ b/src/designer/src/lib/shared/widgetfactory.cpp @@ -486,8 +486,10 @@ QLayout *WidgetFactory::createLayout(QWidget *widget, QLayout *parentLayout, int if (page) { widget = page; } else { - const QString msg = tr("The current page of the container '%1' (%2) could not be determined while creating a layout." -"This indicates an inconsistency in the ui-file, probably a layout being constructed on a container widget.").arg(widget->objectName()).arg(classNameOf(core(), widget)); + const QString msg = + tr("The current page of the container '%1' (%2) could not be determined while creating a layout." + "This indicates an inconsistency in the ui-file, probably a layout being constructed on a container widget.") + .arg(widget->objectName(), classNameOf(core(), widget)); designerWarning(msg); } } @@ -525,7 +527,7 @@ QLayout *WidgetFactory::createLayout(QWidget *widget, QLayout *parentLayout, int if (!box) { // we support only unmanaged box layouts const QString msg = tr("Attempt to add a layout to a widget '%1' (%2) which already has an unmanaged layout of type %3.\n" "This indicates an inconsistency in the ui-file."). - arg(widget->objectName()).arg(classNameOf(core(), widget)).arg(classNameOf(core(), widget->layout())); + arg(widget->objectName(), classNameOf(core(), widget), classNameOf(core(), widget->layout())); designerWarning(msg); return 0; } -- GitLab