summaryrefslogtreecommitdiffstats
path: root/src/designer/src/designer/qdesigner_actions.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-04-04 09:37:07 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-04-07 14:59:21 +0200
commit1c7cca268a06b5a3c34765e1e0e4dd1b020f3302 (patch)
tree4229ee67d541429a93a1d1412b4e25679761ed94 /src/designer/src/designer/qdesigner_actions.cpp
parent483f257e887a590d3462d0fc60b7eebfa50a3d19 (diff)
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>
Diffstat (limited to 'src/designer/src/designer/qdesigner_actions.cpp')
-rw-r--r--src/designer/src/designer/qdesigner_actions.cpp118
1 files changed, 63 insertions, 55 deletions
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();
}