summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-03-21 15:35:44 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-04-21 17:18:09 +0200
commit00ff2b06a17e90921d79831a62e95eecf8c6954a (patch)
tree40877b8e595eda601252c995f57d1dd3166c8cd3
parent6b7f6990aa1abed20c260a2eb2869f39ce59f8f7 (diff)
downloadqttools-00ff2b06a17e90921d79831a62e95eecf8c6954a.tar.gz
Qt Designer: Replace QLatin1Char by modern literals
Pick-to: 6.5 Change-Id: Ied11784e840d03542a5db281590729838ed625c3 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
-rw-r--r--src/designer/src/components/formeditor/deviceprofiledialog.cpp8
-rw-r--r--src/designer/src/components/formeditor/formwindow.cpp6
-rw-r--r--src/designer/src/components/formeditor/formwindowsettings.cpp4
-rw-r--r--src/designer/src/components/formeditor/qdesigner_resource.cpp17
-rw-r--r--src/designer/src/components/lib/qdesigner_components.cpp5
-rw-r--r--src/designer/src/components/propertyeditor/designerpropertymanager.cpp7
-rw-r--r--src/designer/src/components/propertyeditor/propertyeditor.cpp10
-rw-r--r--src/designer/src/components/propertyeditor/qlonglongvalidator.cpp8
-rw-r--r--src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp2
-rw-r--r--src/designer/src/components/taskmenu/itemlisteditor.cpp6
-rw-r--r--src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp6
-rw-r--r--src/designer/src/components/widgetbox/widgetboxtreewidget.cpp9
-rw-r--r--src/designer/src/designer/appfontdialog.cpp4
-rw-r--r--src/designer/src/designer/assistantclient.cpp2
-rw-r--r--src/designer/src/designer/qdesigner.cpp2
-rw-r--r--src/designer/src/designer/qdesigner_actions.cpp14
-rw-r--r--src/designer/src/designer/qdesigner_formwindow.cpp3
-rw-r--r--src/designer/src/designer/qdesigner_server.cpp10
-rw-r--r--src/designer/src/designer/qdesigner_workbench.cpp4
-rw-r--r--src/designer/src/designer/saveformastemplate.cpp4
-rw-r--r--src/designer/src/lib/shared/actioneditor.cpp7
-rw-r--r--src/designer/src/lib/shared/actionrepository.cpp8
-rw-r--r--src/designer/src/lib/shared/csshighlighter.cpp6
-rw-r--r--src/designer/src/lib/shared/formlayoutmenu.cpp2
-rw-r--r--src/designer/src/lib/shared/htmlhighlighter.cpp25
-rw-r--r--src/designer/src/lib/shared/iconselector.cpp4
-rw-r--r--src/designer/src/lib/shared/morphmenu.cpp4
-rw-r--r--src/designer/src/lib/shared/newformwidget.cpp12
-rw-r--r--src/designer/src/lib/shared/previewmanager.cpp5
-rw-r--r--src/designer/src/lib/shared/qdesigner_formbuilder.cpp8
-rw-r--r--src/designer/src/lib/shared/qdesigner_membersheet.cpp10
-rw-r--r--src/designer/src/lib/shared/qdesigner_promotion.cpp2
-rw-r--r--src/designer/src/lib/shared/qdesigner_promotiondialog.cpp5
-rw-r--r--src/designer/src/lib/shared/qdesigner_utils.cpp9
-rw-r--r--src/designer/src/lib/shared/qtresourceeditordialog.cpp14
-rw-r--r--src/designer/src/lib/shared/qtresourceview.cpp4
-rw-r--r--src/designer/src/lib/shared/richtexteditor.cpp2
-rw-r--r--src/designer/src/lib/shared/signalslotdialog.cpp7
-rw-r--r--src/designer/src/lib/shared/stylesheeteditor.cpp18
-rw-r--r--src/designer/src/lib/shared/textpropertyeditor.cpp16
-rw-r--r--src/designer/src/lib/shared/widgetdatabase.cpp13
-rw-r--r--src/designer/src/lib/uilib/abstractformbuilder.cpp3
-rw-r--r--src/designer/src/lib/uilib/formbuilder.cpp8
-rw-r--r--src/designer/src/lib/uilib/formbuilderextra.cpp4
-rw-r--r--src/designer/src/lib/uilib/properties.cpp4
-rw-r--r--src/designer/src/plugins/activeqt/qaxwidgettaskmenu.cpp8
46 files changed, 151 insertions, 188 deletions
diff --git a/src/designer/src/components/formeditor/deviceprofiledialog.cpp b/src/designer/src/components/formeditor/deviceprofiledialog.cpp
index 8e77b9ba3..3af31d47f 100644
--- a/src/designer/src/components/formeditor/deviceprofiledialog.cpp
+++ b/src/designer/src/components/formeditor/deviceprofiledialog.cpp
@@ -19,6 +19,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static const char *profileExtensionC = "qdp";
static inline QString fileFilter()
@@ -130,10 +132,8 @@ void DeviceProfileDialog::save()
QString fn = m_dlgGui->getSaveFileName(this, tr("Save Profile"), QString(), fileFilter());
if (fn.isEmpty())
return;
- if (QFileInfo(fn).completeSuffix().isEmpty()) {
- fn += QLatin1Char('.');
- fn += QLatin1String(profileExtensionC);
- }
+ if (QFileInfo(fn).completeSuffix().isEmpty())
+ fn += u'.' + QLatin1StringView(profileExtensionC);
QFile file(fn);
if (!file.open(QIODevice::WriteOnly|QIODevice::Text)) {
diff --git a/src/designer/src/components/formeditor/formwindow.cpp b/src/designer/src/components/formeditor/formwindow.cpp
index efad969c8..74e80cfa6 100644
--- a/src/designer/src/components/formeditor/formwindow.cpp
+++ b/src/designer/src/components/formeditor/formwindow.cpp
@@ -1126,13 +1126,13 @@ bool FormWindow::unify(QObject *w, QString &s, bool changeIt)
qlonglong num = 0;
qlonglong factor = 1;
qsizetype idx = s.size() - 1;
- const ushort zeroUnicode = QLatin1Char('0').unicode();
+ const char16_t zeroUnicode = u'0';
for ( ; idx > 0 && s.at(idx).isDigit(); --idx) {
num += (s.at(idx).unicode() - zeroUnicode) * factor;
factor *= 10;
}
// Position index past '_'.
- const QChar underscore = QLatin1Char('_');
+ const QChar underscore = u'_';
if (idx >= 0 && s.at(idx) == underscore) {
idx++;
} else {
@@ -1699,7 +1699,7 @@ static inline DomUI *domUIFromClipboard(int *widgetCount, int *actionCount)
{
*widgetCount = *actionCount = 0;
const QString clipboardText = qApp->clipboard()->text();
- if (clipboardText.isEmpty() || clipboardText.indexOf(QLatin1Char('<')) == -1)
+ if (clipboardText.isEmpty() || clipboardText.indexOf(u'<') == -1)
return nullptr;
QXmlStreamReader reader(clipboardText);
diff --git a/src/designer/src/components/formeditor/formwindowsettings.cpp b/src/designer/src/components/formeditor/formwindowsettings.cpp
index e1206cca6..3b64c2f8a 100644
--- a/src/designer/src/components/formeditor/formwindowsettings.cpp
+++ b/src/designer/src/components/formeditor/formwindowsettings.cpp
@@ -189,7 +189,7 @@ FormWindowData FormWindowSettings::data() const
const QString hints = m_ui->includeHintsTextEdit->toPlainText();
if (!hints.isEmpty()) {
- rc.includeHints = hints.split(QLatin1Char('\n'));
+ rc.includeHints = hints.split(u'\n');
// Purge out any lines consisting of blanks only
const QRegularExpression blankLine(u"^\\s*$"_s);
Q_ASSERT(blankLine.isValid());
@@ -223,7 +223,7 @@ void FormWindowSettings::setData(const FormWindowData &data)
if (data.includeHints.isEmpty()) {
m_ui->includeHintsTextEdit->clear();
} else {
- m_ui->includeHintsTextEdit->setText(data.includeHints.join(QLatin1Char('\n')));
+ m_ui->includeHintsTextEdit->setText(data.includeHints.join(u'\n'));
}
m_ui->gridPanel->setChecked(data.hasFormGrid);
diff --git a/src/designer/src/components/formeditor/qdesigner_resource.cpp b/src/designer/src/components/formeditor/qdesigner_resource.cpp
index 719d55ddc..64b227d0c 100644
--- a/src/designer/src/components/formeditor/qdesigner_resource.cpp
+++ b/src/designer/src/components/formeditor/qdesigner_resource.cpp
@@ -518,10 +518,10 @@ void QDesignerResource::saveDom(DomUI *ui, QWidget *widget)
if (includeHint.isEmpty())
continue;
DomInclude *incl = new DomInclude;
- const QString location = includeHint.at(0) == QLatin1Char('<') ? global : local;
- includeHint.remove(QLatin1Char('"'));
- includeHint.remove(QLatin1Char('<'));
- includeHint.remove(QLatin1Char('>'));
+ const QString location = includeHint.at(0) == u'<' ? global : local;
+ includeHint.remove(u'"');
+ includeHint.remove(u'<');
+ includeHint.remove(u'>');
incl->setAttributeLocation(location);
incl->setText(includeHint);
ui_includes.append(incl);
@@ -671,9 +671,11 @@ QWidget *QDesignerResource::create(DomUI *ui, QWidget *parentWidget)
continue;
if (incl->hasAttributeLocation() && incl->attributeLocation() == global ) {
- text = text.prepend(QLatin1Char('<')).append(QLatin1Char('>'));
+ text.prepend(u'<');
+ text.append(u'>');
} else {
- text = text.prepend(QLatin1Char('"')).append(QLatin1Char('"'));
+ text.prepend(u'"');
+ text.append(u'"');
}
includeHints.append(text);
@@ -2112,7 +2114,8 @@ DomResources *QDesignerResource::saveResources(const QStringList &qrcPaths)
QString conv_path = path;
if (m_resourceBuilder->isSaveRelative())
conv_path = m_formWindow->absoluteDir().relativeFilePath(path);
- dom_res->setAttributeLocation(conv_path.replace(QDir::separator(), QLatin1Char('/')));
+ conv_path.replace(QDir::separator(), u'/');
+ dom_res->setAttributeLocation(conv_path);
dom_include.append(dom_res);
}
}
diff --git a/src/designer/src/components/lib/qdesigner_components.cpp b/src/designer/src/components/lib/qdesigner_components.cpp
index 7409ef53b..bf50cbc0d 100644
--- a/src/designer/src/components/lib/qdesigner_components.cpp
+++ b/src/designer/src/components/lib/qdesigner_components.cpp
@@ -123,7 +123,6 @@ static inline void setMinorVersion(int minorVersion, int *qtVersion)
static inline QString widgetBoxFileName(int qtVersion, const QDesignerLanguageExtension *lang = nullptr)
{
QString rc; {
- const QChar dot = QLatin1Char('.');
QTextStream str(&rc);
str << QDir::homePath() << QDir::separator() << ".designer" << QDir::separator()
<< "widgetbox";
@@ -131,9 +130,9 @@ static inline QString widgetBoxFileName(int qtVersion, const QDesignerLanguageEx
const int major = qtMajorVersion(qtVersion);
const int minor = qtMinorVersion(qtVersion);
if (major >= 4 && minor >= 4)
- str << major << dot << minor;
+ str << major << '.' << minor;
if (lang)
- str << dot << lang->uiExtension();
+ str << '.' << lang->uiExtension();
str << ".xml";
}
return rc;
diff --git a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp
index 57152f3d2..b7dba1e5d 100644
--- a/src/designer/src/components/propertyeditor/designerpropertymanager.cpp
+++ b/src/designer/src/components/propertyeditor/designerpropertymanager.cpp
@@ -438,7 +438,7 @@ void TextEditor::resourceActionActivated()
oldPath.remove(0, 4);
// returns ':/file'
QString newPath = IconSelector::choosePixmapResource(m_core, m_core->resourceModel(), oldPath, this);
- if (newPath.startsWith(QLatin1Char(':')))
+ if (newPath.startsWith(u':'))
newPath.remove(0, 1);
if (newPath.isEmpty() || newPath == oldPath)
return;
@@ -743,7 +743,7 @@ void PixmapEditor::pasteActionActivated()
QString subtype = u"plain"_s;
QString text = clipboard->text(subtype);
if (!text.isNull()) {
- QStringList list = text.split(QLatin1Char('\n'));
+ QStringList list = text.split(u'\n');
if (!list.isEmpty()) {
text = list.at(0);
if (m_iconThemeModeEnabled && QIcon::hasThemeIcon(text)) {
@@ -1513,14 +1513,13 @@ QString DesignerPropertyManager::valueText(const QtProperty *property) const
if (m_flagValues.contains(const_cast<QtProperty *>(property))) {
const FlagData data = m_flagValues.value(const_cast<QtProperty *>(property));
const uint v = data.val;
- const QChar bar = QLatin1Char('|');
QString valueStr;
for (const DesignerIntPair &p : data.flags) {
const uint val = p.second;
const bool checked = (val == 0) ? (v == 0) : ((val & v) == val);
if (checked) {
if (!valueStr.isEmpty())
- valueStr += bar;
+ valueStr += u'|';
valueStr += p.first;
}
}
diff --git a/src/designer/src/components/propertyeditor/propertyeditor.cpp b/src/designer/src/components/propertyeditor/propertyeditor.cpp
index c7bfd2861..294357196 100644
--- a/src/designer/src/components/propertyeditor/propertyeditor.cpp
+++ b/src/designer/src/components/propertyeditor/propertyeditor.cpp
@@ -407,16 +407,13 @@ bool PropertyEditor::isItemVisible(QtBrowserItem *item) const
void PropertyEditor::storePropertiesExpansionState(const QList<QtBrowserItem *> &items)
{
- const QChar bar = QLatin1Char('|');
for (QtBrowserItem *propertyItem : items) {
if (!propertyItem->children().isEmpty()) {
QtProperty *property = propertyItem->property();
const QString propertyName = property->propertyName();
const QMap<QtProperty *, QString>::const_iterator itGroup = m_propertyToGroup.constFind(property);
if (itGroup != m_propertyToGroup.constEnd()) {
- QString key = itGroup.value();
- key += bar;
- key += propertyName;
+ const QString key = itGroup.value() + u'|' + propertyName;
m_expansionState[key] = isExpanded(propertyItem);
}
}
@@ -450,16 +447,13 @@ void PropertyEditor::collapseAll()
void PropertyEditor::applyPropertiesExpansionState(const QList<QtBrowserItem *> &items)
{
- const QChar bar = QLatin1Char('|');
for (QtBrowserItem *propertyItem : items) {
const QMap<QString, bool>::const_iterator excend = m_expansionState.constEnd();
QtProperty *property = propertyItem->property();
const QString propertyName = property->propertyName();
const QMap<QtProperty *, QString>::const_iterator itGroup = m_propertyToGroup.constFind(property);
if (itGroup != m_propertyToGroup.constEnd()) {
- QString key = itGroup.value();
- key += bar;
- key += propertyName;
+ const QString key = itGroup.value() + u'|' + propertyName;
const QMap<QString, bool>::const_iterator pit = m_expansionState.constFind(key);
if (pit != excend)
setExpanded(propertyItem, pit.value());
diff --git a/src/designer/src/components/propertyeditor/qlonglongvalidator.cpp b/src/designer/src/components/propertyeditor/qlonglongvalidator.cpp
index 1a40530df..906ffdf80 100644
--- a/src/designer/src/components/propertyeditor/qlonglongvalidator.cpp
+++ b/src/designer/src/components/propertyeditor/qlonglongvalidator.cpp
@@ -5,6 +5,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
namespace qdesigner_internal {
// ----------------------------------------------------------------------------
@@ -24,9 +26,9 @@ QLongLongValidator::~QLongLongValidator() = default;
QValidator::State QLongLongValidator::validate(QString & input, int &) const
{
- if (input.contains(QLatin1Char(' ')))
+ if (input.contains(u' '))
return Invalid;
- if (input.isEmpty() || (b < 0 && input == QString(QLatin1Char('-'))))
+ if (input.isEmpty() || (b < 0 && input == "-"_L1))
return Intermediate;
bool ok;
qlonglong entered = input.toLongLong(&ok);
@@ -78,7 +80,7 @@ QValidator::State QULongLongValidator::validate(QString & input, int &) const
bool ok;
qulonglong entered = input.toULongLong(&ok);
- if (input.contains(QLatin1Char(' ')) || input.contains(QLatin1Char('-')) || !ok)
+ if (input.contains(u' ') || input.contains(u'-') || !ok)
return Invalid;
if (entered >= b && entered <= t)
diff --git a/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp b/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp
index 3570f7d96..38a96148d 100644
--- a/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp
+++ b/src/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp
@@ -404,7 +404,7 @@ void InlineEditorModel::addTitle(const QString &title)
const int cnt = rowCount();
insertRows(cnt, 1);
QModelIndex cat_idx = index(cnt, 0);
- setData(cat_idx, QString(title + QLatin1Char(':')), Qt::DisplayRole);
+ setData(cat_idx, QString(title + u':'), Qt::DisplayRole);
setData(cat_idx, TitleItem, Qt::UserRole);
QFont font = QApplication::font();
font.setBold(true);
diff --git a/src/designer/src/components/taskmenu/itemlisteditor.cpp b/src/designer/src/components/taskmenu/itemlisteditor.cpp
index 4fa4f1248..20dd0b919 100644
--- a/src/designer/src/components/taskmenu/itemlisteditor.cpp
+++ b/src/designer/src/components/taskmenu/itemlisteditor.cpp
@@ -401,9 +401,11 @@ void ItemListEditor::setItemData(int role, const QVariant &v)
{
QListWidgetItem *item = ui.listWidget->currentItem();
bool reLayout = false;
- if ((role == Qt::EditRole && (v.toString().count(QLatin1Char('\n')) != item->data(role).toString().count(QLatin1Char('\n'))))
- || role == Qt::FontRole)
+ if ((role == Qt::EditRole
+ && (v.toString().count(u'\n') != item->data(role).toString().count(u'\n')))
+ || role == Qt::FontRole) {
reLayout = true;
+ }
QVariant newValue = v;
if (role == Qt::FontRole && newValue.metaType().id() == QMetaType::QFont) {
QFont oldFont = ui.listWidget->font();
diff --git a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp
index 4fda87479..392e658eb 100644
--- a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp
+++ b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp
@@ -226,10 +226,8 @@ QVariant WidgetBoxCategoryModel::data(const QModelIndex &index, int role) const
return QVariant(item.toolTip);
// Icon mode tooltip should contain the class name
QString tt = item.widget.name();
- if (!item.toolTip.isEmpty()) {
- tt += QLatin1Char('\n');
- tt += item.toolTip;
- }
+ if (!item.toolTip.isEmpty())
+ tt += u'\n' + item.toolTip;
return QVariant(tt);
}
diff --git a/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp b/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp
index d4d6da34f..6f319fd6b 100644
--- a/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp
+++ b/src/designer/src/components/widgetbox/widgetboxtreewidget.cpp
@@ -50,6 +50,8 @@ enum TopLevelRole { NORMAL_ITEM, SCRATCHPAD_ITEM, CUSTOM_ITEM };
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static void setTopLevelRole(TopLevelRole tlr, QTreeWidgetItem *item)
{
item->setData(0, Qt::UserRole, QVariant(tlr));
@@ -131,7 +133,7 @@ void WidgetBoxTreeWidget::restoreExpandedState()
{
using StringSet = QSet<QString>;
QDesignerSettingsInterface *settings = m_core->settingsManager();
- const QString groupKey = QLatin1String(widgetBoxSettingsGroupC) + QLatin1Char('/');
+ const QString groupKey = QLatin1StringView(widgetBoxSettingsGroupC) + u'/';
m_iconMode = settings->value(groupKey + QLatin1String(widgetBoxViewModeKeyC)).toBool();
updateViewMode();
const auto &closedCategoryList = settings->value(groupKey + QLatin1String(widgetBoxExpandedKeyC), QStringList()).toStringList();
@@ -497,9 +499,8 @@ bool WidgetBoxTreeWidget::readWidget(Widget *w, const QString &xml, QXmlStreamRe
}
// Oddity: Startposition is 1 off
QString widgetXml = xml.mid(startTagPosition, endTagPosition - startTagPosition);
- const QChar lessThan = QLatin1Char('<');
- if (!widgetXml.startsWith(lessThan))
- widgetXml.prepend(lessThan);
+ if (!widgetXml.startsWith(u'<'))
+ widgetXml.prepend(u'<');
w->setDomXml(widgetXml);
return true;
}
diff --git a/src/designer/src/designer/appfontdialog.cpp b/src/designer/src/designer/appfontdialog.cpp
index e14b40b33..10ebc8c92 100644
--- a/src/designer/src/designer/appfontdialog.cpp
+++ b/src/designer/src/designer/appfontdialog.cpp
@@ -92,9 +92,7 @@ void AppFontManager::save(QDesignerSettingsInterface *s, const QString &prefix)
void AppFontManager::restore(const QDesignerSettingsInterface *s, const QString &prefix)
{
- QString key = prefix;
- key += QLatin1Char('/');
- key += QLatin1String(fontFileKeyC);
+ const QString key = prefix + u'/' + QLatin1StringView(fontFileKeyC);
const QStringList fontFiles = s->value(key, QStringList()).toStringList();
if (debugAppFontWidget)
diff --git a/src/designer/src/designer/assistantclient.cpp b/src/designer/src/designer/assistantclient.cpp
index 0f01aa295..43934c13e 100644
--- a/src/designer/src/designer/assistantclient.cpp
+++ b/src/designer/src/designer/assistantclient.cpp
@@ -59,7 +59,7 @@ bool AssistantClient::sendCommand(const QString &cmd, QString *errorMessage)
return false;
}
QTextStream str(m_process);
- str << cmd << QLatin1Char('\n') << Qt::endl;
+ str << cmd << "\n\n";
return true;
}
diff --git a/src/designer/src/designer/qdesigner.cpp b/src/designer/src/designer/qdesigner.cpp
index cc20413c5..3181bd557 100644
--- a/src/designer/src/designer/qdesigner.cpp
+++ b/src/designer/src/designer/qdesigner.cpp
@@ -85,7 +85,7 @@ void QDesigner::showErrorMessage(const QString &message)
const QMessageLogContext emptyContext;
previousMessageHandler(QtWarningMsg, emptyContext, message); // just in case we crash
m_initializationErrors += qMessage;
- m_initializationErrors += QLatin1Char('\n');
+ m_initializationErrors += u'\n';
}
}
diff --git a/src/designer/src/designer/qdesigner_actions.cpp b/src/designer/src/designer/qdesigner_actions.cpp
index ba3791f3d..8e01988c1 100644
--- a/src/designer/src/designer/qdesigner_actions.cpp
+++ b/src/designer/src/designer/qdesigner_actions.cpp
@@ -778,11 +778,8 @@ bool QDesignerActions::readInForm(const QString &fileName)
if (!fInfo.exists()) {
// Normalize file name
const QString directory = fInfo.absolutePath();
- if (QDir(directory).exists()) {
- newFormFileName = directory;
- newFormFileName += QLatin1Char('/');
- newFormFileName += fInfo.fileName();
- }
+ if (QDir(directory).exists())
+ newFormFileName = directory + u'/' + fInfo.fileName();
}
showNewFormDialog(newFormFileName);
return false;
@@ -1245,11 +1242,8 @@ void QDesignerActions::savePreviewImage()
const QString filter = tr("Image files (*.%1)").arg(extension);
QString suggestion = fw->fileName();
- if (!suggestion.isEmpty()) {
- suggestion = QFileInfo(suggestion).baseName();
- suggestion += QLatin1Char('.');
- suggestion += extension;
- }
+ if (!suggestion.isEmpty())
+ suggestion = QFileInfo(suggestion).baseName() + u'.' + extension;
QFileDialog dialog(fw, tr("Save Image"), suggestion, filter);
dialog.setAcceptMode(QFileDialog::AcceptSave);
diff --git a/src/designer/src/designer/qdesigner_formwindow.cpp b/src/designer/src/designer/qdesigner_formwindow.cpp
index 7ef8b1f98..3c6dc2f12 100644
--- a/src/designer/src/designer/qdesigner_formwindow.cpp
+++ b/src/designer/src/designer/qdesigner_formwindow.cpp
@@ -174,8 +174,7 @@ void QDesignerFormWindow::updateWindowTitle(const QString &fileName)
if (fileName.isEmpty()) {
fileNameTitle += "untitled"_L1;
if (const int maxUntitled = getNumberOfUntitledWindows()) {
- fileNameTitle += QLatin1Char(' ');
- fileNameTitle += QString::number(maxUntitled + 1);
+ fileNameTitle += u' ' + QString::number(maxUntitled + 1);
}
} else {
fileNameTitle = QFileInfo(fileName).fileName();
diff --git a/src/designer/src/designer/qdesigner_server.cpp b/src/designer/src/designer/qdesigner_server.cpp
index 6b4a81a9a..f12a360d1 100644
--- a/src/designer/src/designer/qdesigner_server.cpp
+++ b/src/designer/src/designer/qdesigner_server.cpp
@@ -15,6 +15,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
// ### review
QDesignerServer::QDesignerServer(QObject *parent)
@@ -56,8 +58,8 @@ void QDesignerServer::readFromClient()
while (m_socket->canReadLine()) {
QString file = QString::fromUtf8(m_socket->readLine());
if (!file.isNull()) {
- file.remove(QLatin1Char('\n'));
- file.remove(QLatin1Char('\r'));
+ file.remove(u'\n');
+ file.remove(u'\r');
qDesigner->postEvent(qDesigner, new QFileOpenEvent(file));
}
}
@@ -102,8 +104,8 @@ void QDesignerClient::readFromSocket()
while (m_socket->canReadLine()) {
QString file = QString::fromUtf8(m_socket->readLine());
if (!file.isNull()) {
- file.remove(QLatin1Char('\n'));
- file.remove(QLatin1Char('\r'));
+ file.remove(u'\n');
+ file.remove(u'\r');
if (QFile::exists(file))
qDesigner->postEvent(qDesigner, new QFileOpenEvent(file));
}
diff --git a/src/designer/src/designer/qdesigner_workbench.cpp b/src/designer/src/designer/qdesigner_workbench.cpp
index 5ee5f7790..58c856047 100644
--- a/src/designer/src/designer/qdesigner_workbench.cpp
+++ b/src/designer/src/designer/qdesigner_workbench.cpp
@@ -885,8 +885,8 @@ QDesignerFormWindow * QDesignerWorkbench::loadForm(const QString &fileName,
const QString text = QString::fromUtf8(file.readLine());
file.close();
- const int lf = text.indexOf(QLatin1Char('\n'));
- if (lf > 0 && text.at(lf-1) == QLatin1Char('\r')) {
+ const auto lf = text.indexOf(u'\n');
+ if (lf > 0 && text.at(lf - 1) == u'\r') {
mode = qdesigner_internal::FormWindowBase::CRLFLineTerminator;
} else if (lf >= 0) {
mode = qdesigner_internal::FormWindowBase::LFLineTerminator;
diff --git a/src/designer/src/designer/saveformastemplate.cpp b/src/designer/src/designer/saveformastemplate.cpp
index a26b057e9..e8bc64477 100644
--- a/src/designer/src/designer/saveformastemplate.cpp
+++ b/src/designer/src/designer/saveformastemplate.cpp
@@ -44,10 +44,8 @@ SaveFormAsTemplate::~SaveFormAsTemplate() = default;
void SaveFormAsTemplate::accept()
{
- QString templateFileName = ui.categoryCombo->currentText();
- templateFileName += QLatin1Char('/');
const QString name = ui.templateNameEdit->text();
- templateFileName += name;
+ QString templateFileName = ui.categoryCombo->currentText() + u'/' + name;
const auto extension = ".ui"_L1;
if (!templateFileName.endsWith(extension))
templateFileName.append(extension);
diff --git a/src/designer/src/lib/shared/actioneditor.cpp b/src/designer/src/lib/shared/actioneditor.cpp
index 057616217..24f3fbd8d 100644
--- a/src/designer/src/lib/shared/actioneditor.cpp
+++ b/src/designer/src/lib/shared/actioneditor.cpp
@@ -672,14 +672,13 @@ void ActionEditor::slotDelete()
// UnderScore: "Open file" -> actionOpen_file
static QString underscore(QString text)
{
- const QString underscore = QString(QLatin1Char('_'));
static const QRegularExpression nonAsciiPattern(u"[^a-zA-Z_0-9]"_s);
Q_ASSERT(nonAsciiPattern.isValid());
- text.replace(nonAsciiPattern, underscore);
+ text.replace(nonAsciiPattern, "_"_L1);
static const QRegularExpression multipleSpacePattern(u"__*"_s);
Q_ASSERT(multipleSpacePattern.isValid());
- text.replace(multipleSpacePattern, underscore);
- if (text.endsWith(underscore.at(0)))
+ text.replace(multipleSpacePattern, "_"_L1);
+ if (text.endsWith(u'_'))
text.chop(1);
return text;
}
diff --git a/src/designer/src/lib/shared/actionrepository.cpp b/src/designer/src/lib/shared/actionrepository.cpp
index 8f49a6dc7..1fa1e0ebc 100644
--- a/src/designer/src/lib/shared/actionrepository.cpp
+++ b/src/designer/src/lib/shared/actionrepository.cpp
@@ -153,10 +153,8 @@ void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action,
// Tooltip, mostly for icon view mode
QString firstTooltip = action->objectName();
const QString text = action->text();
- if (!text.isEmpty()) {
- firstTooltip += QLatin1Char('\n');
- firstTooltip += text;
- }
+ if (!text.isEmpty())
+ firstTooltip += u'\n' + text;
Q_ASSERT(sl.size() == NumColumns);
@@ -201,7 +199,7 @@ void ActionModel::setItems(QDesignerFormEditorInterface *core, QAction *action,
QString toolTip = action->toolTip();
item = sl[ToolTipColumn];
item->setToolTip(toolTip);
- item->setText(toolTip.replace(QLatin1Char('\n'), QLatin1Char(' ')));
+ item->setText(toolTip.replace(u'\n', u' '));
// menuRole
const auto menuRole = action->menuRole();
item = sl[MenuRoleColumn];
diff --git a/src/designer/src/lib/shared/csshighlighter.cpp b/src/designer/src/lib/shared/csshighlighter.cpp
index c74ed8508..d34e7e4de 100644
--- a/src/designer/src/lib/shared/csshighlighter.cpp
+++ b/src/designer/src/lib/shared/csshighlighter.cpp
@@ -5,6 +5,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
namespace qdesigner_internal {
CssHighlighter::CssHighlighter(const CssHighlightColors &colors,
@@ -41,8 +43,8 @@ void CssHighlighter::highlightBlock(const QString& text)
// The initial state is based on the precense of a : and the absense of a {.
// This is because Qt style sheets support both a full stylesheet as well as
// an inline form with just properties.
- state = save_state = (text.indexOf(QLatin1Char(':')) > -1 &&
- text.indexOf(QLatin1Char('{')) == -1) ? Property : Selector;
+ state = save_state = (text.indexOf(u':') > -1 &&
+ text.indexOf(u'{') == -1) ? Property : Selector;
} else {
save_state = state>>16;
state &= 0x00ff;
diff --git a/src/designer/src/lib/shared/formlayoutmenu.cpp b/src/designer/src/lib/shared/formlayoutmenu.cpp
index ba0dc6baa..4058e78b7 100644
--- a/src/designer/src/lib/shared/formlayoutmenu.cpp
+++ b/src/designer/src/lib/shared/formlayoutmenu.cpp
@@ -220,7 +220,7 @@ static inline QString postFixFromClassName(QString className)
if (index != -1)
className.remove(0, index + 2);
if (className.size() > 2)
- if (className.at(0) == QLatin1Char('Q') || className.at(0) == QLatin1Char('K'))
+ if (className.at(0) == u'Q' || className.at(0) == u'K')
if (className.at(1).isUpper())
className.remove(0, 1);
return className;
diff --git a/src/designer/src/lib/shared/htmlhighlighter.cpp b/src/designer/src/lib/shared/htmlhighlighter.cpp
index dead3a100..59e2a5efa 100644
--- a/src/designer/src/lib/shared/htmlhighlighter.cpp
+++ b/src/designer/src/lib/shared/htmlhighlighter.cpp
@@ -48,15 +48,8 @@ void HtmlHighlighter::setFormatFor(Construct construct,
void HtmlHighlighter::highlightBlock(const QString &text)
{
- static const QLatin1Char tab = QLatin1Char('\t');
- static const QLatin1Char space = QLatin1Char(' ');
- static const QLatin1Char amp = QLatin1Char('&');
- static const QLatin1Char startTag = QLatin1Char('<');
- static const QLatin1Char endTag = QLatin1Char('>');
- static const QLatin1Char quot = QLatin1Char('"');
- static const QLatin1Char apos = QLatin1Char('\'');
- static const QLatin1Char semicolon = QLatin1Char(';');
- static const QLatin1Char equals = QLatin1Char('=');
+ static const QChar tab = u'\t';
+ static const QChar space = u' ';
int state = previousBlockState();
qsizetype len = text.size();
@@ -69,14 +62,14 @@ void HtmlHighlighter::highlightBlock(const QString &text)
default:
while (pos < len) {
QChar ch = text.at(pos);
- if (ch == startTag) {
+ if (ch == u'<') {
if (QStringView{text}.sliced(pos).startsWith("<!--"_L1)) {
state = InComment;
} else {
state = InTag;
start = pos;
while (pos < len && text.at(pos) != space
- && text.at(pos) != endTag
+ && text.at(pos) != u'>'
&& text.at(pos) != tab
&& !QStringView{text}.sliced(pos).startsWith("/>"_L1)) {
++pos;
@@ -89,9 +82,9 @@ void HtmlHighlighter::highlightBlock(const QString &text)
}
break;
}
- if (ch == amp) {
+ if (ch == u'&') {
start = pos;
- while (pos < len && text.at(pos++) != semicolon)
+ while (pos < len && text.at(pos++) != u';')
;
setFormat(start, pos - start,
m_formats[Entity]);
@@ -118,9 +111,9 @@ void HtmlHighlighter::highlightBlock(const QString &text)
QChar ch = text.at(pos);
if (quote.isNull()) {
start = pos;
- if (ch == apos || ch == quot) {
+ if (ch == '\''_L1 || ch == u'"') {
quote = ch;
- } else if (ch == endTag) {
+ } else if (ch == u'>') {
++pos;
setFormat(start, pos - start, m_formats[Tag]);
state = NormalState;
@@ -136,7 +129,7 @@ void HtmlHighlighter::highlightBlock(const QString &text)
++pos;
while (pos < len && text.at(pos) != space
&& text.at(pos) != tab
- && text.at(pos) != equals)
+ && text.at(pos) != u'=')
++pos;
setFormat(start, pos - start, m_formats[Attribute]);
start = pos;
diff --git a/src/designer/src/lib/shared/iconselector.cpp b/src/designer/src/lib/shared/iconselector.cpp
index 4ca634192..c6efbbbbd 100644
--- a/src/designer/src/lib/shared/iconselector.cpp
+++ b/src/designer/src/lib/shared/iconselector.cpp
@@ -321,7 +321,7 @@ static QString imageFilter()
const qsizetype count = supportedImageFormats.size();
for (qsizetype i = 0; i < count; ++i) {
if (i)
- filter += QLatin1Char(' ');
+ filter += u' ';
filter += "*."_L1;
const QString outputFormat = QString::fromUtf8(supportedImageFormats.at(i));
if (outputFormat != "JPEG"_L1)
@@ -329,7 +329,7 @@ static QString imageFilter()
else
filter += "jpg *.jpeg"_L1;
}
- filter += QLatin1Char(')');
+ filter += u')';
return filter;
}
diff --git a/src/designer/src/lib/shared/morphmenu.cpp b/src/designer/src/lib/shared/morphmenu.cpp
index 1ad8a4f3a..fb36d4680 100644
--- a/src/designer/src/lib/shared/morphmenu.cpp
+++ b/src/designer/src/lib/shared/morphmenu.cpp
@@ -188,9 +188,9 @@ static QString suggestObjectName(const QString &oldClassName, const QString &new
{
QString oldClassPart = oldClassName;
QString newClassPart = newClassName;
- if (oldClassPart.startsWith(QLatin1Char('Q')))
+ if (oldClassPart.startsWith(u'Q'))
oldClassPart.remove(0, 1);
- if (newClassPart.startsWith(QLatin1Char('Q')))
+ if (newClassPart.startsWith(u'Q'))
newClassPart.remove(0, 1);
QString newName = oldName;
diff --git a/src/designer/src/lib/shared/newformwidget.cpp b/src/designer/src/lib/shared/newformwidget.cpp
index 8ee2c4955..1ed86700a 100644
--- a/src/designer/src/lib/shared/newformwidget.cpp
+++ b/src/designer/src/lib/shared/newformwidget.cpp
@@ -50,7 +50,7 @@ static const char *newFormObjectNameC = "Form";
// else return "Form".
static QString formName(const QString &className)
{
- if (!className.startsWith(QLatin1Char('Q')))
+ if (!className.startsWith(u'Q'))
return QLatin1String(newFormObjectNameC);
QString rc = className;
rc.remove(0, 1);
@@ -386,7 +386,7 @@ void NewFormWidget::loadFrom(const QString &path, bool resourceFile, const QStri
if (list.isEmpty())
return;
- const QChar separator = resourceFile ? QChar(QLatin1Char('/'))
+ const QChar separator = resourceFile ? QChar(u'/')
: QDir::separator();
QTreeWidgetItem *root = new QTreeWidgetItem(m_ui->treeWidget);
root->setFlags(root->flags() & ~Qt::ItemIsSelectable);
@@ -402,9 +402,7 @@ void NewFormWidget::loadFrom(const QString &path, bool resourceFile, const QStri
visiblePath = QDir::toNativeSeparators(visiblePath);
}
- const QChar underscore = QLatin1Char('_');
- const QChar blank = QLatin1Char(' ');
- root->setText(0, visiblePath.replace(underscore, blank));
+ root->setText(0, visiblePath.replace(u'_', u' '));
root->setToolTip(0, path);
for (const auto &fi : list) {
@@ -412,7 +410,7 @@ void NewFormWidget::loadFrom(const QString &path, bool resourceFile, const QStri
continue;
QTreeWidgetItem *item = new QTreeWidgetItem(root);
- const QString text = fi.baseName().replace(underscore, blank);
+ const QString text = fi.baseName().replace(u'_', u' ');
if (selectedItemFound == nullptr && text == selectedItem)
selectedItemFound = item;
item->setText(0, text);
@@ -479,7 +477,7 @@ QString NewFormWidget::itemToTemplate(const QTreeWidgetItem *item, QString *erro
const QFileInfo fiBase(fileName);
QString sizeFileName;
QTextStream(&sizeFileName) << fiBase.path() << QDir::separator()
- << size.width() << QLatin1Char('x') << size.height() << QDir::separator()
+ << size.width() << 'x' << size.height() << QDir::separator()
<< fiBase.fileName();
if (QFileInfo(sizeFileName).isFile())
return readAll(sizeFileName, errorMessage);
diff --git a/src/designer/src/lib/shared/previewmanager.cpp b/src/designer/src/lib/shared/previewmanager.cpp
index e4ab1526d..33e34c5a2 100644
--- a/src/designer/src/lib/shared/previewmanager.cpp
+++ b/src/designer/src/lib/shared/previewmanager.cpp
@@ -37,6 +37,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static inline int compare(const qdesigner_internal::PreviewConfiguration &pc1, const qdesigner_internal::PreviewConfiguration &pc2)
{
int rc = pc1.style().compare(pc2.style());
@@ -484,8 +486,7 @@ void PreviewConfiguration::toSettings(const QString &prefix, QDesignerSettingsIn
void PreviewConfiguration::fromSettings(const QString &prefix, const QDesignerSettingsInterface *settings)
{
clear();
- QString key = prefix;
- key += QLatin1Char('/');
+ QString key = prefix + u'/';
const auto prefixSize = key.size();
PreviewConfigurationData &d = *m_d;
diff --git a/src/designer/src/lib/shared/qdesigner_formbuilder.cpp b/src/designer/src/lib/shared/qdesigner_formbuilder.cpp
index 27b92c4e5..ff52bfd4b 100644
--- a/src/designer/src/lib/shared/qdesigner_formbuilder.cpp
+++ b/src/designer/src/lib/shared/qdesigner_formbuilder.cpp
@@ -323,12 +323,8 @@ QWidget *QDesignerFormBuilder::createPreview(const QDesignerFormWindowInterface
}
// Fake application style sheet by prepending. (If this doesn't work, fake by nesting
// into parent widget).
- if (!appStyleSheet.isEmpty()) {
- QString styleSheet = appStyleSheet;
- styleSheet += QLatin1Char('\n');
- styleSheet += widget->styleSheet();
- widget->setStyleSheet(styleSheet);
- }
+ if (!appStyleSheet.isEmpty())
+ widget->setStyleSheet(appStyleSheet + u'\n' + widget->styleSheet());
return widget;
}
diff --git a/src/designer/src/lib/shared/qdesigner_membersheet.cpp b/src/designer/src/lib/shared/qdesigner_membersheet.cpp
index 29aec04dd..8eae5be07 100644
--- a/src/designer/src/lib/shared/qdesigner_membersheet.cpp
+++ b/src/designer/src/lib/shared/qdesigner_membersheet.cpp
@@ -164,24 +164,24 @@ bool QDesignerMemberSheet::signalMatchesSlot(const QString &signal, const QStrin
bool result = true;
do {
- int signal_idx = signal.indexOf(QLatin1Char('('));
- int slot_idx = slot.indexOf(QLatin1Char('('));
+ qsizetype signal_idx = signal.indexOf(u'(');
+ qsizetype slot_idx = slot.indexOf(u'(');
if (signal_idx == -1 || slot_idx == -1)
break;
++signal_idx; ++slot_idx;
- if (slot.at(slot_idx) == QLatin1Char(')'))
+ if (slot.at(slot_idx) == u')')
break;
while (signal_idx < signal.size() && slot_idx < slot.size()) {
const QChar signal_c = signal.at(signal_idx);
const QChar slot_c = slot.at(slot_idx);
- if (signal_c == QLatin1Char(',') && slot_c == QLatin1Char(')'))
+ if (signal_c == u',' && slot_c == u')')
break;
- if (signal_c == QLatin1Char(')') && slot_c == QLatin1Char(')'))
+ if (signal_c == u')' && slot_c == u')')
break;
if (signal_c != slot_c) {
diff --git a/src/designer/src/lib/shared/qdesigner_promotion.cpp b/src/designer/src/lib/shared/qdesigner_promotion.cpp
index 3f12808bd..53b9eb1df 100644
--- a/src/designer/src/lib/shared/qdesigner_promotion.cpp
+++ b/src/designer/src/lib/shared/qdesigner_promotion.cpp
@@ -67,7 +67,7 @@ namespace {
if (pos == -1)
return QString();
xml.remove(0, pos + tag.size());
- const int closingPos = xml.indexOf(QLatin1Char('"'));
+ const auto closingPos = xml.indexOf(u'"');
if (closingPos == -1)
return QString();
xml.remove(closingPos, xml.size() - closingPos);
diff --git a/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp b/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp
index 004660891..219c675f4 100644
--- a/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp
+++ b/src/designer/src/lib/shared/qdesigner_promotiondialog.cpp
@@ -131,12 +131,11 @@ namespace qdesigner_internal {
void NewPromotedClassPanel::slotNameChanged(const QString &className) {
// Suggest a name
if (!className.isEmpty()) {
- const QChar dot(QLatin1Char('.'));
QString suggestedHeader = m_promotedHeaderLowerCase ?
className.toLower() : className;
suggestedHeader.replace("::"_L1, "_"_L1);
- if (!m_promotedHeaderSuffix.startsWith(dot))
- suggestedHeader += dot;
+ if (!m_promotedHeaderSuffix.startsWith(u'.'))
+ suggestedHeader += u'.';
suggestedHeader += m_promotedHeaderSuffix;
const bool blocked = m_includeFileEdit->blockSignals(true);
diff --git a/src/designer/src/lib/shared/qdesigner_utils.cpp b/src/designer/src/lib/shared/qdesigner_utils.cpp
index ec278645c..bb71f3f2e 100644
--- a/src/designer/src/lib/shared/qdesigner_utils.cpp
+++ b/src/designer/src/lib/shared/qdesigner_utils.cpp
@@ -197,11 +197,10 @@ namespace qdesigner_internal
if (flagIds.isEmpty())
return QString();
- const QChar delimiter = QLatin1Char('|');
QString rc;
for (const auto &id : flagIds) {
if (!rc.isEmpty())
- rc += delimiter ;
+ rc += u'|';
if (sm == FullyQualified)
appendQualifiedName(id, rc);
else
@@ -220,7 +219,7 @@ namespace qdesigner_internal
}
uint flags = 0;
bool valueOk = true;
- const QStringList keys = s.split(QString(QLatin1Char('|')));
+ const QStringList keys = s.split(u'|');
for (const QString &key : keys) {
const uint flagValue = keyToValue(key, &valueOk);
if (!valueOk) {
@@ -271,7 +270,7 @@ namespace qdesigner_internal
{
if (const QDesignerLanguageExtension *lang = qt_extension<QDesignerLanguageExtension *>(core->extensionManager(), core))
return lang->isLanguageResource(path) ? LanguageResourcePixmap : FilePixmap;
- return path.startsWith(QLatin1Char(':')) ? ResourcePixmap : FilePixmap;
+ return path.startsWith(u':') ? ResourcePixmap : FilePixmap;
}
int PropertySheetPixmapValue::compare(const PropertySheetPixmapValue &other) const
@@ -751,7 +750,7 @@ namespace qdesigner_internal
if (qname.size() > 1 && qname.at(1).isUpper()) {
const QChar first = qname.at(0);
- if (first == QLatin1Char('Q') || first == QLatin1Char('K'))
+ if (first == u'Q' || first == u'K')
qname.remove(0, 1);
}
diff --git a/src/designer/src/lib/shared/qtresourceeditordialog.cpp b/src/designer/src/lib/shared/qtresourceeditordialog.cpp
index 588d7e3c7..3a9c7cac3 100644
--- a/src/designer/src/lib/shared/qtresourceeditordialog.cpp
+++ b/src/designer/src/lib/shared/qtresourceeditordialog.cpp
@@ -1302,8 +1302,6 @@ void QtResourceEditorDialogPrivate::slotTreeViewItemChanged(QStandardItem *item)
QString QtResourceEditorDialogPrivate::getSaveFileNameWithExtension(QWidget *parent,
const QString &title, QString dir, const QString &filter, const QString &extension) const
{
- const QChar dot = QLatin1Char('.');
-
QString saveFile;
while (true) {
saveFile = m_dlgGui->getSaveFileName(parent, title, dir, filter, nullptr, QFileDialog::DontConfirmOverwrite);
@@ -1311,10 +1309,8 @@ QString QtResourceEditorDialogPrivate::getSaveFileNameWithExtension(QWidget *par
return saveFile;
const QFileInfo fInfo(saveFile);
- if (fInfo.suffix().isEmpty() && !fInfo.fileName().endsWith(dot)) {
- saveFile += dot;
- saveFile += extension;
- }
+ if (fInfo.suffix().isEmpty() && !fInfo.fileName().endsWith(u'.'))
+ saveFile += u'.' + extension;
const QFileInfo fi(saveFile);
if (!fi.exists())
@@ -1657,7 +1653,7 @@ void QtResourceEditorDialogPrivate::slotClonePrefix()
QDir dir(fi.dir());
QString oldSuffix = fi.completeSuffix();
if (!oldSuffix.isEmpty())
- oldSuffix = QLatin1Char('.') + oldSuffix;
+ oldSuffix = u'.' + oldSuffix;
const QString newBaseName = fi.baseName() + suffix + oldSuffix;
const QString newPath = QDir::cleanPath(dir.filePath(newBaseName));
m_qrcManager->insertResourceFile(newResourcePrefix, newPath,
@@ -2056,13 +2052,13 @@ QString QtResourceEditorDialog::selectedResource() const
if (!currentResourcePrefix)
return QString();
- const QChar slash(QLatin1Char('/'));
+ const QChar slash(u'/');
QString resource = currentResourcePrefix->prefix();
if (!resource.startsWith(slash))
resource.prepend(slash);
if (!resource.endsWith(slash))
resource.append(slash);
- resource.prepend(QLatin1Char(':'));
+ resource.prepend(u':');
QtResourceFile *currentResourceFile = d_ptr->getCurrentResourceFile();
if (!currentResourceFile)
diff --git a/src/designer/src/lib/shared/qtresourceview.cpp b/src/designer/src/lib/shared/qtresourceview.cpp
index c9f3fdfcc..66b6bc40b 100644
--- a/src/designer/src/lib/shared/qtresourceview.cpp
+++ b/src/designer/src/lib/shared/qtresourceview.cpp
@@ -745,8 +745,8 @@ bool QtResourceView::decodeMimeData(const QMimeData *md, ResourceType *t, QStrin
bool QtResourceView::decodeMimeData(const QString &text, ResourceType *t, QString *file)
{
- const QString docElementName = QLatin1String(elementResourceData);
- static const QString docElementString = QLatin1Char('<') + docElementName;
+ static auto docElementName = QLatin1StringView(elementResourceData);
+ static const QString docElementString = u'<' + docElementName;
if (text.isEmpty() || text.indexOf(docElementString) == -1)
return false;
diff --git a/src/designer/src/lib/shared/richtexteditor.cpp b/src/designer/src/lib/shared/richtexteditor.cpp
index eb1d2534c..d7d84cf42 100644
--- a/src/designer/src/lib/shared/richtexteditor.cpp
+++ b/src/designer/src/lib/shared/richtexteditor.cpp
@@ -728,7 +728,7 @@ RichTextEditorDialog::RichTextEditorDialog(QDesignerFormEditorInterface *core, Q
// Read settings
const QDesignerSettingsInterface *settings = core->settingsManager();
- const QString rootKey = QLatin1String(RichTextDialogGroupC) + QLatin1Char('/');
+ const QString rootKey = QLatin1StringView(RichTextDialogGroupC) + u'/';
const QByteArray lastGeometry = settings->value(rootKey + QLatin1String(GeometryKeyC)).toByteArray();
const int initialTab = settings->value(rootKey + QLatin1String(TabKeyC), QVariant(m_initialTab)).toInt();
if (initialTab == RichTextIndex || initialTab == SourceIndex)
diff --git a/src/designer/src/lib/shared/signalslotdialog.cpp b/src/designer/src/lib/shared/signalslotdialog.cpp
index c9016df57..0f6a3aad0 100644
--- a/src/designer/src/lib/shared/signalslotdialog.cpp
+++ b/src/designer/src/lib/shared/signalslotdialog.cpp
@@ -207,12 +207,11 @@ void SignaturePanel::slotAdd()
m_listView->selectionModel()->clearSelection();
// find unique name
for (int i = 1; ; i++) {
- QString newSlot = m_newPrefix;
- newSlot += QString::number(i); // Always add number, Avoid setting 'slot' for first entry
- newSlot += QLatin1Char('(');
+ // Always add number, Avoid setting 'slot' for first entry
+ QString newSlot = m_newPrefix + QString::number(i) + u'(';
// check for function name independent of parameters
if (m_model->findItems(newSlot, Qt::MatchStartsWith, 0).isEmpty()) {
- newSlot += QLatin1Char(')');
+ newSlot += u')';
QStandardItem * item = createEditableItem(newSlot);
m_model->appendRow(item);
const QModelIndex index = m_model->indexFromItem (item);
diff --git a/src/designer/src/lib/shared/stylesheeteditor.cpp b/src/designer/src/lib/shared/stylesheeteditor.cpp
index 8141c4990..a77a51bd7 100644
--- a/src/designer/src/lib/shared/stylesheeteditor.cpp
+++ b/src/designer/src/lib/shared/stylesheeteditor.cpp
@@ -48,7 +48,7 @@ StyleSheetEditor::StyleSheetEditor(QWidget *parent)
{
enum : int { DarkThreshold = 200 }; // Observed 239 on KDE/Dark
- setTabStopDistance(fontMetrics().horizontalAdvance(QLatin1Char(' ')) * 4);
+ setTabStopDistance(fontMetrics().horizontalAdvance(u' ') * 4);
setAcceptRichText(false);
const QColor textColor = palette().color(QPalette::WindowText);
@@ -247,10 +247,8 @@ void StyleSheetEditorDialog::slotAddFont()
QFont font = QFontDialog::getFont(&ok, this);
if (ok) {
QString fontStr;
- if (font.weight() != QFont::Normal) {
- fontStr += QString::number(font.weight());
- fontStr += QLatin1Char(' ');
- }
+ if (font.weight() != QFont::Normal)
+ fontStr += QString::number(font.weight()) + u' ';
switch (font.style()) {
case QFont::StyleItalic:
@@ -265,7 +263,7 @@ void StyleSheetEditorDialog::slotAddFont()
fontStr += QString::number(font.pointSize());
fontStr += "pt \""_L1;
fontStr += font.family();
- fontStr += QLatin1Char('"');
+ fontStr += u'"';
insertCssProperty(u"font"_s, fontStr);
QString decoration;
@@ -273,7 +271,7 @@ void StyleSheetEditorDialog::slotAddFont()
decoration += "underline"_L1;
if (font.strikeOut()) {
if (!decoration.isEmpty())
- decoration += QLatin1Char(' ');
+ decoration += u' ';
decoration += "line-through"_L1;
}
insertCssProperty(u"text-decoration"_s, decoration);
@@ -297,13 +295,13 @@ void StyleSheetEditorDialog::insertCssProperty(const QString &name, const QStrin
closing.position() < opening.position());
QString insertion;
if (m_editor->textCursor().block().length() != 1)
- insertion += QLatin1Char('\n');
+ insertion += u'\n';
if (inSelector)
- insertion += QLatin1Char('\t');
+ insertion += u'\t';
insertion += name;
insertion += ": "_L1;
insertion += value;
- insertion += QLatin1Char(';');
+ insertion += u';';
cursor.insertText(insertion);
cursor.endEditBlock();
} else {
diff --git a/src/designer/src/lib/shared/textpropertyeditor.cpp b/src/designer/src/lib/shared/textpropertyeditor.cpp
index 52418c904..e345580ba 100644
--- a/src/designer/src/lib/shared/textpropertyeditor.cpp
+++ b/src/designer/src/lib/shared/textpropertyeditor.cpp
@@ -20,8 +20,8 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
namespace {
- const QChar NewLineChar(QLatin1Char('\n'));
- const QLatin1String EscapedNewLine("\\n");
+ const QChar NewLineChar(u'\n');
+ const auto EscapedNewLine = "\\n"_L1;
// A validator that replaces offending strings
class ReplacementValidator : public QValidator {
@@ -153,7 +153,7 @@ namespace {
// Might be a short url - try to detect the schema.
if (!hasSchema) {
- const int dotIndex = urlStr.indexOf(QLatin1Char('.'));
+ const int dotIndex = urlStr.indexOf(u'.');
if (dotIndex != -1) {
const QString prefix = urlStr.left(dotIndex).toLower();
QString urlString;
@@ -223,7 +223,7 @@ namespace qdesigner_internal {
break;
case ValidationSingleLine:
// Set a validator that replaces newline characters by a blank.
- m_lineEdit->setValidator(new ReplacementValidator(m_lineEdit, NewLineChar, QString(QLatin1Char(' '))));
+ m_lineEdit->setValidator(new ReplacementValidator(m_lineEdit, NewLineChar, QString(u' ')));
m_lineEdit->setCompleter(nullptr);
break;
case ValidationObjectName:
@@ -354,7 +354,7 @@ namespace qdesigner_internal {
// protect backslashes
rc.replace('\\'_L1, "\\\\"_L1);
// escape newlines
- rc.replace(NewLineChar, QString(EscapedNewLine));
+ rc.replace(u'\n', EscapedNewLine);
return rc;
}
@@ -368,14 +368,14 @@ namespace qdesigner_internal {
return s;
QString rc(s);
- for (qsizetype pos = 0; (pos = rc.indexOf(QLatin1Char('\\'),pos)) >= 0 ; ) {
+ for (qsizetype pos = 0; (pos = rc.indexOf(u'\\', pos)) >= 0 ; ) {
// found an escaped character. If not a newline or at end of string, leave as is, else insert '\n'
const qsizetype nextpos = pos + 1;
if (nextpos >= rc.size()) // trailing '\\'
break;
// Escaped NewLine
- if (rc.at(nextpos) == QChar(QLatin1Char('n')))
- rc[nextpos] = NewLineChar;
+ if (rc.at(nextpos) == u'n')
+ rc[nextpos] = u'\n';
// Remove escape, go past escaped
rc.remove(pos,1);
pos++;
diff --git a/src/designer/src/lib/shared/widgetdatabase.cpp b/src/designer/src/lib/shared/widgetdatabase.cpp
index 441c97887..5f4b770e1 100644
--- a/src/designer/src/lib/shared/widgetdatabase.cpp
+++ b/src/designer/src/lib/shared/widgetdatabase.cpp
@@ -745,20 +745,19 @@ QString WidgetDataBase::scaleFormTemplate(const QString &xml, const QSize &size,
// ---- free functions
QDESIGNER_SHARED_EXPORT IncludeSpecification includeSpecification(QString includeFile)
{
- const bool global = !includeFile.isEmpty() &&
- includeFile[0] == QLatin1Char('<') &&
- includeFile[includeFile.size() - 1] == QLatin1Char('>');
+ const bool global = includeFile.startsWith(u'<') && includeFile.endsWith(u'>');
if (global) {
- includeFile.remove(includeFile.size() - 1, 1);
+ includeFile.chop(1);
includeFile.remove(0, 1);
}
return IncludeSpecification(includeFile, global ? IncludeGlobal : IncludeLocal);
}
-QDESIGNER_SHARED_EXPORT QString buildIncludeFile(QString includeFile, IncludeType includeType) {
+QDESIGNER_SHARED_EXPORT QString buildIncludeFile(QString includeFile, IncludeType includeType)
+{
if (includeType == IncludeGlobal && !includeFile.isEmpty()) {
- includeFile.append(QLatin1Char('>'));
- includeFile.insert(0, QLatin1Char('<'));
+ includeFile.append(u'>');
+ includeFile.prepend(u'<');
}
return includeFile;
}
diff --git a/src/designer/src/lib/uilib/abstractformbuilder.cpp b/src/designer/src/lib/uilib/abstractformbuilder.cpp
index b90876dbd..cd675dcf9 100644
--- a/src/designer/src/lib/uilib/abstractformbuilder.cpp
+++ b/src/designer/src/lib/uilib/abstractformbuilder.cpp
@@ -746,8 +746,7 @@ static inline Qt::Alignment alignmentFromDom(const QString &in)
{
Qt::Alignment rc;
if (!in.isEmpty()) {
- const auto flags = QStringView{in}.split(QLatin1Char('|'));
- for (const auto &f : flags) {
+ for (const auto &f : qTokenize(in, u'|')) {
if (f == "Qt::AlignLeft"_L1) {
rc |= Qt::AlignLeft;
} else if (f == "Qt::AlignRight"_L1) {
diff --git a/src/designer/src/lib/uilib/formbuilder.cpp b/src/designer/src/lib/uilib/formbuilder.cpp
index f27b8e96e..9a54212da 100644
--- a/src/designer/src/lib/uilib/formbuilder.cpp
+++ b/src/designer/src/lib/uilib/formbuilder.cpp
@@ -14,6 +14,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#ifdef QFORMINTERNAL_NAMESPACE
namespace QFormInternal {
#endif
@@ -440,11 +442,7 @@ void QFormBuilder::updateCustomWidgets()
if (!QLibrary::isLibrary(plugin))
continue;
- QString loaderPath = path;
- loaderPath += QLatin1Char('/');
- loaderPath += plugin;
-
- QPluginLoader loader(loaderPath);
+ QPluginLoader loader(path + u'/' + plugin);
if (loader.load())
insertPlugins(loader.instance(), &d->m_customWidgets);
}
diff --git a/src/designer/src/lib/uilib/formbuilderextra.cpp b/src/designer/src/lib/uilib/formbuilderextra.cpp
index 99888ef63..a05d988a1 100644
--- a/src/designer/src/lib/uilib/formbuilderextra.cpp
+++ b/src/designer/src/lib/uilib/formbuilderextra.cpp
@@ -314,7 +314,7 @@ inline QString perCellPropertyToString(const Layout *l, int count, int (Layout::
QTextStream str(&rc);
for (int i = 0; i < count; i++) {
if (i)
- str << QLatin1Char(',');
+ str << ',';
str << (l->*getter)(i);
}
}
@@ -339,7 +339,7 @@ inline bool parsePerCellProperty(Layout *l, int count, void (Layout::*setter)(in
clearPerCellValue(l, count, setter, defaultValue);
return true;
}
- const auto list = QStringView{s}.split(QLatin1Char(','));
+ const auto list = QStringView{s}.split(u',');
if (list.isEmpty()) {
clearPerCellValue(l, count, setter, defaultValue);
return true;
diff --git a/src/designer/src/lib/uilib/properties.cpp b/src/designer/src/lib/uilib/properties.cpp
index 1ce57df0c..8094a394a 100644
--- a/src/designer/src/lib/uilib/properties.cpp
+++ b/src/designer/src/lib/uilib/properties.cpp
@@ -28,9 +28,9 @@ namespace QFormInternal
static inline void fixEnum(QString &s)
{
- int qualifierIndex = s.lastIndexOf(QLatin1Char(':'));
+ qsizetype qualifierIndex = s.lastIndexOf(u':');
if (qualifierIndex == -1)
- qualifierIndex = s.lastIndexOf(QLatin1Char('.'));
+ qualifierIndex = s.lastIndexOf(u'.');
if (qualifierIndex != -1)
s.remove(0, qualifierIndex + 1);
}
diff --git a/src/designer/src/plugins/activeqt/qaxwidgettaskmenu.cpp b/src/designer/src/plugins/activeqt/qaxwidgettaskmenu.cpp
index a5c886012..6f4db2880 100644
--- a/src/designer/src/plugins/activeqt/qaxwidgettaskmenu.cpp
+++ b/src/designer/src/plugins/activeqt/qaxwidgettaskmenu.cpp
@@ -24,6 +24,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/* SetControlCommand: An undo commands that sets a control bypassing
Designer's property system which cannot handle the changing
of the 'control' property's index and other cached information
@@ -138,10 +140,8 @@ void QAxWidgetTaskMenu::setActiveXControl()
Q_ASSERT(formWin != nullptr);
QString value = clsid.toString();
- if (!key.isEmpty()) {
- value += QLatin1Char(':');
- value += key;
- }
+ if (!key.isEmpty())
+ value += u':' + key;
formWin->commandHistory()->push(new SetControlCommand(m_axwidget, formWin, value));
}