Plugins: stop using QLatin1Char constructor for creating char literals

Required for porting away from QLatin1Char/QLatin1String in scope of
QTBUG-98434.

As a drive-by, fix qsizetype -> int narrowing conversion warnings for
the touched lines.

Change-Id: Id76add7e86b6dfb89f758a9efb0644067f0f44de
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Sona Kurazyan 2022-04-12 17:33:01 +02:00 committed by Marc Mutz
parent e65e3f3021
commit 7c9c195235
18 changed files with 32 additions and 31 deletions

View File

@ -745,7 +745,7 @@ QString QIBusPlatformInputContextPrivate::getSocketPath()
return QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) +
QLatin1String("/ibus/bus/") +
QLatin1String(QDBusConnection::localMachineId()) +
QLatin1Char('-') + QString::fromLocal8Bit(host) + QLatin1Char('-') + QString::fromLocal8Bit(displayNumber);
u'-' + QString::fromLocal8Bit(host) + u'-' + QString::fromLocal8Bit(displayNumber);
}
QDBusConnection *QIBusPlatformInputContextPrivate::createConnection()

View File

@ -192,7 +192,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of
+ (id) lineNumberForIndex: (int)index forText:(const QString &)text
{
auto textBefore = QStringView(text).left(index);
int newlines = textBefore.count(QLatin1Char('\n'));
qsizetype newlines = textBefore.count(u'\n');
return @(newlines);
}

View File

@ -290,7 +290,7 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
return NO;
}
if (!(filter & QDir::Hidden)
&& (qtFileName.startsWith(QLatin1Char('.')) || [self isHiddenFileAtURL:url]))
&& (qtFileName.startsWith(u'.') || [self isHiddenFileAtURL:url]))
return NO;
return YES;
@ -446,10 +446,10 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions;
if (!filter.startsWith(QLatin1String("*.")))
continue;
if (filter.contains(QLatin1Char('?')))
if (filter.contains(u'?'))
continue;
if (filter.count(QLatin1Char('*')) != 1)
if (filter.count(u'*') != 1)
continue;
auto extensions = filter.split('.', Qt::SkipEmptyParts);

View File

@ -225,7 +225,7 @@ QString qt_mac_applicationName()
if (appName.isEmpty()) {
QString arg0 = QGuiApplicationPrivate::instance()->appName();
if (arg0.contains("/")) {
QStringList parts = arg0.split(QLatin1Char('/'));
QStringList parts = arg0.split(u'/');
appName = parts.at(parts.count() - 1);
} else {
appName = arg0;

View File

@ -195,7 +195,7 @@ void QCocoaMenuBar::syncMenu_helper(QPlatformMenu *menu, bool menubarUpdate)
cocoaMenu->syncMenuItem_helper(item, menubarUpdate);
const QString captionNoAmpersand = QString::fromNSString(cocoaMenu->nsMenu().title)
.remove(QLatin1Char('&'));
.remove(u'&');
if (captionNoAmpersand == QCoreApplication::translate("QCocoaMenu", "Edit")) {
// prevent recursion from QCocoaMenu::insertMenuItem - when the menu is visible
// it calls syncMenu again. QCocoaMenu::setVisible just sets the bool, which then

View File

@ -216,7 +216,7 @@ void QCocoaMenuItem::setNativeContents(WId item)
static QPlatformMenuItem::MenuRole detectMenuRole(const QString &caption)
{
QString captionNoAmpersand(caption);
captionNoAmpersand.remove(QLatin1Char('&'));
captionNoAmpersand.remove(u'&');
const QString aboutString = QCoreApplication::translate("QCocoaMenuItem", "About");
if (captionNoAmpersand.startsWith(aboutString, Qt::CaseInsensitive)
|| captionNoAmpersand.endsWith(aboutString, Qt::CaseInsensitive)) {

View File

@ -403,7 +403,7 @@ bool QDirectFbBlitterPlatformPixmap::fromFile(const QString &filename, const cha
return QBlittablePlatformPixmap::fromFile(filename, format, flags);
// Deal with resources
if (filename.startsWith(QLatin1Char(':')))
if (filename.startsWith(u':'))
return QBlittablePlatformPixmap::fromFile(filename, format, flags);
// Try to use directfb to load it.

View File

@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
QMinimalBackingStore::QMinimalBackingStore(QWindow *window)
: QPlatformBackingStore(window)
, mDebug(QMinimalIntegration::instance()->options() & QMinimalIntegration::DebugBackingStore)
@ -75,7 +77,7 @@ void QMinimalBackingStore::flush(QWindow *window, const QRegion &region, const Q
if (mDebug) {
static int c = 0;
QString filename = QString("output%1.png").arg(c++, 4, 10, QLatin1Char('0'));
QString filename = QString("output%1.png").arg(c++, 4, 10, QChar(u'0'));
qDebug() << "QMinimalBackingStore::flush() saving contents to" << filename.toLocal8Bit().constData();
mImage.save(filename);
}

View File

@ -86,7 +86,7 @@ static QSize determineScreenSize(screen_display_t display, bool primaryScreen) {
const QString envPhySizeStr = qgetenv("QQNX_PHYSICAL_SCREEN_SIZE");
if (!envPhySizeStr.isEmpty()) {
const auto envPhySizeStrList = QStringView{envPhySizeStr}.split(QLatin1Char(','));
const auto envPhySizeStrList = QStringView{envPhySizeStr}.split(u',');
const int envWidth = envPhySizeStrList.size() == 2 ? envPhySizeStrList[0].toInt() : -1;
const int envHeight = envPhySizeStrList.size() == 2 ? envPhySizeStrList[1].toInt() : -1;

View File

@ -1053,7 +1053,7 @@ static QList<FilterSpec> filterSpecs(const QStringList &filters,
#if QT_CONFIG(regularexpression)
filterSpec.filter.replace(filterSeparatorRE, separator);
#else
filterSpec.filter.replace(QLatin1Char(' '), QLatin1Char(';'));
filterSpec.filter.replace(u' ', u';');
#endif
filterSpec.description = filterString;
if (hideFilterDetails && openingParenPos != -1) { // Do not show pattern in description

View File

@ -501,7 +501,7 @@ static QString argv0BaseName()
const QStringList arguments = QCoreApplication::arguments();
if (!arguments.isEmpty() && !arguments.front().isEmpty()) {
result = arguments.front();
const int lastSlashPos = result.lastIndexOf(QLatin1Char('/'));
const int lastSlashPos = result.lastIndexOf(u'/');
if (lastSlashPos != -1)
result.remove(0, lastSlashPos + 1);
}

View File

@ -112,7 +112,7 @@ bool QXcbMime::mimeDataForAtom(QXcbConnection *connection, xcb_atom_t a, QMimeDa
// so QXcbConnection::atomName() has to be used.
if (atomName == QLatin1String("text/uri-list")
&& connection->atomName(a) == "text/x-moz-url") {
const QString mozUri = QLatin1String(data->split('\n').constFirst()) + QLatin1Char('\n');
const QString mozUri = QLatin1String(data->split('\n').constFirst()) + u'\n';
*data = QByteArray(reinterpret_cast<const char *>(mozUri.data()),
mozUri.length() * 2);
} else if (atomName == QLatin1String("application/x-color"))
@ -195,7 +195,7 @@ QVariant QXcbMime::mimeConvertToFormat(QXcbConnection *connection, xcb_atom_t a,
reinterpret_cast<const char16_t *>(data.constData()), data.size() / 2);
if (!str.isNull()) {
if (format == QLatin1String("text/uri-list")) {
const auto urls = QStringView{str}.split(QLatin1Char('\n'));
const auto urls = QStringView{str}.split(u'\n');
QList<QVariant> list;
list.reserve(urls.size());
for (const QStringView &s : urls) {

View File

@ -613,7 +613,7 @@ static void dumpNativeWindowsRecursion(const QXcbConnection *connection, xcb_win
const int oldFieldWidth = str.fieldWidth();
const QChar oldPadChar =str.padChar();
str.setFieldWidth(8);
str.setPadChar(QLatin1Char('0'));
str.setPadChar(u'0');
str << Qt::hex << window;
str.setFieldWidth(oldFieldWidth);
str.setPadChar(oldPadChar);

View File

@ -729,7 +729,7 @@ QString QXcbScreen::defaultName()
int dotPos = displayName.lastIndexOf('.');
if (dotPos != -1)
displayName.truncate(dotPos);
name = QString::fromLocal8Bit(displayName) + QLatin1Char('.')
name = QString::fromLocal8Bit(displayName) + u'.'
+ QString::number(m_virtualDesktop->number());
return name;
}
@ -762,7 +762,7 @@ QString QXcbScreen::getName(xcb_randr_monitor_info_t *monitorInfo)
int dotPos = displayName.lastIndexOf('.');
if (dotPos != -1)
displayName.truncate(dotPos);
name = QString::fromLocal8Bit(displayName) + QLatin1Char('.')
name = QString::fromLocal8Bit(displayName) + u'.'
+ QString::number(m_virtualDesktop->number());
}
return name;

View File

@ -194,7 +194,7 @@ static void sm_performSaveYourself(QXcbSessionManager *sm)
timeval tv;
gettimeofday(&tv, nullptr);
sm->setSessionKey(QString::number(qulonglong(tv.tv_sec)) +
QLatin1Char('_') +
u'_' +
QString::number(qulonglong(tv.tv_usec)));
QStringList arguments = QCoreApplication::arguments();
@ -228,8 +228,7 @@ static void sm_performSaveYourself(QXcbSessionManager *sm)
// generate a restart and discard command that makes sense
QStringList restart;
restart << argument0 << QLatin1String("-session")
<< sm->sessionId() + QLatin1Char('_') + sm->sessionKey();
restart << argument0 << QLatin1String("-session") << sm->sessionId() + u'_' + sm->sessionKey();
QFileInfo fi(QCoreApplication::applicationFilePath());
if (qAppName().compare(fi.fileName(), Qt::CaseInsensitive) != 0)

View File

@ -521,7 +521,7 @@ void QGtk3FileDialogHelper::setNameFilters(const QStringList &filters)
foreach (const QString &filter, filters) {
GtkFileFilter *gtkFilter = gtk_file_filter_new();
const QString name = filter.left(filter.indexOf(QLatin1Char('(')));
const QString name = filter.left(filter.indexOf(u'('));
const QStringList extensions = cleanFilterList(filter);
gtk_file_filter_set_name(gtkFilter, qUtf8Printable(name.isEmpty() ? extensions.join(QLatin1String(", ")) : name));

View File

@ -158,23 +158,23 @@ static QString convertMnemonics(QString text, bool *found)
{
*found = false;
int i = text.length() - 1;
qsizetype i = text.length() - 1;
while (i >= 0) {
const QChar c = text.at(i);
if (c == QLatin1Char('&')) {
if (i == 0 || text.at(i - 1) != QLatin1Char('&')) {
if (c == u'&') {
if (i == 0 || text.at(i - 1) != u'&') {
// convert Qt to GTK mnemonic
if (i < text.length() - 1 && !text.at(i + 1).isSpace()) {
text.replace(i, 1, QLatin1Char('_'));
text.replace(i, 1, u'_');
*found = true;
}
} else if (text.at(i - 1) == QLatin1Char('&')) {
} else if (text.at(i - 1) == u'&') {
// unescape ampersand
text.replace(--i, 2, QLatin1Char('&'));
text.replace(--i, 2, u'&');
}
} else if (c == QLatin1Char('_')) {
} else if (c == u'_') {
// escape GTK mnemonic
text.insert(i, QLatin1Char('_'));
text.insert(i, u'_');
}
--i;
}

View File

@ -251,7 +251,7 @@ void QXdgDesktopPortalFileDialog::openPortal()
QRegularExpressionMatch match = regexp.match(nameFilter);
if (match.hasMatch()) {
QString userVisibleName = match.captured(1);
QStringList filterStrings = match.captured(2).split(QLatin1Char(' '), Qt::SkipEmptyParts);
QStringList filterStrings = match.captured(2).split(u' ', Qt::SkipEmptyParts);
if (filterStrings.isEmpty()) {
qWarning() << "Filter " << userVisibleName << " is empty and will be ignored.";