diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-04-04 09:37:07 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-04-07 14:59:21 +0200 |
commit | 1c7cca268a06b5a3c34765e1e0e4dd1b020f3302 (patch) | |
tree | 4229ee67d541429a93a1d1412b4e25679761ed94 | |
parent | 483f257e887a590d3462d0fc60b7eebfa50a3d19 (diff) | |
download | qttools-1c7cca268a06b5a3c34765e1e0e4dd1b020f3302.tar.gz |
Qt Designer: Replace QStringLiteral by modern literals
As a drive-by, extend the list of C++ keywords checked for naming.
Pick-to: 6.5
Change-Id: I37b095d0fa29b9c431b7ad11bb5f962a8eeb5d79
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
108 files changed, 1256 insertions, 1117 deletions
diff --git a/src/designer/src/components/buddyeditor/buddyeditor.cpp b/src/designer/src/components/buddyeditor/buddyeditor.cpp index 6f3b3946f..69b903804 100644 --- a/src/designer/src/components/buddyeditor/buddyeditor.cpp +++ b/src/designer/src/components/buddyeditor/buddyeditor.cpp @@ -28,6 +28,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static const char *buddyPropertyC = "buddy"; static bool canBeBuddy(QWidget *w, QDesignerFormWindowInterface *form) @@ -39,7 +41,7 @@ static bool canBeBuddy(QWidget *w, QDesignerFormWindowInterface *form) QExtensionManager *ext = form->core()->extensionManager(); if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(ext, w)) { - const int index = sheet->indexOf(QStringLiteral("focusPolicy")); + const int index = sheet->indexOf(u"focusPolicy"_s); if (index != -1) { bool ok = false; const Qt::FocusPolicy q = static_cast<Qt::FocusPolicy>(qdesigner_internal::Utils::valueOf(sheet->property(index), &ok)); diff --git a/src/designer/src/components/buddyeditor/buddyeditor_plugin.cpp b/src/designer/src/components/buddyeditor/buddyeditor_plugin.cpp index 5f3d55884..b4128bad4 100644 --- a/src/designer/src/components/buddyeditor/buddyeditor_plugin.cpp +++ b/src/designer/src/components/buddyeditor/buddyeditor_plugin.cpp @@ -12,6 +12,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { BuddyEditorPlugin::BuddyEditorPlugin() = default; @@ -28,9 +30,9 @@ void BuddyEditorPlugin::initialize(QDesignerFormEditorInterface *core) Q_ASSERT(!isInitialized()); m_action = new QAction(tr("Edit Buddies"), this); - m_action->setObjectName(QStringLiteral("__qt_edit_buddies_action")); - QIcon buddyIcon = QIcon::fromTheme(QStringLiteral("designer-edit-buddy"), - QIcon(core->resourceLocation() + QStringLiteral("/buddytool.png"))); + m_action->setObjectName(u"__qt_edit_buddies_action"_s); + QIcon buddyIcon = QIcon::fromTheme(u"designer-edit-buddy"_s, + QIcon(core->resourceLocation() + "/buddytool.png"_L1)); m_action->setIcon(buddyIcon); m_action->setEnabled(false); diff --git a/src/designer/src/components/formeditor/formeditor.cpp b/src/designer/src/components/formeditor/formeditor.cpp index 3ce7b85f0..2fbcc8b1b 100644 --- a/src/designer/src/components/formeditor/formeditor.cpp +++ b/src/designer/src/components/formeditor/formeditor.cpp @@ -40,6 +40,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { FormEditor::FormEditor(QObject *parent) @@ -102,8 +104,7 @@ FormEditor::FormEditor(QObject *parent) QTreeViewPropertySheetFactory::registerExtension(mgr); QTableViewPropertySheetFactory::registerExtension(mgr); - const QString internalTaskMenuId = QStringLiteral("QDesignerInternalTaskMenuExtension"); - QDesignerTaskMenuFactory::registerExtension(mgr, internalTaskMenuId); + QDesignerTaskMenuFactory::registerExtension(mgr, u"QDesignerInternalTaskMenuExtension"_s); mgr->registerExtensions(new QDesignerMemberSheetFactory(mgr), Q_TYPEID(QDesignerMemberSheetExtension)); diff --git a/src/designer/src/components/formeditor/formwindow.cpp b/src/designer/src/components/formeditor/formwindow.cpp index 51a0084b8..efad969c8 100644 --- a/src/designer/src/components/formeditor/formwindow.cpp +++ b/src/designer/src/components/formeditor/formwindow.cpp @@ -77,6 +77,8 @@ Q_DECLARE_METATYPE(QWidget*) QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { class BlockSelection { @@ -454,11 +456,11 @@ void FormWindow::setMainContainer(QWidget *w) manageWidget(m_mainContainer); if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), m_mainContainer)) { - sheet->setVisible(sheet->indexOf(QStringLiteral("windowTitle")), true); - sheet->setVisible(sheet->indexOf(QStringLiteral("windowIcon")), true); - sheet->setVisible(sheet->indexOf(QStringLiteral("windowModality")), true); - sheet->setVisible(sheet->indexOf(QStringLiteral("windowOpacity")), true); - sheet->setVisible(sheet->indexOf(QStringLiteral("windowFilePath")), true); + sheet->setVisible(sheet->indexOf(u"windowTitle"_s), true); + sheet->setVisible(sheet->indexOf(u"windowIcon"_s), true); + sheet->setVisible(sheet->indexOf(u"windowModality"_s), true); + sheet->setVisible(sheet->indexOf(u"windowOpacity"_s), true); + sheet->setVisible(sheet->indexOf(u"windowFilePath"_s), true); // ### generalize } @@ -989,129 +991,98 @@ static inline void insertNames(const QDesignerMetaDataBaseInterface *metaDataBas static QSet<QString> languageKeywords() { - static QSet<QString> keywords; - if (keywords.isEmpty()) { + static const QSet<QString> keywords = { // C++ keywords - keywords.insert(QStringLiteral("asm")); - keywords.insert(QStringLiteral("auto")); - keywords.insert(QStringLiteral("bool")); - keywords.insert(QStringLiteral("break")); - keywords.insert(QStringLiteral("case")); - keywords.insert(QStringLiteral("catch")); - keywords.insert(QStringLiteral("char")); - keywords.insert(QStringLiteral("class")); - keywords.insert(QStringLiteral("const")); - keywords.insert(QStringLiteral("const_cast")); - keywords.insert(QStringLiteral("continue")); - keywords.insert(QStringLiteral("default")); - keywords.insert(QStringLiteral("delete")); - keywords.insert(QStringLiteral("do")); - keywords.insert(QStringLiteral("double")); - keywords.insert(QStringLiteral("dynamic_cast")); - keywords.insert(QStringLiteral("else")); - keywords.insert(QStringLiteral("enum")); - keywords.insert(QStringLiteral("explicit")); - keywords.insert(QStringLiteral("export")); - keywords.insert(QStringLiteral("extern")); - keywords.insert(QStringLiteral("false")); - keywords.insert(QStringLiteral("float")); - keywords.insert(QStringLiteral("for")); - keywords.insert(QStringLiteral("friend")); - keywords.insert(QStringLiteral("goto")); - keywords.insert(QStringLiteral("if")); - keywords.insert(QStringLiteral("inline")); - keywords.insert(QStringLiteral("int")); - keywords.insert(QStringLiteral("long")); - keywords.insert(QStringLiteral("mutable")); - keywords.insert(QStringLiteral("namespace")); - keywords.insert(QStringLiteral("new")); - keywords.insert(QStringLiteral("NULL")); - keywords.insert(QStringLiteral("operator")); - keywords.insert(QStringLiteral("private")); - keywords.insert(QStringLiteral("protected")); - keywords.insert(QStringLiteral("public")); - keywords.insert(QStringLiteral("register")); - keywords.insert(QStringLiteral("reinterpret_cast")); - keywords.insert(QStringLiteral("return")); - keywords.insert(QStringLiteral("short")); - keywords.insert(QStringLiteral("signed")); - keywords.insert(QStringLiteral("sizeof")); - keywords.insert(QStringLiteral("static")); - keywords.insert(QStringLiteral("static_cast")); - keywords.insert(QStringLiteral("struct")); - keywords.insert(QStringLiteral("switch")); - keywords.insert(QStringLiteral("template")); - keywords.insert(QStringLiteral("this")); - keywords.insert(QStringLiteral("throw")); - keywords.insert(QStringLiteral("true")); - keywords.insert(QStringLiteral("try")); - keywords.insert(QStringLiteral("typedef")); - keywords.insert(QStringLiteral("typeid")); - keywords.insert(QStringLiteral("typename")); - keywords.insert(QStringLiteral("union")); - keywords.insert(QStringLiteral("unsigned")); - keywords.insert(QStringLiteral("using")); - keywords.insert(QStringLiteral("virtual")); - keywords.insert(QStringLiteral("void")); - keywords.insert(QStringLiteral("volatile")); - keywords.insert(QStringLiteral("wchar_t")); - keywords.insert(QStringLiteral("while")); + u"asm"_s, + u"assert"_s, + u"auto"_s, + u"bool"_s, + u"break"_s, + u"case"_s, + u"catch"_s, + u"char"_s, + u"class"_s, + u"const"_s, + u"const_cast"_s, + u"continue"_s, + u"default"_s, + u"delete"_s, + u"do"_s, + u"double"_s, + u"dynamic_cast"_s, + u"else"_s, + u"enum"_s, + u"explicit"_s, + u"export"_s, + u"extern"_s, + u"false"_s, + u"final"_s, + u"float"_s, + u"for"_s, + u"friend"_s, + u"goto"_s, + u"if"_s, + u"inline"_s, + u"int"_s, + u"long"_s, + u"mutable"_s, + u"namespace"_s, + u"new"_s, + u"noexcept"_s, + u"NULL"_s, + u"nullptr"_s, + u"operator"_s, + u"override"_s, + u"private"_s, + u"protected"_s, + u"public"_s, + u"register"_s, + u"reinterpret_cast"_s, + u"return"_s, + u"short"_s, + u"signed"_s, + u"sizeof"_s, + u"static"_s, + u"static_cast"_s, + u"struct"_s, + u"switch"_s, + u"template"_s, + u"this"_s, + u"throw"_s, + u"true"_s, + u"try"_s, + u"typedef"_s, + u"typeid"_s, + u"typename"_s, + u"union"_s, + u"unsigned"_s, + u"using"_s, + u"virtual"_s, + u"void"_s, + u"volatile"_s, + u"wchar_t"_s, + u"while"_s, // java keywords - keywords.insert(QStringLiteral("abstract")); - keywords.insert(QStringLiteral("assert")); - keywords.insert(QStringLiteral("boolean")); - keywords.insert(QStringLiteral("break")); - keywords.insert(QStringLiteral("byte")); - keywords.insert(QStringLiteral("case")); - keywords.insert(QStringLiteral("catch")); - keywords.insert(QStringLiteral("char")); - keywords.insert(QStringLiteral("class")); - keywords.insert(QStringLiteral("const")); - keywords.insert(QStringLiteral("continue")); - keywords.insert(QStringLiteral("default")); - keywords.insert(QStringLiteral("do")); - keywords.insert(QStringLiteral("double")); - keywords.insert(QStringLiteral("else")); - keywords.insert(QStringLiteral("enum")); - keywords.insert(QStringLiteral("extends")); - keywords.insert(QStringLiteral("false")); - keywords.insert(QStringLiteral("final")); - keywords.insert(QStringLiteral("finality")); - keywords.insert(QStringLiteral("float")); - keywords.insert(QStringLiteral("for")); - keywords.insert(QStringLiteral("goto")); - keywords.insert(QStringLiteral("if")); - keywords.insert(QStringLiteral("implements")); - keywords.insert(QStringLiteral("import")); - keywords.insert(QStringLiteral("instanceof")); - keywords.insert(QStringLiteral("int")); - keywords.insert(QStringLiteral("interface")); - keywords.insert(QStringLiteral("long")); - keywords.insert(QStringLiteral("native")); - keywords.insert(QStringLiteral("new")); - keywords.insert(QStringLiteral("null")); - keywords.insert(QStringLiteral("package")); - keywords.insert(QStringLiteral("private")); - keywords.insert(QStringLiteral("protected")); - keywords.insert(QStringLiteral("public")); - keywords.insert(QStringLiteral("return")); - keywords.insert(QStringLiteral("short")); - keywords.insert(QStringLiteral("static")); - keywords.insert(QStringLiteral("strictfp")); - keywords.insert(QStringLiteral("super")); - keywords.insert(QStringLiteral("switch")); - keywords.insert(QStringLiteral("synchronized")); - keywords.insert(QStringLiteral("this")); - keywords.insert(QStringLiteral("throw")); - keywords.insert(QStringLiteral("throws")); - keywords.insert(QStringLiteral("transient")); - keywords.insert(QStringLiteral("true")); - keywords.insert(QStringLiteral("try")); - keywords.insert(QStringLiteral("void")); - keywords.insert(QStringLiteral("volatile")); - keywords.insert(QStringLiteral("while")); - } + u"abstract"_s, + u"boolean"_s, + u"byte"_s, + u"extends"_s, + u"finality"_s, + u"implements"_s, + u"import"_s, + u"instanceof"_s, + u"interface"_s, + u"native"_s, + u"null"_s, + u"package"_s, + u"strictfp"_s, + u"super"_s, + u"synchronized"_s, + u"throws"_s, + u"transient"_s, + }; + return keywords; } @@ -1193,7 +1164,7 @@ void FormWindow::insertWidget(QWidget *w, const QRect &rect, QWidget *container, QRect r = rect; Q_ASSERT(r.isValid()); SetPropertyCommand *geom_cmd = new SetPropertyCommand(this); - geom_cmd->init(w, QStringLiteral("geometry"), r); // ### use rc.size() + geom_cmd->init(w, u"geometry"_s, r); // ### use rc.size() if (w->parentWidget() != container) { ReparentWidgetCommand *cmd = new ReparentWidgetCommand(this); @@ -1258,7 +1229,7 @@ void FormWindow::resizeWidget(QWidget *widget, const QRect &geometry) QRect r = geometry; SetPropertyCommand *cmd = new SetPropertyCommand(this); - cmd->init(widget, QStringLiteral("geometry"), r); + cmd->init(widget, u"geometry"_s, r); cmd->setText(tr("Resize")); m_undoStack.push(cmd); } @@ -1503,7 +1474,7 @@ void ArrowKeyPropertyCommand::init(QWidgetList &l, const ArrowKeyOperation &op) QObjectList ol; for (QWidget *w : std::as_const(l)) ol.push_back(w); - SetPropertyCommand::init(ol, QStringLiteral("geometry"), QVariant::fromValue(op)); + SetPropertyCommand::init(ol, u"geometry"_s, QVariant::fromValue(op)); setText(op.resize ? FormWindow::tr("Key Resize") : FormWindow::tr("Key Move")); } @@ -1733,10 +1704,9 @@ static inline DomUI *domUIFromClipboard(int *widgetCount, int *actionCount) QXmlStreamReader reader(clipboardText); DomUI *ui = nullptr; - const QString uiElement = QStringLiteral("ui"); while (!reader.atEnd()) { if (reader.readNext() == QXmlStreamReader::StartElement) { - if (reader.name().compare(uiElement, Qt::CaseInsensitive) == 0 && !ui) { + if (reader.name().compare("ui"_L1, Qt::CaseInsensitive) == 0 && !ui) { ui = new DomUI(); ui->read(reader); break; @@ -2348,7 +2318,7 @@ QPoint FormWindow::mapToForm(const QWidget *w, const QPoint &pos) const bool FormWindow::canBeBuddy(QWidget *w) const // ### rename me. { if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), w)) { - const int index = sheet->indexOf(QStringLiteral("focusPolicy")); + const int index = sheet->indexOf(u"focusPolicy"_s); if (index != -1) { bool ok = false; const Qt::FocusPolicy q = static_cast<Qt::FocusPolicy>(Utils::valueOf(sheet->property(index), &ok)); @@ -2793,7 +2763,7 @@ bool FormWindow::dropDockWidget(QDesignerDnDItemInterface *item, const QPoint &g QDesignerPropertySheetExtension *propertySheet = qobject_cast<QDesignerPropertySheetExtension*>(m_core->extensionManager()->extension(widget, Q_TYPEID(QDesignerPropertySheetExtension))); if (propertySheet) { - const QString dockWidgetAreaName = QStringLiteral("dockWidgetArea"); + const QString dockWidgetAreaName = u"dockWidgetArea"_s; PropertySheetEnumValue e = qvariant_cast<PropertySheetEnumValue>(propertySheet->property(propertySheet->indexOf(dockWidgetAreaName))); e.value = area; QVariant v; diff --git a/src/designer/src/components/formeditor/formwindow_widgetstack.cpp b/src/designer/src/components/formeditor/formwindow_widgetstack.cpp index 503f384ec..e42345b41 100644 --- a/src/designer/src/components/formeditor/formwindow_widgetstack.cpp +++ b/src/designer/src/components/formeditor/formwindow_widgetstack.cpp @@ -15,6 +15,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { FormWindowWidgetStack::FormWindowWidgetStack(QObject *parent) : @@ -31,7 +33,7 @@ FormWindowWidgetStack::FormWindowWidgetStack(QObject *parent) : // the form windows as it ignores the sizePolicy of // its child (for example, Fixed would cause undesired side effects). m_formContainerLayout->setContentsMargins(QMargins()); - m_formContainer->setObjectName(QStringLiteral("formContainer")); + m_formContainer->setObjectName(u"formContainer"_s); m_formContainer->setLayout(m_formContainerLayout); m_formContainerLayout->setStackingMode(QStackedLayout::StackAll); // System settings might have different background colors, autofill them diff --git a/src/designer/src/components/formeditor/formwindowmanager.cpp b/src/designer/src/components/formeditor/formwindowmanager.cpp index ccb7473d2..e81f8c67d 100644 --- a/src/designer/src/components/formeditor/formwindowmanager.cpp +++ b/src/designer/src/components/formeditor/formwindowmanager.cpp @@ -53,6 +53,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { enum { debugFWM = 0 }; } @@ -340,151 +342,162 @@ QWidget *FormWindowManager::findManagedWidget(FormWindow *fw, QWidget *w) void FormWindowManager::setupActions() { #if QT_CONFIG(clipboard) - const QIcon cutIcon = QIcon::fromTheme(QStringLiteral("edit-cut"), createIconSet(QStringLiteral("editcut.png"))); + const QIcon cutIcon = QIcon::fromTheme(u"edit-cut"_s, createIconSet(u"editcut.png"_s)); m_actionCut = new QAction(cutIcon, tr("Cu&t"), this); - m_actionCut->setObjectName(QStringLiteral("__qt_cut_action")); + m_actionCut->setObjectName(u"__qt_cut_action"_s); m_actionCut->setShortcut(QKeySequence::Cut); m_actionCut->setStatusTip(tr("Cuts the selected widgets and puts them on the clipboard")); - m_actionCut->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Cut"))); + m_actionCut->setWhatsThis(whatsThisFrom(u"Edit|Cut"_s)); connect(m_actionCut, &QAction::triggered, this, &FormWindowManager::slotActionCutActivated); m_actionCut->setEnabled(false); - const QIcon copyIcon = QIcon::fromTheme(QStringLiteral("edit-copy"), createIconSet(QStringLiteral("editcopy.png"))); + const QIcon copyIcon = QIcon::fromTheme(u"edit-copy"_s, + createIconSet(u"editcopy.png"_s)); m_actionCopy = new QAction(copyIcon, tr("&Copy"), this); - m_actionCopy->setObjectName(QStringLiteral("__qt_copy_action")); + m_actionCopy->setObjectName(u"__qt_copy_action"_s); m_actionCopy->setShortcut(QKeySequence::Copy); m_actionCopy->setStatusTip(tr("Copies the selected widgets to the clipboard")); - m_actionCopy->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Copy"))); + m_actionCopy->setWhatsThis(whatsThisFrom(u"Edit|Copy"_s)); connect(m_actionCopy, &QAction::triggered, this, &FormWindowManager::slotActionCopyActivated); m_actionCopy->setEnabled(false); - const QIcon pasteIcon = QIcon::fromTheme(QStringLiteral("edit-paste"), createIconSet(QStringLiteral("editpaste.png"))); + const QIcon pasteIcon = QIcon::fromTheme(u"edit-paste"_s, + createIconSet(u"editpaste.png"_s)); m_actionPaste = new QAction(pasteIcon, tr("&Paste"), this); - m_actionPaste->setObjectName(QStringLiteral("__qt_paste_action")); + m_actionPaste->setObjectName(u"__qt_paste_action"_s); m_actionPaste->setShortcut(QKeySequence::Paste); m_actionPaste->setStatusTip(tr("Pastes the clipboard's contents")); - m_actionPaste->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Paste"))); + m_actionPaste->setWhatsThis(whatsThisFrom(u"Edit|Paste"_s)); connect(m_actionPaste, &QAction::triggered, this, &FormWindowManager::slotActionPasteActivated); m_actionPaste->setEnabled(false); #endif - m_actionDelete = new QAction(QIcon::fromTheme(QStringLiteral("edit-delete")), tr("&Delete"), this); - m_actionDelete->setObjectName(QStringLiteral("__qt_delete_action")); + m_actionDelete = new QAction(QIcon::fromTheme(u"edit-delete"_s), + tr("&Delete"), this); + m_actionDelete->setObjectName(u"__qt_delete_action"_s); m_actionDelete->setStatusTip(tr("Deletes the selected widgets")); - m_actionDelete->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Delete"))); + m_actionDelete->setWhatsThis(whatsThisFrom(u"Edit|Delete"_s)); connect(m_actionDelete, &QAction::triggered, this, &FormWindowManager::slotActionDeleteActivated); m_actionDelete->setEnabled(false); m_actionSelectAll = new QAction(tr("Select &All"), this); - m_actionSelectAll->setObjectName(QStringLiteral("__qt_select_all_action")); + m_actionSelectAll->setObjectName(u"__qt_select_all_action"_s); m_actionSelectAll->setShortcut(QKeySequence::SelectAll); m_actionSelectAll->setStatusTip(tr("Selects all widgets")); - m_actionSelectAll->setWhatsThis(whatsThisFrom(QStringLiteral("Edit|Select All"))); + m_actionSelectAll->setWhatsThis(whatsThisFrom(u"Edit|Select All"_s)); connect(m_actionSelectAll, &QAction::triggered, this, &FormWindowManager::slotActionSelectAllActivated); m_actionSelectAll->setEnabled(false); - m_actionRaise = new QAction(createIconSet(QStringLiteral("editraise.png")), tr("Bring to &Front"), this); - m_actionRaise->setObjectName(QStringLiteral("__qt_raise_action")); + m_actionRaise = new QAction(createIconSet(u"editraise.png"_s), + tr("Bring to &Front"), this); + m_actionRaise->setObjectName(u"__qt_raise_action"_s); m_actionRaise->setShortcut(Qt::CTRL | Qt::Key_L); m_actionRaise->setStatusTip(tr("Raises the selected widgets")); m_actionRaise->setWhatsThis(tr("Raises the selected widgets")); connect(m_actionRaise, &QAction::triggered, this, &FormWindowManager::slotActionRaiseActivated); m_actionRaise->setEnabled(false); - m_actionLower = new QAction(createIconSet(QStringLiteral("editlower.png")), tr("Send to &Back"), this); - m_actionLower->setObjectName(QStringLiteral("__qt_lower_action")); + m_actionLower = new QAction(createIconSet(u"editlower.png"_s), + tr("Send to &Back"), this); + m_actionLower->setObjectName(u"__qt_lower_action"_s); m_actionLower->setShortcut(Qt::CTRL | Qt::Key_K); m_actionLower->setStatusTip(tr("Lowers the selected widgets")); m_actionLower->setWhatsThis(tr("Lowers the selected widgets")); connect(m_actionLower, &QAction::triggered, this, &FormWindowManager::slotActionLowerActivated); m_actionLower->setEnabled(false); - m_actionAdjustSize = new QAction(createIconSet(QStringLiteral("adjustsize.png")), tr("Adjust &Size"), this); - m_actionAdjustSize->setObjectName(QStringLiteral("__qt_adjust_size_action")); + m_actionAdjustSize = new QAction(createIconSet(u"adjustsize.png"_s), + tr("Adjust &Size"), this); + m_actionAdjustSize->setObjectName(u"__qt_adjust_size_action"_s); m_actionAdjustSize->setShortcut(Qt::CTRL | Qt::Key_J); m_actionAdjustSize->setStatusTip(tr("Adjusts the size of the selected widget")); - m_actionAdjustSize->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Adjust Size"))); + m_actionAdjustSize->setWhatsThis(whatsThisFrom(u"Layout|Adjust Size"_s)); connect(m_actionAdjustSize, &QAction::triggered, this, &FormWindowManager::slotActionAdjustSizeActivated); m_actionAdjustSize->setEnabled(false); - m_actionHorizontalLayout = new QAction(createIconSet(QStringLiteral("edithlayout.png")), tr("Lay Out &Horizontally"), this); - m_actionHorizontalLayout->setObjectName(QStringLiteral("__qt_horizontal_layout_action")); + m_actionHorizontalLayout = new QAction(createIconSet(u"edithlayout.png"_s), + tr("Lay Out &Horizontally"), this); + m_actionHorizontalLayout->setObjectName(u"__qt_horizontal_layout_action"_s); m_actionHorizontalLayout->setShortcut(Qt::CTRL | Qt::Key_1); m_actionHorizontalLayout->setStatusTip(tr("Lays out the selected widgets horizontally")); - m_actionHorizontalLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Horizontally"))); + m_actionHorizontalLayout->setWhatsThis(whatsThisFrom(u"Layout|Lay Out Horizontally"_s)); m_actionHorizontalLayout->setData(LayoutInfo::HBox); m_actionHorizontalLayout->setEnabled(false); connect(m_actionHorizontalLayout, &QAction::triggered, this, &FormWindowManager::createLayout); - m_actionVerticalLayout = new QAction(createIconSet(QStringLiteral("editvlayout.png")), tr("Lay Out &Vertically"), this); - m_actionVerticalLayout->setObjectName(QStringLiteral("__qt_vertical_layout_action")); + m_actionVerticalLayout = new QAction(createIconSet(u"editvlayout.png"_s), + tr("Lay Out &Vertically"), this); + m_actionVerticalLayout->setObjectName(u"__qt_vertical_layout_action"_s); m_actionVerticalLayout->setShortcut(Qt::CTRL | Qt::Key_2); m_actionVerticalLayout->setStatusTip(tr("Lays out the selected widgets vertically")); - m_actionVerticalLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Vertically"))); + m_actionVerticalLayout->setWhatsThis(whatsThisFrom(u"Layout|Lay Out Vertically"_s)); m_actionVerticalLayout->setData(LayoutInfo::VBox); m_actionVerticalLayout->setEnabled(false); connect(m_actionVerticalLayout, &QAction::triggered, this, &FormWindowManager::createLayout); - QIcon formIcon = QIcon::fromTheme(QStringLiteral("designer-form-layout"), createIconSet(QStringLiteral("editform.png"))); + QIcon formIcon = QIcon::fromTheme(u"designer-form-layout"_s, + createIconSet(u"editform.png"_s)); m_actionFormLayout = new QAction(formIcon, tr("Lay Out in a &Form Layout"), this); - m_actionFormLayout->setObjectName(QStringLiteral("__qt_form_layout_action")); + m_actionFormLayout->setObjectName(u"__qt_form_layout_action"_s); m_actionFormLayout->setShortcut(Qt::CTRL | Qt::Key_6); m_actionFormLayout->setStatusTip(tr("Lays out the selected widgets in a form layout")); - m_actionFormLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out in a Form"))); + m_actionFormLayout->setWhatsThis(whatsThisFrom(u"Layout|Lay Out in a Form"_s)); m_actionFormLayout->setData(LayoutInfo::Form); m_actionFormLayout->setEnabled(false); connect(m_actionFormLayout, &QAction::triggered, this, &FormWindowManager::createLayout); - m_actionGridLayout = new QAction(createIconSet(QStringLiteral("editgrid.png")), tr("Lay Out in a &Grid"), this); - m_actionGridLayout->setObjectName(QStringLiteral("__qt_grid_layout_action")); + m_actionGridLayout = new QAction(createIconSet(u"editgrid.png"_s), + tr("Lay Out in a &Grid"), this); + m_actionGridLayout->setObjectName(u"__qt_grid_layout_action"_s); m_actionGridLayout->setShortcut(Qt::CTRL | Qt::Key_5); m_actionGridLayout->setStatusTip(tr("Lays out the selected widgets in a grid")); - m_actionGridLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out in a Grid"))); + m_actionGridLayout->setWhatsThis(whatsThisFrom(u"Layout|Lay Out in a Grid"_s)); m_actionGridLayout->setData(LayoutInfo::Grid); m_actionGridLayout->setEnabled(false); connect(m_actionGridLayout, &QAction::triggered, this, &FormWindowManager::createLayout); - m_actionSplitHorizontal = new QAction(createIconSet(QStringLiteral("edithlayoutsplit.png")), + m_actionSplitHorizontal = new QAction(createIconSet(u"edithlayoutsplit.png"_s), tr("Lay Out Horizontally in S&plitter"), this); - m_actionSplitHorizontal->setObjectName(QStringLiteral("__qt_split_horizontal_action")); + m_actionSplitHorizontal->setObjectName(u"__qt_split_horizontal_action"_s); m_actionSplitHorizontal->setShortcut(Qt::CTRL | Qt::Key_3); m_actionSplitHorizontal->setStatusTip(tr("Lays out the selected widgets horizontally in a splitter")); - m_actionSplitHorizontal->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Horizontally in Splitter"))); + m_actionSplitHorizontal->setWhatsThis(whatsThisFrom(u"Layout|Lay Out Horizontally in Splitter"_s)); m_actionSplitHorizontal->setData(LayoutInfo::HSplitter); m_actionSplitHorizontal->setEnabled(false); connect(m_actionSplitHorizontal, &QAction::triggered, this, &FormWindowManager::createLayout); - m_actionSplitVertical = new QAction(createIconSet(QStringLiteral("editvlayoutsplit.png")), + m_actionSplitVertical = new QAction(createIconSet(u"editvlayoutsplit.png"_s), tr("Lay Out Vertically in Sp&litter"), this); - m_actionSplitVertical->setObjectName(QStringLiteral("__qt_split_vertical_action")); + m_actionSplitVertical->setObjectName(u"__qt_split_vertical_action"_s); m_actionSplitVertical->setShortcut(Qt::CTRL | Qt::Key_4); m_actionSplitVertical->setStatusTip(tr("Lays out the selected widgets vertically in a splitter")); - m_actionSplitVertical->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Lay Out Vertically in Splitter"))); + m_actionSplitVertical->setWhatsThis(whatsThisFrom(u"Layout|Lay Out Vertically in Splitter"_s)); connect(m_actionSplitVertical, &QAction::triggered, this, &FormWindowManager::createLayout); m_actionSplitVertical->setData(LayoutInfo::VSplitter); m_actionSplitVertical->setEnabled(false); - m_actionBreakLayout = new QAction(createIconSet(QStringLiteral("editbreaklayout.png")), tr("&Break Layout"), this); - m_actionBreakLayout->setObjectName(QStringLiteral("__qt_break_layout_action")); + m_actionBreakLayout = new QAction(createIconSet(u"editbreaklayout.png"_s), + tr("&Break Layout"), this); + m_actionBreakLayout->setObjectName(u"__qt_break_layout_action"_s); m_actionBreakLayout->setShortcut(Qt::CTRL | Qt::Key_0); m_actionBreakLayout->setStatusTip(tr("Breaks the selected layout")); - m_actionBreakLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Break Layout"))); + m_actionBreakLayout->setWhatsThis(whatsThisFrom(u"Layout|Break Layout"_s)); connect(m_actionBreakLayout, &QAction::triggered, this, &FormWindowManager::slotActionBreakLayoutActivated); m_actionBreakLayout->setEnabled(false); m_actionSimplifyLayout = new QAction(tr("Si&mplify Grid Layout"), this); - m_actionSimplifyLayout->setObjectName(QStringLiteral("__qt_simplify_layout_action")); + m_actionSimplifyLayout->setObjectName(u"__qt_simplify_layout_action"_s); m_actionSimplifyLayout->setStatusTip(tr("Removes empty columns and rows")); - m_actionSimplifyLayout->setWhatsThis(whatsThisFrom(QStringLiteral("Layout|Simplify Layout"))); + m_actionSimplifyLayout->setWhatsThis(whatsThisFrom(u"Layout|Simplify Layout"_s)); connect(m_actionSimplifyLayout, &QAction::triggered, this, &FormWindowManager::slotActionSimplifyLayoutActivated); m_actionSimplifyLayout->setEnabled(false); m_actionDefaultPreview = new QAction(tr("&Preview..."), this); - m_actionDefaultPreview->setObjectName(QStringLiteral("__qt_default_preview_action")); + m_actionDefaultPreview->setObjectName(u"__qt_default_preview_action"_s); m_actionDefaultPreview->setStatusTip(tr("Preview current form")); - m_actionDefaultPreview->setWhatsThis(whatsThisFrom(QStringLiteral("Form|Preview"))); + m_actionDefaultPreview->setWhatsThis(whatsThisFrom(u"Form|Preview"_s)); connect(m_actionDefaultPreview, &QAction::triggered, this, &FormWindowManager::showPreview); @@ -493,13 +506,13 @@ void FormWindowManager::setupActions() m_actionUndo = m_undoGroup->createUndoAction(this); m_actionUndo->setEnabled(false); - m_actionUndo->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo"), createIconSet(QStringLiteral("undo.png")))); + m_actionUndo->setIcon(QIcon::fromTheme(u"edit-undo"_s, createIconSet(u"undo.png"_s))); m_actionRedo = m_undoGroup->createRedoAction(this); m_actionRedo->setEnabled(false); - m_actionRedo->setIcon(QIcon::fromTheme(QStringLiteral("edit-redo"), createIconSet(QStringLiteral("redo.png")))); + m_actionRedo->setIcon(QIcon::fromTheme(u"edit-redo"_s, createIconSet(u"redo.png"_s))); m_actionShowFormWindowSettingsDialog = new QAction(tr("Form &Settings..."), this); - m_actionShowFormWindowSettingsDialog->setObjectName(QStringLiteral("__qt_form_settings_action")); + m_actionShowFormWindowSettingsDialog->setObjectName(u"__qt_form_settings_action"_s); connect(m_actionShowFormWindowSettingsDialog, &QAction::triggered, this, &FormWindowManager::slotActionShowFormWindowSettingsDialog); m_actionShowFormWindowSettingsDialog->setEnabled(false); diff --git a/src/designer/src/components/formeditor/formwindowsettings.cpp b/src/designer/src/components/formeditor/formwindowsettings.cpp index 8df4b93ee..e1206cca6 100644 --- a/src/designer/src/components/formeditor/formwindowsettings.cpp +++ b/src/designer/src/components/formeditor/formwindowsettings.cpp @@ -16,6 +16,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // Data structure containing form dialog data providing comparison @@ -189,7 +191,7 @@ FormWindowData FormWindowSettings::data() const if (!hints.isEmpty()) { rc.includeHints = hints.split(QLatin1Char('\n')); // Purge out any lines consisting of blanks only - const QRegularExpression blankLine(QStringLiteral("^\\s*$")); + const QRegularExpression blankLine(u"^\\s*$"_s); Q_ASSERT(blankLine.isValid()); rc.includeHints.erase(std::remove_if(rc.includeHints.begin(), rc.includeHints.end(), [blankLine](const QString &hint){ return blankLine.match(hint).hasMatch(); }), diff --git a/src/designer/src/components/formeditor/itemview_propertysheet.cpp b/src/designer/src/components/formeditor/itemview_propertysheet.cpp index 76bc9cc64..f750b087f 100644 --- a/src/designer/src/components/formeditor/itemview_propertysheet.cpp +++ b/src/designer/src/components/formeditor/itemview_propertysheet.cpp @@ -11,6 +11,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { struct Property { @@ -116,7 +118,7 @@ ItemViewPropertySheet::ItemViewPropertySheet(QTreeView *treeViewObject, QObject : QDesignerPropertySheet(treeViewObject, parent), d(new ItemViewPropertySheetPrivate(core(), treeViewObject->header(), nullptr)) { - initHeaderProperties(treeViewObject->header(), QStringLiteral("header")); + initHeaderProperties(treeViewObject->header(), u"header"_s); } ItemViewPropertySheet::ItemViewPropertySheet(QTableView *tableViewObject, QObject *parent) @@ -125,8 +127,8 @@ ItemViewPropertySheet::ItemViewPropertySheet(QTableView *tableViewObject, QObjec tableViewObject->horizontalHeader(), tableViewObject->verticalHeader())) { - initHeaderProperties(tableViewObject->horizontalHeader(), QStringLiteral("horizontalHeader")); - initHeaderProperties(tableViewObject->verticalHeader(), QStringLiteral("verticalHeader")); + initHeaderProperties(tableViewObject->horizontalHeader(), u"horizontalHeader"_s); + initHeaderProperties(tableViewObject->verticalHeader(), u"verticalHeader"_s); } ItemViewPropertySheet::~ItemViewPropertySheet() diff --git a/src/designer/src/components/formeditor/layout_propertysheet.cpp b/src/designer/src/components/formeditor/layout_propertysheet.cpp index 2f07f3596..e26db101d 100644 --- a/src/designer/src/components/formeditor/layout_propertysheet.cpp +++ b/src/designer/src/components/formeditor/layout_propertysheet.cpp @@ -23,6 +23,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #define USE_LAYOUT_SIZE_CONSTRAINT static const char *leftMargin = "leftMargin"; @@ -67,7 +69,7 @@ namespace { static bool isIntegerList(const QString &s) { // Check for empty string or comma-separated list of integers - static const QRegularExpression re(QStringLiteral("^[0-9]+(,[0-9]+)+$")); + static const QRegularExpression re(u"^[0-9]+(,[0-9]+)+$"_s); Q_ASSERT(re.isValid()); return s.isEmpty() || re.match(s).hasMatch(); } @@ -150,7 +152,7 @@ namespace qdesigner_internal { LayoutPropertySheet::LayoutPropertySheet(QLayout *l, QObject *parent) : QDesignerPropertySheet(l, parent), m_layout(l) { - const QString layoutGroup = QStringLiteral("Layout"); + const QString layoutGroup = u"Layout"_s; int pindex = createFakeProperty(QLatin1String(leftMargin), 0); setPropertyGroup(pindex, layoutGroup); diff --git a/src/designer/src/components/formeditor/line_propertysheet.cpp b/src/designer/src/components/formeditor/line_propertysheet.cpp index ebf228f4b..b155e78db 100644 --- a/src/designer/src/components/formeditor/line_propertysheet.cpp +++ b/src/designer/src/components/formeditor/line_propertysheet.cpp @@ -13,6 +13,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { LinePropertySheet::LinePropertySheet(Line *object, QObject *parent) @@ -27,7 +29,7 @@ bool LinePropertySheet::isVisible(int index) const { const QString name = propertyName(index); - if (name == QStringLiteral("frameShape")) + if (name == "frameShape"_L1) return false; return QDesignerPropertySheet::isVisible(index); } diff --git a/src/designer/src/components/formeditor/previewactiongroup.cpp b/src/designer/src/components/formeditor/previewactiongroup.cpp index 5d914d455..abcf0b8bd 100644 --- a/src/designer/src/components/formeditor/previewactiongroup.cpp +++ b/src/designer/src/components/formeditor/previewactiongroup.cpp @@ -11,6 +11,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + enum { MaxDeviceActions = 20 }; namespace qdesigner_internal { @@ -25,22 +27,17 @@ PreviewActionGroup::PreviewActionGroup(QDesignerFormEditorInterface *core, QObje connect(this, &PreviewActionGroup::triggered, this, &PreviewActionGroup::slotTriggered); setExclusive(true); - const QString objNamePostfix = QStringLiteral("_action"); // Create invisible actions for devices. Set index as action data. - QString objNamePrefix = QStringLiteral("__qt_designer_device_"); for (int i = 0; i < MaxDeviceActions; i++) { QAction *a = new QAction(this); - QString objName = objNamePrefix; - objName += QString::number(i); - objName += objNamePostfix; - a->setObjectName(objName); + a->setObjectName(QString::asprintf("__qt_designer_device_%d_action", i)); a->setVisible(false); a->setData(i); addAction(a); } // Create separator at index MaxDeviceActions QAction *sep = new QAction(this); - sep->setObjectName(QStringLiteral("__qt_designer_deviceseparator")); + sep->setObjectName(u"__qt_designer_deviceseparator"_s); sep->setSeparator(true); sep->setVisible(false); addAction(sep); @@ -50,14 +47,10 @@ PreviewActionGroup::PreviewActionGroup(QDesignerFormEditorInterface *core, QObje // Add style actions const QStringList styles = QStyleFactory::keys(); // Make sure ObjectName is unique in case toolbar solution is used. - objNamePrefix = QStringLiteral("__qt_designer_style_"); // Create styles. Set style name string as action data. for (const auto &s : styles) { QAction *a = new QAction(tr("%1 Style").arg(s), this); - QString objName = objNamePrefix; - objName += s; - objName += objNamePostfix; - a->setObjectName(objName); + a->setObjectName("__qt_designer_style_"_L1 + s + "_action"_L1); a->setData(s); addAction(a); } diff --git a/src/designer/src/components/formeditor/qdesigner_resource.cpp b/src/designer/src/components/formeditor/qdesigner_resource.cpp index c04c39bec..d63f36c3c 100644 --- a/src/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/src/designer/src/components/formeditor/qdesigner_resource.cpp @@ -83,6 +83,8 @@ Q_DECLARE_METATYPE(QWidgetList) QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { using DomPropertyList = QList<DomProperty *>; } @@ -318,7 +320,7 @@ inline void translationParametersToDom(const PropertySheetTranslatableData &data if (!id.isEmpty()) e->setAttributeId(id); if (!data.translatable()) - e->setAttributeNotr(QStringLiteral("true")); + e->setAttributeNotr(u"true"_s); } template <class DomElement> // for DomString, potentially DomStringList @@ -332,7 +334,7 @@ inline void translationParametersFromDom(const DomElement *e, PropertySheetTrans data->setId(e->attributeId()); if (e->hasAttributeNotr()) { const QString notr = e->attributeNotr(); - const bool translatable = !(notr == QStringLiteral("true") || notr == QStringLiteral("yes")); + const bool translatable = !(notr == "true"_L1 || notr == "yes"_L1); data->setTranslatable(translatable); } } @@ -414,15 +416,15 @@ QDesignerResource::QDesignerResource(FormWindow *formWindow) : setTextBuilder(new QDesignerTextBuilder()); // ### generalise - const QString designerWidget = QStringLiteral("QDesignerWidget"); - const QString layoutWidget = QStringLiteral("QLayoutWidget"); - const QString widget = QStringLiteral("QWidget"); + const QString designerWidget = u"QDesignerWidget"_s; + const QString layoutWidget = u"QLayoutWidget"_s; + const QString widget = u"QWidget"_s; m_internal_to_qt.insert(layoutWidget, widget); m_internal_to_qt.insert(designerWidget, widget); - m_internal_to_qt.insert(QStringLiteral("QDesignerDialog"), QStringLiteral("QDialog")); - m_internal_to_qt.insert(QStringLiteral("QDesignerMenuBar"), QStringLiteral("QMenuBar")); - m_internal_to_qt.insert(QStringLiteral("QDesignerMenu"), QStringLiteral("QMenu")); - m_internal_to_qt.insert(QStringLiteral("QDesignerDockWidget"), QStringLiteral("QDockWidget")); + m_internal_to_qt.insert(u"QDesignerDialog"_s, u"QDialog"_s); + m_internal_to_qt.insert(u"QDesignerMenuBar"_s, u"QMenuBar"_s); + m_internal_to_qt.insert(u"QDesignerMenu"_s, u"QMenu"_s); + m_internal_to_qt.insert(u"QDesignerDockWidget"_s, u"QDockWidget"_s); // invert QHash<QString, QString>::const_iterator cend = m_internal_to_qt.constEnd(); @@ -457,7 +459,7 @@ void QDesignerResource::saveDom(DomUI *ui, QWidget *widget) QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), widget); Q_ASSERT(sheet != nullptr); - const QVariant classVar = sheet->property(sheet->indexOf(QStringLiteral("objectName"))); + const QVariant classVar = sheet->property(sheet->indexOf(u"objectName"_s)); QString classStr; if (classVar.canConvert<QString>()) classStr = classVar.toString(); @@ -507,8 +509,8 @@ void QDesignerResource::saveDom(DomUI *ui, QWidget *widget) } if (!m_formWindow->includeHints().isEmpty()) { - const QString local = QStringLiteral("local"); - const QString global = QStringLiteral("global"); + const QString local = u"local"_s; + const QString global = u"global"_s; QList<DomInclude *> ui_includes; const QStringList &includeHints = m_formWindow->includeHints(); ui_includes.reserve(includeHints.size()); @@ -659,7 +661,7 @@ QWidget *QDesignerResource::create(DomUI *ui, QWidget *parentWidget) } if (DomIncludes *includes = ui->elementIncludes()) { - const QString global = QStringLiteral("global"); + const auto global = "global"_L1; QStringList includeHints; const auto &elementInclude = includes->elementInclude(); for (DomInclude *incl : elementInclude) { @@ -713,9 +715,8 @@ QWidget *QDesignerResource::create(DomUI *ui, QWidget *parentWidget) bool hasExplicitGeometry = false; const auto &properties = ui->elementWidget()->elementProperty(); if (!properties.isEmpty()) { - const QString geometry = QStringLiteral("geometry"); for (const DomProperty *p : properties) { - if (p->attributeName() == geometry) { + if (p->attributeName() == "geometry"_L1) { hasExplicitGeometry = true; break; } @@ -757,7 +758,7 @@ 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") + if (!m_isMainWidget && className == "QWidget"_L1 && !ui_widget->elementLayout().isEmpty() && !ui_widget->hasAttributeNative()) { // ### check if elementLayout.size() == 1 @@ -766,7 +767,7 @@ QWidget *QDesignerResource::create(DomWidget *ui_widget, QWidget *parentWidget) if (container == nullptr) { // generate a QLayoutWidget iff the parent is not an QDesignerContainerExtension. - ui_widget->setAttributeClass(QStringLiteral("QLayoutWidget")); + ui_widget->setAttributeClass(u"QLayoutWidget"_s); } } @@ -791,7 +792,7 @@ QWidget *QDesignerResource::create(DomWidget *ui_widget, QWidget *parentWidget) for (DomActionRef *ui_action_ref : actionRefs) { const QString name = ui_action_ref->attributeName(); - if (name == QStringLiteral("separator")) { + if (name == "separator"_L1) { QAction *sep = new QAction(w); sep->setSeparator(true); w->addAction(sep); @@ -837,7 +838,7 @@ QLayoutItem *QDesignerResource::create(DomLayoutItem *ui_layoutItem, QLayout *la { if (ui_layoutItem->kind() == DomLayoutItem::Spacer) { const DomSpacer *domSpacer = ui_layoutItem->elementSpacer(); - Spacer *spacer = static_cast<Spacer*>(core()->widgetFactory()->createWidget(QStringLiteral("Spacer"), parentWidget)); + Spacer *spacer = static_cast<Spacer*>(core()->widgetFactory()->createWidget(u"Spacer"_s, parentWidget)); if (domSpacer->hasAttributeName()) changeObjectName(spacer, domSpacer->attributeName()); core()->metaDataBase()->add(spacer); @@ -849,7 +850,7 @@ QLayoutItem *QDesignerResource::create(DomLayoutItem *ui_layoutItem, QLayout *la if (m_formWindow) { m_formWindow->manageWidget(spacer); if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), spacer)) - sheet->setChanged(sheet->indexOf(QStringLiteral("orientation")), true); + sheet->setChanged(sheet->indexOf(u"orientation"_s), true); } return new QWidgetItem(spacer); @@ -946,7 +947,6 @@ void QDesignerResource::applyProperties(QObject *o, const QList<DomProperty*> &p QDesignerDynamicPropertySheetExtension *dynamicSheet = qt_extension<QDesignerDynamicPropertySheetExtension*>(core()->extensionManager(), o); const bool dynamicPropertiesAllowed = dynamicSheet && dynamicSheet->dynamicPropertiesAllowed(); - const QString objectNameProperty = QStringLiteral("objectName"); for (DomProperty *p : properties) { if (isDeprecatedQt5Property(o, p)) // ### fixme Qt 7 remove this continue; // ### fixme Qt 7 remove this: Exclude deprecated value of Qt 5. @@ -1015,7 +1015,7 @@ void QDesignerResource::applyProperties(QObject *o, const QList<DomProperty*> &p } } - if (propertyName == objectNameProperty) + if (propertyName == "objectName"_L1) changeObjectName(o, o->objectName()); } } @@ -1132,9 +1132,8 @@ DomWidget *QDesignerResource::createDom(QWidget *widget, DomWidget *ui_parentWid Q_ASSERT( w != nullptr ); - if (!qobject_cast<QLayoutWidget*>(widget) && w->attributeClass() == QStringLiteral("QWidget")) { + if (!qobject_cast<QLayoutWidget*>(widget) && w->attributeClass() == "QWidget"_L1) w->setAttributeNative(true); - } const QString className = w->attributeClass(); if (m_internal_to_qt.contains(className)) @@ -1147,7 +1146,7 @@ DomWidget *QDesignerResource::createDom(QWidget *widget, DomWidget *ui_parentWid const auto &prop_list = w->elementProperty(); for (DomProperty *prop : prop_list) { - if (prop->attributeName() == QStringLiteral("geometry")) { + if (prop->attributeName() == "geometry"_L1) { if (DomRect *rect = prop->elementRect()) { rect->setElementX(widget->x()); rect->setElementY(widget->y()); @@ -1337,12 +1336,12 @@ DomWidget *QDesignerResource::saveWidget(QToolBar *toolBar, DomWidget *ui_parent auto attributes = ui_widget->elementAttribute(); DomProperty *attr = new DomProperty(); - attr->setAttributeName(QStringLiteral("toolBarArea")); + attr->setAttributeName(u"toolBarArea"_s); attr->setElementEnum(QLatin1String(toolBarAreaMetaEnum().valueToKey(area))); attributes << attr; attr = new DomProperty(); - attr->setAttributeName(QStringLiteral("toolBarBreak")); + attr->setAttributeName(u"toolBarBreak"_s); attr->setElementBool(toolBarBreak ? QLatin1String("true") : QLatin1String("false")); attributes << attr; ui_widget->setElementAttribute(attributes); @@ -1357,7 +1356,7 @@ DomWidget *QDesignerResource::saveWidget(QDesignerDockWidget *dockWidget, DomWid if (QMainWindow *mainWindow = qobject_cast<QMainWindow*>(dockWidget->parentWidget())) { const Qt::DockWidgetArea area = mainWindow->dockWidgetArea(dockWidget); DomProperty *attr = new DomProperty(); - attr->setAttributeName(QStringLiteral("dockWidgetArea")); + attr->setAttributeName(u"dockWidgetArea"_s); attr->setElementNumber(int(area)); ui_widget->setElementAttribute(ui_widget->elementAttribute() << attr); } @@ -1387,21 +1386,21 @@ DomWidget *QDesignerResource::saveWidget(QTabWidget *widget, DomWidget *ui_paren // attribute `icon' widget->setCurrentIndex(i); QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), widget); - PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(QStringLiteral("currentTabIcon")))); + PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(u"currentTabIcon"_s))); DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), QVariant::fromValue(icon)); if (p) { p->setAttributeName(strings.iconAttribute); ui_attribute_list.append(p); } // attribute `title' - p = textBuilder()->saveText(sheet->property(sheet->indexOf(QStringLiteral("currentTabText")))); + p = textBuilder()->saveText(sheet->property(sheet->indexOf(u"currentTabText"_s))); if (p) { p->setAttributeName(strings.titleAttribute); ui_attribute_list.append(p); } // attribute `toolTip' - QVariant v = sheet->property(sheet->indexOf(QStringLiteral("currentTabToolTip"))); + QVariant v = sheet->property(sheet->indexOf(u"currentTabToolTip"_s)); if (!qvariant_cast<PropertySheetStringValue>(v).value().isEmpty()) { p = textBuilder()->saveText(v); if (p) { @@ -1411,7 +1410,7 @@ DomWidget *QDesignerResource::saveWidget(QTabWidget *widget, DomWidget *ui_paren } // attribute `whatsThis' - v = sheet->property(sheet->indexOf(QStringLiteral("currentTabWhatsThis"))); + v = sheet->property(sheet->indexOf(u"currentTabWhatsThis"_s)); if (!qvariant_cast<PropertySheetStringValue>(v).value().isEmpty()) { p = textBuilder()->saveText(v); if (p) { @@ -1457,20 +1456,20 @@ DomWidget *QDesignerResource::saveWidget(QToolBox *widget, DomWidget *ui_parentW // attribute `icon' widget->setCurrentIndex(i); QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), widget); - PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(QStringLiteral("currentItemIcon")))); + PropertySheetIconValue icon = qvariant_cast<PropertySheetIconValue>(sheet->property(sheet->indexOf(u"currentItemIcon"_s))); DomProperty *p = resourceBuilder()->saveResource(workingDirectory(), QVariant::fromValue(icon)); if (p) { p->setAttributeName(strings.iconAttribute); ui_attribute_list.append(p); } - p = textBuilder()->saveText(sheet->property(sheet->indexOf(QStringLiteral("currentItemText")))); + p = textBuilder()->saveText(sheet->property(sheet->indexOf(u"currentItemText"_s))); if (p) { p->setAttributeName(strings.labelAttribute); ui_attribute_list.append(p); } // attribute `toolTip' - QVariant v = sheet->property(sheet->indexOf(QStringLiteral("currentItemToolTip"))); + QVariant v = sheet->property(sheet->indexOf(u"currentItemToolTip"_s)); if (!qvariant_cast<PropertySheetStringValue>(v).value().isEmpty()) { p = textBuilder()->saveText(v); if (p) { @@ -1501,7 +1500,7 @@ DomWidget *QDesignerResource::saveWidget(QWizardPage *wizardPage, DomWidget *ui_ if (pageIdIndex != -1 && sheet->isChanged(pageIdIndex)) { DomProperty *property = variantToDomProperty(this, wizardPage->metaObject(), pageIdPropertyName, sheet->property(pageIdIndex)); Q_ASSERT(property); - property->elementString()->setAttributeNotr(QStringLiteral("true")); + property->elementString()->setAttributeNotr(u"true"_s); DomPropertyList attributes = ui_widget->elementAttribute(); attributes.push_back(property); ui_widget->setElementAttribute(attributes); @@ -1531,14 +1530,14 @@ bool QDesignerResource::checkProperty(QObject *obj, const QString &prop) const if (pindex != -1 && !meta->property(pindex)->attributes().testFlag(QDesignerMetaPropertyInterface::StoredAttribute)) return false; - if (prop == QStringLiteral("objectName") || prop == QStringLiteral("spacerName")) // ### don't store the property objectName + if (prop == "objectName"_L1 || prop == "spacerName"_L1) // ### don't store the property objectName return false; QWidget *check_widget = nullptr; if (obj->isWidgetType()) check_widget = static_cast<QWidget*>(obj); - if (check_widget && prop == QStringLiteral("geometry")) { + if (check_widget && prop == "geometry"_L1) { if (check_widget == m_formWindow->mainContainer()) return true; // Save although maincontainer is technically laid-out by embedding container if (m_selected && m_selected == check_widget) @@ -1610,19 +1609,19 @@ bool QDesignerResource::addItem(DomWidget *ui_widget, QWidget *widget, QWidget * QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), parentWidget); if (DomProperty *picon = attributes.value(strings.iconAttribute)) { QVariant v = resourceBuilder()->loadResource(workingDirectory(), picon); - sheet->setProperty(sheet->indexOf(QStringLiteral("currentTabIcon")), v); + sheet->setProperty(sheet->indexOf(u"currentTabIcon"_s), v); } if (DomProperty *ptext = attributes.value(strings.titleAttribute)) { QVariant v = textBuilder()->loadText(ptext); - sheet->setProperty(sheet->indexOf(QStringLiteral("currentTabText")), v); + sheet->setProperty(sheet->indexOf(u"currentTabText"_s), v); } if (DomProperty *ptext = attributes.value(strings.toolTipAttribute)) { QVariant v = textBuilder()->loadText(ptext); - sheet->setProperty(sheet->indexOf(QStringLiteral("currentTabToolTip")), v); + sheet->setProperty(sheet->indexOf(u"currentTabToolTip"_s), v); } if (DomProperty *ptext = attributes.value(strings.whatsThisAttribute)) { QVariant v = textBuilder()->loadText(ptext); - sheet->setProperty(sheet->indexOf(QStringLiteral("currentTabWhatsThis")), v); + sheet->setProperty(sheet->indexOf(u"currentTabWhatsThis"_s), v); } tabWidget->setCurrentIndex(current); } else if (QToolBox *toolBox = qobject_cast<QToolBox*>(parentWidget)) { @@ -1637,15 +1636,15 @@ bool QDesignerResource::addItem(DomWidget *ui_widget, QWidget *widget, QWidget * QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), parentWidget); if (DomProperty *picon = attributes.value(strings.iconAttribute)) { QVariant v = resourceBuilder()->loadResource(workingDirectory(), picon); - sheet->setProperty(sheet->indexOf(QStringLiteral("currentItemIcon")), v); + sheet->setProperty(sheet->indexOf(u"currentItemIcon"_s), v); } if (DomProperty *ptext = attributes.value(strings.labelAttribute)) { QVariant v = textBuilder()->loadText(ptext); - sheet->setProperty(sheet->indexOf(QStringLiteral("currentItemText")), v); + sheet->setProperty(sheet->indexOf(u"currentItemText"_s), v); } if (DomProperty *ptext = attributes.value(strings.toolTipAttribute)) { QVariant v = textBuilder()->loadText(ptext); - sheet->setProperty(sheet->indexOf(QStringLiteral("currentItemToolTip")), v); + sheet->setProperty(sheet->indexOf(u"currentItemToolTip"_s), v); } toolBox->setCurrentIndex(current); } @@ -1774,10 +1773,9 @@ FormBuilderClipboard QDesignerResource::paste(QIODevice *dev, QWidget *widgetPar QXmlStreamReader reader(dev); bool uiInitialized = false; - const QString uiElement = QStringLiteral("ui"); while (!reader.atEnd()) { if (reader.readNext() == QXmlStreamReader::StartElement) { - if (reader.name().compare(uiElement, Qt::CaseInsensitive)) { + if (reader.name().compare("ui"_L1, Qt::CaseInsensitive)) { ui.read(reader); uiInitialized = true; } else { @@ -1823,8 +1821,6 @@ DomCustomWidgets *QDesignerResource::saveCustomWidgets() typedef QMap<int,DomCustomWidget*> OrderedDBIndexDomCustomWidgetMap; OrderedDBIndexDomCustomWidgetMap orderedMap; - const QString global = QStringLiteral("global"); - for (auto it = m_usedCustomWidgets.cbegin(), end = m_usedCustomWidgets.cend(); it != end; ++it) { QDesignerWidgetDataBaseItemInterface *item = it.key(); const QString name = item->name(); @@ -1839,7 +1835,7 @@ DomCustomWidgets *QDesignerResource::saveCustomWidgets() const IncludeSpecification spec = includeSpecification(item->includeFile()); header->setText(spec.first); if (spec.second == IncludeGlobal) { - header->setAttributeLocation(global); + header->setAttributeLocation(u"global"_s); } custom_widget->setElementHeader(header); custom_widget->setElementExtends(item->extends()); @@ -1872,8 +1868,8 @@ bool QDesignerResource::canCompressSpacings(QObject *object) const { if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), object)) { if (qobject_cast<QGridLayout *>(object)) { - const int h = sheet->property(sheet->indexOf(QStringLiteral("horizontalSpacing"))).toInt(); - const int v = sheet->property(sheet->indexOf(QStringLiteral("verticalSpacing"))).toInt(); + const int h = sheet->property(sheet->indexOf(u"horizontalSpacing"_s)).toInt(); + const int v = sheet->property(sheet->indexOf(u"verticalSpacing"_s)).toInt(); if (h == v) return true; } @@ -1895,13 +1891,13 @@ QList<DomProperty*> QDesignerResource::computeProperties(QObject *object) const QString propertyName = sheet->propertyName(index); // Suppress windowModality in legacy forms that have it set on child widgets - if (propertyName == QStringLiteral("windowModality") && !sheet->isVisible(index)) + if (propertyName == "windowModality"_L1 && !sheet->isVisible(index)) continue; const QVariant value = sheet->property(index); if (DomProperty *p = createProperty(object, propertyName, value)) { - if (compressSpacings && (propertyName == QStringLiteral("horizontalSpacing") - || propertyName == QStringLiteral("verticalSpacing"))) { + if (compressSpacings && (propertyName == "horizontalSpacing"_L1 + || propertyName == "verticalSpacing"_L1)) { spacingProperties.append(p); } else { properties.append(p); @@ -1911,7 +1907,7 @@ QList<DomProperty*> QDesignerResource::computeProperties(QObject *object) if (compressSpacings) { if (spacingProperties.size() == 2) { DomProperty *spacingProperty = spacingProperties.at(0); - spacingProperty->setAttributeName(QStringLiteral("spacing")); + spacingProperty->setAttributeName(u"spacing"_s); properties.append(spacingProperty); delete spacingProperties.at(1); } else { diff --git a/src/designer/src/components/formeditor/qlayoutwidget_propertysheet.cpp b/src/designer/src/components/formeditor/qlayoutwidget_propertysheet.cpp index 8d692fca8..78fc443a2 100644 --- a/src/designer/src/components/formeditor/qlayoutwidget_propertysheet.cpp +++ b/src/designer/src/components/formeditor/qlayoutwidget_propertysheet.cpp @@ -12,6 +12,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { QLayoutWidgetPropertySheet::QLayoutWidgetPropertySheet(QLayoutWidget *object, QObject *parent) @@ -24,8 +26,7 @@ QLayoutWidgetPropertySheet::~QLayoutWidgetPropertySheet() = default; bool QLayoutWidgetPropertySheet::isVisible(int index) const { - static const QString layoutPropertyGroup = QStringLiteral("Layout"); - if (propertyGroup(index) == layoutPropertyGroup) + if (propertyGroup(index) == "Layout"_L1) return QDesignerPropertySheet::isVisible(index); return false; } diff --git a/src/designer/src/components/formeditor/qmdiarea_container.cpp b/src/designer/src/components/formeditor/qmdiarea_container.cpp index 617b78057..9400d57d6 100644 --- a/src/designer/src/components/formeditor/qmdiarea_container.cpp +++ b/src/designer/src/components/formeditor/qmdiarea_container.cpp @@ -14,6 +14,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { QMdiAreaContainer::QMdiAreaContainer(QMdiArea *widget, QObject *parent) @@ -109,7 +111,7 @@ static const char *subWindowNameC = "activeSubWindowName"; QMdiAreaPropertySheet::QMdiAreaPropertySheet(QWidget *mdiArea, QObject *parent) : QDesignerPropertySheet(mdiArea, parent), - m_windowTitleProperty(QStringLiteral("windowTitle")) + m_windowTitleProperty(u"windowTitle"_s) { createFakeProperty(QLatin1String(subWindowNameC), QString()); createFakeProperty(QLatin1String(subWindowTitleC), QString()); diff --git a/src/designer/src/components/formeditor/qwizard_container.cpp b/src/designer/src/components/formeditor/qwizard_container.cpp index d4b65b29d..40c8aa024 100644 --- a/src/designer/src/components/formeditor/qwizard_container.cpp +++ b/src/designer/src/components/formeditor/qwizard_container.cpp @@ -12,6 +12,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + using WizardPageList = QList<QWizardPage *>; namespace qdesigner_internal { @@ -168,7 +170,7 @@ bool QWizardPagePropertySheet::reset(int index) // ---------------- QWizardPropertySheet QWizardPropertySheet::QWizardPropertySheet(QWizard *object, QObject *parent) : QDesignerPropertySheet(object, parent), - m_startId(QStringLiteral("startId")) + m_startId(u"startId"_s) { } diff --git a/src/designer/src/components/formeditor/spacer_propertysheet.cpp b/src/designer/src/components/formeditor/spacer_propertysheet.cpp index f2c4fdb14..9c3da1303 100644 --- a/src/designer/src/components/formeditor/spacer_propertysheet.cpp +++ b/src/designer/src/components/formeditor/spacer_propertysheet.cpp @@ -12,6 +12,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { SpacerPropertySheet::SpacerPropertySheet(Spacer *object, QObject *parent) @@ -24,8 +26,7 @@ SpacerPropertySheet::~SpacerPropertySheet() = default; bool SpacerPropertySheet::isVisible(int index) const { - static const QString spacerGroup = QStringLiteral("Spacer"); - return propertyGroup(index) == spacerGroup; + return propertyGroup(index) == "Spacer"_L1; } void SpacerPropertySheet::setProperty(int index, const QVariant &value) diff --git a/src/designer/src/components/formeditor/templateoptionspage.cpp b/src/designer/src/components/formeditor/templateoptionspage.cpp index efd089c84..ca797a663 100644 --- a/src/designer/src/components/formeditor/templateoptionspage.cpp +++ b/src/designer/src/components/formeditor/templateoptionspage.cpp @@ -12,6 +12,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // ----------------- TemplateOptionsWidget diff --git a/src/designer/src/components/formeditor/widgetselection.cpp b/src/designer/src/components/formeditor/widgetselection.cpp index 92d28e5a3..75d8a5fb7 100644 --- a/src/designer/src/components/formeditor/widgetselection.cpp +++ b/src/designer/src/components/formeditor/widgetselection.cpp @@ -33,6 +33,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { enum { debugWidgetSelection = 0 }; @@ -326,7 +328,7 @@ void WidgetHandle::mouseReleaseEvent(QMouseEvent *e) case WidgetSelection::UnlaidOut: if (m_geom != m_widget->geometry()) { SetPropertyCommand *cmd = new SetPropertyCommand(m_formWindow); - cmd->init(m_widget, QStringLiteral("geometry"), m_widget->geometry()); + cmd->init(m_widget, u"geometry"_s, m_widget->geometry()); cmd->setOldValue(m_origGeom); m_formWindow->commandHistory()->push(cmd); m_formWindow->emitSelectionChanged(); diff --git a/src/designer/src/components/lib/qdesigner_components.cpp b/src/designer/src/components/lib/qdesigner_components.cpp index 307b1b618..7409ef53b 100644 --- a/src/designer/src/components/lib/qdesigner_components.cpp +++ b/src/designer/src/components/lib/qdesigner_components.cpp @@ -64,6 +64,8 @@ static void initInstances() QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + /*! \class QDesignerComponents \brief The QDesignerComponents class provides a central resource for the various components @@ -123,8 +125,8 @@ static inline QString widgetBoxFileName(int qtVersion, const QDesignerLanguageEx QString rc; { const QChar dot = QLatin1Char('.'); QTextStream str(&rc); - str << QDir::homePath() << QDir::separator() << QStringLiteral(".designer") << QDir::separator() - << QStringLiteral("widgetbox"); + str << QDir::homePath() << QDir::separator() << ".designer" << QDir::separator() + << "widgetbox"; // The naming convention using the version was introduced with 4.4 const int major = qtMajorVersion(qtVersion); const int minor = qtMinorVersion(qtVersion); @@ -132,7 +134,7 @@ static inline QString widgetBoxFileName(int qtVersion, const QDesignerLanguageEx str << major << dot << minor; if (lang) str << dot << lang->uiExtension(); - str << QStringLiteral(".xml"); + str << ".xml"; } return rc; } @@ -154,7 +156,7 @@ QDesignerWidgetBoxInterface *QDesignerComponents::createWidgetBox(QDesignerFormE } } - widgetBox->setFileName(QStringLiteral(":/qt-project.org/widgetbox/widgetbox.xml")); + widgetBox->setFileName(u":/qt-project.org/widgetbox/widgetbox.xml"_s); widgetBox->load(); } while (false); @@ -209,7 +211,7 @@ QWidget *QDesignerComponents::createResourceEditor(QDesignerFormEditorInterface } QtResourceView *resourceView = new QtResourceView(core, parent); resourceView->setResourceModel(core->resourceModel()); - resourceView->setSettingsKey(QStringLiteral("ResourceBrowser")); + resourceView->setSettingsKey(u"ResourceBrowser"_s); // Note for integrators: make sure you call createResourceEditor() after you instantiated your subclass of designer integration // (designer doesn't do that since by default editing resources is enabled) const QDesignerIntegrationInterface *integration = core->integration(); diff --git a/src/designer/src/components/objectinspector/objectinspectormodel.cpp b/src/designer/src/components/objectinspector/objectinspectormodel.cpp index a02141704..db4747287 100644 --- a/src/designer/src/components/objectinspector/objectinspectormodel.cpp +++ b/src/designer/src/components/objectinspector/objectinspectormodel.cpp @@ -30,6 +30,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { enum { DataRole = 1000 }; } @@ -89,7 +91,7 @@ namespace qdesigner_internal { }; ModelRecursionContext::ModelRecursionContext(QDesignerFormEditorInterface *c, const QString &sepName) : - designerPrefix(QStringLiteral("QDesigner")), + designerPrefix(u"QDesigner"_s), separator(sepName), core(c), db(c->widgetDataBase()), @@ -307,13 +309,13 @@ namespace qdesigner_internal { setColumnCount(NumColumns); setHorizontalHeaderLabels(headers); // Icons - m_icons.layoutIcons[LayoutInfo::NoLayout] = createIconSet(QStringLiteral("editbreaklayout.png")); - m_icons.layoutIcons[LayoutInfo::HSplitter] = createIconSet(QStringLiteral("edithlayoutsplit.png")); - m_icons.layoutIcons[LayoutInfo::VSplitter] = createIconSet(QStringLiteral("editvlayoutsplit.png")); - m_icons.layoutIcons[LayoutInfo::HBox] = createIconSet(QStringLiteral("edithlayout.png")); - m_icons.layoutIcons[LayoutInfo::VBox] = createIconSet(QStringLiteral("editvlayout.png")); - m_icons.layoutIcons[LayoutInfo::Grid] = createIconSet(QStringLiteral("editgrid.png")); - m_icons.layoutIcons[LayoutInfo::Form] = createIconSet(QStringLiteral("editform.png")); + m_icons.layoutIcons[LayoutInfo::NoLayout] = createIconSet(u"editbreaklayout.png"_s); + m_icons.layoutIcons[LayoutInfo::HSplitter] = createIconSet(u"edithlayoutsplit.png"_s); + m_icons.layoutIcons[LayoutInfo::VSplitter] = createIconSet(u"editvlayoutsplit.png"_s); + m_icons.layoutIcons[LayoutInfo::HBox] = createIconSet(u"edithlayout.png"_s); + m_icons.layoutIcons[LayoutInfo::VBox] = createIconSet(u"editvlayout.png"_s); + m_icons.layoutIcons[LayoutInfo::Grid] = createIconSet(u"editgrid.png"_s); + m_icons.layoutIcons[LayoutInfo::Form] = createIconSet(u"editform.png"_s); } void ObjectInspectorModel::clearItems() @@ -452,7 +454,7 @@ namespace qdesigner_internal { if (!object) return false; // Is this a layout widget? - const QString nameProperty = isQLayoutWidget(object) ? QStringLiteral("layoutName") : QStringLiteral("objectName"); + const QString nameProperty = isQLayoutWidget(object) ? u"layoutName"_s : u"objectName"_s; m_formWindow->commandHistory()->push(createTextPropertyCommand(nameProperty, value.toString(), object, m_formWindow)); return true; } diff --git a/src/designer/src/components/propertyeditor/brushpropertymanager.cpp b/src/designer/src/components/propertyeditor/brushpropertymanager.cpp index d3bdd5d8f..db5374f92 100644 --- a/src/designer/src/components/propertyeditor/brushpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/brushpropertymanager.cpp @@ -30,6 +30,8 @@ QT_TRANSLATE_NOOP("BrushPropertyManager", "Crossing diagonal"), QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { BrushPropertyManager::BrushPropertyManager() = default; @@ -129,8 +131,8 @@ void BrushPropertyManager::initializeProperty(QtVariantPropertyManager *vm, QtPr QStringList styles; for (const char *brushStyle : brushStyles) styles.push_back(QCoreApplication::translate("BrushPropertyManager", brushStyle)); - styleSubProperty->setAttribute(QStringLiteral("enumNames"), styles); - styleSubProperty->setAttribute(QStringLiteral("enumIcons"), QVariant::fromValue(brushStyleIcons())); + styleSubProperty->setAttribute(u"enumNames"_s, styles); + styleSubProperty->setAttribute(u"enumIcons"_s, QVariant::fromValue(brushStyleIcons())); m_brushPropertyToStyleSubProperty.insert(property, styleSubProperty); m_brushStyleSubPropertyToProperty.insert(styleSubProperty, property); // color diff --git a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp index ee67c0826..ca852e5ce 100644 --- a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp @@ -46,6 +46,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static const char *resettableAttributeC = "resettable"; static const char *flagsAttributeC = "flags"; static const char *validationModesAttributeC = "validationMode"; @@ -415,7 +417,7 @@ void TextEditor::buttonClicked() } break; case ValidationURL: - if (oldText.isEmpty() || oldText.startsWith(QStringLiteral("qrc:"))) + if (oldText.isEmpty() || oldText.startsWith("qrc:"_L1)) resourceActionActivated(); else fileActionActivated(); @@ -432,7 +434,7 @@ void TextEditor::buttonClicked() void TextEditor::resourceActionActivated() { QString oldPath = m_editor->text(); - if (oldPath.startsWith(QStringLiteral("qrc:"))) + if (oldPath.startsWith("qrc:"_L1)) oldPath.remove(0, 4); // returns ':/file' QString newPath = IconSelector::choosePixmapResource(m_core, m_core->resourceModel(), oldPath, this); @@ -440,7 +442,7 @@ void TextEditor::resourceActionActivated() newPath.remove(0, 1); if (newPath.isEmpty() || newPath == oldPath) return; - const QString newText = QStringLiteral("qrc:") + newPath; + const QString newText = "qrc:"_L1 + newPath; m_editor->setText(newText); emit textChanged(newText); } @@ -448,7 +450,7 @@ void TextEditor::resourceActionActivated() void TextEditor::fileActionActivated() { QString oldPath = m_editor->text(); - if (oldPath.startsWith(QStringLiteral("file:"))) + if (oldPath.startsWith("file:"_L1)) oldPath = oldPath.mid(5); const QString newPath = m_core->dialogGui()->getOpenFileName(this, tr("Choose a File"), oldPath); if (newPath.isEmpty() || newPath == oldPath) @@ -562,8 +564,8 @@ PixmapEditor::PixmapEditor(QDesignerFormEditorInterface *core, QWidget *parent) m_resourceAction(new QAction(tr("Choose Resource..."), this)), m_fileAction(new QAction(tr("Choose File..."), this)), m_themeAction(new QAction(tr("Set Icon From Theme..."), this)), - m_copyAction(new QAction(createIconSet(QStringLiteral("editcopy.png")), tr("Copy Path"), this)), - m_pasteAction(new QAction(createIconSet(QStringLiteral("editpaste.png")), tr("Paste Path"), this)), + m_copyAction(new QAction(createIconSet(u"editcopy.png"_s), tr("Copy Path"), this)), + m_pasteAction(new QAction(createIconSet(u"editpaste.png"_s), tr("Paste Path"), this)), m_layout(new QHBoxLayout(this)), m_pixmapCache(nullptr) { @@ -738,7 +740,7 @@ void PixmapEditor::copyActionActivated() void PixmapEditor::pasteActionActivated() { QClipboard *clipboard = QApplication::clipboard(); - QString subtype = QStringLiteral("plain"); + QString subtype = u"plain"_s; QString text = clipboard->text(subtype); if (!text.isNull()) { QStringList list = text.split(QLatin1Char('\n')); @@ -760,7 +762,7 @@ void PixmapEditor::pasteActionActivated() void PixmapEditor::clipboardDataChanged() { QClipboard *clipboard = QApplication::clipboard(); - QString subtype = QStringLiteral("plain"); + QString subtype = u"plain"_s; const QString text = clipboard->text(subtype); m_pasteAction->setEnabled(!text.isNull()); } @@ -801,7 +803,7 @@ ResetWidget::ResetWidget(QtProperty *property, QWidget *parent) : m_textLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed)); m_iconLabel->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); m_button->setToolButtonStyle(Qt::ToolButtonIconOnly); - m_button->setIcon(createIconSet(QStringLiteral("resetproperty.png"))); + m_button->setIcon(createIconSet(u"resetproperty.png"_s)); m_button->setIconSize(QSize(8,8)); m_button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding)); connect(m_button, &QAbstractButton::clicked, this, &ResetWidget::slotClicked); @@ -1466,7 +1468,7 @@ int DesignerPropertyManager::designerKeySequenceTypeId() QString DesignerPropertyManager::alignDefaultAttribute() { - return QStringLiteral("alignDefault"); + return u"alignDefault"_s; } uint DesignerPropertyManager::alignDefault(const QtVariantProperty *prop) @@ -2047,7 +2049,7 @@ void DesignerPropertyManager::initializeProperty(QtProperty *property) QtVariantProperty *alignH = addProperty(enumTypeId(), tr("Horizontal")); QStringList namesH; namesH << indexHToString(0) << indexHToString(1) << indexHToString(2) << indexHToString(3); - alignH->setAttribute(QStringLiteral("enumNames"), namesH); + alignH->setAttribute(u"enumNames"_s, namesH); alignH->setValue(alignToIndexH(align)); m_propertyToAlignH[property] = alignH; m_alignHToProperty[alignH] = property; @@ -2056,7 +2058,7 @@ void DesignerPropertyManager::initializeProperty(QtProperty *property) QtVariantProperty *alignV = addProperty(enumTypeId(), tr("Vertical")); QStringList namesV; namesV << indexVToString(0) << indexVToString(1) << indexVToString(2); - alignV->setAttribute(QStringLiteral("enumNames"), namesV); + alignV->setAttribute(u"enumNames"_s, namesV); alignV->setValue(alignToIndexV(align)); m_propertyToAlignV[property] = alignV; m_alignVToProperty[alignV] = property; @@ -2098,7 +2100,7 @@ void DesignerPropertyManager::initializeProperty(QtProperty *property) QtVariantPropertyManager::initializeProperty(property); m_fontManager.postInitializeProperty(this, property, type, DesignerPropertyManager::enumTypeId()); if (type == QMetaType::Double) - setAttribute(property, QStringLiteral("decimals"), 6); + setAttribute(property, u"decimals"_s, 6); } void DesignerPropertyManager::createIconSubProperty(QtProperty *iconProperty, QIcon::Mode mode, QIcon::State state, const QString &subName) diff --git a/src/designer/src/components/propertyeditor/fontpropertymanager.cpp b/src/designer/src/components/propertyeditor/fontpropertymanager.cpp index decea7d58..9ab6954ea 100644 --- a/src/designer/src/components/propertyeditor/fontpropertymanager.cpp +++ b/src/designer/src/components/propertyeditor/fontpropertymanager.cpp @@ -18,6 +18,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { static const char *aliasingC[] = { @@ -85,7 +87,7 @@ namespace qdesigner_internal { QtVariantProperty *antialiasing = vm->addProperty(enumTypeId, QCoreApplication::translate("FontPropertyManager", "Antialiasing")); const QFont font = qvariant_cast<QFont>(vm->variantProperty(property)->value()); - antialiasing->setAttribute(QStringLiteral("enumNames"), m_aliasingEnumNames); + antialiasing->setAttribute(u"enumNames"_s, m_aliasingEnumNames); antialiasing->setValue(antialiasingToIndex(font.styleStrategy())); property->addSubProperty(antialiasing); @@ -95,7 +97,7 @@ namespace qdesigner_internal { if (!m_familyMappings.isEmpty()) { const PropertyToSubPropertiesMap::iterator it = m_propertyToFontSubProperties.find(m_createdFontProperty); QtVariantProperty *familyProperty = vm->variantProperty(it.value().constFirst()); - const QString enumNamesAttribute = QStringLiteral("enumNames"); + const QString enumNamesAttribute = u"enumNames"_s; QStringList plainFamilyNames = familyProperty->attributeValue(enumNamesAttribute).toStringList(); // Did someone load fonts or something? if (m_designerFamilyNames.size() != plainFamilyNames.size()) @@ -291,7 +293,7 @@ namespace qdesigner_internal { bool FontPropertyManager::readFamilyMapping(NameMap *rc, QString *errorMessage) { rc->clear(); - const QString fileName = QStringLiteral(":/qt-project.org/propertyeditor/fontmapping.xml"); + const QString fileName = u":/qt-project.org/propertyeditor/fontmapping.xml"_s; QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { *errorMessage = QString::fromUtf8("Unable to open %1: %2").arg(fileName, file.errorString()); diff --git a/src/designer/src/components/propertyeditor/newdynamicpropertydialog.cpp b/src/designer/src/components/propertyeditor/newdynamicpropertydialog.cpp index 44db7f81d..404540911 100644 --- a/src/designer/src/components/propertyeditor/newdynamicpropertydialog.cpp +++ b/src/designer/src/components/propertyeditor/newdynamicpropertydialog.cpp @@ -10,6 +10,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { NewDynamicPropertyDialog::NewDynamicPropertyDialog(QDesignerDialogGuiInterface *dialogGui, @@ -21,61 +23,61 @@ NewDynamicPropertyDialog::NewDynamicPropertyDialog(QDesignerDialogGuiInterface * m_ui->setupUi(this); connect(m_ui->m_lineEdit, &QLineEdit::textChanged, this, &NewDynamicPropertyDialog::nameChanged); - m_ui->m_comboBox->addItem(QStringLiteral("String"), + m_ui->m_comboBox->addItem(u"String"_s, QVariant(QMetaType(QMetaType::QString))); - m_ui->m_comboBox->addItem(QStringLiteral("StringList"), + m_ui->m_comboBox->addItem(u"StringList"_s, QVariant(QMetaType(QMetaType::QStringList))); - m_ui->m_comboBox->addItem(QStringLiteral("Char"), + m_ui->m_comboBox->addItem(u"Char"_s, QVariant(QMetaType(QMetaType::QChar))); - m_ui->m_comboBox->addItem(QStringLiteral("ByteArray"), + m_ui->m_comboBox->addItem(u"ByteArray"_s, QVariant(QMetaType(QMetaType::QByteArray))); - m_ui->m_comboBox->addItem(QStringLiteral("Url"), + m_ui->m_comboBox->addItem(u"Url"_s, QVariant(QMetaType(QMetaType::QUrl))); - m_ui->m_comboBox->addItem(QStringLiteral("Bool"), + m_ui->m_comboBox->addItem(u"Bool"_s, QVariant(QMetaType(QMetaType::Bool))); - m_ui->m_comboBox->addItem(QStringLiteral("Int"), + m_ui->m_comboBox->addItem(u"Int"_s, QVariant(QMetaType(QMetaType::Int))); - m_ui->m_comboBox->addItem(QStringLiteral("UInt"), + m_ui->m_comboBox->addItem(u"UInt"_s, QVariant(QMetaType(QMetaType::UInt))); - m_ui->m_comboBox->addItem(QStringLiteral("LongLong"), + m_ui->m_comboBox->addItem(u"LongLong"_s, QVariant(QMetaType(QMetaType::LongLong))); - m_ui->m_comboBox->addItem(QStringLiteral("ULongLong"), + m_ui->m_comboBox->addItem(u"ULongLong"_s, QVariant(QMetaType(QMetaType::ULongLong))); - m_ui->m_comboBox->addItem(QStringLiteral("Double"), + m_ui->m_comboBox->addItem(u"Double"_s, QVariant(QMetaType(QMetaType::Double))); - m_ui->m_comboBox->addItem(QStringLiteral("Size"), + m_ui->m_comboBox->addItem(u"Size"_s, QVariant(QMetaType(QMetaType::QSize))); - m_ui->m_comboBox->addItem(QStringLiteral("SizeF"), + m_ui->m_comboBox->addItem(u"SizeF"_s, QVariant(QMetaType(QMetaType::QSizeF))); - m_ui->m_comboBox->addItem(QStringLiteral("Point"), + m_ui->m_comboBox->addItem(u"Point"_s, QVariant(QMetaType(QMetaType::QPoint))); - m_ui->m_comboBox->addItem(QStringLiteral("PointF"), + m_ui->m_comboBox->addItem(u"PointF"_s, QVariant(QMetaType(QMetaType::QPointF))); - m_ui->m_comboBox->addItem(QStringLiteral("Rect"), + m_ui->m_comboBox->addItem(u"Rect"_s, QVariant(QMetaType(QMetaType::QRect))); - m_ui->m_comboBox->addItem(QStringLiteral("RectF"), + m_ui->m_comboBox->addItem(u"RectF"_s, QVariant(QMetaType(QMetaType::QRectF))); - m_ui->m_comboBox->addItem(QStringLiteral("Date"), + m_ui->m_comboBox->addItem(u"Date"_s, QVariant(QMetaType(QMetaType::QDate))); - m_ui->m_comboBox->addItem(QStringLiteral("Time"), + m_ui->m_comboBox->addItem(u"Time"_s, QVariant(QMetaType(QMetaType::QTime))); - m_ui->m_comboBox->addItem(QStringLiteral("DateTime"), + m_ui->m_comboBox->addItem(u"DateTime"_s, QVariant(QMetaType(QMetaType::QDateTime))); - m_ui->m_comboBox->addItem(QStringLiteral("Font"), + m_ui->m_comboBox->addItem(u"Font"_s, QVariant(QMetaType(QMetaType::QFont))); - m_ui->m_comboBox->addItem(QStringLiteral("Palette"), + m_ui->m_comboBox->addItem(u"Palette"_s, QVariant(QMetaType(QMetaType::QPalette))); - m_ui->m_comboBox->addItem(QStringLiteral("Color"), + m_ui->m_comboBox->addItem(u"Color"_s, QVariant(QMetaType(QMetaType::QColor))); - m_ui->m_comboBox->addItem(QStringLiteral("Pixmap"), + m_ui->m_comboBox->addItem(u"Pixmap"_s, QVariant(QMetaType(QMetaType::QPixmap))); - m_ui->m_comboBox->addItem(QStringLiteral("Icon"), + m_ui->m_comboBox->addItem(u"Icon"_s, QVariant(QMetaType(QMetaType::QIcon))); - m_ui->m_comboBox->addItem(QStringLiteral("Cursor"), + m_ui->m_comboBox->addItem(u"Cursor"_s, QVariant(QMetaType(QMetaType::QCursor))); - m_ui->m_comboBox->addItem(QStringLiteral("SizePolicy"), + m_ui->m_comboBox->addItem(u"SizePolicy"_s, QVariant(QMetaType(QMetaType::QSizePolicy))); - m_ui->m_comboBox->addItem(QStringLiteral("KeySequence"), + m_ui->m_comboBox->addItem(u"KeySequence"_s, QVariant(QMetaType(QMetaType::QKeySequence))); m_ui->m_comboBox->setCurrentIndex(0); // String @@ -133,7 +135,7 @@ bool NewDynamicPropertyDialog::validatePropertyName(const QString& name) information(tr("The current object already has a property named '%1'.\nPlease select another, unique one.").arg(name)); return false; } - if (!QDesignerPropertySheet::internalDynamicPropertiesEnabled() && name.startsWith(QStringLiteral("_q_"))) { + if (!QDesignerPropertySheet::internalDynamicPropertiesEnabled() && name.startsWith("_q_"_L1)) { information(tr("The '_q_' prefix is reserved for the Qt library.\nPlease select another name.")); return false; } diff --git a/src/designer/src/components/propertyeditor/paletteeditor.cpp b/src/designer/src/components/propertyeditor/paletteeditor.cpp index c15b3cf01..3ff9c882c 100644 --- a/src/designer/src/components/propertyeditor/paletteeditor.cpp +++ b/src/designer/src/components/propertyeditor/paletteeditor.cpp @@ -36,6 +36,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { enum { BrushRole = 33 }; @@ -255,8 +257,6 @@ void PaletteEditor::viewContextMenuRequested(const QPoint &pos) m_paletteModel->setData(index, QVariant(brush), BrushRole); } -static inline QString paletteSuffix() { return QStringLiteral("xml"); } - static inline QString paletteFilter() { return PaletteEditor::tr("QPalette UI file (*.xml)"); @@ -333,7 +333,7 @@ void PaletteEditor::save() { QFileDialog dialog(this, tr("Save Palette"), QString(), paletteFilter()); dialog.setAcceptMode(QFileDialog::AcceptSave); - dialog.setDefaultSuffix(paletteSuffix()); + dialog.setDefaultSuffix(u"xml"_s); while (dialog.exec() == QDialog::Accepted) { QString errorMessage; if (savePalette(dialog.selectedFiles().constFirst(), palette(), &errorMessage)) @@ -613,7 +613,7 @@ RoleEditor::RoleEditor(QWidget *parent) : QToolButton *button = new QToolButton(this); button->setToolButtonStyle(Qt::ToolButtonIconOnly); - button->setIcon(createIconSet(QStringLiteral("resetproperty.png"))); + button->setIcon(createIconSet(u"resetproperty.png"_s)); button->setIconSize(QSize(8,8)); button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding)); layout->addWidget(button); diff --git a/src/designer/src/components/propertyeditor/propertyeditor.cpp b/src/designer/src/components/propertyeditor/propertyeditor.cpp index eaaa01ed1..751d92342 100644 --- a/src/designer/src/components/propertyeditor/propertyeditor.cpp +++ b/src/designer/src/components/propertyeditor/propertyeditor.cpp @@ -56,6 +56,8 @@ enum SettingsView { TreeView, ButtonView }; QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // --------------------------------------------------------------------------------- namespace qdesigner_internal { @@ -110,20 +112,20 @@ void ElidingLabel::paintEvent(QPaintEvent *) { // ----------- PropertyEditor::Strings PropertyEditor::Strings::Strings() : - m_fontProperty(QStringLiteral("font")), - m_qLayoutWidget(QStringLiteral("QLayoutWidget")), - m_designerPrefix(QStringLiteral("QDesigner")), - m_layout(QStringLiteral("Layout")), - m_validationModeAttribute(QStringLiteral("validationMode")), - m_fontAttribute(QStringLiteral("font")), - m_superPaletteAttribute(QStringLiteral("superPalette")), - m_enumNamesAttribute(QStringLiteral("enumNames")), - m_resettableAttribute(QStringLiteral("resettable")), - m_flagsAttribute(QStringLiteral("flags")) + m_alignmentProperties{u"alignment"_s, + u"layoutLabelAlignment"_s, // QFormLayout + u"layoutFormAlignment"_s}, + m_fontProperty(u"font"_s), + m_qLayoutWidget(u"QLayoutWidget"_s), + m_designerPrefix(u"QDesigner"_s), + m_layout(u"Layout"_s), + m_validationModeAttribute(u"validationMode"_s), + m_fontAttribute(u"font"_s), + m_superPaletteAttribute(u"superPalette"_s), + m_enumNamesAttribute(u"enumNames"_s), + m_resettableAttribute(u"resettable"_s), + m_flagsAttribute(u"flags"_s) { - m_alignmentProperties.insert(QStringLiteral("alignment")); - m_alignmentProperties.insert(QStringLiteral("layoutLabelAlignment")); // QFormLayout - m_alignmentProperties.insert(QStringLiteral("layoutFormAlignment")); } // ----------- PropertyEditor @@ -181,10 +183,10 @@ PropertyEditor::PropertyEditor(QDesignerFormEditorInterface *core, QWidget *pare m_propertyManager(new DesignerPropertyManager(m_core, this)), m_stackedWidget(new QStackedWidget), m_filterWidget(new QLineEdit), - m_addDynamicAction(new QAction(createIconSet(QStringLiteral("plus.png")), tr("Add Dynamic Property..."), this)), - m_removeDynamicAction(new QAction(createIconSet(QStringLiteral("minus.png")), tr("Remove Dynamic Property"), this)), - m_sortingAction(new QAction(createIconSet(QStringLiteral("sort.png")), tr("Sorting"), this)), - m_coloringAction(new QAction(createIconSet(QStringLiteral("color.png")), tr("Color Groups"), this)), + m_addDynamicAction(new QAction(createIconSet(u"plus.png"_s), tr("Add Dynamic Property..."), this)), + m_removeDynamicAction(new QAction(createIconSet(u"minus.png"_s), tr("Remove Dynamic Property"), this)), + m_sortingAction(new QAction(createIconSet(u"sort.png"_s), tr("Sorting"), this)), + m_coloringAction(new QAction(createIconSet(u"color.png"_s), tr("Color Groups"), this)), m_treeAction(new QAction(tr("Tree View"), this)), m_buttonAction(new QAction(tr("Drop Down Button View"), this)), m_classLabel(new ElidingLabel) @@ -205,9 +207,9 @@ PropertyEditor::PropertyEditor(QDesignerFormEditorInterface *core, QWidget *pare QActionGroup *actionGroup = new QActionGroup(this); m_treeAction->setCheckable(true); - m_treeAction->setIcon(createIconSet(QStringLiteral("widgets/listview.png"))); + m_treeAction->setIcon(createIconSet(u"widgets/listview.png"_s)); m_buttonAction->setCheckable(true); - m_buttonAction->setIcon(createIconSet(QStringLiteral("dropdownbutton.png"))); + m_buttonAction->setIcon(createIconSet(u"dropdownbutton.png"_s)); actionGroup->addAction(m_treeAction); actionGroup->addAction(m_buttonAction); @@ -237,7 +239,7 @@ PropertyEditor::PropertyEditor(QDesignerFormEditorInterface *core, QWidget *pare connect(m_removeDynamicAction, &QAction::triggered, this, &PropertyEditor::slotRemoveDynamicProperty); // Configure QAction *configureAction = new QAction(tr("Configure Property Editor"), this); - configureAction->setIcon(createIconSet(QStringLiteral("configure.png"))); + configureAction->setIcon(createIconSet(u"configure.png"_s)); QMenu *configureMenu = new QMenu(this); configureAction->setMenu(configureMenu); @@ -754,7 +756,7 @@ void PropertyEditor::updateToolBarLabel() QString classLabelText; if (!objectName.isEmpty()) - classLabelText += objectName + QStringLiteral(" : "); + classLabelText += objectName + " : "_L1; classLabelText += className; m_classLabel->setText(classLabelText); @@ -794,7 +796,7 @@ void PropertyEditor::updateBrowserValue(QtVariantProperty *property, const QVari m_updatingBrowser = true; property->setValue(v); if (sheet && sheet->isResourceProperty(index)) - property->setAttribute(QStringLiteral("defaultResource"), sheet->defaultResourceProperty(index)); + property->setAttribute(u"defaultResource"_s, sheet->defaultResourceProperty(index)); m_updatingBrowser = false; } @@ -1078,11 +1080,11 @@ void PropertyEditor::setObject(QObject *object) updateBrowserValue(property, value); property->setModified(m_propertySheet->isChanged(i)); - if (propertyName == QStringLiteral("geometry") && type == QMetaType::QRect) { + if (propertyName == "geometry"_L1 && type == QMetaType::QRect) { const auto &subProperties = property->subProperties(); for (QtProperty *subProperty : subProperties) { const QString subPropertyName = subProperty->propertyName(); - if (subPropertyName == QStringLiteral("X") || subPropertyName == QStringLiteral("Y")) + if (subPropertyName == "X"_L1 || subPropertyName == "Y"_L1) subProperty->setEnabled(!isMainContainer); } } diff --git a/src/designer/src/components/signalsloteditor/signalsloteditor.cpp b/src/designer/src/components/signalsloteditor/signalsloteditor.cpp index a0a5bcddc..ce0fb308d 100644 --- a/src/designer/src/components/signalsloteditor/signalsloteditor.cpp +++ b/src/designer/src/components/signalsloteditor/signalsloteditor.cpp @@ -25,6 +25,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { /******************************************************************************* @@ -52,13 +54,13 @@ DomConnection *SignalSlotConnection::toUi() const QPoint tp = endPointPos(EndPoint::Target); DomConnectionHint *hint = new DomConnectionHint; - hint->setAttributeType(QStringLiteral("sourcelabel")); + hint->setAttributeType(u"sourcelabel"_s); hint->setElementX(sp.x()); hint->setElementY(sp.y()); list.append(hint); hint = new DomConnectionHint; - hint->setAttributeType(QStringLiteral("destinationlabel")); + hint->setAttributeType(u"destinationlabel"_s); hint->setElementX(tp.x()); hint->setElementY(tp.y()); list.append(hint); @@ -388,9 +390,9 @@ void SignalSlotEditor::fromUi(const DomConnections *connections, QWidget *parent for (DomConnectionHint *hint : hints) { QString attr_type = hint->attributeType(); QPoint p = QPoint(hint->elementX(), hint->elementY()); - if (attr_type == QStringLiteral("sourcelabel")) + if (attr_type == "sourcelabel"_L1) sp = p; - else if (attr_type == QStringLiteral("destinationlabel")) + else if (attr_type == "destinationlabel"_L1) tp = p; } } @@ -423,13 +425,13 @@ void SignalSlotEditor::fromUi(const DomConnections *connections, QWidget *parent static bool skipWidget(const QWidget *w) { const QString name = QLatin1String(w->metaObject()->className()); - if (name == QStringLiteral("QDesignerWidget")) + if (name == "QDesignerWidget"_L1) return true; - if (name == QStringLiteral("QLayoutWidget")) + if (name == "QLayoutWidget"_L1) return true; - if (name == QStringLiteral("qdesigner_internal::FormWindow")) + if (name == "qdesigner_internal::FormWindow"_L1) return true; - if (name == QStringLiteral("Spacer")) + if (name == "Spacer"_L1) return true; return false; } diff --git a/src/designer/src/components/signalsloteditor/signalsloteditor_plugin.cpp b/src/designer/src/components/signalsloteditor/signalsloteditor_plugin.cpp index 90d373dcd..8b0b1f75a 100644 --- a/src/designer/src/components/signalsloteditor/signalsloteditor_plugin.cpp +++ b/src/designer/src/components/signalsloteditor/signalsloteditor_plugin.cpp @@ -11,6 +11,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { SignalSlotEditorPlugin::SignalSlotEditorPlugin() = default; @@ -27,10 +29,10 @@ void SignalSlotEditorPlugin::initialize(QDesignerFormEditorInterface *core) Q_ASSERT(!isInitialized()); m_action = new QAction(tr("Edit Signals/Slots"), this); - m_action->setObjectName(QStringLiteral("__qt_edit_signals_slots_action")); + m_action->setObjectName(u"__qt_edit_signals_slots_action"_s); m_action->setShortcut(tr("F4")); - QIcon icon = QIcon::fromTheme(QStringLiteral("designer-edit-signals"), - QIcon(core->resourceLocation() + QStringLiteral("/signalslottool.png"))); + QIcon icon = QIcon::fromTheme(u"designer-edit-signals"_s, + QIcon(core->resourceLocation() + "/signalslottool.png"_L1)); m_action->setIcon(icon); m_action->setEnabled(false); diff --git a/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp b/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp index 6ceb07e51..3570f7d96 100644 --- a/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp +++ b/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp @@ -42,6 +42,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // Add suitable form widgets to a list of objects for the signal slot // editor. Prevent special widgets from showing up there. static void addWidgetToObjectList(const QWidget *w, QStringList &r) @@ -682,11 +684,11 @@ SignalSlotEditorWindow::SignalSlotEditorWindow(QDesignerFormEditorInterface *cor QToolBar *toolBar = new QToolBar; toolBar->setIconSize(QSize(22, 22)); - m_add_button->setIcon(createIconSet(QStringLiteral("plus.png"))); + m_add_button->setIcon(createIconSet(u"plus.png"_s)); connect(m_add_button, &QAbstractButton::clicked, this, &SignalSlotEditorWindow::addConnection); toolBar->addWidget(m_add_button); - m_remove_button->setIcon(createIconSet(QStringLiteral("minus.png"))); + m_remove_button->setIcon(createIconSet(u"minus.png"_s)); connect(m_remove_button, &QAbstractButton::clicked, this, &SignalSlotEditorWindow::removeConnection); toolBar->addWidget(m_remove_button); diff --git a/src/designer/src/components/tabordereditor/tabordereditor.cpp b/src/designer/src/components/tabordereditor/tabordereditor.cpp index 797f0f923..e2869decc 100644 --- a/src/designer/src/components/tabordereditor/tabordereditor.cpp +++ b/src/designer/src/components/tabordereditor/tabordereditor.cpp @@ -25,6 +25,8 @@ Q_DECLARE_METATYPE(QWidgetList) QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { enum { VBOX_MARGIN = 1, HBOX_MARGIN = 4, BG_ALPHA = 32 }; } @@ -165,7 +167,7 @@ bool TabOrderEditor::skipWidget(QWidget *w) const QExtensionManager *ext = formWindow()->core()->extensionManager(); if (const QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(ext, w)) { - const int index = sheet->indexOf(QStringLiteral("focusPolicy")); + const int index = sheet->indexOf(u"focusPolicy"_s); if (index != -1) { bool ok = false; Qt::FocusPolicy q = (Qt::FocusPolicy) Utils::valueOf(sheet->property(index), &ok); diff --git a/src/designer/src/components/tabordereditor/tabordereditor_plugin.cpp b/src/designer/src/components/tabordereditor/tabordereditor_plugin.cpp index 84f9e4702..2fe3a4212 100644 --- a/src/designer/src/components/tabordereditor/tabordereditor_plugin.cpp +++ b/src/designer/src/components/tabordereditor/tabordereditor_plugin.cpp @@ -12,6 +12,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { TabOrderEditorPlugin::TabOrderEditorPlugin() = default; @@ -28,9 +30,9 @@ void TabOrderEditorPlugin::initialize(QDesignerFormEditorInterface *core) Q_ASSERT(!isInitialized()); m_action = new QAction(tr("Edit Tab Order"), this); - m_action->setObjectName(QStringLiteral("_qt_edit_tab_order_action")); - QIcon icon = QIcon::fromTheme(QStringLiteral("designer-edit-tabs"), - QIcon(core->resourceLocation() + QStringLiteral("/tabordertool.png"))); + m_action->setObjectName(u"_qt_edit_tab_order_action"_s); + QIcon icon = QIcon::fromTheme(u"designer-edit-tabs"_s, + QIcon(core->resourceLocation() + "/tabordertool.png"_L1)); m_action->setIcon(icon); m_action->setEnabled(false); diff --git a/src/designer/src/components/taskmenu/button_taskmenu.cpp b/src/designer/src/components/taskmenu/button_taskmenu.cpp index 96aac5263..7edf6c04a 100644 --- a/src/designer/src/components/taskmenu/button_taskmenu.cpp +++ b/src/designer/src/components/taskmenu/button_taskmenu.cpp @@ -29,6 +29,8 @@ Q_DECLARE_METATYPE(QButtonGroup*) QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { enum { debugButtonMenu = 0 }; @@ -137,7 +139,7 @@ QString ButtonGroupCommand::nameList(const ButtonList& bl) { QString rc; const QChar quote = QLatin1Char('\''); - const QString separator = QStringLiteral(", "); + const auto separator = ", "_L1; for (qsizetype i = 0, size = bl.size(); i < size; ++i) { if (i) rc += separator; @@ -188,7 +190,7 @@ bool CreateButtonGroupCommand::init(const ButtonList &bl) return false; QDesignerFormWindowInterface *fw = formWindow(); QButtonGroup *buttonGroup = new QButtonGroup(fw->mainContainer()); - buttonGroup->setObjectName(QStringLiteral("buttonGroup")); + buttonGroup->setObjectName(u"buttonGroup"_s); fw->ensureUniqueObjectName(buttonGroup); initialize(bl, buttonGroup); return true; @@ -353,7 +355,7 @@ protected: }; ButtonTextTaskMenuInlineEditor::ButtonTextTaskMenuInlineEditor(QAbstractButton *button, QObject *parent) : - TaskMenuInlineEditor(button, ValidationMultiLine, QStringLiteral("text"), parent) + TaskMenuInlineEditor(button, ValidationMultiLine, u"text"_s, parent) { } @@ -376,7 +378,7 @@ protected: }; LinkDescriptionTaskMenuInlineEditor::LinkDescriptionTaskMenuInlineEditor(QAbstractButton *button, QObject *parent) : - TaskMenuInlineEditor(button, ValidationMultiLine, QStringLiteral("description"), parent) + TaskMenuInlineEditor(button, ValidationMultiLine, u"description"_s, parent) { } diff --git a/src/designer/src/components/taskmenu/containerwidget_taskmenu.cpp b/src/designer/src/components/taskmenu/containerwidget_taskmenu.cpp index 3133d0447..a9cec6eb2 100644 --- a/src/designer/src/components/taskmenu/containerwidget_taskmenu.cpp +++ b/src/designer/src/components/taskmenu/containerwidget_taskmenu.cpp @@ -28,6 +28,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { ContainerWidgetTaskMenu::ContainerWidgetTaskMenu(QWidget *widget, ContainerType type, QObject *parent) : @@ -267,7 +269,7 @@ ContainerWidgetTaskMenuFactory::ContainerWidgetTaskMenuFactory(QDesignerFormEdit QObject *ContainerWidgetTaskMenuFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const { - if (iid != QStringLiteral("QDesignerInternalTaskMenuExtension") || !object->isWidgetType()) + if (iid != "QDesignerInternalTaskMenuExtension"_L1 || !object->isWidgetType()) return nullptr; QWidget *widget = qobject_cast<QWidget*>(object); diff --git a/src/designer/src/components/taskmenu/groupbox_taskmenu.cpp b/src/designer/src/components/taskmenu/groupbox_taskmenu.cpp index 3d291294a..f8818bdf0 100644 --- a/src/designer/src/components/taskmenu/groupbox_taskmenu.cpp +++ b/src/designer/src/components/taskmenu/groupbox_taskmenu.cpp @@ -13,6 +13,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // -------- GroupBoxTaskMenuInlineEditor @@ -26,7 +28,7 @@ protected: }; GroupBoxTaskMenuInlineEditor::GroupBoxTaskMenuInlineEditor(QGroupBox *w, QObject *parent) : - TaskMenuInlineEditor(w, ValidationSingleLine, QStringLiteral("title"), parent) + TaskMenuInlineEditor(w, ValidationSingleLine, u"title"_s, parent) { } diff --git a/src/designer/src/components/taskmenu/inplace_editor.cpp b/src/designer/src/components/taskmenu/inplace_editor.cpp index cc1708b8d..5afbea3a4 100644 --- a/src/designer/src/components/taskmenu/inplace_editor.cpp +++ b/src/designer/src/components/taskmenu/inplace_editor.cpp @@ -15,6 +15,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // ----------------- InPlaceEditor @@ -28,7 +30,7 @@ InPlaceEditor::InPlaceEditor(QWidget *widget, m_InPlaceWidgetHelper(this, widget, fw) { setAlignment(m_InPlaceWidgetHelper.alignment()); - setObjectName(QStringLiteral("__qt__passive_m_editor")); + setObjectName(u"__qt__passive_m_editor"_s); setText(text); selectAll(); diff --git a/src/designer/src/components/taskmenu/itemlisteditor.cpp b/src/designer/src/components/taskmenu/itemlisteditor.cpp index ad9dac500..668769ef5 100644 --- a/src/designer/src/components/taskmenu/itemlisteditor.cpp +++ b/src/designer/src/components/taskmenu/itemlisteditor.cpp @@ -16,6 +16,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { class ItemPropertyBrowser : public QtTreePropertyBrowser @@ -28,7 +30,7 @@ public: const QString widthSampleString = QCoreApplication::translate("ItemPropertyBrowser", "XX Icon Selected off"); m_width = fontMetrics().horizontalAdvance(widthSampleString); setSplitterPosition(m_width); - m_width += fontMetrics().horizontalAdvance(QStringLiteral("/this/is/some/random/path")); + m_width += fontMetrics().horizontalAdvance(u"/this/is/some/random/path"_s); } QSize sizeHint() const override @@ -103,16 +105,16 @@ void AbstractItemEditor::setupProperties(const PropertyDefinition *propList, } Q_ASSERT(prop); if (role == Qt::ToolTipPropertyRole || role == Qt::WhatsThisPropertyRole) - prop->setAttribute(QStringLiteral("validationMode"), ValidationRichText); + prop->setAttribute(u"validationMode"_s, ValidationRichText); else if (role == Qt::DisplayPropertyRole) - prop->setAttribute(QStringLiteral("validationMode"), ValidationMultiLine); + prop->setAttribute(u"validationMode"_s, ValidationMultiLine); else if (role == Qt::StatusTipPropertyRole) - prop->setAttribute(QStringLiteral("validationMode"), ValidationSingleLine); + prop->setAttribute(u"validationMode"_s, ValidationSingleLine); else if (role == ItemFlagsShadowRole) - prop->setAttribute(QStringLiteral("flagNames"), c2qStringList(itemFlagNames)); + prop->setAttribute(u"flagNames"_s, c2qStringList(itemFlagNames)); else if (role == Qt::CheckStateRole) - prop->setAttribute(QStringLiteral("enumNames"), c2qStringList(checkStateNames)); - prop->setAttribute(QStringLiteral("resettable"), true); + prop->setAttribute(u"enumNames"_s, c2qStringList(checkStateNames)); + prop->setAttribute(u"resettable"_s, true); m_properties.append(prop); m_rootProperties.append(prop); m_propertyToRole.insert(prop, role); diff --git a/src/designer/src/components/taskmenu/lineedit_taskmenu.cpp b/src/designer/src/components/taskmenu/lineedit_taskmenu.cpp index ac74618a1..88dcf456a 100644 --- a/src/designer/src/components/taskmenu/lineedit_taskmenu.cpp +++ b/src/designer/src/components/taskmenu/lineedit_taskmenu.cpp @@ -13,6 +13,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // -------- LineEditTaskMenuInlineEditor @@ -26,7 +28,7 @@ protected: }; LineEditTaskMenuInlineEditor::LineEditTaskMenuInlineEditor(QLineEdit *w, QObject *parent) : - TaskMenuInlineEditor(w, ValidationSingleLine, QStringLiteral("text"), parent) + TaskMenuInlineEditor(w, ValidationSingleLine, u"text"_s, parent) { } diff --git a/src/designer/src/components/taskmenu/tablewidgeteditor.cpp b/src/designer/src/components/taskmenu/tablewidgeteditor.cpp index eda2c89dd..7c5ca1f5b 100644 --- a/src/designer/src/components/taskmenu/tablewidgeteditor.cpp +++ b/src/designer/src/components/taskmenu/tablewidgeteditor.cpp @@ -19,17 +19,19 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { TableWidgetEditor::TableWidgetEditor(QDesignerFormWindowInterface *form, QDialog *dialog) : AbstractItemEditor(form, nullptr), m_updatingBrowser(false) { m_columnEditor = new ItemListEditor(form, this); - m_columnEditor->setObjectName(QStringLiteral("columnEditor")); + m_columnEditor->setObjectName(u"columnEditor"_s); m_columnEditor->setAlignDefault(Qt::AlignCenter); m_columnEditor->setNewItemText(tr("New Column")); m_rowEditor = new ItemListEditor(form, this); - m_rowEditor->setObjectName(QStringLiteral("rowEditor")); + m_rowEditor->setObjectName(u"rowEditor"_s); m_rowEditor->setNewItemText(tr("New Row")); ui.setupUi(dialog); diff --git a/src/designer/src/components/taskmenu/taskmenu_component.cpp b/src/designer/src/components/taskmenu/taskmenu_component.cpp index ef82880b2..8da00ee87 100644 --- a/src/designer/src/components/taskmenu/taskmenu_component.cpp +++ b/src/designer/src/components/taskmenu/taskmenu_component.cpp @@ -21,6 +21,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { TaskMenuComponent::TaskMenuComponent(QDesignerFormEditorInterface *core, QObject *parent) @@ -30,7 +32,7 @@ TaskMenuComponent::TaskMenuComponent(QDesignerFormEditorInterface *core, QObject Q_ASSERT(m_core != nullptr); QExtensionManager *mgr = core->extensionManager(); - const QString taskMenuId = QStringLiteral("QDesignerInternalTaskMenuExtension"); + const QString taskMenuId = u"QDesignerInternalTaskMenuExtension"_s; ButtonTaskMenuFactory::registerExtension(mgr, taskMenuId); CommandLinkButtonTaskMenuFactory::registerExtension(mgr, taskMenuId); // Order! diff --git a/src/designer/src/components/taskmenu/textedit_taskmenu.cpp b/src/designer/src/components/taskmenu/textedit_taskmenu.cpp index 2c2d57e37..ed85cf792 100644 --- a/src/designer/src/components/taskmenu/textedit_taskmenu.cpp +++ b/src/designer/src/components/taskmenu/textedit_taskmenu.cpp @@ -12,12 +12,14 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { TextEditTaskMenu::TextEditTaskMenu(QTextEdit *textEdit, QObject *parent) : QDesignerTaskMenu(textEdit, parent), m_format(Qt::RichText), - m_property(QStringLiteral("html")), + m_property(u"html"_s), m_windowTitle(tr("Edit HTML")), m_editTextAction(new QAction(tr("Change HTML..."), this)) { @@ -27,7 +29,7 @@ TextEditTaskMenu::TextEditTaskMenu(QTextEdit *textEdit, QObject *parent) : TextEditTaskMenu::TextEditTaskMenu(QPlainTextEdit *textEdit, QObject *parent) : QDesignerTaskMenu(textEdit, parent), m_format(Qt::PlainText), - m_property(QStringLiteral("plainText")), + m_property(u"plainText"_s), m_windowTitle(tr("Edit Text")), m_editTextAction(new QAction(tr("Change Plain Text..."), this)) { diff --git a/src/designer/src/components/taskmenu/treewidgeteditor.cpp b/src/designer/src/components/taskmenu/treewidgeteditor.cpp index ac5e86ab0..e9c1b4678 100644 --- a/src/designer/src/components/taskmenu/treewidgeteditor.cpp +++ b/src/designer/src/components/taskmenu/treewidgeteditor.cpp @@ -20,13 +20,15 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { TreeWidgetEditor::TreeWidgetEditor(QDesignerFormWindowInterface *form, QDialog *dialog) : AbstractItemEditor(form, nullptr), m_updatingBrowser(false) { m_columnEditor = new ItemListEditor(form, this); - m_columnEditor->setObjectName(QStringLiteral("columnEditor")); + m_columnEditor->setObjectName(u"columnEditor"_s); m_columnEditor->setNewItemText(tr("New Column")); ui.setupUi(dialog); diff --git a/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp b/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp index dc6f26fa4..afbfc0567 100644 --- a/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp +++ b/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp @@ -22,6 +22,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { /******************************************************************************* ** WidgetBoxResource @@ -58,7 +60,7 @@ WidgetBoxResource::WidgetBoxResource(QDesignerFormEditorInterface *core) : QWidget *WidgetBoxResource::createWidget(const QString &widgetName, QWidget *parentWidget, const QString &name) { - if (widgetName == QStringLiteral("Spacer")) { + if (widgetName == "Spacer"_L1) { Spacer *spacer = new Spacer(parentWidget); spacer->setObjectName(name); return spacer; @@ -99,9 +101,8 @@ void WidgetBoxResource::createCustomWidgets(DomCustomWidgets *dc) static QSize geometryProp(const DomWidget *dw) { const auto &prop_list = dw->elementProperty(); - const QString geometry = QStringLiteral("geometry"); for (DomProperty *prop : prop_list) { - if (prop->attributeName() != geometry) + if (prop->attributeName() != "geometry"_L1) continue; DomRect *dr = prop->elementRect(); if (dr == nullptr) diff --git a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp index 7aa37879c..4fda87479 100644 --- a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp +++ b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp @@ -28,6 +28,8 @@ static const char *uiClosingTagC = "</ui>"; QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + enum { FilterRole = Qt::UserRole + 11 }; static QString domToString(const QDomElement &elt) @@ -180,7 +182,7 @@ void WidgetBoxCategoryModel::addWidget(const QDesignerWidgetBoxInterface::Widget // Filter on name + class name if it is different and not a layout. QString filter = widget.name(); - if (!className.isEmpty() && !filter.contains(QStringLiteral("Layout")) && !filter.contains(className)) + if (!className.isEmpty() && !filter.contains("Layout"_L1) && !filter.contains(className)) filter += className; WidgetBoxCategoryEntry item(widget, filter, icon, editable); @@ -324,7 +326,7 @@ QWidget *WidgetBoxCategoryEntryDelegate::createEditor(QWidget *parent, { QWidget *result = QItemDelegate::createEditor(parent, option, index); if (QLineEdit *line_edit = qobject_cast<QLineEdit*>(result)) { - static const QRegularExpression re(QStringLiteral("^[_a-zA-Z][_a-zA-Z0-9]*$")); + static const QRegularExpression re(u"^[_a-zA-Z][_a-zA-Z0-9]*$"_s); Q_ASSERT(re.isValid()); line_edit->setValidator(new QRegularExpressionValidator(re, line_edit)); } diff --git a/src/designer/src/designer/assistantclient.cpp b/src/designer/src/designer/assistantclient.cpp index 8e8a58995..0f01aa295 100644 --- a/src/designer/src/designer/assistantclient.cpp +++ b/src/designer/src/designer/assistantclient.cpp @@ -15,6 +15,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + enum { debugAssistantClient = 0 }; AssistantClient::AssistantClient() = default; @@ -30,22 +32,19 @@ AssistantClient::~AssistantClient() bool AssistantClient::showPage(const QString &path, QString *errorMessage) { - QString cmd = QStringLiteral("SetSource "); - cmd += path; + const QString cmd = "SetSource "_L1 + path; return sendCommand(cmd, errorMessage); } bool AssistantClient::activateIdentifier(const QString &identifier, QString *errorMessage) { - QString cmd = QStringLiteral("ActivateIdentifier "); - cmd += identifier; + const QString cmd = "ActivateIdentifier "_L1 + identifier; return sendCommand(cmd, errorMessage); } bool AssistantClient::activateKeyword(const QString &keyword, QString *errorMessage) { - QString cmd = QStringLiteral("ActivateKeyword "); - cmd += keyword; + const QString cmd = "ActivateKeyword "_L1 + keyword; return sendCommand(cmd, errorMessage); } @@ -73,13 +72,13 @@ QString AssistantClient::binary() { QString app = QLibraryInfo::path(QLibraryInfo::BinariesPath) + QDir::separator(); #if !defined(Q_OS_MACOS) - app += QStringLiteral("assistant"); + app += "assistant"_L1; #else - app += QStringLiteral("Assistant.app/Contents/MacOS/Assistant"); + app += "Assistant.app/Contents/MacOS/Assistant"_L1; #endif #if defined(Q_OS_WIN) - app += QStringLiteral(".exe"); + app += ".exe"_L1; #endif return app; @@ -122,7 +121,7 @@ bool AssistantClient::ensureRunning(QString *errorMessage) if (debugAssistantClient) qDebug() << "Running " << app; // run - QStringList args(QStringLiteral("-enableRemoteControl")); + QStringList args{u"-enableRemoteControl"_s}; m_process->start(app, args); if (!m_process->waitForStarted()) { *errorMessage = QCoreApplication::translate("AssistantClient", "Unable to launch assistant (%1).").arg(app); @@ -144,12 +143,12 @@ QString AssistantClient::documentUrl(const QString &module, int qtVersion) QString AssistantClient::designerManualUrl(int qtVersion) { - return documentUrl(QStringLiteral("qtdesigner"), qtVersion); + return documentUrl(u"qtdesigner"_s, qtVersion); } QString AssistantClient::qtReferenceManualUrl(int qtVersion) { - return documentUrl(QStringLiteral("qtdoc"), qtVersion); + return documentUrl(u"qtdoc"_s, qtVersion); } QT_END_NAMESPACE diff --git a/src/designer/src/designer/mainwindow.cpp b/src/designer/src/designer/mainwindow.cpp index 332741940..6c9e1d2c5 100644 --- a/src/designer/src/designer/mainwindow.cpp +++ b/src/designer/src/designer/mainwindow.cpp @@ -33,6 +33,8 @@ static const char *uriListMimeFormatC = "text/uri-list"; QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + using ActionList = QList<QAction *>; // Helpers for creating toolbars and menu @@ -44,7 +46,9 @@ static void addActionsToToolBar(const ActionList &actions, QToolBar *t) t->addAction(action); } } -static QToolBar *createToolBar(const QString &title, const QString &objectName, const ActionList &actions) + +static QToolBar *createToolBar(const QString &title, const QString &objectName, + const ActionList &actions) { QToolBar *rc = new QToolBar; rc->setObjectName(objectName); @@ -82,16 +86,21 @@ QList<QToolBar *> MainWindowBase::createToolBars(const QDesignerActions *actions QList<QToolBar *> rc; if (singleToolBar) { //: Not currently used (main tool bar) - QToolBar *main = createToolBar(tr("Main"), QStringLiteral("mainToolBar"), actions->fileActions()->actions()); + QToolBar *main = createToolBar(tr("Main"), u"mainToolBar"_s, + actions->fileActions()->actions()); addActionsToToolBar(actions->editActions()->actions(), main); addActionsToToolBar(actions->toolActions()->actions(), main); addActionsToToolBar(actions->formActions()->actions(), main); rc.push_back(main); } else { - rc.push_back(createToolBar(tr("File"), QStringLiteral("fileToolBar"), actions->fileActions()->actions())); - rc.push_back(createToolBar(tr("Edit"), QStringLiteral("editToolBar"), actions->editActions()->actions())); - rc.push_back(createToolBar(tr("Tools"), QStringLiteral("toolsToolBar"), actions->toolActions()->actions())); - rc.push_back(createToolBar(tr("Form"), QStringLiteral("formToolBar"), actions->formActions()->actions())); + rc.append(createToolBar(tr("File"), u"fileToolBar"_s, + actions->fileActions()->actions())); + rc.append(createToolBar(tr("Edit"), u"editToolBar"_s, + actions->editActions()->actions())); + rc.append(createToolBar(tr("Tools"), u"toolsToolBar"_s, + actions->toolActions()->actions())); + rc.append(createToolBar(tr("Form"), u"formToolBar"_s, + actions->formActions()->actions())); } return rc; } @@ -189,7 +198,7 @@ ToolBarManager::ToolBarManager(QMainWindow *configureableMainWindow, m_toolbars(toolbars) { m_configureAction->setMenuRole(QAction::NoRole); - m_configureAction->setObjectName(QStringLiteral("__qt_configure_tool_bars_action")); + m_configureAction->setObjectName(u"__qt_configure_tool_bars_action"_s); connect(m_configureAction, &QAction::triggered, this, &ToolBarManager::configureToolBars); m_manager->setMainWindow(configureableMainWindow); @@ -268,7 +277,7 @@ DockedMainWindow::DockedMainWindow(QDesignerWorkbench *wb, const QList<QDesignerToolWindow *> &toolWindows) : m_toolBarManager(nullptr) { - setObjectName(QStringLiteral("MDIWindow")); + setObjectName(u"MDIWindow"_s); setWindowTitle(mainWindowTitle()); const QList<QToolBar *> toolbars = createToolBars(wb->actionManager(), false); @@ -326,7 +335,7 @@ DockedMainWindow::DockWidgetList DockedMainWindow::addToolWindows(const Designer DockWidgetList rc; for (QDesignerToolWindow *tw : tls) { QDockWidget *dockWidget = new QDockWidget; - dockWidget->setObjectName(tw->objectName() + QStringLiteral("_dock")); + dockWidget->setObjectName(tw->objectName() + "_dock"_L1); dockWidget->setWindowTitle(tw->windowTitle()); addDockWidget(tw->dockWidgetAreaHint(), dockWidget); dockWidget->setWidget(tw); diff --git a/src/designer/src/designer/newform.cpp b/src/designer/src/designer/newform.cpp index 365ad06a3..467c5dd84 100644 --- a/src/designer/src/designer/newform.cpp +++ b/src/designer/src/designer/newform.cpp @@ -31,6 +31,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + NewForm::NewForm(QDesignerWorkbench *workbench, QWidget *parentWidget, const QString &fileName) : QDialog(parentWidget, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint), m_fileName(fileName), @@ -100,11 +102,8 @@ NewForm::~NewForm() void NewForm::recentFileChosen() { QAction *action = qobject_cast<QAction *>(sender()); - if (!action) - return; - if (action->objectName() == QStringLiteral("__qt_action_clear_menu_")) - return; - close(); + if (action && action->objectName() != "__qt_action_clear_menu_"_L1) + close(); } void NewForm::slotCurrentTemplateChanged(bool templateSelected) @@ -158,7 +157,7 @@ bool NewForm::openTemplate(QString *ptrToErrorMessage) QString tempPattern = QDir::tempPath(); if (!tempPattern.endsWith(QDir::separator())) // platform-dependant tempPattern += QDir::separator(); - tempPattern += QStringLiteral("XXXXXX.ui"); + tempPattern += "XXXXXX.ui"_L1; QTemporaryFile tempFormFile(tempPattern); tempFormFile.setAutoRemove(true); diff --git a/src/designer/src/designer/qdesigner.cpp b/src/designer/src/designer/qdesigner.cpp index 8c218e8f5..099e7509c 100644 --- a/src/designer/src/designer/qdesigner.cpp +++ b/src/designer/src/designer/qdesigner.cpp @@ -55,13 +55,13 @@ QDesigner::QDesigner(int &argc, char **argv) m_client(nullptr), m_workbench(0), m_suppressNewFormShow(false) { - setOrganizationName(QStringLiteral("QtProject")); + setOrganizationName(u"QtProject"_s); QGuiApplication::setApplicationDisplayName(QLatin1String(designerDisplayName)); setApplicationName(QLatin1String(designerApplicationName)); QDesignerComponents::initializeResources(); #if !defined(Q_OS_OSX) && !defined(Q_OS_WIN) - setWindowIcon(QIcon(QStringLiteral(":/qt-project.org/designer/images/designer.png"))); + setWindowIcon(QIcon(u":/qt-project.org/designer/images/designer.png"_s)); #endif } @@ -147,28 +147,28 @@ static inline QDesigner::ParseArgumentsResult parseDesignerCommandLineArguments(QCommandLineParser &parser, Options *options, QString *errorMessage) { - parser.setApplicationDescription(QStringLiteral("Qt Designer ") + parser.setApplicationDescription(u"Qt Designer "_s + QLatin1String(QT_VERSION_STR) + QLatin1String("\n\nUI designer for QWidget-based applications.")); const QCommandLineOption helpOption = parser.addHelpOption(); parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); - const QCommandLineOption serverOption(QStringLiteral("server"), - QStringLiteral("Server mode")); + const QCommandLineOption serverOption(u"server"_s, + u"Server mode"_s); parser.addOption(serverOption); - const QCommandLineOption clientOption(QStringLiteral("client"), - QStringLiteral("Client mode"), - QStringLiteral("port")); + const QCommandLineOption clientOption(u"client"_s, + u"Client mode"_s, + u"port"_s); parser.addOption(clientOption); - const QCommandLineOption resourceDirOption(QStringLiteral("resourcedir"), - QStringLiteral("Resource directory"), - QStringLiteral("directory")); + const QCommandLineOption resourceDirOption(u"resourcedir"_s, + u"Resource directory"_s, + u"directory"_s); parser.addOption(resourceDirOption); - const QCommandLineOption internalDynamicPropertyOption(QStringLiteral("enableinternaldynamicproperties"), - QStringLiteral("Enable internal dynamic properties")); + const QCommandLineOption internalDynamicPropertyOption(u"enableinternaldynamicproperties"_s, + u"Enable internal dynamic properties"_s); parser.addOption(internalDynamicPropertyOption); - parser.addPositionalArgument(QStringLiteral("files"), - QStringLiteral("The UI files to open.")); + parser.addPositionalArgument(u"files"_s, + u"The UI files to open."_s); if (!parser.parse(QCoreApplication::arguments())) { *errorMessage = parser.errorText(); @@ -186,7 +186,7 @@ static inline QDesigner::ParseArgumentsResult bool ok; options->clientPort = parser.value(clientOption).toUShort(&ok); if (!ok) { - *errorMessage = QStringLiteral("Non-numeric argument specified for -client"); + *errorMessage = u"Non-numeric argument specified for -client"_s; return QDesigner::ParseArgumentsError; } } @@ -219,10 +219,10 @@ QDesigner::ParseArgumentsResult QDesigner::parseCommandLineArguments() QDesignerPropertySheet::setInternalDynamicPropertiesEnabled(true); std::unique_ptr<QTranslator> designerTranslator(new QTranslator(this)); - if (designerTranslator->load(QLocale(), QStringLiteral("designer"), QStringLiteral("_"), options.resourceDir)) { + if (designerTranslator->load(QLocale(), u"designer"_s, u"_"_s, options.resourceDir)) { installTranslator(designerTranslator.release()); std::unique_ptr<QTranslator> qtTranslator(new QTranslator(this)); - if (qtTranslator->load(QLocale(), QStringLiteral("qt"), QStringLiteral("_"), options.resourceDir)) + if (qtTranslator->load(QLocale(), u"qt"_s, u"_"_s, options.resourceDir)) installTranslator(qtTranslator.release()); } diff --git a/src/designer/src/designer/qdesigner_actions.cpp b/src/designer/src/designer/qdesigner_actions.cpp index b24273943..ac85c91a6 100644 --- a/src/designer/src/designer/qdesigner_actions.cpp +++ b/src/designer/src/designer/qdesigner_actions.cpp @@ -139,9 +139,12 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) m_windowActions(createActionGroup(this)), m_toolActions(createActionGroup(this, true)), m_editWidgetsAction(new QAction(tr("Edit Widgets"), this)), - m_newFormAction(new QAction(qdesigner_internal::createIconSet(QStringLiteral("filenew.png")), tr("&New..."), this)), - m_openFormAction(new QAction(qdesigner_internal::createIconSet(QStringLiteral("fileopen.png")), tr("&Open..."), this)), - m_saveFormAction(new QAction(qdesigner_internal::createIconSet(QStringLiteral("filesave.png")), tr("&Save"), this)), + m_newFormAction(new QAction(qdesigner_internal::createIconSet(u"filenew.png"_s), + tr("&New..."), this)), + m_openFormAction(new QAction(qdesigner_internal::createIconSet(u"fileopen.png"_s), + tr("&Open..."), this)), + m_saveFormAction(new QAction(qdesigner_internal::createIconSet(u"filesave.png"_s), + tr("&Save"), this)), m_saveFormAsAction(new QAction(tr("Save &As..."), this)), m_saveAllFormsAction(new QAction(tr("Save A&ll"), this)), m_saveFormAsTemplateAction(new QAction(tr("Save As &Template..."), this)), @@ -159,13 +162,18 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) m_appFontAction(new QAction(tr("Additional Fonts..."), this)) { #if defined (Q_OS_UNIX) && !defined(Q_OS_MACOS) - m_newFormAction->setIcon(QIcon::fromTheme(QStringLiteral("document-new"), m_newFormAction->icon())); - m_openFormAction->setIcon(QIcon::fromTheme(QStringLiteral("document-open"), m_openFormAction->icon())); - m_saveFormAction->setIcon(QIcon::fromTheme(QStringLiteral("document-save"), m_saveFormAction->icon())); - m_saveFormAsAction->setIcon(QIcon::fromTheme(QStringLiteral("document-save-as"), m_saveFormAsAction->icon())); - m_printPreviewAction->setIcon(QIcon::fromTheme(QStringLiteral("document-print"), m_printPreviewAction->icon())); - m_closeFormAction->setIcon(QIcon::fromTheme(QStringLiteral("window-close"), m_closeFormAction->icon())); - m_quitAction->setIcon(QIcon::fromTheme(QStringLiteral("application-exit"), m_quitAction->icon())); + m_newFormAction->setIcon(QIcon::fromTheme(u"document-new"_s, + m_newFormAction->icon())); + m_openFormAction->setIcon(QIcon::fromTheme(u"document-open"_s, + m_openFormAction->icon())); + m_saveFormAction->setIcon(QIcon::fromTheme(u"document-save"_s, + m_saveFormAction->icon())); + m_saveFormAsAction->setIcon(QIcon::fromTheme(u"document-save-as"_s, + m_saveFormAsAction->icon())); + m_printPreviewAction->setIcon(QIcon::fromTheme(u"document-print"_s, + m_printPreviewAction->icon())); + m_closeFormAction->setIcon(QIcon::fromTheme(u"window-close"_s, m_closeFormAction->icon())); + m_quitAction->setIcon(QIcon::fromTheme(u"application-exit"_s, m_quitAction->icon())); #endif Q_ASSERT(m_core != nullptr); @@ -177,21 +185,21 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) connect(ifwm, &QDesignerFormWindowManagerInterface::formWindowSettingsChanged, this, &QDesignerActions::formWindowSettingsChanged); - m_editWidgetsAction->setObjectName(QStringLiteral("__qt_edit_widgets_action")); - m_newFormAction->setObjectName(QStringLiteral("__qt_new_form_action")); - m_openFormAction->setObjectName(QStringLiteral("__qt_open_form_action")); - m_saveFormAction->setObjectName(QStringLiteral("__qt_save_form_action")); - m_saveFormAsAction->setObjectName(QStringLiteral("__qt_save_form_as_action")); - m_saveAllFormsAction->setObjectName(QStringLiteral("__qt_save_all_forms_action")); - m_saveFormAsTemplateAction->setObjectName(QStringLiteral("__qt_save_form_as_template_action")); - m_closeFormAction->setObjectName(QStringLiteral("__qt_close_form_action")); - m_quitAction->setObjectName(QStringLiteral("__qt_quit_action")); - m_previewFormAction->setObjectName(QStringLiteral("__qt_preview_form_action")); - m_viewCppCodeAction->setObjectName(QStringLiteral("__qt_preview_cpp_code_action")); - m_viewPythonCodeAction->setObjectName(QStringLiteral("__qt_preview_python_code_action")); - m_minimizeAction->setObjectName(QStringLiteral("__qt_minimize_action")); - m_bringAllToFrontAction->setObjectName(QStringLiteral("__qt_bring_all_to_front_action")); - m_preferencesAction->setObjectName(QStringLiteral("__qt_preferences_action")); + m_editWidgetsAction->setObjectName(u"__qt_edit_widgets_action"_s); + m_newFormAction->setObjectName(u"__qt_new_form_action"_s); + m_openFormAction->setObjectName(u"__qt_open_form_action"_s); + m_saveFormAction->setObjectName(u"__qt_save_form_action"_s); + m_saveFormAsAction->setObjectName(u"__qt_save_form_as_action"_s); + m_saveAllFormsAction->setObjectName(u"__qt_save_all_forms_action"_s); + m_saveFormAsTemplateAction->setObjectName(u"__qt_save_form_as_template_action"_s); + m_closeFormAction->setObjectName(u"__qt_close_form_action"_s); + m_quitAction->setObjectName(u"__qt_quit_action"_s); + m_previewFormAction->setObjectName(u"__qt_preview_form_action"_s); + m_viewCppCodeAction->setObjectName(u"__qt_preview_cpp_code_action"_s); + m_viewPythonCodeAction->setObjectName(u"__qt_preview_python_code_action"_s); + m_minimizeAction->setObjectName(u"__qt_minimize_action"_s); + m_bringAllToFrontAction->setObjectName(u"__qt_bring_all_to_front_action"_s); + m_preferencesAction->setObjectName(u"__qt_preferences_action"_s); m_helpActions = createHelpActions(); @@ -241,10 +249,10 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) m_printPreviewAction->setShortcut(QKeySequence::Print); connect(m_printPreviewAction, &QAction::triggered, this, &QDesignerActions::printPreviewImage); m_fileActions->addAction(m_printPreviewAction); - m_printPreviewAction->setObjectName(QStringLiteral("__qt_print_action")); + m_printPreviewAction->setObjectName(u"__qt_print_action"_s); connect(m_savePreviewImageAction, &QAction::triggered, this, &QDesignerActions::savePreviewImage); - m_savePreviewImageAction->setObjectName(QStringLiteral("__qt_saveimage_action")); + m_savePreviewImageAction->setObjectName(u"__qt_saveimage_action"_s); m_fileActions->addAction(m_savePreviewImageAction); m_fileActions->addAction(createSeparator(this)); @@ -264,12 +272,12 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) // edit actions // QAction *undoAction = formWindowManager->action(QDesignerFormWindowManagerInterface::UndoAction); - undoAction->setObjectName(QStringLiteral("__qt_undo_action")); + undoAction->setObjectName(u"__qt_undo_action"_s); undoAction->setShortcut(QKeySequence::Undo); m_editActions->addAction(undoAction); QAction *redoAction = formWindowManager->action(QDesignerFormWindowManagerInterface::RedoAction); - redoAction->setObjectName(QStringLiteral("__qt_redo_action")); + redoAction->setObjectName(u"__qt_redo_action"_s); redoAction->setShortcut(QKeySequence::Redo); m_editActions->addAction(redoAction); @@ -301,8 +309,8 @@ QDesignerActions::QDesignerActions(QDesignerWorkbench *workbench) shortcuts.append(QKeySequence(Qt::Key_F3)); shortcuts.append(QKeySequence(Qt::Key_Escape)); m_editWidgetsAction->setShortcuts(shortcuts); - QIcon fallback(m_core->resourceLocation() + QStringLiteral("/widgettool.png")); - m_editWidgetsAction->setIcon(QIcon::fromTheme(QStringLiteral("designer-edit-widget"), + QIcon fallback(m_core->resourceLocation() + "/widgettool.png"_L1); + m_editWidgetsAction->setIcon(QIcon::fromTheme(u"designer-edit-widget"_s, fallback)); connect(m_editWidgetsAction, &QAction::triggered, this, &QDesignerActions::editWidgetsSlot); m_editWidgetsAction->setChecked(true); @@ -421,14 +429,14 @@ QActionGroup *QDesignerActions::createHelpActions() #ifndef QT_JAMBI_BUILD QAction *mainHelpAction = new QAction(tr("Qt Designer &Help"), this); - mainHelpAction->setObjectName(QStringLiteral("__qt_designer_help_action")); + mainHelpAction->setObjectName(u"__qt_designer_help_action"_s); connect(mainHelpAction, &QAction::triggered, this, &QDesignerActions::showDesignerHelp); mainHelpAction->setShortcut(Qt::CTRL | Qt::Key_Question); helpActions->addAction(mainHelpAction); helpActions->addAction(createSeparator(this)); QAction *widgetHelp = new QAction(tr("Current Widget Help"), this); - widgetHelp->setObjectName(QStringLiteral("__qt_current_widget_help_action")); + widgetHelp->setObjectName(u"__qt_current_widget_help_action"_s); widgetHelp->setShortcut(Qt::Key_F1); connect(widgetHelp, &QAction::triggered, this, &QDesignerActions::showWidgetSpecificHelp); helpActions->addAction(widgetHelp); @@ -437,7 +445,7 @@ QActionGroup *QDesignerActions::createHelpActions() helpActions->addAction(createSeparator(this)); QAction *aboutPluginsAction = new QAction(tr("About Plugins"), this); - aboutPluginsAction->setObjectName(QStringLiteral("__qt_about_plugins_action")); + aboutPluginsAction->setObjectName(u"__qt_about_plugins_action"_s); aboutPluginsAction->setMenuRole(QAction::ApplicationSpecificRole); connect(aboutPluginsAction, &QAction::triggered, m_core->formWindowManager(), &QDesignerFormWindowManagerInterface::showPluginDialog); @@ -445,13 +453,13 @@ QActionGroup *QDesignerActions::createHelpActions() QAction *aboutDesignerAction = new QAction(tr("About Qt Designer"), this); aboutDesignerAction->setMenuRole(QAction::AboutRole); - aboutDesignerAction->setObjectName(QStringLiteral("__qt_about_designer_action")); + aboutDesignerAction->setObjectName(u"__qt_about_designer_action"_s); connect(aboutDesignerAction, &QAction::triggered, this, &QDesignerActions::aboutDesigner); helpActions->addAction(aboutDesignerAction); QAction *aboutQtAction = new QAction(tr("About Qt"), this); aboutQtAction->setMenuRole(QAction::AboutQtRole); - aboutQtAction->setObjectName(QStringLiteral("__qt_about_qt_action")); + aboutQtAction->setObjectName(u"__qt_about_qt_action"_s); connect(aboutQtAction, &QAction::triggered, qApp, &QApplication::aboutQt); helpActions->addAction(aboutQtAction); return helpActions; @@ -470,7 +478,7 @@ QString QDesignerActions::uiExtension() const = qt_extension<QDesignerLanguageExtension *>(m_core->extensionManager(), m_core); if (lang) return lang->uiExtension(); - return QStringLiteral("ui"); + return u"ui"_s; } QAction *QDesignerActions::createRecentFilesMenu() @@ -487,14 +495,14 @@ QAction *QDesignerActions::createRecentFilesMenu() } updateRecentFileActions(); m_recentMenu->addSeparator(); - act = new QAction(QIcon::fromTheme(QStringLiteral("edit-clear")), + act = new QAction(QIcon::fromTheme(u"edit-clear"_s), tr("Clear &Menu"), this); - act->setObjectName(QStringLiteral("__qt_action_clear_menu_")); + act->setObjectName(u"__qt_action_clear_menu_"_s); connect(act, &QAction::triggered, this, &QDesignerActions::clearRecentFiles); m_recentFilesActions->addAction(act); m_recentMenu->addAction(act); - act = new QAction(QIcon::fromTheme(QStringLiteral("document-open-recent")), + act = new QAction(QIcon::fromTheme(u"document-open-recent"_s), tr("&Recent Forms"), this); act->setMenu(m_recentMenu.get()); return act; @@ -606,7 +614,7 @@ bool QDesignerActions::saveFormAs(QDesignerFormWindowInterface *fw) dir = QDir::current().absolutePath(); } while (false); dir += QDir::separator(); - dir += QStringLiteral("untitled."); + dir += "untitled."_L1; dir += extension; } @@ -634,7 +642,7 @@ void QDesignerActions::saveAllForms() QString fileNames; QDesignerFormWindowManagerInterface *formWindowManager = core()->formWindowManager(); if (const int totalWindows = formWindowManager->formWindowCount()) { - const QString separator = QStringLiteral(", "); + const auto separator = ", "_L1; for (int i = 0; i < totalWindows; ++i) { QDesignerFormWindowInterface *fw = formWindowManager->formWindow(i); if (fw && fw->isDirty()) { @@ -797,7 +805,7 @@ bool QDesignerActions::writeOutForm(QDesignerFormWindowInterface *fw, const QStr QString contents = fw->contents(); if (qdesigner_internal::FormWindowBase *fwb = qobject_cast<qdesigner_internal::FormWindowBase *>(fw)) { if (fwb->lineTerminatorMode() == qdesigner_internal::FormWindowBase::CRLFLineTerminator) - contents.replace(QLatin1Char('\n'), QStringLiteral("\r\n")); + contents.replace('\n'_L1, "\r\n"_L1); } m_workbench->updateBackup(fw); @@ -961,7 +969,7 @@ QAction *QDesignerActions::minimizeAction() const void QDesignerActions::showDesignerHelp() { QString url = AssistantClient::designerManualUrl(); - url += QStringLiteral("qtdesigner-manual.html"); + url += "qtdesigner-manual.html"_L1; showHelp(url); } @@ -984,9 +992,9 @@ void QDesignerActions::aboutDesigner() VersionDialog mb(core()->topLevel()); mb.setWindowTitle(tr("About Qt Designer")); if (mb.exec()) { - QMessageBox messageBox(QMessageBox::Information, QStringLiteral("Easter Egg"), - QStringLiteral("Easter Egg"), QMessageBox::Ok, core()->topLevel()); - messageBox.setInformativeText(QStringLiteral("The Easter Egg has been removed.")); + QMessageBox messageBox(QMessageBox::Information, u"Easter Egg"_s, + u"Easter Egg"_s, QMessageBox::Ok, core()->topLevel()); + messageBox.setInformativeText(u"The Easter Egg has been removed."_s); messageBox.exec(); } } @@ -1036,7 +1044,7 @@ void QDesignerActions::backupForms() QString formBackupName; QTextStream(&formBackupName) << m_backupPath << QDir::separator() - << QStringLiteral("backup") << i << QStringLiteral(".bak"); + << "backup" << i << ".bak"; QString fwn = QDir::toNativeSeparators(fwi->fileName()); if (fwn.isEmpty()) @@ -1049,7 +1057,7 @@ void QDesignerActions::backupForms() QString contents = fixResourceFileBackupPath(fwi, backupDir); if (qdesigner_internal::FormWindowBase *fwb = qobject_cast<qdesigner_internal::FormWindowBase *>(fwi)) { if (fwb->lineTerminatorMode() == qdesigner_internal::FormWindowBase::CRLFLineTerminator) - contents.replace(QLatin1Char('\n'), QStringLiteral("\r\n")); + contents.replace('\n'_L1, "\r\n"_L1); } const QByteArray utf8Array = contents.toUtf8(); if (file.write(utf8Array, utf8Array.size()) != utf8Array.size()) { @@ -1082,11 +1090,11 @@ void QDesignerActions::backupForms() QString QDesignerActions::fixResourceFileBackupPath(QDesignerFormWindowInterface *fwi, const QDir& backupDir) { const QString content = fwi->contents(); - QDomDocument domDoc(QStringLiteral("backup")); + QDomDocument domDoc(u"backup"_s); if(!domDoc.setContent(content)) return content; - const QDomNodeList list = domDoc.elementsByTagName(QStringLiteral("resources")); + const QDomNodeList list = domDoc.elementsByTagName(u"resources"_s); if (list.isEmpty()) return content; @@ -1094,14 +1102,14 @@ QString QDesignerActions::fixResourceFileBackupPath(QDesignerFormWindowInterface const QDomNode node = list.at(i); if (!node.isNull()) { const QDomElement element = node.toElement(); - if(!element.isNull() && element.tagName() == QStringLiteral("resources")) { + if (!element.isNull() && element.tagName() == "resources"_L1) { QDomNode childNode = element.firstChild(); while (!childNode.isNull()) { QDomElement childElement = childNode.toElement(); - if(!childElement.isNull() && childElement.tagName() == QStringLiteral("include")) { - const QString attr = childElement.attribute(QStringLiteral("location")); + if (!childElement.isNull() && childElement.tagName() == "include"_L1) { + const QString attr = childElement.attribute(u"location"_s); const QString path = fwi->absoluteDir().absoluteFilePath(attr); - childElement.setAttribute(QStringLiteral("location"), backupDir.relativeFilePath(path)); + childElement.setAttribute(u"location"_s, backupDir.relativeFilePath(path)); } childNode = childNode.nextSibling(); } diff --git a/src/designer/src/designer/qdesigner_formwindow.cpp b/src/designer/src/designer/qdesigner_formwindow.cpp index 133fc39ce..7ef8b1f98 100644 --- a/src/designer/src/designer/qdesigner_formwindow.cpp +++ b/src/designer/src/designer/qdesigner_formwindow.cpp @@ -28,6 +28,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QDesignerFormWindow::QDesignerFormWindow(QDesignerFormWindowInterface *editor, QDesignerWorkbench *workbench, QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags), m_editor(editor), @@ -73,7 +75,7 @@ void QDesignerFormWindow::changeEvent(QEvent *e) { switch (e->type()) { case QEvent::WindowTitleChange: - m_action->setText(windowTitle().remove(QStringLiteral("[*]"))); + m_action->setText(windowTitle().remove("[*]"_L1)); break; case QEvent::WindowIconChange: m_action->setIcon(windowIcon()); @@ -138,7 +140,7 @@ int QDesignerFormWindow::getNumberOfUntitledWindows() const // Find the number of untitled windows excluding ourselves. // Do not fall for 'untitled.ui', match with modified place holder. // This will cause some problems with i18n, but for now I need the string to be "static" - static const QRegularExpression rx(QStringLiteral("untitled( (\\d+))?\\[\\*\\]$")); + static const QRegularExpression rx(u"untitled( (\\d+))?\\[\\*\\]$"_s); Q_ASSERT(rx.isValid()); for (int i = 0; i < totalWindows; ++i) { QDesignerFormWindow *fw = m_workbench->formWindow(i); @@ -170,7 +172,7 @@ void QDesignerFormWindow::updateWindowTitle(const QString &fileName) QString fileNameTitle; if (fileName.isEmpty()) { - fileNameTitle = QStringLiteral("untitled"); + fileNameTitle += "untitled"_L1; if (const int maxUntitled = getNumberOfUntitledWindows()) { fileNameTitle += QLatin1Char(' '); fileNameTitle += QString::number(maxUntitled + 1); @@ -245,7 +247,7 @@ void QDesignerFormWindow::slotGeometryChanged() QObject *object = core->propertyEditor()->object(); if (object == nullptr || !object->isWidgetType()) return; - static const QString geometryProperty = QStringLiteral("geometry"); + static const QString geometryProperty = u"geometry"_s; const QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), object); const int geometryIndex = sheet->indexOf(geometryProperty); if (geometryIndex == -1) diff --git a/src/designer/src/designer/qdesigner_settings.cpp b/src/designer/src/designer/qdesigner_settings.cpp index f3ce0aedb..033b0ff7d 100644 --- a/src/designer/src/designer/qdesigner_settings.cpp +++ b/src/designer/src/designer/qdesigner_settings.cpp @@ -24,6 +24,8 @@ enum { debugSettings = 0 }; QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static const char *newFormShowKey = "newFormDialog/ShowOnStartup"; // Change the version whenever the arrangement changes significantly. @@ -62,8 +64,8 @@ void QDesignerSettings::saveGeometryFor(const QWidget *w) if (debugSettings) qDebug() << Q_FUNC_INFO << w << "visible=" << visible; s->beginGroup(w->objectName()); - s->setValue(QStringLiteral("visible"), visible); - s->setValue(QStringLiteral("geometry"), w->saveGeometry()); + s->setValue(u"visible"_s, visible); + s->setValue(u"geometry"_s, w->saveGeometry()); s->endGroup(); } @@ -71,8 +73,8 @@ void QDesignerSettings::restoreGeometry(QWidget *w, QRect fallBack) const { Q_ASSERT(w && !w->objectName().isEmpty()); const QString key = w->objectName(); - const QByteArray ba(settings()->value(key + QStringLiteral("/geometry")).toByteArray()); - const bool visible = settings()->value(key + QStringLiteral("/visible"), true).toBool(); + const QByteArray ba(settings()->value(key + "/geometry"_L1).toByteArray()); + const bool visible = settings()->value(key + "/visible"_L1, true).toBool(); if (debugSettings) qDebug() << Q_FUNC_INFO << w << fallBack << "visible=" << visible; @@ -171,8 +173,8 @@ QMap<QString, QString> QDesignerSettings::backup() const void QDesignerSettings::setUiMode(UIMode mode) { QDesignerSettingsInterface *s = settings(); - s->beginGroup(QStringLiteral("UI")); - s->setValue(QStringLiteral("currentMode"), mode); + s->beginGroup(u"UI"_s); + s->setValue(u"currentMode"_s, mode); s->endGroup(); } @@ -183,17 +185,17 @@ UIMode QDesignerSettings::uiMode() const #else const UIMode defaultMode = DockedMode; #endif - UIMode uiMode = static_cast<UIMode>(value(QStringLiteral("UI/currentMode"), defaultMode).toInt()); + UIMode uiMode = static_cast<UIMode>(value(u"UI/currentMode"_s, defaultMode).toInt()); return uiMode; } void QDesignerSettings::setToolWindowFont(const ToolWindowFontSettings &fontSettings) { QDesignerSettingsInterface *s = settings(); - s->beginGroup(QStringLiteral("UI")); - s->setValue(QStringLiteral("font"), fontSettings.m_font); - s->setValue(QStringLiteral("useFont"), fontSettings.m_useFont); - s->setValue(QStringLiteral("writingSystem"), fontSettings.m_writingSystem); + s->beginGroup(u"UI"_s); + s->setValue(u"font"_s, fontSettings.m_font); + s->setValue(u"useFont"_s, fontSettings.m_useFont); + s->setValue(u"writingSystem"_s, fontSettings.m_writingSystem); s->endGroup(); } @@ -201,11 +203,11 @@ ToolWindowFontSettings QDesignerSettings::toolWindowFont() const { ToolWindowFontSettings fontSettings; fontSettings.m_writingSystem = - static_cast<QFontDatabase::WritingSystem>(value(QStringLiteral("UI/writingSystem"), + static_cast<QFontDatabase::WritingSystem>(value(u"UI/writingSystem"_s, QFontDatabase::Any).toInt()); - fontSettings.m_font = qvariant_cast<QFont>(value(QStringLiteral("UI/font"))); + fontSettings.m_font = qvariant_cast<QFont>(value(u"UI/font"_s)); fontSettings.m_useFont = - settings()->value(QStringLiteral("UI/useFont"), QVariant(false)).toBool(); + settings()->value(u"UI/useFont"_s, QVariant(false)).toBool(); return fontSettings; } diff --git a/src/designer/src/designer/qdesigner_toolwindow.cpp b/src/designer/src/designer/qdesigner_toolwindow.cpp index ea13907b1..dc65a8f46 100644 --- a/src/designer/src/designer/qdesigner_toolwindow.cpp +++ b/src/designer/src/designer/qdesigner_toolwindow.cpp @@ -22,6 +22,8 @@ enum { debugToolWindow = 0 }; QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // ---------------- QDesignerToolWindowFontSettings bool ToolWindowFontSettings::equals(const ToolWindowFontSettings &rhs) const { @@ -142,9 +144,9 @@ protected: PropertyEditorToolWindow::PropertyEditorToolWindow(QDesignerWorkbench *workbench) : QDesignerToolWindow(workbench, createPropertyEditor(workbench->core()), - QStringLiteral("qt_designer_propertyeditor"), + u"qt_designer_propertyeditor"_s, QDesignerToolWindow::tr("Property Editor"), - QStringLiteral("__qt_property_editor_action"), + u"__qt_property_editor_action"_s, Qt::RightDockWidgetArea) { action()->setShortcut(Qt::CTRL | Qt::Key_I); @@ -196,9 +198,9 @@ public: ActionEditorToolWindow::ActionEditorToolWindow(QDesignerWorkbench *workbench) : QDesignerToolWindow(workbench, createActionEditor(workbench->core()), - QStringLiteral("qt_designer_actioneditor"), + u"qt_designer_actioneditor"_s, QDesignerToolWindow::tr("Action Editor"), - QStringLiteral("__qt_action_editor_tool_action"), + u"__qt_action_editor_tool_action"_s, Qt::RightDockWidgetArea) { } @@ -238,9 +240,9 @@ public: ObjectInspectorToolWindow::ObjectInspectorToolWindow(QDesignerWorkbench *workbench) : QDesignerToolWindow(workbench, createObjectInspector(workbench->core()), - QStringLiteral("qt_designer_objectinspector"), + u"qt_designer_objectinspector"_s, QDesignerToolWindow::tr("Object Inspector"), - QStringLiteral("__qt_object_inspector_tool_action"), + u"__qt_object_inspector_tool_action"_s, Qt::RightDockWidgetArea) { } @@ -273,9 +275,9 @@ public: ResourceEditorToolWindow::ResourceEditorToolWindow(QDesignerWorkbench *workbench) : QDesignerToolWindow(workbench, QDesignerComponents::createResourceEditor(workbench->core(), nullptr), - QStringLiteral("qt_designer_resourceeditor"), + u"qt_designer_resourceeditor"_s, QDesignerToolWindow::tr("Resource Browser"), - QStringLiteral("__qt_resource_editor_tool_action"), + u"__qt_resource_editor_tool_action"_s, Qt::RightDockWidgetArea) { } @@ -307,9 +309,9 @@ public: SignalSlotEditorToolWindow::SignalSlotEditorToolWindow(QDesignerWorkbench *workbench) : QDesignerToolWindow(workbench, QDesignerComponents::createSignalSlotEditor(workbench->core(), nullptr), - QStringLiteral("qt_designer_signalsloteditor"), + u"qt_designer_signalsloteditor"_s, QDesignerToolWindow::tr("Signal/Slot Editor"), - QStringLiteral("__qt_signal_slot_editor_tool_action"), + u"__qt_signal_slot_editor_tool_action"_s, Qt::RightDockWidgetArea) { } @@ -348,9 +350,9 @@ public: WidgetBoxToolWindow::WidgetBoxToolWindow(QDesignerWorkbench *workbench) : QDesignerToolWindow(workbench, createWidgetBox(workbench->core()), - QStringLiteral("qt_designer_widgetbox"), + u"qt_designer_widgetbox"_s, QDesignerToolWindow::tr("Widget Box"), - QStringLiteral("__qt_widget_box_tool_action"), + u"__qt_widget_box_tool_action"_s, Qt::LeftDockWidgetArea) { } diff --git a/src/designer/src/designer/qdesigner_workbench.cpp b/src/designer/src/designer/qdesigner_workbench.cpp index adcb508b8..5ee5f7790 100644 --- a/src/designer/src/designer/qdesigner_workbench.cpp +++ b/src/designer/src/designer/qdesigner_workbench.cpp @@ -47,6 +47,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static const char *appFontPrefixC = "AppFonts"; using ActionList = QList<QAction *>; @@ -793,7 +795,7 @@ bool QDesignerWorkbench::readInBackup() if (answer == QMessageBox::No) return false; - const QString modifiedPlaceHolder = QStringLiteral("[*]"); + const auto modifiedPlaceHolder = "[*]"_L1; for (auto it = backupFileMap.cbegin(), end = backupFileMap.cend(); it != end; ++it) { QString fileName = it.key(); fileName.remove(modifiedPlaceHolder); diff --git a/src/designer/src/designer/saveformastemplate.cpp b/src/designer/src/designer/saveformastemplate.cpp index 10c0c06d2..a26b057e9 100644 --- a/src/designer/src/designer/saveformastemplate.cpp +++ b/src/designer/src/designer/saveformastemplate.cpp @@ -14,6 +14,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + SaveFormAsTemplate::SaveFormAsTemplate(QDesignerFormEditorInterface *core, QDesignerFormWindowInterface *formWindow, QWidget *parent) @@ -46,7 +48,7 @@ void SaveFormAsTemplate::accept() templateFileName += QLatin1Char('/'); const QString name = ui.templateNameEdit->text(); templateFileName += name; - const QString extension = QStringLiteral(".ui"); + const auto extension = ".ui"_L1; if (!templateFileName.endsWith(extension)) templateFileName.append(extension); QFile file(templateFileName); diff --git a/src/designer/src/designer/versiondialog.cpp b/src/designer/src/designer/versiondialog.cpp index 05d433539..b438a7b22 100644 --- a/src/designer/src/designer/versiondialog.cpp +++ b/src/designer/src/designer/versiondialog.cpp @@ -17,6 +17,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + class VersionLabel : public QLabel { Q_OBJECT @@ -42,7 +44,7 @@ private: VersionLabel::VersionLabel(QWidget *parent) : QLabel(parent) { - QPixmap pixmap(QStringLiteral(":/qt-project.org/designer/images/designer.png")); + QPixmap pixmap(u":/qt-project.org/designer/images/designer.png"_s); pixmap.setDevicePixelRatio(devicePixelRatioF()); setPixmap(pixmap); hitPoints.append(QPoint(56, 25)); @@ -140,7 +142,7 @@ VersionDialog::VersionDialog(QWidget *parent) lbl->setText(tr("%1" "<br/>Copyright (C) %2 The Qt Company Ltd." - ).arg(version, QStringLiteral("2023"))); + ).arg(version, "2023"_L1)); lbl->setWordWrap(true); lbl->setOpenExternalLinks(true); diff --git a/src/designer/src/lib/sdk/abstractformeditor.cpp b/src/designer/src/lib/sdk/abstractformeditor.cpp index 5f34febb7..58e55cbba 100644 --- a/src/designer/src/lib/sdk/abstractformeditor.cpp +++ b/src/designer/src/lib/sdk/abstractformeditor.cpp @@ -47,6 +47,8 @@ static void initResources() QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + class QDesignerFormEditorInterfacePrivate { public: QDesignerFormEditorInterfacePrivate(); @@ -511,9 +513,9 @@ void QDesignerFormEditorInterface::setIntrospection(QDesignerIntrospectionInterf QString QDesignerFormEditorInterface::resourceLocation() const { #ifdef Q_OS_MACOS - return QStringLiteral(":/qt-project.org/formeditor/images/mac"); + return u":/qt-project.org/formeditor/images/mac"_s; #else - return QStringLiteral(":/qt-project.org/formeditor/images/win"); + return u":/qt-project.org/formeditor/images/win"_s; #endif } diff --git a/src/designer/src/lib/sdk/abstractintegration.cpp b/src/designer/src/lib/sdk/abstractintegration.cpp index 896d444ab..ee0ff7f45 100644 --- a/src/designer/src/lib/sdk/abstractintegration.cpp +++ b/src/designer/src/lib/sdk/abstractintegration.cpp @@ -296,7 +296,7 @@ public: QDesignerIntegrationPrivate::QDesignerIntegrationPrivate(QDesignerIntegration *qq) : q(qq), - headerSuffix(QStringLiteral(".h")), + headerSuffix(u".h"_s), headerLowercase(true), m_features(QDesignerIntegrationInterface::DefaultFeature), m_resourceFileWatcherBehaviour(QDesignerIntegrationInterface::PromptToReloadResourceFile), @@ -349,7 +349,7 @@ void QDesignerIntegrationPrivate::initialize() QtGradientUtils::restoreState(m_gradientManager, QString::fromLatin1(f.readAll())); f.close(); } else { - QFile defaultGradients(QStringLiteral(":/qt-project.org/designer/defaultgradients.xml")); + QFile defaultGradients(u":/qt-project.org/designer/defaultgradients.xml"_s); if (defaultGradients.open(QIODevice::ReadOnly)) { QtGradientUtils::restoreState(m_gradientManager, QString::fromLatin1(defaultGradients.readAll())); defaultGradients.close(); @@ -565,12 +565,12 @@ void QDesignerIntegrationPrivate::updateCustomWidgetPlugins() static QString fixHelpClassName(const QString &className) { // ### generalize using the Widget Data Base - if (className == QStringLiteral("Line")) - return QStringLiteral("QFrame"); - if (className == QStringLiteral("Spacer")) - return QStringLiteral("QSpacerItem"); - if (className == QStringLiteral("QLayoutWidget")) - return QStringLiteral("QLayout"); + if (className == "Line"_L1) + return u"QFrame"_s; + if (className == "Spacer"_L1) + return u"QSpacerItem"_s; + if (className == "QLayoutWidget"_L1) + return u"QLayout"_s; return className; } @@ -604,7 +604,7 @@ QString QDesignerIntegrationPrivate::contextHelpId() const } QString helpId = fixHelpClassName(className); if (!currentPropertyName.isEmpty()) { - helpId += QStringLiteral("::"); + helpId += "::"_L1; helpId += currentPropertyName; } return helpId; diff --git a/src/designer/src/lib/shared/actioneditor.cpp b/src/designer/src/lib/shared/actioneditor.cpp index 4c8893540..057616217 100644 --- a/src/designer/src/lib/shared/actioneditor.cpp +++ b/src/designer/src/lib/shared/actioneditor.cpp @@ -47,6 +47,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static const char *actionEditorViewModeKey = "ActionEditorViewMode"; static const char *iconPropertyC = "icon"; @@ -112,7 +114,8 @@ ActionEditor::ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent, toolbar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); l->addWidget(toolbar); // edit actions - QIcon documentNewIcon = QIcon::fromTheme(QStringLiteral("document-new"), createIconSet(QStringLiteral("filenew.png"))); + QIcon documentNewIcon = QIcon::fromTheme(u"document-new"_s, + createIconSet(u"filenew.png"_s)); m_actionNew->setIcon(documentNewIcon); m_actionNew->setEnabled(false); connect(m_actionNew, &QAction::triggered, this, &ActionEditor::slotNewAction); @@ -123,17 +126,20 @@ ActionEditor::ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent, #if QT_CONFIG(clipboard) m_actionCut->setEnabled(false); connect(m_actionCut, &QAction::triggered, this, &ActionEditor::slotCut); - QIcon editCutIcon = QIcon::fromTheme(QStringLiteral("edit-cut"), createIconSet(QStringLiteral("editcut.png"))); + QIcon editCutIcon = QIcon::fromTheme(u"edit-cut"_s, + createIconSet(u"editcut.png"_s)); m_actionCut->setIcon(editCutIcon); m_actionCopy->setEnabled(false); connect(m_actionCopy, &QAction::triggered, this, &ActionEditor::slotCopy); - QIcon editCopyIcon = QIcon::fromTheme(QStringLiteral("edit-copy"), createIconSet(QStringLiteral("editcopy.png"))); + QIcon editCopyIcon = QIcon::fromTheme(u"edit-copy"_s, + createIconSet(u"editcopy.png"_s)); m_actionCopy->setIcon(editCopyIcon); toolbar->addAction(m_actionCopy); connect(m_actionPaste, &QAction::triggered, this, &ActionEditor::slotPaste); - QIcon editPasteIcon = QIcon::fromTheme(QStringLiteral("edit-paste"), createIconSet(QStringLiteral("editpaste.png"))); + QIcon editPasteIcon = QIcon::fromTheme(u"edit-paste"_s, + createIconSet(u"editpaste.png"_s)); m_actionPaste->setIcon(editPasteIcon); toolbar->addAction(m_actionPaste); #endif @@ -143,7 +149,8 @@ ActionEditor::ActionEditor(QDesignerFormEditorInterface *core, QWidget *parent, connect(m_actionNavigateToSlot, &QAction::triggered, this, &ActionEditor::navigateToSlotCurrentAction); - QIcon editDeleteIcon = QIcon::fromTheme(QStringLiteral("edit-delete"), createIconSet(QStringLiteral("editdelete.png"))); + QIcon editDeleteIcon = QIcon::fromTheme(u"edit-delete"_s, + createIconSet(u"editdelete.png"_s)); m_actionDelete->setIcon(editDeleteIcon); m_actionDelete->setEnabled(false); connect(m_actionDelete, &QAction::triggered, this, &ActionEditor::slotDelete); @@ -222,7 +229,8 @@ QToolButton *ActionEditor::createConfigureMenuButton(const QString &t, QMenu **p { QToolButton *configureButton = new QToolButton; QAction *configureAction = new QAction(t, configureButton); - QIcon configureIcon = QIcon::fromTheme(QStringLiteral("document-properties"), createIconSet(QStringLiteral("configure.png"))); + QIcon configureIcon = QIcon::fromTheme(u"document-properties"_s, + createIconSet(u"configure.png"_s)); configureAction->setIcon(configureIcon); QMenu *configureMenu = new QMenu(configureButton); configureAction->setMenu(configureMenu); @@ -569,7 +577,7 @@ void ActionEditor::editAction(QAction *action, int column) QDesignerFormWindowInterface *fw = formWindow(); QUndoStack *undoStack = fw->commandHistory(); if (severalChanges) - fw->beginCommand(QStringLiteral("Edit action")); + fw->beginCommand(u"Edit action"_s); if (changeMask & ActionData::NameChanged) undoStack->push(createTextPropertyCommand(QLatin1String(objectNamePropertyC), newActionData.name, action, fw)); @@ -605,7 +613,7 @@ void ActionEditor::editCurrentAction() void ActionEditor::navigateToSlotCurrentAction() { if (QAction *a = m_actionView->currentAction()) - QDesignerTaskMenu::navigateToSlot(m_core, a, QStringLiteral("triggered()")); + QDesignerTaskMenu::navigateToSlot(m_core, a, u"triggered()"_s); } void ActionEditor::deleteActions(QDesignerFormWindowInterface *fw, const ActionList &actions) @@ -665,10 +673,10 @@ void ActionEditor::slotDelete() static QString underscore(QString text) { const QString underscore = QString(QLatin1Char('_')); - static const QRegularExpression nonAsciiPattern(QStringLiteral("[^a-zA-Z_0-9]")); + static const QRegularExpression nonAsciiPattern(u"[^a-zA-Z_0-9]"_s); Q_ASSERT(nonAsciiPattern.isValid()); text.replace(nonAsciiPattern, underscore); - static const QRegularExpression multipleSpacePattern(QStringLiteral("__*")); + static const QRegularExpression multipleSpacePattern(u"__*"_s); Q_ASSERT(multipleSpacePattern.isValid()); text.replace(multipleSpacePattern, underscore); if (text.endsWith(underscore.at(0))) diff --git a/src/designer/src/lib/shared/actionrepository.cpp b/src/designer/src/lib/shared/actionrepository.cpp index b6a452bb0..8f49a6dc7 100644 --- a/src/designer/src/lib/shared/actionrepository.cpp +++ b/src/designer/src/lib/shared/actionrepository.cpp @@ -27,6 +27,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { enum { listModeIconSize = 16, iconModeIconSize = 24 }; } @@ -137,7 +139,7 @@ PropertySheetKeySequenceValue ActionModel::actionShortCut(QDesignerFormEditorInt PropertySheetKeySequenceValue ActionModel::actionShortCut(const QDesignerPropertySheetExtension *sheet) { - const int index = sheet->indexOf(QStringLiteral("shortcut")); + const int index = sheet->indexOf(u"shortcut"_s); if (index == -1) return PropertySheetKeySequenceValue(); return qvariant_cast<PropertySheetKeySequenceValue>(sheet->property(index)); @@ -173,7 +175,7 @@ void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action, item->setCheckState(used ? Qt::Checked : Qt::Unchecked); if (used) { QString usedToolTip; - const QString separator = QStringLiteral(", "); + const auto separator = ", "_L1; const int count = associatedDesignerWidgets.size(); for (int i = 0; i < count; i++) { if (i) diff --git a/src/designer/src/lib/shared/codedialog.cpp b/src/designer/src/lib/shared/codedialog.cpp index 4d918462e..ae91ea6dc 100644 --- a/src/designer/src/lib/shared/codedialog.cpp +++ b/src/designer/src/lib/shared/codedialog.cpp @@ -30,6 +30,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // ----------------- CodeDialogPrivate struct CodeDialog::CodeDialogPrivate { @@ -57,12 +59,12 @@ CodeDialog::CodeDialog(QWidget *parent) : // Edit tool bar QToolBar *toolBar = new QToolBar; - const QIcon saveIcon = createIconSet(QStringLiteral("filesave.png")); + const QIcon saveIcon = createIconSet(u"filesave.png"_s); QAction *saveAction = toolBar->addAction(saveIcon, tr("Save...")); connect(saveAction, &QAction::triggered, this, &CodeDialog::slotSaveAs); #if QT_CONFIG(clipboard) - const QIcon copyIcon = createIconSet(QStringLiteral("editcopy.png")); + const QIcon copyIcon = createIconSet(u"editcopy.png"_s); QAction *copyAction = toolBar->addAction(copyIcon, tr("Copy All")); connect(copyAction, &QAction::triggered, this, &CodeDialog::copyAll); #endif @@ -136,11 +138,11 @@ bool CodeDialog::generateCode(const QDesignerFormWindowInterface *fw, tempPattern += QDir::separator(); const QString fileName = fw->fileName(); if (fileName.isEmpty()) { - tempPattern += QStringLiteral("designer"); + tempPattern += "designer"_L1; } else { tempPattern += QFileInfo(fileName).baseName(); } - tempPattern += QStringLiteral("XXXXXX.ui"); + tempPattern += "XXXXXX.ui"_L1; // Write to temp file QTemporaryFile tempFormFile(tempPattern); diff --git a/src/designer/src/lib/shared/formlayoutmenu.cpp b/src/designer/src/lib/shared/formlayoutmenu.cpp index 116afe885..ba0dc6baa 100644 --- a/src/designer/src/lib/shared/formlayoutmenu.cpp +++ b/src/designer/src/lib/shared/formlayoutmenu.cpp @@ -39,6 +39,8 @@ static const char *fieldWidgetBaseClasses[] = { QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // Struct that describes a row of controls (descriptive label and control) to @@ -102,7 +104,7 @@ private: FormLayoutRowDialog::FormLayoutRowDialog(QDesignerFormEditorInterface *core, QWidget *parent) : QDialog(parent), - m_buddyMarkerRegexp(QStringLiteral("\\&[^&]")), + m_buddyMarkerRegexp(u"\\&[^&]"_s), m_labelNameEdited(false), m_fieldNameEdited(false), m_buddyClicked(false) @@ -113,7 +115,7 @@ FormLayoutRowDialog::FormLayoutRowDialog(QDesignerFormEditorInterface *core, m_ui.setupUi(this); connect(m_ui.labelTextLineEdit, &QLineEdit::textEdited, this, &FormLayoutRowDialog::labelTextEdited); - QRegularExpressionValidator *nameValidator = new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^[a-zA-Z0-9_]+$")), this); + auto *nameValidator = new QRegularExpressionValidator(QRegularExpression(u"^[a-zA-Z0-9_]+$"_s), this); Q_ASSERT(nameValidator->regularExpression().isValid()); m_ui.labelNameLineEdit->setValidator(nameValidator); @@ -214,7 +216,7 @@ void FormLayoutRowDialog::labelTextEdited(const QString &text) // "namespace::QLineEdit"->"LineEdit" static inline QString postFixFromClassName(QString className) { - const int index = className.lastIndexOf(QStringLiteral("::")); + const int index = className.lastIndexOf("::"_L1); if (index != -1) className.remove(0, index + 2); if (className.size() > 2) @@ -295,7 +297,7 @@ void FormLayoutRowDialog::updateObjectNames(bool updateLabel, bool updateField) const QString prefix = prefixFromLabel(labelText()); // Set names if (doUpdateLabel) - m_ui.labelNameLineEdit->setText(prefix + QStringLiteral("Label")); + m_ui.labelNameLineEdit->setText(prefix + "Label"_L1); if (doUpdateField) m_ui.fieldNameLineEdit->setText(prefix + postFixFromClassName(fieldClass())); } @@ -384,16 +386,16 @@ static QPair<QWidget *,QWidget *> QDesignerFormEditorInterface *core = formWindow->core(); QDesignerWidgetFactoryInterface *wf = core->widgetFactory(); - QPair<QWidget *,QWidget *> rc = QPair<QWidget *,QWidget *>(wf->createWidget(QStringLiteral("QLabel"), parent), - wf->createWidget(row.fieldClassName, parent)); + QPair<QWidget *,QWidget *> rc{wf->createWidget(u"QLabel"_s, parent), + wf->createWidget(row.fieldClassName, parent)}; // Set up properties of the label - const QString objectNameProperty = QStringLiteral("objectName"); + const QString objectNameProperty = u"objectName"_s; QDesignerPropertySheetExtension *labelSheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), rc.first); int nameIndex = labelSheet->indexOf(objectNameProperty); labelSheet->setProperty(nameIndex, QVariant::fromValue(PropertySheetStringValue(row.labelName))); labelSheet->setChanged(nameIndex, true); formWindow->ensureUniqueObjectName(rc.first); - const int textIndex = labelSheet->indexOf(QStringLiteral("text")); + const int textIndex = labelSheet->indexOf(u"text"_s); labelSheet->setProperty(textIndex, QVariant::fromValue(PropertySheetStringValue(row.labelText))); labelSheet->setChanged(textIndex, true); // Set up properties of the control diff --git a/src/designer/src/lib/shared/formwindowbase.cpp b/src/designer/src/lib/shared/formwindowbase.cpp index 4ef3a2b9f..7d93f7098 100644 --- a/src/designer/src/lib/shared/formwindowbase.cpp +++ b/src/designer/src/lib/shared/formwindowbase.cpp @@ -41,6 +41,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { class FormWindowBasePrivate { @@ -207,11 +209,11 @@ void FormWindowBase::reloadProperties() for (auto jt = it.value().begin(), end = it.value().end(); jt != end; ++jt) { const int index = jt.key(); const QVariant newValue = sheet->property(index); - if (qobject_cast<QLabel *>(sheet->object()) && sheet->propertyName(index) == QStringLiteral("text")) { + if (qobject_cast<QLabel *>(sheet->object()) && sheet->propertyName(index) == "text"_L1) { const PropertySheetStringValue newString = qvariant_cast<PropertySheetStringValue>(newValue); // optimize a bit, reset only if the text value might contain a reference to qt resources // (however reloading of icons other than taken from resources might not work here) - if (newString.value().contains(QStringLiteral(":/"))) { + if (newString.value().contains(":/"_L1)) { const QVariant resetValue = QVariant::fromValue(PropertySheetStringValue()); sheet->setProperty(index, resetValue); } @@ -221,7 +223,7 @@ void FormWindowBase::reloadProperties() if (QTabWidget *tabWidget = qobject_cast<QTabWidget *>(sheet->object())) { const int count = tabWidget->count(); const int current = tabWidget->currentIndex(); - const QString currentTabIcon = QStringLiteral("currentTabIcon"); + const QString currentTabIcon = u"currentTabIcon"_s; for (int i = 0; i < count; i++) { tabWidget->setCurrentIndex(i); const int index = sheet->indexOf(currentTabIcon); @@ -231,7 +233,7 @@ void FormWindowBase::reloadProperties() } else if (QToolBox *toolBox = qobject_cast<QToolBox *>(sheet->object())) { const int count = toolBox->count(); const int current = toolBox->currentIndex(); - const QString currentItemIcon = QStringLiteral("currentItemIcon"); + const QString currentItemIcon = u"currentItemIcon"_s; for (int i = 0; i < count; i++) { toolBox->setCurrentIndex(i); const int index = sheet->indexOf(currentItemIcon); @@ -441,7 +443,7 @@ QMenu *FormWindowBase::createExtensionTaskMenu(QDesignerFormWindowInterface *fw, QExtensionManager *em = fw->core()->extensionManager(); if (const QDesignerTaskMenuExtension *extTaskMenu = qt_extension<QDesignerTaskMenuExtension*>(em, o)) actions += extTaskMenu->taskActions(); - if (const QDesignerTaskMenuExtension *intTaskMenu = qobject_cast<QDesignerTaskMenuExtension *>(em->extension(o, QStringLiteral("QDesignerInternalTaskMenuExtension")))) { + if (const auto *intTaskMenu = qobject_cast<QDesignerTaskMenuExtension *>(em->extension(o, u"QDesignerInternalTaskMenuExtension"_s))) { if (!actions.isEmpty()) { QAction *a = new QAction(fw); a->setSeparator(true); diff --git a/src/designer/src/lib/shared/iconloader.cpp b/src/designer/src/lib/shared/iconloader.cpp index 739f57a19..e67e06cca 100644 --- a/src/designer/src/lib/shared/iconloader.cpp +++ b/src/designer/src/lib/shared/iconloader.cpp @@ -9,6 +9,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { QDESIGNER_SHARED_EXPORT QIcon createIconSet(const QString &name) @@ -32,7 +34,7 @@ QDESIGNER_SHARED_EXPORT QIcon createIconSet(const QString &name) QDESIGNER_SHARED_EXPORT QIcon emptyIcon() { - return QIcon(QStringLiteral(":/qt-project.org/formeditor/images/emptyicon.png")); + return QIcon(u":/qt-project.org/formeditor/images/emptyicon.png"_s); } static QIcon buildIcon(const QString &prefix, const int *sizes, size_t sizeCount) @@ -40,7 +42,7 @@ static QIcon buildIcon(const QString &prefix, const int *sizes, size_t sizeCount QIcon result; for (size_t i = 0; i < sizeCount; ++i) { const QString size = QString::number(sizes[i]); - const QPixmap pixmap(prefix + size + QLatin1Char('x') + size + QStringLiteral(".png")); + const QPixmap pixmap(prefix + size + 'x'_L1 + size + ".png"_L1); Q_ASSERT(!pixmap.size().isEmpty()); result.addPixmap(pixmap); } @@ -51,7 +53,7 @@ QDESIGNER_SHARED_EXPORT QIcon qtLogoIcon() { static const int sizes[] = {16, 24, 32, 64, 128}; static const QIcon result = - buildIcon(QStringLiteral(":/qt-project.org/formeditor/images/qtlogo"), + buildIcon(u":/qt-project.org/formeditor/images/qtlogo"_s, sizes, sizeof(sizes) / sizeof(sizes[0])); return result; } diff --git a/src/designer/src/lib/shared/iconselector.cpp b/src/designer/src/lib/shared/iconselector.cpp index 4cf73eb5b..677f155eb 100644 --- a/src/designer/src/lib/shared/iconselector.cpp +++ b/src/designer/src/lib/shared/iconselector.cpp @@ -36,6 +36,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // Validator for theme line edit, accepts empty or non-blank strings. @@ -316,17 +318,16 @@ static QString imageFilter() { QString filter = QApplication::translate("IconSelector", "All Pixmaps ("); const auto supportedImageFormats = QImageReader::supportedImageFormats(); - const QString jpeg = QStringLiteral("JPEG"); const qsizetype count = supportedImageFormats.size(); for (qsizetype i = 0; i < count; ++i) { if (i) filter += QLatin1Char(' '); - filter += QStringLiteral("*."); + filter += "*."_L1; const QString outputFormat = QString::fromUtf8(supportedImageFormats.at(i)); - if (outputFormat != jpeg) + if (outputFormat != "JPEG"_L1) filter += outputFormat.toLower(); else - filter += QStringLiteral("jpg *.jpeg"); + filter += "jpg *.jpeg"_L1; } filter += QLatin1Char(')'); return filter; @@ -503,7 +504,7 @@ static const QMap<QString, QIcon> &themeIcons() { static QMap<QString, QIcon> result; if (result.isEmpty()) { - QFile file(QStringLiteral(":/qt-project.org/designer/icon-naming-spec.txt")); + QFile file(u":/qt-project.org/designer/icon-naming-spec.txt"_s); if (file.open(QIODevice::ReadOnly)) { while (!file.atEnd()) { const auto line = file.readLine().trimmed(); @@ -546,7 +547,7 @@ IconThemeEditor::IconThemeEditor(QWidget *parent, bool wantResetButton) : if (wantResetButton) { QToolButton *themeResetButton = new QToolButton; - themeResetButton->setIcon(createIconSet(QStringLiteral("resetproperty.png"))); + themeResetButton->setIcon(createIconSet(u"resetproperty.png"_s)); connect(themeResetButton, &QAbstractButton::clicked, this, &IconThemeEditor::reset); mainHLayout->addWidget(themeResetButton); } diff --git a/src/designer/src/lib/shared/layout.cpp b/src/designer/src/lib/shared/layout.cpp index da2a4cb3a..7ec7775e2 100644 --- a/src/designer/src/lib/shared/layout.cpp +++ b/src/designer/src/lib/shared/layout.cpp @@ -38,6 +38,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + enum { FormLayoutColumns = 2 }; namespace qdesigner_internal { @@ -198,7 +200,7 @@ bool Layout::prepareLayout(bool &needMove, bool &needReparent) const QString baseWidgetClassName = useSplitter ? QLatin1String("QSplitter") : QLatin1String("QLayoutWidget"); m_layoutBase = widgetFactory->createWidget(baseWidgetClassName, widgetFactory->containerOfWidget(m_parentWidget)); if (useSplitter) { - m_layoutBase->setObjectName(QStringLiteral("splitter")); + m_layoutBase->setObjectName(u"splitter"_s); m_formWindow->ensureUniqueObjectName(m_layoutBase); } } else { @@ -402,11 +404,11 @@ static QString suggestLayoutName(const char *className) { // Legacy if (!qstrcmp(className, "QHBoxLayout")) - return QStringLiteral("horizontalLayout"); + return u"horizontalLayout"_s; if (!qstrcmp(className, "QVBoxLayout")) - return QStringLiteral("verticalLayout"); + return u"verticalLayout"_s; if (!qstrcmp(className, "QGridLayout")) - return QStringLiteral("gridLayout"); + return u"gridLayout"_s; return qtify(QString::fromUtf8(className)); } @@ -420,10 +422,10 @@ QLayout *Layout::createLayout(int type) // QLayoutWidget QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(m_formWindow->core()->extensionManager(), layout); if (sheet && qobject_cast<QLayoutWidget*>(m_layoutBase)) { - sheet->setProperty(sheet->indexOf(QStringLiteral("leftMargin")), 0); - sheet->setProperty(sheet->indexOf(QStringLiteral("topMargin")), 0); - sheet->setProperty(sheet->indexOf(QStringLiteral("rightMargin")), 0); - sheet->setProperty(sheet->indexOf(QStringLiteral("bottomMargin")), 0); + sheet->setProperty(sheet->indexOf(u"leftMargin"_s), 0); + sheet->setProperty(sheet->indexOf(u"topMargin"_s), 0); + sheet->setProperty(sheet->indexOf(u"rightMargin"_s), 0); + sheet->setProperty(sheet->indexOf(u"bottomMargin"_s), 0); } return layout; } diff --git a/src/designer/src/lib/shared/layoutinfo.cpp b/src/designer/src/lib/shared/layoutinfo.cpp index ec6e0917c..182e42f37 100644 --- a/src/designer/src/lib/shared/layoutinfo.cpp +++ b/src/designer/src/lib/shared/layoutinfo.cpp @@ -17,6 +17,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { /*! \overload @@ -39,13 +41,12 @@ LayoutInfo::Type LayoutInfo::layoutType(const QDesignerFormEditorInterface *core static const QHash<QString, LayoutInfo::Type> &layoutNameTypeMap() { - static QHash<QString, LayoutInfo::Type> nameTypeMap; - if (nameTypeMap.isEmpty()) { - nameTypeMap.insert(QStringLiteral("QVBoxLayout"), LayoutInfo::VBox); - nameTypeMap.insert(QStringLiteral("QHBoxLayout"), LayoutInfo::HBox); - nameTypeMap.insert(QStringLiteral("QGridLayout"), LayoutInfo::Grid); - nameTypeMap.insert(QStringLiteral("QFormLayout"), LayoutInfo::Form); - } + static const QHash<QString, LayoutInfo::Type> nameTypeMap = { + {u"QVBoxLayout"_s, LayoutInfo::VBox}, + {u"QHBoxLayout"_s, LayoutInfo::HBox}, + {u"QGridLayout"_s, LayoutInfo::Grid}, + {u"QFormLayout"_s, LayoutInfo::Form} + }; return nameTypeMap; } diff --git a/src/designer/src/lib/shared/morphmenu.cpp b/src/designer/src/lib/shared/morphmenu.cpp index 0b3e87d6d..1ad8a4f3a 100644 --- a/src/designer/src/lib/shared/morphmenu.cpp +++ b/src/designer/src/lib/shared/morphmenu.cpp @@ -48,6 +48,8 @@ Q_DECLARE_METATYPE(QWidgetList) QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // Helpers for the dynamic properties that store Z/Widget order static const char *widgetOrderPropertyC = "_q_widgetOrder"; static const char *zOrderPropertyC = "_q_zOrder"; @@ -134,29 +136,29 @@ static QStringList classesOfCategory(MorphCategory cat) case MorphSimpleContainer: // Do not generally allow to morph into a layout. // This can be risky in case of container pages,etc. - l << QStringLiteral("QWidget") << QStringLiteral("QFrame") << QStringLiteral("QGroupBox"); + l << u"QWidget"_s << u"QFrame"_s << u"QGroupBox"_s; break; case MorphPageContainer: - l << QStringLiteral("QTabWidget") << QStringLiteral("QStackedWidget") << QStringLiteral("QToolBox"); + l << u"QTabWidget"_s << u"QStackedWidget"_s << u"QToolBox"_s; break; case MorphItemView: - l << QStringLiteral("QListView") << QStringLiteral("QListWidget") - << QStringLiteral("QTreeView") << QStringLiteral("QTreeWidget") - << QStringLiteral("QTableView") << QStringLiteral("QTableWidget") - << QStringLiteral("QColumnView"); + l << u"QListView"_s << u"QListWidget"_s + << u"QTreeView"_s << u"QTreeWidget"_s + << u"QTableView"_s << u"QTableWidget"_s + << u"QColumnView"_s; break; case MorphButton: - l << QStringLiteral("QCheckBox") << QStringLiteral("QRadioButton") - << QStringLiteral("QPushButton") << QStringLiteral("QToolButton") - << QStringLiteral("QCommandLinkButton"); + l << u"QCheckBox"_s << u"QRadioButton"_s + << u"QPushButton"_s << u"QToolButton"_s + << u"QCommandLinkButton"_s; break; case MorphSpinBox: - l << QStringLiteral("QDateTimeEdit") << QStringLiteral("QDateEdit") - << QStringLiteral("QTimeEdit") - << QStringLiteral("QSpinBox") << QStringLiteral("QDoubleSpinBox"); + l << u"QDateTimeEdit"_s << u"QDateEdit"_s + << u"QTimeEdit"_s + << u"QSpinBox"_s << u"QDoubleSpinBox"_s; break; case MorphTextEdit: - l << QStringLiteral("QTextEdit") << QStringLiteral("QPlainTextEdit") << QStringLiteral("QTextBrowser"); + l << u"QTextEdit"_s << u"QPlainTextEdit"_s << u"QTextBrowser"_s; break; } } @@ -276,7 +278,7 @@ bool MorphWidgetCommand::addMorphMacro(QDesignerFormWindowInterface *fw, QWidget // restore buddy using the QByteArray name. if (buddyLabel) { SetPropertyCommand *buddyCmd = new SetPropertyCommand(fw); - buddyCmd->init(buddyLabel, QStringLiteral("buddy"), QVariant(newWidgetName.toUtf8())); + buddyCmd->init(buddyLabel, u"buddy"_s, QVariant(newWidgetName.toUtf8())); us->push(buddyCmd); } us->endMacro(); @@ -317,13 +319,12 @@ bool MorphWidgetCommand::init(QWidget *widget, const QString &newClassName) // up the children of the before widget if (QDesignerContainerExtension* c = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), m_afterWidget)) { if (const auto pageCount = childContainers(core, m_beforeWidget).size()) { - const QString qWidget = QStringLiteral("QWidget"); const QString containerName = m_afterWidget->objectName(); for (qsizetype i = 0; i < pageCount; ++i) { QString name = containerName; - name += QStringLiteral("Page"); + name += "Page"_L1; name += QString::number(i + 1); - QWidget *page = core->widgetFactory()->createWidget(qWidget); + QWidget *page = core->widgetFactory()->createWidget(u"QWidget"_s); page->setObjectName(name); fw->ensureUniqueObjectName(page); c->addWidget(page); @@ -335,12 +336,11 @@ bool MorphWidgetCommand::init(QWidget *widget, const QString &newClassName) // Copy over applicable properties const QDesignerPropertySheetExtension *beforeSheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), widget); QDesignerPropertySheetExtension *afterSheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), m_afterWidget); - const QString objectNameProperty = QStringLiteral("objectName"); const int count = beforeSheet->count(); for (int i = 0; i < count; i++) if (beforeSheet->isVisible(i) && beforeSheet->isChanged(i)) { const QString name = beforeSheet->propertyName(i); - if (name != objectNameProperty) { + if (name != "objectName"_L1) { const int afterIndex = afterSheet->indexOf(name); if (afterIndex != -1 && afterSheet->isVisible(afterIndex) && afterSheet->propertyGroup(afterIndex) == beforeSheet->propertyGroup(i)) { afterSheet->setProperty(i, beforeSheet->property(i)); diff --git a/src/designer/src/lib/shared/newactiondialog.cpp b/src/designer/src/lib/shared/newactiondialog.cpp index 381a4edfb..3ff08f6c6 100644 --- a/src/designer/src/lib/shared/newactiondialog.cpp +++ b/src/designer/src/lib/shared/newactiondialog.cpp @@ -17,6 +17,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // Returns a combination of ChangeMask flags unsigned ActionData::compare(const ActionData &rhs) const @@ -51,7 +53,7 @@ NewActionDialog::NewActionDialog(ActionEditor *parent) : m_ui->tooltipEditor->setTextPropertyValidationMode(ValidationRichText); connect(m_ui->toolTipToolButton, &QAbstractButton::clicked, this, &NewActionDialog::slotEditToolTip); - m_ui->keysequenceResetToolButton->setIcon(createIconSet(QStringLiteral("resetproperty.png"))); + m_ui->keysequenceResetToolButton->setIcon(createIconSet(u"resetproperty.png"_s)); connect(m_ui->keysequenceResetToolButton, &QAbstractButton::clicked, this, &NewActionDialog::slotResetKeySequence); diff --git a/src/designer/src/lib/shared/newformwidget.cpp b/src/designer/src/lib/shared/newformwidget.cpp index dbe1c0219..8ee2c4955 100644 --- a/src/designer/src/lib/shared/newformwidget.cpp +++ b/src/designer/src/lib/shared/newformwidget.cpp @@ -32,6 +32,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + enum { profileComboIndexOffset = 1 }; enum { debugNewFormWidget = 0 }; @@ -116,12 +118,12 @@ NewFormWidget::NewFormWidget(QDesignerFormEditorInterface *core, QWidget *parent m_ui->lblPreview->setBackgroundRole(QPalette::Base); QDesignerSharedSettings settings(m_core); - QString uiExtension = QStringLiteral("ui"); - QString templatePath = QStringLiteral(":/qt-project.org/designer/templates/forms"); + QString uiExtension = u"ui"_s; + QString templatePath = u":/qt-project.org/designer/templates/forms"_s; QDesignerLanguageExtension *lang = qt_extension<QDesignerLanguageExtension *>(core->extensionManager(), core); if (lang) { - templatePath = QStringLiteral(":/templates/forms"); + templatePath = u":/templates/forms"_s; uiExtension = lang->uiExtension(); } @@ -378,7 +380,7 @@ void NewFormWidget::loadFrom(const QString &path, bool resourceFile, const QStri return; // Iterate through the directory and add the templates - const QFileInfoList list = dir.entryInfoList(QStringList(QStringLiteral("*.") + uiExtension), + const QFileInfoList list = dir.entryInfoList(QStringList{"*."_L1 + uiExtension}, QDir::Files); if (list.isEmpty()) diff --git a/src/designer/src/lib/shared/plugindialog.cpp b/src/designer/src/lib/shared/plugindialog.cpp index dda523b7c..9b954802f 100644 --- a/src/designer/src/lib/shared/plugindialog.cpp +++ b/src/designer/src/lib/shared/plugindialog.cpp @@ -28,6 +28,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + enum { ErrorItemRole = Qt::UserRole + 1 }; namespace qdesigner_internal { diff --git a/src/designer/src/lib/shared/pluginmanager.cpp b/src/designer/src/lib/shared/pluginmanager.cpp index 4c6e822ad..7ab9d17aa 100644 --- a/src/designer/src/lib/shared/pluginmanager.cpp +++ b/src/designer/src/lib/shared/pluginmanager.cpp @@ -76,9 +76,9 @@ QStringList QDesignerPluginManager::defaultPluginPaths() const QStringList path_list = QCoreApplication::libraryPaths(); for (const QString &path : path_list) - result.append(path + u"/designer"_s); + result.append(path + "/designer"_L1); - result.append(qdesigner_internal::dataDirectory() + u"/plugins"_s); + result.append(qdesigner_internal::dataDirectory() + "/plugins"_L1); return result; } @@ -88,11 +88,11 @@ QStringList QDesignerPluginManager::defaultPluginPaths() static inline QString getDesignerLanguage(QDesignerFormEditorInterface *core) { if (QDesignerLanguageExtension *lang = qt_extension<QDesignerLanguageExtension *>(core->extensionManager(), core)) { - if (lang->uiExtension() == QStringLiteral("jui")) + if (lang->uiExtension() == "jui"_L1) return QLatin1String(jambiLanguageC); - return QStringLiteral("unknown"); + return u"unknown"_s; } - return QStringLiteral("c++"); + return u"c++"_s; } // ---------------- QDesignerCustomWidgetSharedData @@ -239,19 +239,19 @@ static inline QString msgAttributeMissing(const QString &name) static qdesigner_internal::TextPropertyValidationMode typeStringToType(const QString &v, bool *ok) { *ok = true; - if (v == QStringLiteral("multiline")) + if (v == "multiline"_L1) return qdesigner_internal::ValidationMultiLine; - if (v == QStringLiteral("richtext")) + if (v == "richtext"_L1) return qdesigner_internal::ValidationRichText; - if (v == QStringLiteral("stylesheet")) + if (v == "stylesheet"_L1) return qdesigner_internal::ValidationStyleSheet; - if (v == QStringLiteral("singleline")) + if (v == "singleline"_L1) return qdesigner_internal::ValidationSingleLine; - if (v == QStringLiteral("objectname")) + if (v == "objectname"_L1) return qdesigner_internal::ValidationObjectName; - if (v == QStringLiteral("objectnamescope")) + if (v == "objectnamescope"_L1) return qdesigner_internal::ValidationObjectNameScope; - if (v == QStringLiteral("url")) + if (v == "url"_L1) return qdesigner_internal::ValidationURL; *ok = false; return qdesigner_internal::ValidationRichText; @@ -286,7 +286,7 @@ static bool parsePropertySpecs(QXmlStreamReader &sr, return false; } bool typeOk; - const bool noTr = notrS == QStringLiteral("true") || notrS == QStringLiteral("1"); + const bool noTr = notrS == "true"_L1 || notrS == "1"_L1; QDesignerCustomWidgetSharedData::StringPropertyType v(typeStringToType(type, &typeOk), !noTr); if (!typeOk) { *errorMessage = QDesignerPluginManager::tr("'%1' is not a valid string property specification.").arg(type); @@ -526,7 +526,7 @@ QDesignerPluginManager::QDesignerPluginManager(QDesignerFormEditorInterface *cor { m_d->m_pluginPaths = defaultPluginPaths(); const QSettings settings(qApp->organizationName(), QDesignerQSettings::settingsApplicationName()); - m_d->m_disabledPlugins = unique(settings.value(QStringLiteral("PluginManager/DisabledPlugins")).toStringList()); + m_d->m_disabledPlugins = unique(settings.value("PluginManager/DisabledPlugins").toStringList()); // Register plugins updateRegisteredPlugins(); @@ -684,8 +684,8 @@ void QDesignerPluginManager::registerPlugin(const QString &plugin) bool QDesignerPluginManager::syncSettings() { QSettings settings(qApp->organizationName(), QDesignerQSettings::settingsApplicationName()); - settings.beginGroup(QStringLiteral("PluginManager")); - settings.setValue(QStringLiteral("DisabledPlugins"), m_d->m_disabledPlugins); + settings.beginGroup("PluginManager"); + settings.setValue("DisabledPlugins", m_d->m_disabledPlugins); settings.endGroup(); return settings.status() == QSettings::NoError; } diff --git a/src/designer/src/lib/shared/previewconfigurationwidget.cpp b/src/designer/src/lib/shared/previewconfigurationwidget.cpp index d8c8a81ce..ba9f11e26 100644 --- a/src/designer/src/lib/shared/previewconfigurationwidget.cpp +++ b/src/designer/src/lib/shared/previewconfigurationwidget.cpp @@ -28,6 +28,8 @@ static const char *skinResourcePathC = ":/skins/"; QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static const char *skinExtensionC = "skin"; // Pair of skin name, path @@ -40,8 +42,7 @@ static const Skins &defaultSkins() { static Skins rc; if (rc.isEmpty()) { const QString skinPath = QLatin1String(skinResourcePathC); - QString pattern = QStringLiteral("*."); - pattern += QLatin1String(skinExtensionC); + const QString pattern = "*."_L1 + QLatin1StringView(skinExtensionC); const QDir dir(skinPath, pattern); const QFileInfoList list = dir.entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot, QDir::Name); if (list.isEmpty()) diff --git a/src/designer/src/lib/shared/propertylineedit.cpp b/src/designer/src/lib/shared/propertylineedit.cpp index 2f3f6b311..bea91010a 100644 --- a/src/designer/src/lib/shared/propertylineedit.cpp +++ b/src/designer/src/lib/shared/propertylineedit.cpp @@ -8,6 +8,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { PropertyLineEdit::PropertyLineEdit(QWidget *parent) : QLineEdit(parent), m_wantNewLine(false) @@ -30,7 +32,7 @@ namespace qdesigner_internal { } void PropertyLineEdit::insertNewLine() { - insertText(QStringLiteral("\\n")); + insertText(u"\\n"_s); } void PropertyLineEdit::insertText(const QString &text) { diff --git a/src/designer/src/lib/shared/qdesigner_command.cpp b/src/designer/src/lib/shared/qdesigner_command.cpp index 6f3aa74b3..91b5bf443 100644 --- a/src/designer/src/lib/shared/qdesigner_command.cpp +++ b/src/designer/src/lib/shared/qdesigner_command.cpp @@ -50,10 +50,12 @@ Q_DECLARE_METATYPE(QWidgetList) QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static inline void setPropertySheetWindowTitle(const QDesignerFormEditorInterface *core, QObject *o, const QString &t) { if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), o)) { - const int idx = sheet->indexOf(QStringLiteral("windowTitle")); + const int idx = sheet->indexOf(u"windowTitle"_s); if (idx != -1) { sheet->setProperty(idx, t); sheet->setChanged(idx, true); @@ -209,7 +211,7 @@ void InsertWidgetCommand::refreshBuddyLabels() if (label_list.isEmpty()) return; - const QString buddyProperty = QStringLiteral("buddy"); + const QString buddyProperty = u"buddy"_s; const QByteArray objectNameU8 = m_widget->objectName().toUtf8(); // Re-set the buddy (The sheet locates the object by name and sets it) for (QLabel *label : label_list) { @@ -957,7 +959,7 @@ void ToolBoxCommand::addPage() QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(formWindow()->core()->extensionManager(), m_toolBox); if (sheet) { qdesigner_internal::PropertySheetStringValue itemText(m_itemText); - sheet->setProperty(sheet->indexOf(QStringLiteral("currentItemText")), QVariant::fromValue(itemText)); + sheet->setProperty(sheet->indexOf(u"currentItemText"_s), QVariant::fromValue(itemText)); } m_widget->show(); @@ -1048,7 +1050,7 @@ void AddToolBoxPageCommand::init(QToolBox *toolBox, InsertionMode mode) m_widget = new QDesignerWidget(formWindow(), m_toolBox); m_itemText = QApplication::translate("Command", "Page"); m_itemIcon = QIcon(); - m_widget->setObjectName(QStringLiteral("page")); + m_widget->setObjectName(u"page"_s); formWindow()->ensureUniqueObjectName(m_widget); setText(QApplication::translate("Command", "Insert Page")); @@ -1109,7 +1111,8 @@ void TabWidgetCommand::addPage() QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(formWindow()->core()->extensionManager(), m_tabWidget); if (sheet) { qdesigner_internal::PropertySheetStringValue itemText(m_itemText); - sheet->setProperty(sheet->indexOf(QStringLiteral("currentTabText")), QVariant::fromValue(itemText)); + sheet->setProperty(sheet->indexOf(u"currentTabText"_s), + QVariant::fromValue(itemText)); } formWindow()->clearSelection(); @@ -1165,7 +1168,7 @@ void AddTabPageCommand::init(QTabWidget *tabWidget, InsertionMode mode) m_widget = new QDesignerWidget(formWindow(), m_tabWidget); m_itemText = QApplication::translate("Command", "Page"); m_itemIcon = QIcon(); - m_widget->setObjectName(QStringLiteral("tab")); + m_widget->setObjectName(u"tab"_s); formWindow()->ensureUniqueObjectName(m_widget); setText(QApplication::translate("Command", "Insert Page")); @@ -1341,7 +1344,7 @@ void AddStackedWidgetPageCommand::init(QStackedWidget *stackedWidget, InsertionM if (mode == InsertAfter) m_index++; m_widget = new QDesignerWidget(formWindow(), m_stackedWidget); - m_widget->setObjectName(QStringLiteral("page")); + m_widget->setObjectName(u"page"_s); formWindow()->ensureUniqueObjectName(m_widget); setText(QApplication::translate("Command", "Insert Page")); @@ -1400,7 +1403,7 @@ void CreateMenuBarCommand::init(QMainWindow *mainWindow) { m_mainWindow = mainWindow; QDesignerFormEditorInterface *core = formWindow()->core(); - m_menuBar = qobject_cast<QMenuBar*>(core->widgetFactory()->createWidget(QStringLiteral("QMenuBar"), m_mainWindow)); + m_menuBar = qobject_cast<QMenuBar*>(core->widgetFactory()->createWidget(u"QMenuBar"_s, m_mainWindow)); core->widgetFactory()->initialize(m_menuBar); } @@ -1411,7 +1414,7 @@ void CreateMenuBarCommand::redo() c = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), m_mainWindow); c->addWidget(m_menuBar); - m_menuBar->setObjectName(QStringLiteral("menuBar")); + m_menuBar->setObjectName(u"menuBar"_s); formWindow()->ensureUniqueObjectName(m_menuBar); core->metaDataBase()->add(m_menuBar); formWindow()->emitSelectionChanged(); @@ -1491,7 +1494,7 @@ void CreateStatusBarCommand::init(QMainWindow *mainWindow) { m_mainWindow = mainWindow; QDesignerFormEditorInterface *core = formWindow()->core(); - m_statusBar = qobject_cast<QStatusBar*>(core->widgetFactory()->createWidget(QStringLiteral("QStatusBar"), m_mainWindow)); + m_statusBar = qobject_cast<QStatusBar*>(core->widgetFactory()->createWidget(u"QStatusBar"_s, m_mainWindow)); core->widgetFactory()->initialize(m_statusBar); } @@ -1502,7 +1505,7 @@ void CreateStatusBarCommand::redo() c = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), m_mainWindow); c->addWidget(m_statusBar); - m_statusBar->setObjectName(QStringLiteral("statusBar")); + m_statusBar->setObjectName(u"statusBar"_s); formWindow()->ensureUniqueObjectName(m_statusBar); core->metaDataBase()->add(m_statusBar); formWindow()->emitSelectionChanged(); @@ -1579,7 +1582,7 @@ void AddToolBarCommand::init(QMainWindow *mainWindow, Qt::ToolBarArea area) m_mainWindow = mainWindow; QDesignerWidgetFactoryInterface * wf = formWindow()->core()->widgetFactory(); // Pass on 0 parent first to avoid reparenting flicker. - m_toolBar = qobject_cast<QToolBar*>(wf->createWidget(QStringLiteral("QToolBar"), nullptr)); + m_toolBar = qobject_cast<QToolBar*>(wf->createWidget(u"QToolBar"_s, nullptr)); m_toolBar->setProperty("_q_desiredArea", QVariant(area)); wf->initialize(m_toolBar); m_toolBar->hide(); @@ -1593,7 +1596,7 @@ void AddToolBarCommand::redo() QDesignerContainerExtension *c = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), m_mainWindow); c->addWidget(m_toolBar); - m_toolBar->setObjectName(QStringLiteral("toolBar")); + m_toolBar->setObjectName(u"toolBar"_s); formWindow()->ensureUniqueObjectName(m_toolBar); setPropertySheetWindowTitle(core, m_toolBar, m_toolBar->objectName()); formWindow()->emitSelectionChanged(); @@ -1642,7 +1645,7 @@ void AddDockWidgetCommand::init(QMainWindow *mainWindow) { m_mainWindow = mainWindow; QDesignerFormEditorInterface *core = formWindow()->core(); - m_dockWidget = qobject_cast<QDockWidget*>(core->widgetFactory()->createWidget(QStringLiteral("QDockWidget"), m_mainWindow)); + m_dockWidget = qobject_cast<QDockWidget*>(core->widgetFactory()->createWidget(u"QDockWidget"_s, m_mainWindow)); } void AddDockWidgetCommand::redo() @@ -1651,7 +1654,7 @@ void AddDockWidgetCommand::redo() QDesignerContainerExtension *c = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), m_mainWindow); c->addWidget(m_dockWidget); - m_dockWidget->setObjectName(QStringLiteral("dockWidget")); + m_dockWidget->setObjectName(u"dockWidget"_s); formWindow()->ensureUniqueObjectName(m_dockWidget); formWindow()->manageWidget(m_dockWidget); formWindow()->emitSelectionChanged(); @@ -1732,7 +1735,7 @@ void AdjustWidgetSizeCommand::updatePropertyEditor() const { if (QDesignerPropertyEditorInterface *propertyEditor = formWindow()->core()->propertyEditor()) { if (propertyEditor->object() == m_widget) - propertyEditor->setPropertyValue(QStringLiteral("geometry"), m_widget->geometry(), true); + propertyEditor->setPropertyValue(u"geometry"_s, m_widget->geometry(), true); } } // ------------ ChangeFormLayoutItemRoleCommand @@ -2006,16 +2009,16 @@ void AddContainerWidgetPageCommand::init(QWidget *containerWidget, ContainerType case PageContainer: setText(QApplication::translate("Command", "Insert Page")); m_widget = new QDesignerWidget(formWindow(), m_containerWidget); - m_widget->setObjectName(QStringLiteral("page")); + m_widget->setObjectName(u"page"_s); break; case MdiContainer: setText(QApplication::translate("Command", "Insert Subwindow")); m_widget = new QDesignerWidget(formWindow(), m_containerWidget); - m_widget->setObjectName(QStringLiteral("subwindow")); + m_widget->setObjectName(u"subwindow"_s); setPropertySheetWindowTitle(core, m_widget, QApplication::translate("Command", "Subwindow")); break; case WizardContainer: // Apply style, don't manage - m_widget = core->widgetFactory()->createWidget(QStringLiteral("QWizardPage"), nullptr); + m_widget = core->widgetFactory()->createWidget(u"QWizardPage"_s, nullptr); break; } formWindow()->ensureUniqueObjectName(m_widget); diff --git a/src/designer/src/lib/shared/qdesigner_formbuilder.cpp b/src/designer/src/lib/shared/qdesigner_formbuilder.cpp index 02af81672..27b92c4e5 100644 --- a/src/designer/src/lib/shared/qdesigner_formbuilder.cpp +++ b/src/designer/src/lib/shared/qdesigner_formbuilder.cpp @@ -44,6 +44,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { QDesignerFormBuilder::QDesignerFormBuilder(QDesignerFormEditorInterface *core, @@ -98,11 +100,11 @@ QWidget *QDesignerFormBuilder::createWidget(const QString &widgetName, QWidget * { QWidget *widget = nullptr; - if (widgetName == QStringLiteral("QToolBar")) { + if (widgetName == "QToolBar"_L1) { widget = new QToolBar(parentWidget); - } else if (widgetName == QStringLiteral("QMenu")) { + } else if (widgetName == "QMenu"_L1) { widget = new QMenu(parentWidget); - } else if (widgetName == QStringLiteral("QMenuBar")) { + } else if (widgetName == "QMenuBar"_L1) { widget = new QMenuBar(parentWidget); } else { widget = core()->widgetFactory()->createWidget(widgetName, parentWidget); @@ -206,7 +208,7 @@ void QDesignerFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> const QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), o); const QDesignerDynamicPropertySheetExtension *dynamicSheet = qt_extension<QDesignerDynamicPropertySheetExtension*>(core()->extensionManager(), o); - const bool changingMetaObject = WidgetFactory::classNameOf(core(), o) == QStringLiteral("QAxWidget"); + const bool changingMetaObject = WidgetFactory::classNameOf(core(), o) == "QAxWidget"_L1; const QDesignerMetaObjectInterface *meta = core()->introspection()->metaObject(o); const bool dynamicPropertiesAllowed = dynamicSheet && dynamicSheet->dynamicPropertiesAllowed(); @@ -242,7 +244,7 @@ void QDesignerFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> QObject *obj = o; QAbstractScrollArea *scroll = qobject_cast<QAbstractScrollArea *>(o); - if (scroll && attributeName == QStringLiteral("cursor") && scroll->viewport()) + if (scroll && attributeName == "cursor"_L1 && scroll->viewport()) obj = scroll->viewport(); // a real property diff --git a/src/designer/src/lib/shared/qdesigner_formwindowcommand.cpp b/src/designer/src/lib/shared/qdesigner_formwindowcommand.cpp index f6e3370c2..48687277e 100644 --- a/src/designer/src/lib/shared/qdesigner_formwindowcommand.cpp +++ b/src/designer/src/lib/shared/qdesigner_formwindowcommand.cpp @@ -21,6 +21,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // ---- QDesignerFormWindowCommand ---- @@ -79,7 +81,7 @@ void QDesignerFormWindowCommand::updateBuddies(QDesignerFormWindowInterface *for if (label_list.isEmpty()) return; - const QString buddyProperty = QStringLiteral("buddy"); + const QString buddyProperty = u"buddy"_s; const QByteArray oldNameU8 = old_name.toUtf8(); const QByteArray newNameU8 = new_name.toUtf8(); diff --git a/src/designer/src/lib/shared/qdesigner_introspection.cpp b/src/designer/src/lib/shared/qdesigner_introspection.cpp index d918abbb9..8c2dd3736 100644 --- a/src/designer/src/lib/shared/qdesigner_introspection.cpp +++ b/src/designer/src/lib/shared/qdesigner_introspection.cpp @@ -10,6 +10,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // Qt Implementation static QStringList byteArrayListToStringList(const QByteArrayList &l) { @@ -60,8 +62,7 @@ namespace { QString QDesignerMetaEnum::separator() const { - static const QString rc = QStringLiteral("::"); - return rc; + return u"::"_s; } // ------- QDesignerMetaProperty diff --git a/src/designer/src/lib/shared/qdesigner_membersheet.cpp b/src/designer/src/lib/shared/qdesigner_membersheet.cpp index 31f92bb1d..29aec04dd 100644 --- a/src/designer/src/lib/shared/qdesigner_membersheet.cpp +++ b/src/designer/src/lib/shared/qdesigner_membersheet.cpp @@ -8,8 +8,11 @@ #include <abstractintrospection_p.h> #include <QtWidgets/qwidget.h> + QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static QByteArrayList stringListToByteArray(const QStringList &l) { QByteArrayList rc; @@ -142,7 +145,7 @@ bool QDesignerMemberSheet::isSlot(int index) const bool QDesignerMemberSheet::inheritedFromWidget(int index) const { - return declaredInClass(index) == QStringLiteral("QWidget") || declaredInClass(index) == QStringLiteral("QObject"); + return declaredInClass(index) == "QWidget"_L1 || declaredInClass(index) == "QObject"_L1; } diff --git a/src/designer/src/lib/shared/qdesigner_menu.cpp b/src/designer/src/lib/shared/qdesigner_menu.cpp index 9b558189b..c19f98dec 100644 --- a/src/designer/src/lib/shared/qdesigner_menu.cpp +++ b/src/designer/src/lib/shared/qdesigner_menu.cpp @@ -33,6 +33,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // give the user a little more space to click on the sub menu rectangle static inline void extendClickableArea(QRect *subMenuRect, Qt::LayoutDirection dir) { @@ -49,7 +51,7 @@ static inline void extendClickableArea(QRect *subMenuRect, Qt::LayoutDirection d QDesignerMenu::QDesignerMenu(QWidget *parent) : QMenu(parent), - m_subMenuPixmap(QPixmap(QStringLiteral(":/qt-project.org/formeditor/images/submenu.png"))), + m_subMenuPixmap(QPixmap(u":/qt-project.org/formeditor/images/submenu.png"_s)), m_currentIndex(0), m_addItem(new qdesigner_internal::SpecialMenuAction(this)), m_addSeparator(new qdesigner_internal::SpecialMenuAction(this)), @@ -75,7 +77,7 @@ QDesignerMenu::QDesignerMenu(QWidget *parent) : connect(m_deactivateWindowTimer, &QTimer::timeout, this, &QDesignerMenu::slotDeactivateNow); - m_editor->setObjectName(QStringLiteral("__qt__passive_editor")); + m_editor->setObjectName(u"__qt__passive_editor"_s); m_editor->hide(); m_editor->installEventFilter(this); @@ -979,7 +981,7 @@ void QDesignerMenu::createRealMenuAction(QAction *action) core->widgetFactory()->initialize(menu); - const QString niceObjectName = ActionEditor::actionTextToName(menu->title(), QStringLiteral("menu")); + const QString niceObjectName = ActionEditor::actionTextToName(menu->title(), u"menu"_s); menu->setObjectName(niceObjectName); core->metaDataBase()->add(menu); @@ -1173,7 +1175,7 @@ void QDesignerMenu::leaveEditMode(LeaveEditMode mode) } auto *cmd = new qdesigner_internal::SetPropertyCommand(fw); - cmd->init(action, QStringLiteral("text"), m_editor->text()); + cmd->init(action, u"text"_s, m_editor->text()); fw->commandHistory()->push(cmd); if (parentMenu()) { diff --git a/src/designer/src/lib/shared/qdesigner_menubar.cpp b/src/designer/src/lib/shared/qdesigner_menubar.cpp index 016f1cbfa..7b442ed31 100644 --- a/src/designer/src/lib/shared/qdesigner_menubar.cpp +++ b/src/designer/src/lib/shared/qdesigner_menubar.cpp @@ -29,6 +29,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + using ActionList = QList<QAction *>; namespace qdesigner_internal @@ -65,7 +67,7 @@ QDesignerMenuBar::QDesignerMenuBar(QWidget *parent) : italic.setItalic(true); m_addMenu->setFont(italic); - m_editor->setObjectName(QStringLiteral("__qt__passive_editor")); + m_editor->setObjectName(u"__qt__passive_editor"_s); m_editor->hide(); m_editor->installEventFilter(this); installEventFilter(this); @@ -438,8 +440,8 @@ void QDesignerMenuBar::leaveEditMode(LeaveEditMode mode) fw->beginCommand(QApplication::translate("Command", "Change Title")); } else { fw->beginCommand(QApplication::translate("Command", "Insert Menu")); - const QString niceObjectName = ActionEditor::actionTextToName(m_editor->text(), QStringLiteral("menu")); - QMenu *menu = qobject_cast<QMenu*>(fw->core()->widgetFactory()->createWidget(QStringLiteral("QMenu"), this)); + const QString niceObjectName = ActionEditor::actionTextToName(m_editor->text(), u"menu"_s); + QMenu *menu = qobject_cast<QMenu*>(fw->core()->widgetFactory()->createWidget(u"QMenu"_s, this)); fw->core()->widgetFactory()->initialize(menu); menu->setObjectName(niceObjectName); menu->setTitle(tr("Menu")); @@ -451,7 +453,7 @@ void QDesignerMenuBar::leaveEditMode(LeaveEditMode mode) } auto *cmd = new qdesigner_internal::SetPropertyCommand(fw); - cmd->init(action, QStringLiteral("text"), m_editor->text()); + cmd->init(action, u"text"_s, m_editor->text()); fw->commandHistory()->push(cmd); fw->endCommand(); } diff --git a/src/designer/src/lib/shared/qdesigner_promotion.cpp b/src/designer/src/lib/shared/qdesigner_promotion.cpp index d02336f27..3f12808bd 100644 --- a/src/designer/src/lib/shared/qdesigner_promotion.cpp +++ b/src/designer/src/lib/shared/qdesigner_promotion.cpp @@ -19,19 +19,20 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { // Return a set of on-promotable classes const QSet<QString> &nonPromotableClasses() { - static QSet<QString> rc; - if (rc.isEmpty()) { - rc.insert(QStringLiteral("Line")); - rc.insert(QStringLiteral("QAction")); - rc.insert(QStringLiteral("Spacer")); - rc.insert(QStringLiteral("QMainWindow")); - rc.insert(QStringLiteral("QDialog")); - rc.insert(QStringLiteral("QMdiArea")); - rc.insert(QStringLiteral("QMdiSubWindow")); - } + static const QSet<QString> rc = { + u"Line"_s, + u"QAction"_s, + u"Spacer"_s, + u"QMainWindow"_s, + u"QDialog"_s, + u"QMdiArea"_s, + u"QMdiSubWindow"_s + }; return rc; } @@ -59,8 +60,9 @@ namespace { } // extract class name from xml "<widget class="QWidget" ...>". Quite a hack. - QString classNameFromXml(QString xml) { - static const QString tag = QStringLiteral("class=\""); + QString classNameFromXml(QString xml) + { + constexpr auto tag = "class=\""_L1; const int pos = xml.indexOf(tag); if (pos == -1) return QString(); @@ -168,8 +170,7 @@ namespace qdesigner_internal { if (nonPromotableClasses().contains(name)) return false; - if (name.startsWith(QStringLiteral("QDesigner")) || - name.startsWith(QStringLiteral("QLayout"))) + if (name.startsWith("QDesigner"_L1) || name.startsWith("QLayout"_L1)) return false; return true; diff --git a/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp b/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp index 84e200721..5dc4e7d9c 100644 --- a/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp +++ b/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp @@ -35,6 +35,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // PromotionParameters struct PromotionParameters { @@ -58,7 +60,7 @@ namespace qdesigner_internal { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum); QHBoxLayout *hboxLayout = new QHBoxLayout(this); - m_classNameEdit->setValidator(new QRegularExpressionValidator(QRegularExpression(QStringLiteral("^[_a-zA-Z:][:_a-zA-Z0-9]*$")), m_classNameEdit)); + m_classNameEdit->setValidator(new QRegularExpressionValidator(QRegularExpression(u"^[_a-zA-Z:][:_a-zA-Z0-9]*$"_s), m_classNameEdit)); connect(m_classNameEdit, &QLineEdit::textChanged, this, &NewPromotedClassPanel::slotNameChanged); connect(m_includeFileEdit, &QLineEdit::textChanged, @@ -132,7 +134,7 @@ namespace qdesigner_internal { const QChar dot(QLatin1Char('.')); QString suggestedHeader = m_promotedHeaderLowerCase ? className.toLower() : className; - suggestedHeader.replace(QStringLiteral("::"), QString(QLatin1Char('_'))); + suggestedHeader.replace("::"_L1, "_"_L1); if (!m_promotedHeaderSuffix.startsWith(dot)) suggestedHeader += dot; suggestedHeader += m_promotedHeaderSuffix; @@ -226,7 +228,7 @@ namespace qdesigner_internal { preselectedBaseClass = baseClassNameList.indexOf(m_promotableWidgetClassName); } if (preselectedBaseClass == -1) - preselectedBaseClass = baseClassNameList.indexOf(QStringLiteral("QFrame")); + preselectedBaseClass = baseClassNameList.indexOf("QFrame"_L1); NewPromotedClassPanel *newPromotedClassPanel = new NewPromotedClassPanel(baseClassNameList, preselectedBaseClass); newPromotedClassPanel->setPromotedHeaderSuffix(core->integration()->headerSuffix()); diff --git a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp index 814c439d3..355b2a331 100644 --- a/src/designer/src/lib/shared/qdesigner_propertycommand.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertycommand.cpp @@ -34,6 +34,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { enum { debugPropertyCommands = 0 }; @@ -44,21 +46,21 @@ QString fontMask(unsigned m) { QString rc; if (m & QFontFamiliesResolved) - rc += QStringLiteral("Family"); + rc += "Family"_L1; if (m & QFont::SizeResolved) - rc += QStringLiteral("Size "); + rc += "Size "_L1; if (m & QFont::WeightResolved) - rc += QStringLiteral("Bold "); + rc += "Bold "_L1; if (m & QFont::StyleResolved) - rc += QStringLiteral("Style "); + rc += "Style "_L1; if (m & QFont::UnderlineResolved) - rc += QStringLiteral("Underline "); + rc += "Underline "_L1; if (m & QFont::StrikeOutResolved) - rc += QStringLiteral("StrikeOut "); + rc += "StrikeOut "_L1; if (m & QFont::KerningResolved) - rc += QStringLiteral("Kerning "); + rc += "Kerning "_L1; if (m & QFont::StyleStrategyResolved) - rc += QStringLiteral("StyleStrategy"); + rc += "StyleStrategy"_L1; return rc; } @@ -66,22 +68,20 @@ QString fontMask(unsigned m) QString fontString(const QFont &f) { QString rc; { - const QChar comma = QLatin1Char(','); QTextStream str(&rc); - str << QStringLiteral("QFont(\"") << f.family() << comma << - f.pointSize(); + str << "QFont(\"" << f.family() << ',' << f.pointSize(); if (f.bold()) - str << comma << QStringLiteral("bold"); + str << ',' << "bold"; if (f.italic()) - str << comma << QStringLiteral("italic"); + str << ',' << "italic"; if (f.underline()) - str << comma << QStringLiteral("underline"); + str << ',' << "underline"; if (f.strikeOut()) - str << comma << QStringLiteral("strikeOut"); + str << ',' << "strikeOut"; if (f.kerning()) - str << comma << QStringLiteral("kerning"); - str << comma << f.styleStrategy() << QStringLiteral(" resolve: ") - << fontMask(f.resolveMask()) << QLatin1Char(')'); + str << ',' << "kerning"; + str << ',' << f.styleStrategy() << " resolve: " + << fontMask(f.resolveMask()) << ')'; } return rc; } @@ -575,35 +575,35 @@ PropertyHelper::Value applySubProperty(const QVariant &oldValue, const QVariant // figure out special property enum SpecialProperty getSpecialProperty(const QString& propertyName) { - if (propertyName == QStringLiteral("objectName")) + if (propertyName == "objectName"_L1) return SP_ObjectName; - if (propertyName == QStringLiteral("layoutName")) + if (propertyName == "layoutName"_L1) return SP_LayoutName; - if (propertyName == QStringLiteral("spacerName")) + if (propertyName == "spacerName"_L1) return SP_SpacerName; - if (propertyName == QStringLiteral("icon")) + if (propertyName == "icon"_L1) return SP_Icon; - if (propertyName == QStringLiteral("currentTabName")) + if (propertyName == "currentTabName"_L1) return SP_CurrentTabName; - if (propertyName == QStringLiteral("currentItemName")) + if (propertyName == "currentItemName"_L1) return SP_CurrentItemName; - if (propertyName == QStringLiteral("currentPageName")) + if (propertyName == "currentPageName"_L1) return SP_CurrentPageName; - if (propertyName == QStringLiteral("geometry")) + if (propertyName == "geometry"_L1) return SP_Geometry; - if (propertyName == QStringLiteral("windowTitle")) + if (propertyName == "windowTitle"_L1) return SP_WindowTitle; - if (propertyName == QStringLiteral("minimumSize")) + if (propertyName == "minimumSize"_L1) return SP_MinimumSize; - if (propertyName == QStringLiteral("maximumSize")) + if (propertyName == "maximumSize"_L1) return SP_MaximumSize; - if (propertyName == QStringLiteral("alignment")) + if (propertyName == "alignment"_L1) return SP_Alignment; - if (propertyName == QStringLiteral("autoDefault")) + if (propertyName == "autoDefault"_L1) return SP_AutoDefault; - if (propertyName == QStringLiteral("shortcut")) + if (propertyName == "shortcut"_L1) return SP_Shortcut; - if (propertyName == QStringLiteral("orientation")) + if (propertyName == "orientation"_L1) return SP_Orientation; return SP_None; } diff --git a/src/designer/src/lib/shared/qdesigner_propertyeditor.cpp b/src/designer/src/lib/shared/qdesigner_propertyeditor.cpp index 3c2785a90..866dbe95a 100644 --- a/src/designer/src/lib/shared/qdesigner_propertyeditor.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertyeditor.cpp @@ -17,6 +17,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { using StringPropertyParameters = QDesignerPropertyEditor::StringPropertyParameters; // A map of property name to type @@ -29,31 +31,31 @@ static const PropertyNameTypeMap &stringPropertyTypes() if (propertyNameTypeMap.isEmpty()) { const StringPropertyParameters richtext(ValidationRichText, true); // Accessibility. Both are texts the narrator reads - propertyNameTypeMap.insert(QStringLiteral("accessibleDescription"), richtext); - propertyNameTypeMap.insert(QStringLiteral("accessibleName"), richtext); + propertyNameTypeMap.insert(u"accessibleDescription"_s, richtext); + propertyNameTypeMap.insert(u"accessibleName"_s, richtext); // object names const StringPropertyParameters objectName(ValidationObjectName, false); - propertyNameTypeMap.insert(QStringLiteral("buddy"), objectName); - propertyNameTypeMap.insert(QStringLiteral("currentItemName"), objectName); - propertyNameTypeMap.insert(QStringLiteral("currentPageName"), objectName); - propertyNameTypeMap.insert(QStringLiteral("currentTabName"), objectName); - propertyNameTypeMap.insert(QStringLiteral("layoutName"), objectName); - propertyNameTypeMap.insert(QStringLiteral("spacerName"), objectName); + propertyNameTypeMap.insert(u"buddy"_s, objectName); + propertyNameTypeMap.insert(u"currentItemName"_s, objectName); + propertyNameTypeMap.insert(u"currentPageName"_s, objectName); + propertyNameTypeMap.insert(u"currentTabName"_s, objectName); + propertyNameTypeMap.insert(u"layoutName"_s, objectName); + propertyNameTypeMap.insert(u"spacerName"_s, objectName); // Style sheet - propertyNameTypeMap.insert(QStringLiteral("styleSheet"), StringPropertyParameters(ValidationStyleSheet, false)); + propertyNameTypeMap.insert(u"styleSheet"_s, StringPropertyParameters(ValidationStyleSheet, false)); // Buttons/ QCommandLinkButton const StringPropertyParameters multiline(ValidationMultiLine, true); - propertyNameTypeMap.insert(QStringLiteral("description"), multiline); - propertyNameTypeMap.insert(QStringLiteral("iconText"), multiline); + propertyNameTypeMap.insert(u"description"_s, multiline); + propertyNameTypeMap.insert(u"iconText"_s, multiline); // Tooltips, etc. - propertyNameTypeMap.insert(QStringLiteral("toolTip"), richtext); - propertyNameTypeMap.insert(QStringLiteral("whatsThis"), richtext); - propertyNameTypeMap.insert(QStringLiteral("windowIconText"), richtext); - propertyNameTypeMap.insert(QStringLiteral("html"), richtext); + propertyNameTypeMap.insert(u"toolTip"_s, richtext); + propertyNameTypeMap.insert(u"whatsThis"_s, richtext); + propertyNameTypeMap.insert(u"windowIconText"_s, richtext); + propertyNameTypeMap.insert(u"html"_s, richtext); // A QWizard page id - propertyNameTypeMap.insert(QStringLiteral("pageId"), StringPropertyParameters(ValidationSingleLine, false)); + propertyNameTypeMap.insert(u"pageId"_s, StringPropertyParameters(ValidationSingleLine, false)); // QPlainTextEdit - propertyNameTypeMap.insert(QStringLiteral("plainText"), StringPropertyParameters(ValidationMultiLine, true)); + propertyNameTypeMap.insert(u"plainText"_s, StringPropertyParameters(ValidationMultiLine, true)); } return propertyNameTypeMap; } @@ -85,7 +87,7 @@ QDesignerPropertyEditor::StringPropertyParameters QDesignerPropertyEditor::textP const QString &propertyName, bool isMainContainer) { // object name - no comment - if (propertyName == QStringLiteral("objectName")) { + if (propertyName == "objectName"_L1) { const TextPropertyValidationMode vm = isMainContainer ? ValidationObjectNameScope : ValidationObjectName; return StringPropertyParameters(vm, false); } @@ -108,7 +110,7 @@ QDesignerPropertyEditor::StringPropertyParameters QDesignerPropertyEditor::textP return hit.value(); // text: Check according to widget type. - if (propertyName == QStringLiteral("text")) { + if (propertyName == "text"_L1) { if (qobject_cast<const QAction *>(object) || qobject_cast<const QLineEdit *>(object)) return StringPropertyParameters(ValidationSingleLine, true); if (qobject_cast<const QAbstractButton *>(object)) @@ -117,14 +119,14 @@ QDesignerPropertyEditor::StringPropertyParameters QDesignerPropertyEditor::textP } // Fuzzy matching - if (propertyName.endsWith(QStringLiteral("Name"))) + if (propertyName.endsWith("Name"_L1)) return StringPropertyParameters(ValidationSingleLine, true); - if (propertyName.endsWith(QStringLiteral("ToolTip"))) + if (propertyName.endsWith("ToolTip"_L1)) return StringPropertyParameters(ValidationRichText, true); #ifdef Q_OS_WIN // No translation for the active X "control" property - if (propertyName == QStringLiteral("control") && className == QStringLiteral("QAxWidget")) + if (propertyName == "control"_L1 && className == "QAxWidget"_L1) return StringPropertyParameters(ValidationSingleLine, false); #endif diff --git a/src/designer/src/lib/shared/qdesigner_propertysheet.cpp b/src/designer/src/lib/shared/qdesigner_propertysheet.cpp index 31369ae40..abdf5f749 100644 --- a/src/designer/src/lib/shared/qdesigner_propertysheet.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertysheet.cpp @@ -34,6 +34,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #define USE_LAYOUT_SIZE_CONSTRAINT static const QDesignerMetaObjectInterface *propertyIntroducedBy(const QDesignerMetaObjectInterface *meta, int index) @@ -438,27 +440,26 @@ QDesignerPropertySheet::PropertyType QDesignerPropertySheetPrivate::propertyType QString QDesignerPropertySheetPrivate::transformLayoutPropertyName(int index) const { using TypeNameMap = QMap<QDesignerPropertySheet::PropertyType, QString>; - static TypeNameMap typeNameMap; - if (typeNameMap.isEmpty()) { - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutObjectName, QStringLiteral("objectName")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutLeftMargin, QStringLiteral("leftMargin")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutTopMargin, QStringLiteral("topMargin")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutRightMargin, QStringLiteral("rightMargin")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutBottomMargin, QStringLiteral("bottomMargin")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutSpacing, QStringLiteral("spacing")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutHorizontalSpacing, QStringLiteral("horizontalSpacing")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutVerticalSpacing, QStringLiteral("verticalSpacing")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutSizeConstraint, QStringLiteral("sizeConstraint")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutFieldGrowthPolicy, QStringLiteral("fieldGrowthPolicy")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutRowWrapPolicy, QStringLiteral("rowWrapPolicy")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutLabelAlignment, QStringLiteral("labelAlignment")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutFormAlignment, QStringLiteral("formAlignment")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutBoxStretch, QStringLiteral("stretch")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutGridRowStretch, QStringLiteral("rowStretch")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutGridColumnStretch, QStringLiteral("columnStretch")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutGridRowMinimumHeight, QStringLiteral("rowMinimumHeight")); - typeNameMap.insert(QDesignerPropertySheet::PropertyLayoutGridColumnMinimumWidth, QStringLiteral("columnMinimumWidth")); - } + static const TypeNameMap typeNameMap = { + {QDesignerPropertySheet::PropertyLayoutObjectName, u"objectName"_s}, + {QDesignerPropertySheet::PropertyLayoutLeftMargin, u"leftMargin"_s}, + {QDesignerPropertySheet::PropertyLayoutTopMargin, u"topMargin"_s}, + {QDesignerPropertySheet::PropertyLayoutRightMargin, u"rightMargin"_s}, + {QDesignerPropertySheet::PropertyLayoutBottomMargin, u"bottomMargin"_s}, + {QDesignerPropertySheet::PropertyLayoutSpacing, u"spacing"_s}, + {QDesignerPropertySheet::PropertyLayoutHorizontalSpacing, u"horizontalSpacing"_s}, + {QDesignerPropertySheet::PropertyLayoutVerticalSpacing, u"verticalSpacing"_s}, + {QDesignerPropertySheet::PropertyLayoutSizeConstraint, u"sizeConstraint"_s}, + {QDesignerPropertySheet::PropertyLayoutFieldGrowthPolicy, u"fieldGrowthPolicy"_s}, + {QDesignerPropertySheet::PropertyLayoutRowWrapPolicy, u"rowWrapPolicy"_s}, + {QDesignerPropertySheet::PropertyLayoutLabelAlignment, u"labelAlignment"_s}, + {QDesignerPropertySheet::PropertyLayoutFormAlignment, u"formAlignment"_s}, + {QDesignerPropertySheet::PropertyLayoutBoxStretch, u"stretch"_s}, + {QDesignerPropertySheet::PropertyLayoutGridRowStretch, u"rowStretch"_s}, + {QDesignerPropertySheet::PropertyLayoutGridColumnStretch, u"columnStretch"_s}, + {QDesignerPropertySheet::PropertyLayoutGridRowMinimumHeight, u"rowMinimumHeight"_s}, + {QDesignerPropertySheet::PropertyLayoutGridColumnMinimumWidth, u"columnMinimumWidth"_s} + }; const TypeNameMap::const_iterator it = typeNameMap.constFind(propertyType(index)); if (it != typeNameMap.constEnd()) return it.value(); @@ -498,43 +499,42 @@ QDesignerPropertySheet::ObjectFlags QDesignerPropertySheet::objectFlagsFromObjec QDesignerPropertySheet::PropertyType QDesignerPropertySheet::propertyTypeFromName(const QString &name) { typedef QHash<QString, PropertyType> PropertyTypeHash; - static PropertyTypeHash propertyTypeHash; - if (propertyTypeHash.isEmpty()) { - propertyTypeHash.insert(QLatin1String(layoutObjectNameC), PropertyLayoutObjectName); - propertyTypeHash.insert(QLatin1String(layoutLeftMarginC), PropertyLayoutLeftMargin); - propertyTypeHash.insert(QLatin1String(layoutTopMarginC), PropertyLayoutTopMargin); - propertyTypeHash.insert(QLatin1String(layoutRightMarginC), PropertyLayoutRightMargin); - propertyTypeHash.insert(QLatin1String(layoutBottomMarginC), PropertyLayoutBottomMargin); - propertyTypeHash.insert(QLatin1String(layoutSpacingC), PropertyLayoutSpacing); - propertyTypeHash.insert(QLatin1String(layoutHorizontalSpacingC), PropertyLayoutHorizontalSpacing); - propertyTypeHash.insert(QLatin1String(layoutVerticalSpacingC), PropertyLayoutVerticalSpacing); - propertyTypeHash.insert(QLatin1String(layoutSizeConstraintC), PropertyLayoutSizeConstraint); - propertyTypeHash.insert(QLatin1String(layoutFieldGrowthPolicyC), PropertyLayoutFieldGrowthPolicy); - propertyTypeHash.insert(QLatin1String(layoutRowWrapPolicyC), PropertyLayoutRowWrapPolicy); - propertyTypeHash.insert(QLatin1String(layoutLabelAlignmentC), PropertyLayoutLabelAlignment); - propertyTypeHash.insert(QLatin1String(layoutFormAlignmentC), PropertyLayoutFormAlignment); - propertyTypeHash.insert(QLatin1String(layoutboxStretchPropertyC), PropertyLayoutBoxStretch); - propertyTypeHash.insert(QLatin1String(layoutGridRowStretchPropertyC), PropertyLayoutGridRowStretch); - propertyTypeHash.insert(QLatin1String(layoutGridColumnStretchPropertyC), PropertyLayoutGridColumnStretch); - propertyTypeHash.insert(QLatin1String(layoutGridRowMinimumHeightC), PropertyLayoutGridRowMinimumHeight); - propertyTypeHash.insert(QLatin1String(layoutGridColumnMinimumWidthC), PropertyLayoutGridColumnMinimumWidth); - propertyTypeHash.insert(QStringLiteral("buddy"), PropertyBuddy); - propertyTypeHash.insert(QStringLiteral("geometry"), PropertyGeometry); - propertyTypeHash.insert(QStringLiteral("checked"), PropertyChecked); - propertyTypeHash.insert(QStringLiteral("checkable"), PropertyCheckable); - propertyTypeHash.insert(QStringLiteral("accessibleName"), PropertyAccessibility); - propertyTypeHash.insert(QStringLiteral("accessibleDescription"), PropertyAccessibility); - propertyTypeHash.insert(QStringLiteral("visible"), PropertyVisible); - propertyTypeHash.insert(QStringLiteral("windowTitle"), PropertyWindowTitle); - propertyTypeHash.insert(QStringLiteral("windowIcon"), PropertyWindowIcon); - propertyTypeHash.insert(QStringLiteral("windowFilePath"), PropertyWindowFilePath); - propertyTypeHash.insert(QStringLiteral("windowOpacity"), PropertyWindowOpacity); - propertyTypeHash.insert(QStringLiteral("windowIconText"), PropertyWindowIconText); - propertyTypeHash.insert(QStringLiteral("windowModality"), PropertyWindowModality); - propertyTypeHash.insert(QStringLiteral("windowModified"), PropertyWindowModified); - propertyTypeHash.insert(QStringLiteral("styleSheet"), PropertyStyleSheet); - propertyTypeHash.insert(QStringLiteral("text"), PropertyText); - } + static const PropertyTypeHash propertyTypeHash= { + {QLatin1StringView(layoutObjectNameC), PropertyLayoutObjectName}, + {QLatin1StringView(layoutLeftMarginC), PropertyLayoutLeftMargin}, + {QLatin1StringView(layoutTopMarginC), PropertyLayoutTopMargin}, + {QLatin1StringView(layoutRightMarginC), PropertyLayoutRightMargin}, + {QLatin1StringView(layoutBottomMarginC), PropertyLayoutBottomMargin}, + {QLatin1StringView(layoutSpacingC), PropertyLayoutSpacing}, + {QLatin1StringView(layoutHorizontalSpacingC), PropertyLayoutHorizontalSpacing}, + {QLatin1StringView(layoutVerticalSpacingC), PropertyLayoutVerticalSpacing}, + {QLatin1StringView(layoutSizeConstraintC), PropertyLayoutSizeConstraint}, + {QLatin1StringView(layoutFieldGrowthPolicyC), PropertyLayoutFieldGrowthPolicy}, + {QLatin1StringView(layoutRowWrapPolicyC), PropertyLayoutRowWrapPolicy}, + {QLatin1StringView(layoutLabelAlignmentC), PropertyLayoutLabelAlignment}, + {QLatin1StringView(layoutFormAlignmentC), PropertyLayoutFormAlignment}, + {QLatin1StringView(layoutboxStretchPropertyC), PropertyLayoutBoxStretch}, + {QLatin1StringView(layoutGridRowStretchPropertyC), PropertyLayoutGridRowStretch}, + {QLatin1StringView(layoutGridColumnStretchPropertyC), PropertyLayoutGridColumnStretch}, + {QLatin1StringView(layoutGridRowMinimumHeightC), PropertyLayoutGridRowMinimumHeight}, + {QLatin1StringView(layoutGridColumnMinimumWidthC), PropertyLayoutGridColumnMinimumWidth}, + {u"buddy"_s, PropertyBuddy}, + {u"geometry"_s, PropertyGeometry}, + {u"checked"_s, PropertyChecked}, + {u"checkable"_s, PropertyCheckable}, + {u"accessibleName"_s, PropertyAccessibility}, + {u"accessibleDescription"_s, PropertyAccessibility}, + {u"visible"_s, PropertyVisible}, + {u"windowTitle"_s, PropertyWindowTitle}, + {u"windowIcon"_s, PropertyWindowIcon}, + {u"windowFilePath"_s, PropertyWindowFilePath}, + {u"windowOpacity"_s, PropertyWindowOpacity}, + {u"windowIconText"_s, PropertyWindowIconText}, + {u"windowModality"_s, PropertyWindowModality}, + {u"windowModified"_s, PropertyWindowModified}, + {u"styleSheet"_s, PropertyStyleSheet}, + {u"text"_s, PropertyText} + }; return propertyTypeHash.value(name, PropertyNone); } @@ -545,7 +545,7 @@ QDesignerPropertySheet::QDesignerPropertySheet(QObject *object, QObject *parent) using Info = QDesignerPropertySheetPrivate::Info; const QDesignerMetaObjectInterface *baseMeta = d->m_meta; - while (baseMeta &&baseMeta->className().startsWith(QStringLiteral("QDesigner"))) { + while (baseMeta &&baseMeta->className().startsWith("QDesigner"_L1)) { baseMeta = baseMeta->superClass(); } Q_ASSERT(baseMeta != nullptr); @@ -601,27 +601,27 @@ QDesignerPropertySheet::QDesignerPropertySheet(QObject *object, QObject *parent) } if (object->isWidgetType()) { - createFakeProperty(QStringLiteral("focusPolicy")); - createFakeProperty(QStringLiteral("cursor")); - createFakeProperty(QStringLiteral("toolTip")); - createFakeProperty(QStringLiteral("whatsThis")); - createFakeProperty(QStringLiteral("acceptDrops")); - createFakeProperty(QStringLiteral("dragEnabled")); + createFakeProperty(u"focusPolicy"_s); + createFakeProperty(u"cursor"_s); + createFakeProperty(u"toolTip"_s); + createFakeProperty(u"whatsThis"_s); + createFakeProperty(u"acceptDrops"_s); + createFakeProperty(u"dragEnabled"_s); // windowModality/Opacity is visible only for the main container, in which case the form windows enables it on loading - setVisible(createFakeProperty(QStringLiteral("windowModality")), false); - setVisible(createFakeProperty(QStringLiteral("windowOpacity"), double(1.0)), false); + setVisible(createFakeProperty(u"windowModality"_s), false); + setVisible(createFakeProperty(u"windowOpacity"_s, double(1.0)), false); if (qobject_cast<const QToolBar *>(d->m_object)) { // prevent toolbars from being dragged off - createFakeProperty(QStringLiteral("floatable"), QVariant(true)); + createFakeProperty(u"floatable"_s, QVariant(true)); } 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 = !QCoreApplication::testAttribute(Qt::AA_DontUseNativeMenuBar); - createFakeProperty(QStringLiteral("nativeMenuBar"), QVariant(nativeMenuBarDefault)); + createFakeProperty(u"nativeMenuBar"_s, QVariant(nativeMenuBarDefault)); } } if (d->m_canHaveLayoutAttributes) { - static const QString layoutGroup = QStringLiteral("Layout"); + const QString layoutGroup = u"Layout"_s; const char* fakeLayoutProperties[] = { layoutObjectNameC, layoutLeftMarginC, layoutTopMarginC, layoutRightMarginC, layoutBottomMarginC, layoutSpacingC, layoutHorizontalSpacingC, layoutVerticalSpacingC, layoutFieldGrowthPolicyC, layoutRowWrapPolicyC, layoutLabelAlignmentC, layoutFormAlignmentC, @@ -641,19 +641,19 @@ QDesignerPropertySheet::QDesignerPropertySheet(QObject *object, QObject *parent) } if (d->m_objectType == ObjectLabel) - createFakeProperty(QStringLiteral("buddy"), QVariant(QByteArray())); + createFakeProperty(u"buddy"_s, QVariant(QByteArray())); /* We need to create a fake property since the property does not work * for non-toplevel windows or on other systems than Mac and only if * it is above a certain Mac OS version. */ if (qobject_cast<const QMainWindow *>(d->m_object)) - createFakeProperty(QStringLiteral("unifiedTitleAndToolBarOnMac"), false); + createFakeProperty(u"unifiedTitleAndToolBarOnMac"_s, false); } if (qobject_cast<const QDialog*>(object)) { - createFakeProperty(QStringLiteral("modal")); + createFakeProperty(u"modal"_s); } if (qobject_cast<const QDockWidget*>(object)) { - createFakeProperty(QStringLiteral("floating")); + createFakeProperty(u"floating"_s); } const QByteArrayList names = object->dynamicPropertyNames(); @@ -683,8 +683,7 @@ bool QDesignerPropertySheet::dynamicPropertiesAllowed() const bool QDesignerPropertySheet::canAddDynamicProperty(const QString &propName) const { // used internally - if (propName == QStringLiteral("database") || - propName == QStringLiteral("buttonGroupId")) + if (propName == "database"_L1 || propName == "buttonGroupId"_L1) return false; const int index = d->m_meta->indexOfProperty(propName); if (index != -1) @@ -694,7 +693,7 @@ bool QDesignerPropertySheet::canAddDynamicProperty(const QString &propName) cons return !isVisible(idx); // dynamic property already exists } return QDesignerPropertySheet::internalDynamicPropertiesEnabled() - || !propName.startsWith(QStringLiteral("_q_")); + || !propName.startsWith("_q_"_L1); } int QDesignerPropertySheet::addDynamicProperty(const QString &propName, const QVariant &value) @@ -1211,7 +1210,7 @@ void QDesignerPropertySheet::setProperty(int index, const QVariant &value) const QDesignerMetaPropertyInterface *p = d->m_meta->property(index); p->write(d->m_object, resolvePropertyValue(index, value)); if (qobject_cast<QGroupBox *>(d->m_object) && propertyType(index) == PropertyCheckable) { - const int idx = indexOf(QStringLiteral("focusPolicy")); + const int idx = indexOf(u"focusPolicy"_s); if (!isChanged(idx)) { qdesigner_internal::PropertySheetEnumValue e = qvariant_cast<qdesigner_internal::PropertySheetEnumValue>(property(idx)); if (value.toBool()) { @@ -1248,7 +1247,7 @@ bool QDesignerPropertySheet::reset(int index) if (d->isStringProperty(index)) { qdesigner_internal::PropertySheetStringValue value; // Main container: Reset to stored class name as not to change the file names generated by uic. - if (propertyName(index) == QStringLiteral("objectName")) { + if (propertyName(index) == "objectName"_L1) { const QVariant classNameDefaultV = d->m_object->property("_q_classname"); if (classNameDefaultV.isValid()) value.setValue(classNameDefaultV.toString()); diff --git a/src/designer/src/lib/shared/qdesigner_stackedbox.cpp b/src/designer/src/lib/shared/qdesigner_stackedbox.cpp index 40255398a..d24847d08 100644 --- a/src/designer/src/lib/shared/qdesigner_stackedbox.cpp +++ b/src/designer/src/lib/shared/qdesigner_stackedbox.cpp @@ -21,7 +21,10 @@ QT_BEGIN_NAMESPACE -static QToolButton *createToolButton(QWidget *parent, Qt::ArrowType at, const QString &name) { +using namespace Qt::StringLiterals; + +static QToolButton *createToolButton(QWidget *parent, Qt::ArrowType at, const QString &name) +{ QToolButton *rc = new QToolButton(); rc->setAttribute(Qt::WA_NoChildEventsForParent, true); rc->setParent(parent); @@ -38,8 +41,8 @@ QStackedWidgetPreviewEventFilter::QStackedWidgetPreviewEventFilter(QStackedWidge QObject(parent), m_buttonToolTipEnabled(false), // Not on preview m_stackedWidget(parent), - m_prev(createToolButton(m_stackedWidget, Qt::LeftArrow, QStringLiteral("__qt__passive_prev"))), - m_next(createToolButton(m_stackedWidget, Qt::RightArrow, QStringLiteral("__qt__passive_next"))) + m_prev(createToolButton(m_stackedWidget, Qt::LeftArrow, u"__qt__passive_prev"_s)), + m_next(createToolButton(m_stackedWidget, Qt::RightArrow, u"__qt__passive_next"_s)) { connect(m_prev, &QAbstractButton::clicked, this, &QStackedWidgetPreviewEventFilter::prevPage); connect(m_next, &QAbstractButton::clicked, this, &QStackedWidgetPreviewEventFilter::nextPage); @@ -133,7 +136,7 @@ static inline QString stackedClassName(QStackedWidget *w) { if (const QDesignerFormWindowInterface *fw = QDesignerFormWindowInterface::findFormWindow(w)) return qdesigner_internal::WidgetFactory::classNameOf(fw->core(), w); - return QStringLiteral("Stacked widget"); + return u"Stacked widget"_s; } void QStackedWidgetPreviewEventFilter::updateButtonToolTip(QObject *o) @@ -265,7 +268,7 @@ void QStackedWidgetEventFilter::gotoPage(int page) { // Are we on a form or in a preview? if (QDesignerFormWindowInterface *fw = QDesignerFormWindowInterface::findFormWindow(stackedWidget())) { qdesigner_internal::SetPropertyCommand *cmd = new qdesigner_internal::SetPropertyCommand(fw); - cmd->init(stackedWidget(), QStringLiteral("currentIndex"), page); + cmd->init(stackedWidget(), u"currentIndex"_s, page); fw->commandHistory()->push(cmd); fw->emitSelectionChanged(); // Magically prevent an endless loop triggered by auto-repeat. updateButtons(); diff --git a/src/designer/src/lib/shared/qdesigner_tabwidget.cpp b/src/designer/src/lib/shared/qdesigner_tabwidget.cpp index 6b2c5db22..060bc5f99 100644 --- a/src/designer/src/lib/shared/qdesigner_tabwidget.cpp +++ b/src/designer/src/lib/shared/qdesigner_tabwidget.cpp @@ -24,6 +24,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { // Store tab widget as drag source class MyMimeData : public QMimeData @@ -154,7 +156,7 @@ bool QTabWidgetEventFilter::eventFilter(QObject *o, QEvent *e) if (tabbar->tabRect(i).contains(m_pressPoint)) { if (i != tabbar->currentIndex()) { qdesigner_internal::SetPropertyCommand *cmd = new qdesigner_internal::SetPropertyCommand(fw); - cmd->init(m_tabWidget, QStringLiteral("currentIndex"), i); + cmd->init(m_tabWidget, u"currentIndex"_s, i); fw->commandHistory()->push(cmd); } break; diff --git a/src/designer/src/lib/shared/qdesigner_taskmenu.cpp b/src/designer/src/lib/shared/qdesigner_taskmenu.cpp index 10538a7ba..9b34135e5 100644 --- a/src/designer/src/lib/shared/qdesigner_taskmenu.cpp +++ b/src/designer/src/lib/shared/qdesigner_taskmenu.cpp @@ -52,6 +52,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static inline QAction *createSeparatorHelper(QObject *parent) { QAction *rc = new QAction(parent); rc->setSeparator(true); @@ -63,8 +65,7 @@ static QString objName(const QDesignerFormEditorInterface *core, QObject *object = qt_extension<QDesignerPropertySheetExtension*>(core->extensionManager(), object); Q_ASSERT(sheet != nullptr); - const QString objectNameProperty = QStringLiteral("objectName"); - const int index = sheet->indexOf(objectNameProperty); + const int index = sheet->indexOf(u"objectName"_s); const QVariant v = sheet->property(index); if (v.canConvert<qdesigner_internal::PropertySheetStringValue>()) return v.value<qdesigner_internal::PropertySheetStringValue>().value(); @@ -504,10 +505,10 @@ void QDesignerTaskMenu::changeObjectName() if (dialog.exec() == QDialog::Accepted) { const QString newObjectName = dialog.newObjectName(); if (!newObjectName.isEmpty() && newObjectName != oldObjectName ) { - const QString objectNameProperty = QStringLiteral("objectName"); PropertySheetStringValue objectNameValue; objectNameValue.setValue(newObjectName); - setProperty(fw, CurrentWidgetMode, objectNameProperty, QVariant::fromValue(objectNameValue)); + setProperty(fw, CurrentWidgetMode, u"objectName"_s, + QVariant::fromValue(objectNameValue)); } } } @@ -563,12 +564,12 @@ void QDesignerTaskMenu::changeTextProperty(const QString &propertyName, const QS void QDesignerTaskMenu::changeToolTip() { - changeTextProperty(QStringLiteral("toolTip"), tr("Edit ToolTip"), MultiSelectionMode, Qt::AutoText); + changeTextProperty(u"toolTip"_s, tr("Edit ToolTip"), MultiSelectionMode, Qt::AutoText); } void QDesignerTaskMenu::changeWhatsThis() { - changeTextProperty(QStringLiteral("whatsThis"), tr("Edit WhatsThis"), MultiSelectionMode, Qt::AutoText); + changeTextProperty(u"whatsThis"_s, tr("Edit WhatsThis"), MultiSelectionMode, Qt::AutoText); } void QDesignerTaskMenu::changeStyleSheet() @@ -628,7 +629,7 @@ static void createSizeCommand(QDesignerFormWindowInterface *fw, QWidget *w, int if (flags & ApplyMinimumHeight) minimumSize.setHeight(size.height()); SetPropertyCommand* cmd = new SetPropertyCommand(fw); - cmd->init(w, QStringLiteral("minimumSize"), minimumSize); + cmd->init(w, u"minimumSize"_s, minimumSize); fw->commandHistory()->push(cmd); } if (flags & (ApplyMaximumWidth|ApplyMaximumHeight)) { @@ -638,7 +639,7 @@ static void createSizeCommand(QDesignerFormWindowInterface *fw, QWidget *w, int if (flags & ApplyMaximumHeight) maximumSize.setHeight(size.height()); SetPropertyCommand* cmd = new SetPropertyCommand(fw); - cmd->init(w, QStringLiteral("maximumSize"), maximumSize); + cmd->init(w, u"maximumSize"_s, maximumSize); fw->commandHistory()->push(cmd); } } diff --git a/src/designer/src/lib/shared/qdesigner_toolbar.cpp b/src/designer/src/lib/shared/qdesigner_toolbar.cpp index c3a729d67..f04ba9113 100644 --- a/src/designer/src/lib/shared/qdesigner_toolbar.cpp +++ b/src/designer/src/lib/shared/qdesigner_toolbar.cpp @@ -29,6 +29,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + using ActionList = QList<QAction *>; namespace qdesigner_internal { @@ -190,7 +192,7 @@ void ToolBarEventFilter::slotInsertSeparator() QAction *theSender = qobject_cast<QAction*>(sender()); QAction *previous = qvariant_cast<QAction *>(theSender->data()); fw->beginCommand(tr("Insert Separator")); - QAction *action = createAction(fw, QStringLiteral("separator"), true); + QAction *action = createAction(fw, u"separator"_s, true); InsertActionIntoCommand *cmd = new InsertActionIntoCommand(fw); cmd->init(m_toolBar, action, previous); fw->commandHistory()->push(cmd); diff --git a/src/designer/src/lib/shared/qdesigner_utils.cpp b/src/designer/src/lib/shared/qdesigner_utils.cpp index f8ab045f3..f2e2372ff 100644 --- a/src/designer/src/lib/shared/qdesigner_utils.cpp +++ b/src/designer/src/lib/shared/qdesigner_utils.cpp @@ -696,8 +696,8 @@ namespace qdesigner_internal } } if (!action) { - if (const QDesignerTaskMenuExtension *taskMenu = qobject_cast<QDesignerTaskMenuExtension *>( - core->extensionManager()->extension(managedWidget, QStringLiteral("QDesignerInternalTaskMenuExtension")))) { + if (const auto *taskMenu = qobject_cast<QDesignerTaskMenuExtension *>( + core->extensionManager()->extension(managedWidget, u"QDesignerInternalTaskMenuExtension"_s))) { action = taskMenu->preferredEditAction(); if (!action) { const auto actions = taskMenu->taskActions(); @@ -714,7 +714,7 @@ namespace qdesigner_internal { QProcess uic; QStringList arguments; - QString binary = QLibraryInfo::path(QLibraryInfo::LibraryExecutablesPath) + QStringLiteral("/uic"); + QString binary = QLibraryInfo::path(QLibraryInfo::LibraryExecutablesPath) + "/uic"_L1; switch (language) { case UicLanguage::Cpp: break; diff --git a/src/designer/src/lib/shared/qdesigner_widgetbox.cpp b/src/designer/src/lib/shared/qdesigner_widgetbox.cpp index d2ac9ea68..260f68a9c 100644 --- a/src/designer/src/lib/shared/qdesigner_widgetbox.cpp +++ b/src/designer/src/lib/shared/qdesigner_widgetbox.cpp @@ -13,6 +13,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + class QDesignerWidgetBoxWidgetData : public QSharedData { public: @@ -129,7 +131,6 @@ bool QDesignerWidgetBox::findWidget(const QDesignerWidgetBoxInterface *wbox, // Note that entry names do not necessarily match the class name // (at least, not for the standard widgets), so, // look in the XML for the class name of the first widget to appear - const QString widgetTag = QStringLiteral("<widget"); QString pattern = QStringLiteral("^<widget\\s+class\\s*=\\s*\""); pattern += className; pattern += QStringLiteral("\".*$"); @@ -143,7 +144,7 @@ bool QDesignerWidgetBox::findWidget(const QDesignerWidgetBoxInterface *wbox, for (int w = 0; w < widgetCount; w++) { const Widget widget = cat.widget(w); QString xml = widget.domXml(); // Erase the <ui> tag that can be present starting from 4.4 - const int widgetTagIndex = xml.indexOf(widgetTag); + const auto widgetTagIndex = xml.indexOf("<widget"_L1); if (widgetTagIndex != -1) { xml.remove(0, widgetTagIndex); if (regexp.match(xml).hasMatch()) { @@ -175,12 +176,12 @@ DomUI *QDesignerWidgetBox::xmlToUi(const QString &name, const QString &xml, bool continue; } - if (name.compare(QStringLiteral("widget"), Qt::CaseInsensitive) == 0) { // 4.3 legacy, wrap into DomUI + if (name.compare("widget"_L1, Qt::CaseInsensitive) == 0) { // 4.3 legacy, wrap into DomUI ui = new DomUI; DomWidget *widget = new DomWidget; widget->read(reader); ui->setElementWidget(widget); - } else if (name.compare(QStringLiteral("ui"), Qt::CaseInsensitive) == 0) { // 4.4 + } else if (name.compare("ui"_L1, Qt::CaseInsensitive) == 0) { // 4.4 ui = new DomUI; ui->read(reader); } else { @@ -207,7 +208,7 @@ DomUI *QDesignerWidgetBox::xmlToUi(const QString &name, const QString &xml, bool if (insertFakeTopLevel) { DomWidget *fakeTopLevel = new DomWidget; - fakeTopLevel->setAttributeClass(QStringLiteral("QWidget")); + fakeTopLevel->setAttributeClass(u"QWidget"_s); QList<DomWidget *> children; children.push_back(ui->takeElementWidget()); fakeTopLevel->setElementWidget(children); diff --git a/src/designer/src/lib/shared/qsimpleresource.cpp b/src/designer/src/lib/shared/qsimpleresource.cpp index 2b753401a..2b0ef4a07 100644 --- a/src/designer/src/lib/shared/qsimpleresource.cpp +++ b/src/designer/src/lib/shared/qsimpleresource.cpp @@ -26,6 +26,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace qdesigner_internal { bool QSimpleResource::m_warningsEnabled = true; @@ -142,7 +144,7 @@ void QSimpleResource::addCustomWidgetsToWidgetDatabase(const QDesignerFormEditor IncludeType includeType = IncludeLocal; if (const DomHeader *header = custom_widget->elementHeader()) { includeFile = header->text(); - if (header->hasAttributeLocation() && header->attributeLocation() == QStringLiteral("global")) + if (header->hasAttributeLocation() && header->attributeLocation() == "global"_L1) includeType = IncludeGlobal; } const bool domIsContainer = custom_widget->elementContainer(); @@ -203,7 +205,7 @@ void QSimpleResource::handleDomCustomWidgets(const QDesignerFormEditorInterface } // Oops, there are classes left whose base class could not be found. // Default them to QWidget with warnings. - const QString fallBackBaseClass = QStringLiteral("QWidget"); + const QString fallBackBaseClass = u"QWidget"_s; for (DomCustomWidget *custom_widget : std::as_const(custom_widget_list)) { const QString customClassName = custom_widget->elementClass(); const QString base_class = custom_widget->elementExtends(); diff --git a/src/designer/src/lib/shared/qtresourceeditordialog.cpp b/src/designer/src/lib/shared/qtresourceeditordialog.cpp index fbbb37736..30223bb11 100644 --- a/src/designer/src/lib/shared/qtresourceeditordialog.cpp +++ b/src/designer/src/lib/shared/qtresourceeditordialog.cpp @@ -24,6 +24,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static const char *rccRootTag = "RCC"; static const char *rccTag = "qresource"; static const char *rccFileTag = "file"; @@ -1340,7 +1342,7 @@ void QtResourceEditorDialogPrivate::slotNewQrcFile() QCoreApplication::translate("QtResourceEditorDialog", "New Resource File"), m_firstQrcFileDialog ? qrcStartDirectory() : QString(), QCoreApplication::translate("QtResourceEditorDialog", "Resource files (*.qrc)"), - QStringLiteral("qrc")); + u"qrc"_s); if (qrcPath.isEmpty()) return; @@ -1540,7 +1542,7 @@ void QtResourceEditorDialogPrivate::slotAddFiles() const QDir dir(fi.absolutePath()); for (QString resourcePath : resourcePaths) { QString relativePath = dir.relativeFilePath(resourcePath); - if (relativePath.startsWith(QStringLiteral(".."))) { + if (relativePath.startsWith(".."_L1)) { QMessageBox msgBox(QMessageBox::Warning, QCoreApplication::translate("QtResourceEditorDialog", "Incorrect Path"), outOfPathWarning(relativePath), QMessageBox::Cancel); @@ -1753,7 +1755,7 @@ QString QtResourceEditorDialogPrivate::browseForNewLocation(const QString &resou QCoreApplication::translate("QtResourceEditorDialog", "Copy As"), initialPath); QString relativePath = rootDir.relativeFilePath(newPath); - if (relativePath.startsWith(QStringLiteral(".."))) { + if (relativePath.startsWith(".."_L1)) { if (warning(QCoreApplication::translate("QtResourceEditorDialog", "Copy As"), QCoreApplication::translate("QtResourceEditorDialog", "<p>The selected file:</p>" "<p>%1</p><p>is outside of the current resource file's directory:</p><p>%2</p>" @@ -2070,8 +2072,8 @@ QString QtResourceEditorDialog::selectedResource() const if (!currentResourceFile->alias().isEmpty()) resourceEnding = currentResourceFile->alias(); - const QString dotSlash(QStringLiteral("./")); - const QString dotDotSlash(QStringLiteral("../")); + const auto dotSlash = "./"_L1; + const auto dotDotSlash = "../"_L1; while (true) { if (resourceEnding.startsWith(slash)) resourceEnding = resourceEnding.mid(1); diff --git a/src/designer/src/lib/shared/qtresourceview.cpp b/src/designer/src/lib/shared/qtresourceview.cpp index 1d38ce7c9..c9f3fdfcc 100644 --- a/src/designer/src/lib/shared/qtresourceview.cpp +++ b/src/designer/src/lib/shared/qtresourceview.cpp @@ -40,6 +40,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static const char *elementResourceData = "resource"; static const char *typeAttribute = "type"; static const char *typeImage = "image"; @@ -337,7 +339,7 @@ void QtResourceViewPrivate::createPaths() return; // Resource root up until 4.6 was ':', changed to ":/" as of 4.7 - const QString root(QStringLiteral(":/")); + const QString root(u":/"_s); QMap<QString, QString> contents = m_resourceModel->contents(); for (auto it = contents.cbegin(), end = contents.cend(); it != end; ++it) { @@ -377,7 +379,7 @@ void QtResourceViewPrivate::filterOutResources() // 3) we hide these items which has pathToVisible value false. const bool matchAll = m_filterPattern.isEmpty(); - const QString root(QStringLiteral(":/")); + const QString root(u":/"_s); QQueue<QString> pathQueue; pathQueue.enqueue(root); @@ -485,7 +487,7 @@ QTreeWidgetItem *QtResourceViewPrivate::createPath(const QString &path, QTreeWid QFileInfo di(path); substPath = di.fileName(); } else { - substPath = QStringLiteral("<resource root>"); + substPath = u"<resource root>"_s; } item->setText(0, substPath); item->setToolTip(0, path); @@ -530,14 +532,16 @@ QtResourceView::QtResourceView(QDesignerFormEditorInterface *core, QWidget *pare { d_ptr->q_ptr = this; - QIcon editIcon = QIcon::fromTheme(QStringLiteral("document-properties"), qdesigner_internal::createIconSet(QStringLiteral("edit.png"))); + QIcon editIcon = QIcon::fromTheme(u"document-properties"_s, + qdesigner_internal::createIconSet(u"edit.png"_s)); d_ptr->m_editResourcesAction = new QAction(editIcon, tr("Edit Resources..."), this); d_ptr->m_toolBar->addAction(d_ptr->m_editResourcesAction); connect(d_ptr->m_editResourcesAction, &QAction::triggered, this, [this] { d_ptr->slotEditResources(); }); d_ptr->m_editResourcesAction->setEnabled(false); - QIcon refreshIcon = QIcon::fromTheme(QStringLiteral("view-refresh"), qdesigner_internal::createIconSet(QStringLiteral("reload.png"))); + QIcon refreshIcon = QIcon::fromTheme(u"view-refresh"_s, + qdesigner_internal::createIconSet(u"reload.png"_s)); d_ptr->m_reloadResourcesAction = new QAction(refreshIcon, tr("Reload"), this); d_ptr->m_toolBar->addAction(d_ptr->m_reloadResourcesAction); @@ -546,7 +550,8 @@ QtResourceView::QtResourceView(QDesignerFormEditorInterface *core, QWidget *pare d_ptr->m_reloadResourcesAction->setEnabled(false); #if QT_CONFIG(clipboard) - QIcon copyIcon = QIcon::fromTheme(QStringLiteral("edit-copy"), qdesigner_internal::createIconSet(QStringLiteral("editcopy.png"))); + QIcon copyIcon = QIcon::fromTheme(u"edit-copy"_s, + qdesigner_internal::createIconSet(u"editcopy.png"_s)); d_ptr->m_copyResourcePathAction = new QAction(copyIcon, tr("Copy Path"), this); connect(d_ptr->m_copyResourcePathAction, &QAction::triggered, this, [this] { d_ptr->slotCopyResourcePath(); }); diff --git a/src/designer/src/lib/shared/richtexteditor.cpp b/src/designer/src/lib/shared/richtexteditor.cpp index 48b55ac00..eb1d2534c 100644 --- a/src/designer/src/lib/shared/richtexteditor.cpp +++ b/src/designer/src/lib/shared/richtexteditor.cpp @@ -53,7 +53,7 @@ namespace qdesigner_internal { // Richtext simplification filter helpers: Elements to be discarded static inline bool filterElement(QStringView name) { - return name != QStringLiteral("meta") && name != QStringLiteral("style"); + return name != "meta"_L1 && name != "style"_L1; } // Richtext simplification filter helpers: Filter attributes of elements @@ -65,15 +65,15 @@ static inline void filterAttributes(QStringView name, return; // No style attributes for <body> - if (name == QStringLiteral("body")) { + if (name == "body"_L1) { atts->clear(); return; } // Clean out everything except 'align' for 'p' - if (name == QStringLiteral("p")) { + if (name == "p"_L1) { for (auto it = atts->begin(); it != atts->end(); ) { - if (it->name() == QStringLiteral("align")) { + if (it->name() == "align"_L1) { ++it; *paragraphAlignmentFound = true; } else { @@ -214,12 +214,7 @@ void AddLinkDialog::accept() const QString url = m_ui->urlInput->text(); if (!title.isEmpty()) { - QString html = QStringLiteral("<a href=\""); - html += url; - html += QStringLiteral("\">"); - html += title; - html += QStringLiteral("</a>"); - + const QString html = "<a href=\""_L1 + url + "\">"_L1 + title + "</a>"_L1; m_editor->insertHtml(html); } @@ -478,12 +473,12 @@ RichTextEditorToolBar::RichTextEditorToolBar(QDesignerFormEditorInterface *core, // Insert hyperlink and image buttons - m_link_action->setIcon(createIconSet(QStringLiteral("textanchor.png"))); + m_link_action->setIcon(createIconSet(u"textanchor.png"_s)); m_link_action->setText(tr("Insert &Link")); connect(m_link_action, &QAction::triggered, this, &RichTextEditorToolBar::insertLink); addAction(m_link_action); - m_image_action->setIcon(createIconSet(QStringLiteral("insertimage.png"))); + m_image_action->setIcon(createIconSet(u"insertimage.png"_s)); m_image_action->setText(tr("Insert &Image")); connect(m_image_action, &QAction::triggered, this, &RichTextEditorToolBar::insertImage); addAction(m_image_action); diff --git a/src/designer/src/lib/shared/shared_settings.cpp b/src/designer/src/lib/shared/shared_settings.cpp index c5d754f71..73ad10689 100644 --- a/src/designer/src/lib/shared/shared_settings.cpp +++ b/src/designer/src/lib/shared/shared_settings.cpp @@ -32,9 +32,9 @@ static const char *deviceProfilesKey = "DeviceProfiles"; static const char *formTemplatePathsKey = "FormTemplatePaths"; static const char *formTemplateKey = "FormTemplate"; static const char *newFormSizeKey = "NewFormSize"; -static inline QString namingModeKey() { return QStringLiteral("naming"); } -static inline QString underScoreNamingMode() { return QStringLiteral("underscore"); } -static inline QString camelCaseNamingMode() { return QStringLiteral("camelcase"); } +static inline QString namingModeKey() { return u"naming"_s; } +static inline QString underScoreNamingMode() { return u"underscore"_s; } +static inline QString camelCaseNamingMode() { return u"camelcase"_s; } static bool checkTemplatePath(const QString &path, bool create) { @@ -79,7 +79,7 @@ const QStringList &QDesignerSharedSettings::defaultFormTemplatePaths() static QStringList rc; if (rc.isEmpty()) { // Ensure default form template paths - const QString templatePath = QStringLiteral("/templates"); + const auto templatePath = "/templates"_L1; // home QString path = dataDirectory() + templatePath; if (checkTemplatePath(path, true)) diff --git a/src/designer/src/lib/shared/signalslotdialog.cpp b/src/designer/src/lib/shared/signalslotdialog.cpp index 720ccdf66..afb0ccd20 100644 --- a/src/designer/src/lib/shared/signalslotdialog.cpp +++ b/src/designer/src/lib/shared/signalslotdialog.cpp @@ -28,6 +28,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // Regexp to match a function signature, arguments potentially // with namespace colons. static const char *signatureRegExp = "^[\\w+_]+\\(([\\w+:]\\*?,?)*\\)$"; @@ -88,7 +90,7 @@ namespace { QString signature = le->text(); if (!m_signatureRegexp.match(signature).hasMatch()) { if (m_methodNameRegexp.match(signature).hasMatch()) { - signature += QStringLiteral("()"); + signature += "()"_L1; le->setText(signature); } else { return; @@ -298,8 +300,10 @@ SignalSlotDialog::SignalSlotDialog(QDesignerDialogGuiInterface *dialogGui, QWidg m_ui->addSignalButton->setIcon(plusIcon); m_ui->removeSignalButton->setIcon(minusIcon); - m_slotPanel = new SignaturePanel(this, m_ui->slotListView, m_ui->addSlotButton, m_ui->removeSlotButton, QStringLiteral("slot")); - m_signalPanel = new SignaturePanel(this, m_ui->signalListView, m_ui->addSignalButton, m_ui->removeSignalButton, QStringLiteral("signal")); + m_slotPanel = new SignaturePanel(this, m_ui->slotListView, m_ui->addSlotButton, + m_ui->removeSlotButton, u"slot"_s); + m_signalPanel = new SignaturePanel(this, m_ui->signalListView, m_ui->addSignalButton, + m_ui->removeSignalButton, u"signal"_s); connect(m_slotPanel, &SignaturePanel::checkSignature, this, &SignalSlotDialog::slotCheckSignature); connect(m_signalPanel, &SignaturePanel::checkSignature, diff --git a/src/designer/src/lib/shared/spacer_widget.cpp b/src/designer/src/lib/shared/spacer_widget.cpp index 7eaeafc85..ac08a67be 100644 --- a/src/designer/src/lib/shared/spacer_widget.cpp +++ b/src/designer/src/lib/shared/spacer_widget.cpp @@ -16,6 +16,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // The Spacer widget is Designer representation of QLayoutItem. // It uses QLayoutItem's sizeHint property as QWidget // sizeHint and the QLayoutItem's sizeType property as QWidget size policy. @@ -127,7 +129,7 @@ void Spacer::resizeEvent(QResizeEvent* e) const QSize oldSize = e->oldSize(); if (oldSize.isNull() || oldSize.width() <= m_SizeOffset.width() || oldSize.height() <= m_SizeOffset.height()) if (QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(m_formWindow->core()->extensionManager(), this)) - sheet->setChanged(sheet->indexOf(QStringLiteral("sizeHint")), true); + sheet->setChanged(sheet->indexOf(u"sizeHint"_s), true); } updateMask(); diff --git a/src/designer/src/lib/shared/stylesheeteditor.cpp b/src/designer/src/lib/shared/stylesheeteditor.cpp index 827d91e4c..8141c4990 100644 --- a/src/designer/src/lib/shared/stylesheeteditor.cpp +++ b/src/designer/src/lib/shared/stylesheeteditor.cpp @@ -35,6 +35,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + static const char *styleSheetProperty = "styleSheet"; static const char *StyleSheetDialogC = "StyleSheetDialog"; static const char *seGeometry = "Geometry"; @@ -208,7 +210,7 @@ void StyleSheetEditorDialog::slotAddResource(const QString &property) { const QString path = IconSelector::choosePixmapResource(m_core, m_core->resourceModel(), QString(), this); if (!path.isEmpty()) - insertCssProperty(property, QString(QStringLiteral("url(%1)")).arg(path)); + insertCssProperty(property, "url("_L1 + path + u')'); } void StyleSheetEditorDialog::slotAddGradient(const QString &property) @@ -228,11 +230,12 @@ void StyleSheetEditorDialog::slotAddColor(const QString &property) QString colorStr; if (color.alpha() == 255) { - colorStr = QString(QStringLiteral("rgb(%1, %2, %3)")).arg( - color.red()).arg(color.green()).arg(color.blue()); + colorStr = QString::asprintf("rgb(%d, %d, %d)", + color.red(), color.green(), color.blue()); } else { - colorStr = QString(QStringLiteral("rgba(%1, %2, %3, %4)")).arg( - color.red()).arg(color.green()).arg(color.blue()).arg(color.alpha()); + colorStr = QString::asprintf("rgba(%d, %d, %d, %d)", + color.red(), color.green(), color.blue(), + color.alpha()); } insertCssProperty(property, colorStr); @@ -251,29 +254,29 @@ void StyleSheetEditorDialog::slotAddFont() switch (font.style()) { case QFont::StyleItalic: - fontStr += QStringLiteral("italic "); + fontStr += "italic "_L1; break; case QFont::StyleOblique: - fontStr += QStringLiteral("oblique "); + fontStr += "oblique "_L1; break; default: break; } fontStr += QString::number(font.pointSize()); - fontStr += QStringLiteral("pt \""); + fontStr += "pt \""_L1; fontStr += font.family(); fontStr += QLatin1Char('"'); - insertCssProperty(QStringLiteral("font"), fontStr); + insertCssProperty(u"font"_s, fontStr); QString decoration; if (font.underline()) - decoration += QStringLiteral("underline"); + decoration += "underline"_L1; if (font.strikeOut()) { if (!decoration.isEmpty()) decoration += QLatin1Char(' '); - decoration += QStringLiteral("line-through"); + decoration += "line-through"_L1; } - insertCssProperty(QStringLiteral("text-decoration"), decoration); + insertCssProperty(u"text-decoration"_s, decoration); } } @@ -288,8 +291,8 @@ void StyleSheetEditorDialog::insertCssProperty(const QString &name, const QStrin // Simple check to see if we're in a selector scope const QTextDocument *doc = m_editor->document(); - const QTextCursor closing = doc->find(QStringLiteral("}"), cursor, QTextDocument::FindBackward); - const QTextCursor opening = doc->find(QStringLiteral("{"), cursor, QTextDocument::FindBackward); + const QTextCursor closing = doc->find(u"}"_s, cursor, QTextDocument::FindBackward); + const QTextCursor opening = doc->find(u"{"_s, cursor, QTextDocument::FindBackward); const bool inSelector = !opening.isNull() && (closing.isNull() || closing.position() < opening.position()); QString insertion; @@ -298,7 +301,7 @@ void StyleSheetEditorDialog::insertCssProperty(const QString &name, const QStrin if (inSelector) insertion += QLatin1Char('\t'); insertion += name; - insertion += QStringLiteral(": "); + insertion += ": "_L1; insertion += value; insertion += QLatin1Char(';'); cursor.insertText(insertion); @@ -311,8 +314,8 @@ void StyleSheetEditorDialog::insertCssProperty(const QString &name, const QStrin void StyleSheetEditorDialog::slotRequestHelp() { - m_core->integration()->emitHelpRequested(QStringLiteral("qtwidgets"), - QStringLiteral("stylesheet-reference.html")); + m_core->integration()->emitHelpRequested(u"qtwidgets"_s, + u"stylesheet-reference.html"_s); } // See QDialog::keyPressEvent() @@ -353,10 +356,7 @@ bool StyleSheetEditorDialog::isStyleSheetValid(const QString &styleSheet) QCss::StyleSheet sheet; if (parser.parse(&sheet)) return true; - QString fullSheet = QStringLiteral("* { "); - fullSheet += styleSheet; - fullSheet += QLatin1Char('}'); - QCss::Parser parser2(fullSheet); + QCss::Parser parser2("* { "_L1 + styleSheet + '}'_L1); return parser2.parse(&sheet); } @@ -366,10 +366,10 @@ void StyleSheetEditorDialog::validateStyleSheet() setOkButtonEnabled(valid); if (valid) { m_validityLabel->setText(tr("Valid Style Sheet")); - m_validityLabel->setStyleSheet(QStringLiteral("color: green")); + m_validityLabel->setStyleSheet(u"color: green"_s); } else { m_validityLabel->setText(tr("Invalid Style Sheet")); - m_validityLabel->setStyleSheet(QStringLiteral("color: red")); + m_validityLabel->setStyleSheet(u"color: red"_s); } } diff --git a/src/designer/src/lib/shared/textpropertyeditor.cpp b/src/designer/src/lib/shared/textpropertyeditor.cpp index a31112202..52418c904 100644 --- a/src/designer/src/lib/shared/textpropertyeditor.cpp +++ b/src/designer/src/lib/shared/textpropertyeditor.cpp @@ -17,6 +17,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + namespace { const QChar NewLineChar(QLatin1Char('\n')); const QLatin1String EscapedNewLine("\\n"); @@ -130,7 +132,7 @@ namespace { QUrl UrlValidator::guessUrlFromString(const QString &string) const { const QString urlStr = string.trimmed(); - const QRegularExpression qualifiedUrl(QStringLiteral("^[a-zA-Z]+\\:.*$")); + const QRegularExpression qualifiedUrl(u"^[a-zA-Z]+\\:.*$"_s); Q_ASSERT(qualifiedUrl.isValid()); // Check if it looks like a qualified URL. Try parsing it and see. @@ -142,8 +144,8 @@ namespace { } // Might be a Qt resource - if (string.startsWith(QStringLiteral(":/"))) - return QUrl(QStringLiteral("qrc") + string); + if (string.startsWith(":/"_L1)) + return QUrl("qrc"_L1 + string); // Might be a file. if (QFile::exists(urlStr)) @@ -155,11 +157,11 @@ namespace { if (dotIndex != -1) { const QString prefix = urlStr.left(dotIndex).toLower(); QString urlString; - if (prefix == QStringLiteral("ftp")) + if (prefix == "ftp"_L1) urlString += prefix; else - urlString += QStringLiteral("http"); - urlString += QStringLiteral("://"); + urlString += "http"_L1; + urlString += "://"_L1; urlString += urlStr; const QUrl url(urlString, QUrl::TolerantMode); if (url.isValid()) @@ -225,26 +227,25 @@ namespace qdesigner_internal { m_lineEdit->setCompleter(nullptr); break; case ValidationObjectName: - setRegularExpressionValidator(QStringLiteral("^[_a-zA-Z][_a-zA-Z0-9]{1,1023}$")); + setRegularExpressionValidator(u"^[_a-zA-Z][_a-zA-Z0-9]{1,1023}$"_s); m_lineEdit->setCompleter(nullptr); break; case ValidationObjectNameScope: - setRegularExpressionValidator(QStringLiteral("^[_a-zA-Z:][_a-zA-Z0-9:]{1,1023}$")); + setRegularExpressionValidator(u"^[_a-zA-Z:][_a-zA-Z0-9:]{1,1023}$"_s); m_lineEdit->setCompleter(nullptr); break; case ValidationURL: { - static QStringList urlCompletions; - if (urlCompletions.isEmpty()) { - urlCompletions.push_back(QStringLiteral("about:blank")); - urlCompletions.push_back(QStringLiteral("http://")); - urlCompletions.push_back(QStringLiteral("http://www.")); - urlCompletions.push_back(QStringLiteral("http://qt.io")); - urlCompletions.push_back(QStringLiteral("file://")); - urlCompletions.push_back(QStringLiteral("ftp://")); - urlCompletions.push_back(QStringLiteral("data:")); - urlCompletions.push_back(QStringLiteral("data:text/html,")); - urlCompletions.push_back(QStringLiteral("qrc:/")); - } + static const QStringList urlCompletions = { + u"about:blank"_s, + u"http://"_s, + u"http://www."_s, + u"http://qt.io"_s, + u"file://"_s, + u"ftp://"_s, + u"data:"_s, + u"data:text/html,"_s, + u"qrc:/"_s, + }; QCompleter *completer = new QCompleter(urlCompletions, m_lineEdit); m_lineEdit->setCompleter(completer); m_lineEdit->setValidator(new UrlValidator(completer, m_lineEdit)); @@ -351,7 +352,7 @@ namespace qdesigner_internal { QString rc(s); // protect backslashes - rc.replace(QLatin1Char('\\'), QStringLiteral("\\\\")); + rc.replace('\\'_L1, "\\\\"_L1); // escape newlines rc.replace(NewLineChar, QString(EscapedNewLine)); return rc; diff --git a/src/designer/src/lib/shared/widgetdatabase.cpp b/src/designer/src/lib/shared/widgetdatabase.cpp index ffe991285..c09b634ed 100644 --- a/src/designer/src/lib/shared/widgetdatabase.cpp +++ b/src/designer/src/lib/shared/widgetdatabase.cpp @@ -305,28 +305,28 @@ WidgetDataBase::WidgetDataBase(QDesignerFormEditorInterface *core, QObject *pare // ### check the casts #if 0 // ### enable me after 4.1 - item(indexOfClassName(QStringLiteral("QToolBar")))->setContainer(true); + item(indexOfClassName(u"QToolBar"_s))->setContainer(true); #endif - item(indexOfClassName(QStringLiteral("QTabWidget")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QGroupBox")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QScrollArea")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QStackedWidget")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QToolBox")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QFrame")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QLayoutWidget")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QDesignerWidget")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QDesignerDialog")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QSplitter")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QMainWindow")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QDockWidget")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QDesignerDockWidget")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QMdiArea")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QWizard")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QWizardPage")))->setContainer(true); - - item(indexOfClassName(QStringLiteral("QWidget")))->setContainer(true); - item(indexOfClassName(QStringLiteral("QDialog")))->setContainer(true); + item(indexOfClassName(u"QTabWidget"_s))->setContainer(true); + item(indexOfClassName(u"QGroupBox"_s))->setContainer(true); + item(indexOfClassName(u"QScrollArea"_s))->setContainer(true); + item(indexOfClassName(u"QStackedWidget"_s))->setContainer(true); + item(indexOfClassName(u"QToolBox"_s))->setContainer(true); + item(indexOfClassName(u"QFrame"_s))->setContainer(true); + item(indexOfClassName(u"QLayoutWidget"_s))->setContainer(true); + item(indexOfClassName(u"QDesignerWidget"_s))->setContainer(true); + item(indexOfClassName(u"QDesignerDialog"_s))->setContainer(true); + item(indexOfClassName(u"QSplitter"_s))->setContainer(true); + item(indexOfClassName(u"QMainWindow"_s))->setContainer(true); + item(indexOfClassName(u"QDockWidget"_s))->setContainer(true); + item(indexOfClassName(u"QDesignerDockWidget"_s))->setContainer(true); + item(indexOfClassName(u"QMdiArea"_s))->setContainer(true); + item(indexOfClassName(u"QWizard"_s))->setContainer(true); + item(indexOfClassName(u"QWizardPage"_s))->setContainer(true); + + item(indexOfClassName(u"QWidget"_s))->setContainer(true); + item(indexOfClassName(u"QDialog"_s))->setContainer(true); } WidgetDataBase::~WidgetDataBase() = default; @@ -478,7 +478,6 @@ void WidgetDataBase::grabStandardWidgetBoxIcons() // At this point, grab the default icons for the non-custom widgets from // the widget box. They will show up in the object inspector. if (const QDesignerWidgetBox *wb = qobject_cast<const QDesignerWidgetBox *>(m_core->widgetBox())) { - const QString qWidgetClass = QStringLiteral("QWidget"); const int itemCount = count(); for (int i = 0; i < itemCount; ++i) { QDesignerWidgetDataBaseItemInterface *dbItem = item(i); @@ -486,8 +485,8 @@ void WidgetDataBase::grabStandardWidgetBoxIcons() // Careful not to catch the layout icons when looking for // QWidget const QString name = dbItem->name(); - if (name == qWidgetClass) { - dbItem->setIcon(wb->iconForWidget(name, QStringLiteral("Containers"))); + if (name == "QWidget"_L1) { + dbItem->setIcon(wb->iconForWidget(name, u"Containers"_s)); } else { dbItem->setIcon(wb->iconForWidget(name)); } @@ -503,7 +502,7 @@ enum { NewFormWidth = 400, NewFormHeight = 300 }; // Check if class is suitable to generate a form from static inline bool isExistingTemplate(const QString &className) { - return className == QStringLiteral("QWidget") || className == QStringLiteral("QDialog") || className == QStringLiteral("QMainWindow"); + return className == "QWidget"_L1 || className == "QDialog"_L1 || className == "QMainWindow"_L1; } // Check if class is suitable to generate a form from @@ -511,9 +510,9 @@ static inline bool suitableForNewForm(const QString &className) { if (className.isEmpty()) // Missing custom widget information return false; - if (className == QStringLiteral("QSplitter")) + if (className == "QSplitter"_L1) return false; - if (className.startsWith(QStringLiteral("QDesigner")) || className.startsWith(QStringLiteral("QLayout"))) + if (className.startsWith("QDesigner"_L1) || className.startsWith("QLayout"_L1)) return false; return true; } @@ -568,22 +567,20 @@ static QString xmlFromWidgetBox(const QDesignerFormEditorInterface *core, const QScopedPointer<DomUI> domUI(QDesignerWidgetBox::xmlToUi(className, widget.domXml(), false)); if (domUI.isNull()) return QString(); - domUI->setAttributeVersion(QStringLiteral("4.0")); + domUI->setAttributeVersion(u"4.0"_s); DomWidget *domWidget = domUI->elementWidget(); if (!domWidget) return QString(); // Properties: Remove the "objectName" property in favour of the name attribute and check geometry. domWidget->setAttributeName(objectName); - const QString geometryProperty = QStringLiteral("geometry"); - const QString objectNameProperty = QStringLiteral("objectName"); PropertyList properties = domWidget->elementProperty(); for (PropertyList::iterator it = properties.begin(); it != properties.end(); ) { DomProperty *property = *it; - if (property->attributeName() == objectNameProperty) { // remove "objectName" + if (property->attributeName() == "objectName"_L1) { // remove "objectName" it = properties.erase(it); delete property; } else { - if (property->attributeName() == geometryProperty) { // Make sure form is at least 400, 300 + if (property->attributeName() == "geometry"_L1) { // Make sure form is at least 400, 300 if (DomRect *geom = property->elementRect()) { if (geom->elementWidth() < NewFormWidth) geom->setElementWidth(NewFormWidth); @@ -598,7 +595,7 @@ static QString xmlFromWidgetBox(const QDesignerFormEditorInterface *core, const DomString *windowTitleString = new DomString; windowTitleString->setText(objectName); DomProperty *windowTitleProperty = new DomProperty; - windowTitleProperty->setAttributeName(QStringLiteral("windowTitle")); + windowTitleProperty->setAttributeName(u"windowTitle"_s); windowTitleProperty->setElementString(windowTitleString); properties.push_back(windowTitleProperty); // ------ @@ -651,7 +648,7 @@ QString WidgetDataBase::formTemplate(const QDesignerFormEditorInterface *core, c // 2) If that fails, only custom main windows, custom dialogs and unsupported Qt Widgets should // be left over. Generate something that is similar to the default templates. Find a similar class. const QDesignerWidgetDataBaseInterface *wdb = core->widgetDataBase(); - QString similarClass = QStringLiteral("QWidget"); + QString similarClass = u"QWidget"_s; const int index = wdb->indexOfClassName(className); if (index != -1) { const QDesignerWidgetDataBaseItemInterface *item = wdb->item(index); @@ -665,16 +662,16 @@ QString WidgetDataBase::formTemplate(const QDesignerFormEditorInterface *core, c // Set a fixed size on a XML template QString WidgetDataBase::scaleFormTemplate(const QString &xml, const QSize &size, bool fixed) { - QScopedPointer<DomUI> domUI(QDesignerWidgetBox::xmlToUi(QStringLiteral("Form"), xml, false)); + QScopedPointer<DomUI> domUI(QDesignerWidgetBox::xmlToUi(u"Form"_s, xml, false)); if (!domUI) return QString(); DomWidget *domWidget = domUI->elementWidget(); if (!domWidget) return QString(); // Properties: Find/Ensure the geometry, minimum and maximum sizes properties - const QString geometryPropertyName = QStringLiteral("geometry"); - const QString minimumSizePropertyName = QStringLiteral("minimumSize"); - const QString maximumSizePropertyName = QStringLiteral("maximumSize"); + const QString geometryPropertyName = u"geometry"_s; + const QString minimumSizePropertyName = u"minimumSize"_s; + const QString maximumSizePropertyName = u"maximumSize"_s; DomProperty *geomProperty = nullptr; DomProperty *minimumSizeProperty = nullptr; DomProperty *maximumSizeProperty = nullptr; @@ -684,13 +681,10 @@ QString WidgetDataBase::scaleFormTemplate(const QString &xml, const QSize &size, const QString name = p->attributeName(); if (name == geometryPropertyName) { geomProperty = p; - } else { - if (name == minimumSizePropertyName) { - minimumSizeProperty = p; - } else { - if (name == maximumSizePropertyName) - maximumSizeProperty = p; - } + } else if (name == minimumSizePropertyName) { + minimumSizeProperty = p; + } else if (name == maximumSizePropertyName) { + maximumSizeProperty = p; } } if (!geomProperty) { @@ -825,8 +819,7 @@ QDESIGNER_SHARED_EXPORT QDesignerWidgetDataBaseItemInterface * derivedItem = WidgetDataBaseItem::clone(baseItem); // Sort of hack: If base class is QWidget, we most likely // do not want to inherit the container attribute. - static const QString qWidgetName = QStringLiteral("QWidget"); - if (baseItem->name() == qWidgetName) + if (baseItem->name() == "QWidget"_L1) derivedItem->setContainer(false); // set new props derivedItem->setName(className); diff --git a/src/designer/src/lib/shared/widgetfactory.cpp b/src/designer/src/lib/shared/widgetfactory.cpp index 7942f4cc8..413cac53a 100644 --- a/src/designer/src/lib/shared/widgetfactory.cpp +++ b/src/designer/src/lib/shared/widgetfactory.cpp @@ -60,6 +60,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #ifdef Q_OS_WIN static inline bool isAxWidget(const QObject *o) { @@ -201,31 +203,31 @@ void WizardPageChangeWatcher::pageChanged() // ---------------- WidgetFactory::Strings WidgetFactory::Strings::Strings() : - m_alignment(QStringLiteral("alignment")), - m_bottomMargin(QStringLiteral("bottomMargin")), - m_geometry(QStringLiteral("geometry")), - m_leftMargin(QStringLiteral("leftMargin")), - m_line(QStringLiteral("Line")), - m_objectName(QStringLiteral("objectName")), - m_spacerName(QStringLiteral("spacerName")), - m_orientation(QStringLiteral("orientation")), - m_qAction(QStringLiteral("QAction")), - m_qButtonGroup(QStringLiteral("QButtonGroup")), - m_qAxWidget(QStringLiteral("QAxWidget")), - m_qDialog(QStringLiteral("QDialog")), - m_qDockWidget(QStringLiteral("QDockWidget")), - m_qLayoutWidget(QStringLiteral("QLayoutWidget")), - m_qMenu(QStringLiteral("QMenu")), - m_qMenuBar(QStringLiteral("QMenuBar")), - m_qWidget(QStringLiteral("QWidget")), - m_rightMargin(QStringLiteral("rightMargin")), - m_sizeHint(QStringLiteral("sizeHint")), - m_spacer(QStringLiteral("Spacer")), - m_text(QStringLiteral("text")), - m_title(QStringLiteral("title")), - m_topMargin(QStringLiteral("topMargin")), - m_windowIcon(QStringLiteral("windowIcon")), - m_windowTitle(QStringLiteral("windowTitle")) + m_alignment(u"alignment"_s), + m_bottomMargin(u"bottomMargin"_s), + m_geometry(u"geometry"_s), + m_leftMargin(u"leftMargin"_s), + m_line(u"Line"_s), + m_objectName(u"objectName"_s), + m_spacerName(u"spacerName"_s), + m_orientation(u"orientation"_s), + m_qAction(u"QAction"_s), + m_qButtonGroup(u"QButtonGroup"_s), + m_qAxWidget(u"QAxWidget"_s), + m_qDialog(u"QDialog"_s), + m_qDockWidget(u"QDockWidget"_s), + m_qLayoutWidget(u"QLayoutWidget"_s), + m_qMenu(u"QMenu"_s), + m_qMenuBar(u"QMenuBar"_s), + m_qWidget(u"QWidget"_s), + m_rightMargin(u"rightMargin"_s), + m_sizeHint(u"sizeHint"_s), + m_spacer(u"Spacer"_s), + m_text(u"text"_s), + m_title(u"title"_s), + m_topMargin(u"topMargin"_s), + m_windowIcon(u"windowIcon"_s), + m_windowTitle(u"windowTitle"_s) { } // ---------------- WidgetFactory @@ -440,7 +442,7 @@ QWidget *WidgetFactory::createWidget(const QString &widgetName, QWidget *parentW if (item == nullptr) { // Emergency: Create, derived from QWidget QString includeFile = widgetName.toLower(); - includeFile += QStringLiteral(".h"); + includeFile += ".h"_L1; item = appendDerived(db,widgetName, tr("%1 Widget").arg(widgetName),fallBackBaseClass, includeFile, true, true); Q_ASSERT(item); @@ -482,18 +484,18 @@ QString WidgetFactory::classNameOf(QDesignerFormEditorInterface *c, const QObjec if (!customClassName.isEmpty()) return customClassName; if (qobject_cast<const QDesignerMenuBar*>(w)) - return QStringLiteral("QMenuBar"); + return u"QMenuBar"_s; if (qobject_cast<const QDesignerMenu*>(w)) - return QStringLiteral("QMenu"); + return u"QMenu"_s; if (qobject_cast<const QDesignerDockWidget*>(w)) - return QStringLiteral("QDockWidget"); + return u"QDockWidget"_s; if (qobject_cast<const QDesignerDialog*>(w)) - return QStringLiteral("QDialog"); + return u"QDialog"_s; if (qobject_cast<const QDesignerWidget*>(w)) - return QStringLiteral("QWidget"); + return u"QWidget"_s; #ifdef Q_OS_WIN if (isAxWidget(w)) - return QStringLiteral("QAxWidget"); + return u"QAxWidget"_s; #endif return QLatin1String(className); } @@ -834,9 +836,6 @@ static bool isTabBarInteractor(const QTabBar *tabBar) static bool isPassiveInteractorHelper(const QWidget *widget) { - static const QString qtPassive = QStringLiteral("__qt__passive_"); - static const QString qtMainWindowSplitter = QStringLiteral("qt_qmainwindow_extended_splitter"); - if (qobject_cast<const QMenuBar*>(widget) #if QT_CONFIG(sizegrip) || qobject_cast<const QSizeGrip*>(widget) @@ -856,10 +855,8 @@ static bool isPassiveInteractorHelper(const QWidget *widget) } else if (qobject_cast<const QScrollBar*>(widget)) { // A scroll bar is an interactor on a QAbstractScrollArea only. if (auto parent = widget->parentWidget()) { - const QString objectName = parent->objectName(); - static const QString scrollAreaVContainer = QStringLiteral("qt_scrollarea_vcontainer"); - static const QString scrollAreaHContainer = QStringLiteral("qt_scrollarea_hcontainer"); - if (objectName == scrollAreaVContainer || objectName == scrollAreaHContainer) + const QString &objectName = parent->objectName(); + if (objectName == "qt_scrollarea_vcontainer"_L1 || objectName == "qt_scrollarea_hcontainer"_L1) return true; } } else if (qstrcmp(widget->metaObject()->className(), "QDockWidgetTitle") == 0) { @@ -868,7 +865,8 @@ static bool isPassiveInteractorHelper(const QWidget *widget) return true; } const QString &name = widget->objectName(); - return name.startsWith(qtPassive) || name == qtMainWindowSplitter; + return name.startsWith("__qt__passive_"_L1) + || name == "qt_qmainwindow_extended_splitter"_L1; } bool WidgetFactory::isPassiveInteractor(QWidget *widget) diff --git a/src/designer/src/lib/uilib/abstractformbuilder.cpp b/src/designer/src/lib/uilib/abstractformbuilder.cpp index 21f695f16..021ea4cbe 100644 --- a/src/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/src/designer/src/lib/uilib/abstractformbuilder.cpp @@ -60,6 +60,8 @@ static const char *buttonGroupPropertyC = "buttonGroup"; QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #ifdef QFORMINTERNAL_NAMESPACE using namespace QFormInternal; #endif @@ -709,40 +711,35 @@ static inline QFormLayout::ItemRole formLayoutRole(int column, int colspan) static inline QString alignmentValue(Qt::Alignment a) { - QString h,v; + QLatin1StringView h; + QLatin1StringView v; switch (a & Qt::AlignHorizontal_Mask) { case Qt::AlignLeft: - h = QStringLiteral("Qt::AlignLeft"); + h = "Qt::AlignLeft"_L1; break; case Qt::AlignRight: - h = QStringLiteral("Qt::AlignRight"); + h = "Qt::AlignRight"_L1; break; case Qt::AlignHCenter: - h = QStringLiteral("Qt::AlignHCenter"); + h = "Qt::AlignHCenter"_L1; break; case Qt::AlignJustify: - h = QStringLiteral("Qt::AlignJustify"); + h = "Qt::AlignJustify"_L1; break; } switch (a & Qt::AlignVertical_Mask) { case Qt::AlignTop: - v = QStringLiteral("Qt::AlignTop"); + v = "Qt::AlignTop"_L1; break; case Qt::AlignBottom: - v = QStringLiteral("Qt::AlignBottom"); + v = "Qt::AlignBottom"_L1; break; case Qt::AlignVCenter: - v = QStringLiteral("Qt::AlignVCenter"); + v = "Qt::AlignVCenter"_L1; break; } - if (h.isEmpty() && v.isEmpty()) - return QString(); - if (!v.isEmpty()) { - if (!h.isEmpty()) - h += QLatin1Char('|'); - h += v; - } - return h; + + return h + (v.isEmpty() || h.isEmpty() ? ""_L1 : "|"_L1) + v; } static inline Qt::Alignment alignmentFromDom(const QString &in) @@ -751,19 +748,19 @@ static inline Qt::Alignment alignmentFromDom(const QString &in) if (!in.isEmpty()) { const auto flags = QStringView{in}.split(QLatin1Char('|')); for (const auto &f : flags) { - if (f == QStringLiteral("Qt::AlignLeft")) { + if (f == "Qt::AlignLeft"_L1) { rc |= Qt::AlignLeft; - } else if (f == QStringLiteral("Qt::AlignRight")) { + } else if (f == "Qt::AlignRight"_L1) { rc |= Qt::AlignRight; - } else if (f == QStringLiteral("Qt::AlignHCenter")) { + } else if (f == "Qt::AlignHCenter"_L1) { rc |= Qt::AlignHCenter; - } else if (f == QStringLiteral("Qt::AlignJustify")) { + } else if (f == "Qt::AlignJustify"_L1) { rc |= Qt::AlignJustify; - } else if (f == QStringLiteral("Qt::AlignTop")) { + } else if (f == "Qt::AlignTop"_L1) { rc |= Qt::AlignTop; - } else if (f == QStringLiteral("Qt::AlignBottom")) { + } else if (f == "Qt::AlignBottom"_L1) { rc |= Qt::AlignBottom; - } else if (f == QStringLiteral("Qt::AlignVCenter")) { + } else if (f == "Qt::AlignVCenter"_L1) { rc |= Qt::AlignVCenter; } } @@ -1008,7 +1005,7 @@ void QAbstractFormBuilder::save(QIODevice *dev, QWidget *widget) Q_ASSERT( ui_widget != nullptr ); DomUI *ui = new DomUI(); - ui->setAttributeVersion(QStringLiteral("4.0")); + ui->setAttributeVersion(u"4.0"_s); ui->setElementWidget(ui_widget); saveDom(ui, widget); @@ -1689,10 +1686,10 @@ void QAbstractFormBuilder::saveTreeWidgetExtraInfo(QTreeWidget *treeWidget, DomW for (const QFormBuilderStrings::TextRoleNName &it : strings.itemTextRoles) { p = saveText(it.second, treeWidget->headerItem()->data(c, it.first.second)); // Prevent uic 4.4.X from crashing if it cannot find a column text - if (!p && it.first.first == Qt::EditRole && it.second == QStringLiteral("text")) { + if (!p && it.first.first == Qt::EditRole && it.second == "text"_L1) { DomString *defaultHeader = new DomString; defaultHeader->setText(QString::number(c + 1)); - defaultHeader->setAttributeNotr(QStringLiteral("true")); + defaultHeader->setAttributeNotr(u"true"_s); p = new DomProperty; p->setAttributeName(it.second); p->setElementString(defaultHeader); @@ -1878,7 +1875,7 @@ void QAbstractFormBuilder::saveButtonExtraInfo(const QAbstractButton *widget, Do DomPropertyList attributes = ui_widget->elementAttribute(); DomString *domString = new DomString(); domString->setText(buttonGroup->objectName()); - domString->setAttributeNotr(QStringLiteral("true")); + domString->setAttributeNotr(u"true"_s); DomProperty *domProperty = new DomProperty(); domProperty->setAttributeName(QLatin1String(buttonGroupPropertyC)); domProperty->setElementString(domString); @@ -1887,6 +1884,11 @@ void QAbstractFormBuilder::saveButtonExtraInfo(const QAbstractButton *widget, Do } } +static const QLatin1StringView tableHeaderPrefixes[] = { + "horizontalHeader"_L1, + "verticalHeader"_L1, +}; + /*! \internal \since 4.5 @@ -1913,7 +1915,7 @@ void QAbstractFormBuilder::saveItemViewExtraInfo(const QAbstractItemView *itemVi for (QString realPropertyName : realPropertyNames) { const QString upperPropertyName = realPropertyName.at(0).toUpper() + realPropertyName.mid(1); - const QString fakePropertyName = QStringLiteral("header") + upperPropertyName; + const QString fakePropertyName = "header"_L1 + upperPropertyName; for (DomProperty *property : headerProperties) { if (property->attributeName() == realPropertyName) { property->setAttributeName(fakePropertyName); @@ -1923,13 +1925,9 @@ void QAbstractFormBuilder::saveItemViewExtraInfo(const QAbstractItemView *itemVi } ui_widget->setElementAttribute(viewProperties); } else if (const QTableView *tableView = qobject_cast<const QTableView*>(itemView)) { - static const QStringList headerPrefixes = - (QStringList() << QStringLiteral("horizontalHeader") - << QStringLiteral("verticalHeader")); - auto viewProperties = ui_widget->elementAttribute(); - for (const QString &headerPrefix : headerPrefixes) { - const auto &headerProperties = headerPrefix == QStringLiteral("horizontalHeader") + for (QLatin1StringView headerPrefix : tableHeaderPrefixes) { + const auto &headerProperties = headerPrefix == "horizontalHeader"_L1 ? computeProperties(tableView->horizontalHeader()) : computeProperties(tableView->verticalHeader()); for (QString realPropertyName : realPropertyNames) { @@ -2291,7 +2289,7 @@ void QAbstractFormBuilder::loadItemViewExtraInfo(DomWidget *ui_widget, QAbstract for (QString realPropertyName : realPropertyNames) { const QString upperPropertyName = realPropertyName.at(0).toUpper() + realPropertyName.mid(1); - const QString fakePropertyName = QStringLiteral("header") + upperPropertyName; + const QString fakePropertyName = "header"_L1 + upperPropertyName; for (DomProperty *attr : allAttributes) { if (attr->attributeName() == fakePropertyName) { attr->setAttributeName(realPropertyName); @@ -2301,12 +2299,8 @@ void QAbstractFormBuilder::loadItemViewExtraInfo(DomWidget *ui_widget, QAbstract } applyProperties(treeView->header(), headerProperties); } else if (QTableView *tableView = qobject_cast<QTableView*>(itemView)) { - static const QStringList headerPrefixes = - (QStringList() << QStringLiteral("horizontalHeader") - << QStringLiteral("verticalHeader")); - const auto &allAttributes = ui_widget->elementAttribute(); - for (const QString &headerPrefix : headerPrefixes) { + for (QLatin1StringView headerPrefix : tableHeaderPrefixes) { QList<DomProperty*> headerProperties; for (QString realPropertyName : realPropertyNames) { const QString upperPropertyName = realPropertyName.at(0).toUpper() @@ -2319,7 +2313,7 @@ void QAbstractFormBuilder::loadItemViewExtraInfo(DomWidget *ui_widget, QAbstract } } } - if (headerPrefix == QStringLiteral("horizontalHeader")) + if (headerPrefix == "horizontalHeader"_L1) applyProperties(tableView->horizontalHeader(), headerProperties); else applyProperties(tableView->verticalHeader(), headerProperties); diff --git a/src/designer/src/lib/uilib/formbuilderextra.cpp b/src/designer/src/lib/uilib/formbuilderextra.cpp index 260bf08d1..99888ef63 100644 --- a/src/designer/src/lib/uilib/formbuilderextra.cpp +++ b/src/designer/src/lib/uilib/formbuilderextra.cpp @@ -23,6 +23,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #ifdef QFORMINTERNAL_NAMESPACE namespace QFormInternal { #endif @@ -44,7 +46,7 @@ QFormBuilderExtra::CustomWidgetData::CustomWidgetData(const DomCustomWidget *dcw QFormBuilderExtra::QFormBuilderExtra() : m_defaultMargin(INT_MIN), m_defaultSpacing(INT_MIN), - m_language(QStringLiteral("c++")) + m_language(u"c++"_s) { } @@ -76,7 +78,6 @@ static inline QString msgXmlError(const QXmlStreamReader &reader) static bool inline readUiAttributes(QXmlStreamReader &reader, const QString &language, QString *errorMessage) { - const QString uiElement = QStringLiteral("ui"); // Read up to first element while (!reader.atEnd()) { switch (reader.readNext()) { @@ -84,9 +85,9 @@ static bool inline readUiAttributes(QXmlStreamReader &reader, const QString &lan *errorMessage = msgXmlError(reader); return false; case QXmlStreamReader::StartElement: - if (reader.name().compare(uiElement, Qt::CaseInsensitive) == 0) { - const QString versionAttribute = QStringLiteral("version"); - const QString languageAttribute = QStringLiteral("language"); + if (reader.name().compare("ui"_L1, Qt::CaseInsensitive) == 0) { + const QString versionAttribute = u"version"_s; + const QString languageAttribute = u"language"_s; const QXmlStreamAttributes attributes = reader.attributes(); if (attributes.hasAttribute(versionAttribute)) { const QVersionNumber version = @@ -694,47 +695,47 @@ DomBrush *QFormBuilderExtra::saveBrush(const QBrush &br) // ------------ QFormBuilderStrings QFormBuilderStrings::QFormBuilderStrings() : - buddyProperty(QStringLiteral("buddy")), - cursorProperty(QStringLiteral("cursor")), - objectNameProperty(QStringLiteral("objectName")), - trueValue(QStringLiteral("true")), - falseValue(QStringLiteral("false")), - horizontalPostFix(QStringLiteral("Horizontal")), - separator(QStringLiteral("separator")), - defaultTitle(QStringLiteral("Page")), - titleAttribute(QStringLiteral("title")), - labelAttribute(QStringLiteral("label")), - toolTipAttribute(QStringLiteral("toolTip")), - whatsThisAttribute(QStringLiteral("whatsThis")), - flagsAttribute(QStringLiteral("flags")), - iconAttribute(QStringLiteral("icon")), - pixmapAttribute(QStringLiteral("pixmap")), - textAttribute(QStringLiteral("text")), - currentIndexProperty(QStringLiteral("currentIndex")), - toolBarAreaAttribute(QStringLiteral("toolBarArea")), - toolBarBreakAttribute(QStringLiteral("toolBarBreak")), - dockWidgetAreaAttribute(QStringLiteral("dockWidgetArea")), - marginProperty(QStringLiteral("margin")), - spacingProperty(QStringLiteral("spacing")), - leftMarginProperty(QStringLiteral("leftMargin")), - topMarginProperty(QStringLiteral("topMargin")), - rightMarginProperty(QStringLiteral("rightMargin")), - bottomMarginProperty(QStringLiteral("bottomMargin")), - horizontalSpacingProperty(QStringLiteral("horizontalSpacing")), - verticalSpacingProperty(QStringLiteral("verticalSpacing")), - sizeHintProperty(QStringLiteral("sizeHint")), - sizeTypeProperty(QStringLiteral("sizeType")), - orientationProperty(QStringLiteral("orientation")), - styleSheetProperty(QStringLiteral("styleSheet")), - qtHorizontal(QStringLiteral("Qt::Horizontal")), - qtVertical(QStringLiteral("Qt::Vertical")), - currentRowProperty(QStringLiteral("currentRow")), - tabSpacingProperty(QStringLiteral("tabSpacing")), - qWidgetClass(QStringLiteral("QWidget")), - lineClass(QStringLiteral("Line")), - geometryProperty(QStringLiteral("geometry")), - scriptWidgetVariable(QStringLiteral("widget")), - scriptChildWidgetsVariable(QStringLiteral("childWidgets")) + buddyProperty(u"buddy"_s), + cursorProperty(u"cursor"_s), + objectNameProperty(u"objectName"_s), + trueValue(u"true"_s), + falseValue(u"false"_s), + horizontalPostFix(u"Horizontal"_s), + separator(u"separator"_s), + defaultTitle(u"Page"_s), + titleAttribute(u"title"_s), + labelAttribute(u"label"_s), + toolTipAttribute(u"toolTip"_s), + whatsThisAttribute(u"whatsThis"_s), + flagsAttribute(u"flags"_s), + iconAttribute(u"icon"_s), + pixmapAttribute(u"pixmap"_s), + textAttribute(u"text"_s), + currentIndexProperty(u"currentIndex"_s), + toolBarAreaAttribute(u"toolBarArea"_s), + toolBarBreakAttribute(u"toolBarBreak"_s), + dockWidgetAreaAttribute(u"dockWidgetArea"_s), + marginProperty(u"margin"_s), + spacingProperty(u"spacing"_s), + leftMarginProperty(u"leftMargin"_s), + topMarginProperty(u"topMargin"_s), + rightMarginProperty(u"rightMargin"_s), + bottomMarginProperty(u"bottomMargin"_s), + horizontalSpacingProperty(u"horizontalSpacing"_s), + verticalSpacingProperty(u"verticalSpacing"_s), + sizeHintProperty(u"sizeHint"_s), + sizeTypeProperty(u"sizeType"_s), + orientationProperty(u"orientation"_s), + styleSheetProperty(u"styleSheet"_s), + qtHorizontal(u"Qt::Horizontal"_s), + qtVertical(u"Qt::Vertical"_s), + currentRowProperty(u"currentRow"_s), + tabSpacingProperty(u"tabSpacing"_s), + qWidgetClass(u"QWidget"_s), + lineClass(u"Line"_s), + geometryProperty(u"geometry"_s), + scriptWidgetVariable(u"widget"_s), + scriptChildWidgetsVariable(u"childWidgets"_s) { itemRoles.append(qMakePair(Qt::FontRole, QString::fromLatin1("font"))); itemRoles.append(qMakePair(Qt::TextAlignmentRole, QString::fromLatin1("textAlignment"))); diff --git a/src/designer/src/lib/uilib/properties.cpp b/src/designer/src/lib/uilib/properties.cpp index 8e31bef7c..1ce57df0c 100644 --- a/src/designer/src/lib/uilib/properties.cpp +++ b/src/designer/src/lib/uilib/properties.cpp @@ -19,6 +19,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #ifdef QFORMINTERNAL_NAMESPACE namespace QFormInternal { @@ -294,7 +296,7 @@ static bool applySimpleProperty(const QVariant &v, bool translateString, DomProp DomString *str = new DomString(); str->setText(v.toString()); if (!translateString) - str->setAttributeNotr(QStringLiteral("true")); + str->setAttributeNotr(u"true"_s); dom_prop->setElementString(str); } return true; diff --git a/src/designer/src/plugins/activeqt/qaxwidgetplugin.cpp b/src/designer/src/plugins/activeqt/qaxwidgetplugin.cpp index 67b28b899..7d563bb45 100644 --- a/src/designer/src/plugins/activeqt/qaxwidgetplugin.cpp +++ b/src/designer/src/plugins/activeqt/qaxwidgetplugin.cpp @@ -16,6 +16,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QAxWidgetPlugin::QAxWidgetPlugin(QObject *parent) : QObject(parent) { @@ -23,12 +25,12 @@ QAxWidgetPlugin::QAxWidgetPlugin(QObject *parent) : QString QAxWidgetPlugin::name() const { - return QStringLiteral("QAxWidget"); + return u"QAxWidget"_s; } QString QAxWidgetPlugin::group() const { - return QStringLiteral("Containers"); + return u"Containers"_s; } QString QAxWidgetPlugin::toolTip() const @@ -43,7 +45,7 @@ QString QAxWidgetPlugin::whatsThis() const QString QAxWidgetPlugin::includeFile() const { - return QStringLiteral("qaxwidget.h"); + return u"qaxwidget.h"_s; } QIcon QAxWidgetPlugin::icon() const diff --git a/src/designer/src/plugins/activeqt/qaxwidgetpropertysheet.cpp b/src/designer/src/plugins/activeqt/qaxwidgetpropertysheet.cpp index 20bafea1e..53cbd69c4 100644 --- a/src/designer/src/plugins/activeqt/qaxwidgetpropertysheet.cpp +++ b/src/designer/src/plugins/activeqt/qaxwidgetpropertysheet.cpp @@ -18,6 +18,8 @@ static const char *geometryPropertyC = "geometry"; QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + const char *QAxWidgetPropertySheet::controlPropertyName = "control"; static QString designerPropertyToString(const QVariant &value) @@ -30,7 +32,7 @@ static QString designerPropertyToString(const QVariant &value) QAxWidgetPropertySheet::QAxWidgetPropertySheet(QDesignerAxWidget *object, QObject *parent) : QDesignerPropertySheet(object, parent), m_controlProperty(controlPropertyName), - m_propertyGroup(QStringLiteral("QAxWidget")) + m_propertyGroup(u"QAxWidget"_s) { if (!axWidget()->loaded()) { // For some obscure reason.... const int controlIndex = QDesignerPropertySheet::indexOf(m_controlProperty); diff --git a/src/designer/src/plugins/qquickwidget/qquickwidget_plugin.cpp b/src/designer/src/plugins/qquickwidget/qquickwidget_plugin.cpp index 56664c354..e82614b7a 100644 --- a/src/designer/src/plugins/qquickwidget/qquickwidget_plugin.cpp +++ b/src/designer/src/plugins/qquickwidget/qquickwidget_plugin.cpp @@ -15,6 +15,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QQuickWidgetPlugin::QQuickWidgetPlugin(QObject *parent) : QObject(parent) { @@ -22,17 +24,17 @@ QQuickWidgetPlugin::QQuickWidgetPlugin(QObject *parent) QString QQuickWidgetPlugin::name() const { - return QStringLiteral("QQuickWidget"); + return u"QQuickWidget"_s; } QString QQuickWidgetPlugin::group() const { - return QStringLiteral("Display Widgets"); + return u"Display Widgets"_s; } QString QQuickWidgetPlugin::toolTip() const { - return QStringLiteral("A widget for displaying a Qt Quick 2 user interface."); + return u"A widget for displaying a Qt Quick 2 user interface."_s; } QString QQuickWidgetPlugin::whatsThis() const @@ -42,12 +44,12 @@ QString QQuickWidgetPlugin::whatsThis() const QString QQuickWidgetPlugin::includeFile() const { - return QStringLiteral("<QtQuickWidgets/QQuickWidget>"); + return u"<QtQuickWidgets/QQuickWidget>"_s; } QIcon QQuickWidgetPlugin::icon() const { - return QIcon(QStringLiteral(":/qt-project.org/qquickwidget/images/qquickwidget.png")); + return QIcon(u":/qt-project.org/qquickwidget/images/qquickwidget.png"_s); } bool QQuickWidgetPlugin::isContainer() const diff --git a/src/designer/src/plugins/qwebview/qwebview_plugin.cpp b/src/designer/src/plugins/qwebview/qwebview_plugin.cpp index 6588605b9..e5208b67f 100644 --- a/src/designer/src/plugins/qwebview/qwebview_plugin.cpp +++ b/src/designer/src/plugins/qwebview/qwebview_plugin.cpp @@ -10,6 +10,8 @@ static const char *toolTipC = "A widget for displaying a web page, from the Qt W QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + QWebViewPlugin::QWebViewPlugin(QObject *parent) : QObject(parent), m_initialized(false) @@ -18,12 +20,12 @@ QWebViewPlugin::QWebViewPlugin(QObject *parent) : QString QWebViewPlugin::name() const { - return QStringLiteral("QWebView"); + return u"QWebView"_s; } QString QWebViewPlugin::group() const { - return QStringLiteral("Display Widgets"); + return u"Display Widgets"_s; } QString QWebViewPlugin::toolTip() const @@ -38,12 +40,12 @@ QString QWebViewPlugin::whatsThis() const QString QWebViewPlugin::includeFile() const { - return QStringLiteral("<QtWebKitWidgets/QWebView>"); + return u"<QtWebKitWidgets/QWebView>"_s; } QIcon QWebViewPlugin::icon() const { - return QIcon(QStringLiteral(":/qt-project.org/qwebview/images/qwebview.png")); + return QIcon(u":/qt-project.org/qwebview/images/qwebview.png"_s); } bool QWebViewPlugin::isContainer() const |