Use initializer list syntax where appropiate

This commit is contained in:
Alexander Lohnau 2023-07-25 21:45:36 +02:00
parent e4c743a680
commit 8edd2a2e52
5 changed files with 12 additions and 12 deletions

View file

@ -36,9 +36,9 @@ int main(int argc, char **argv)
about.addAuthor(i18n("Aleix Pol Gonzalez"), QString(), QStringLiteral("aleixpol@kde.org")); about.addAuthor(i18n("Aleix Pol Gonzalez"), QString(), QStringLiteral("aleixpol@kde.org"));
about.addAuthor(i18n("Albert Vaca Cintora"), QString(), QStringLiteral("albertvaka@gmail.com")); about.addAuthor(i18n("Albert Vaca Cintora"), QString(), QStringLiteral("albertvaka@gmail.com"));
QCommandLineParser parser; QCommandLineParser parser;
parser.addOption(QCommandLineOption(QStringList(QStringLiteral("l")) << QStringLiteral("list-devices"), i18n("List all devices"))); parser.addOption(QCommandLineOption(QStringList{QStringLiteral("l"), QStringLiteral("list-devices")}, i18n("List all devices")));
parser.addOption( parser.addOption(
QCommandLineOption(QStringList(QStringLiteral("a")) << QStringLiteral("list-available"), i18n("List available (paired and reachable) devices"))); QCommandLineOption(QStringList{QStringLiteral("a"), QStringLiteral("list-available")}, i18n("List available (paired and reachable) devices")));
parser.addOption( parser.addOption(
QCommandLineOption(QStringLiteral("id-only"), i18n("Make --list-devices or --list-available print only the devices id, to ease scripting"))); QCommandLineOption(QStringLiteral("id-only"), i18n("Make --list-devices or --list-available print only the devices id, to ease scripting")));
parser.addOption( parser.addOption(
@ -62,8 +62,8 @@ int main(int argc, char **argv)
parser.addOption(QCommandLineOption(QStringLiteral("attachment"), parser.addOption(QCommandLineOption(QStringLiteral("attachment"),
i18n("File urls to send attachments with the message (can be passed multiple times)"), i18n("File urls to send attachments with the message (can be passed multiple times)"),
i18n("file urls"))); i18n("file urls")));
parser.addOption(QCommandLineOption(QStringList(QStringLiteral("device")) << QStringLiteral("d"), i18n("Device ID"), QStringLiteral("dev"))); parser.addOption(QCommandLineOption(QStringList{QStringLiteral("device"), QStringLiteral("d")}, i18n("Device ID"), QStringLiteral("dev")));
parser.addOption(QCommandLineOption(QStringList(QStringLiteral("name")) << QStringLiteral("n"), i18n("Device Name"), QStringLiteral("name"))); parser.addOption(QCommandLineOption(QStringList{QStringLiteral("name"), QStringLiteral("n")}, i18n("Device Name"), QStringLiteral("name")));
parser.addOption(QCommandLineOption(QStringLiteral("encryption-info"), i18n("Get encryption info about said device"))); parser.addOption(QCommandLineOption(QStringLiteral("encryption-info"), i18n("Get encryption info about said device")));
parser.addOption(QCommandLineOption(QStringLiteral("list-commands"), i18n("Lists remote commands and their ids"))); parser.addOption(QCommandLineOption(QStringLiteral("list-commands"), i18n("Lists remote commands and their ids")));
parser.addOption(QCommandLineOption(QStringLiteral("execute-command"), i18n("Executes a remote command by id"), QStringLiteral("id"))); parser.addOption(QCommandLineOption(QStringLiteral("execute-command"), i18n("Executes a remote command by id"), QStringLiteral("id")));
@ -210,7 +210,7 @@ int main(int argc, char **argv)
QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("org.kde.kdeconnect.device.share"),
QStringLiteral("shareUrls")); QStringLiteral("shareUrls"));
msg.setArguments(QVariantList() << QVariant(urls)); msg.setArguments(QVariantList{QVariant(urls)});
blockOnReply(QDBusConnection::sessionBus().asyncCall(msg)); blockOnReply(QDBusConnection::sessionBus().asyncCall(msg));
for (const QString &url : qAsConst(urls)) { for (const QString &url : qAsConst(urls)) {
@ -221,7 +221,7 @@ int main(int argc, char **argv)
QStringLiteral("/modules/kdeconnect/devices/") + device + QStringLiteral("/share"), QStringLiteral("/modules/kdeconnect/devices/") + device + QStringLiteral("/share"),
QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("org.kde.kdeconnect.device.share"),
QStringLiteral("shareText")); QStringLiteral("shareText"));
msg.setArguments(QVariantList() << parser.value(QStringLiteral("share-text"))); msg.setArguments(QVariantList{parser.value(QStringLiteral("share-text"))});
blockOnReply(QDBusConnection::sessionBus().asyncCall(msg)); blockOnReply(QDBusConnection::sessionBus().asyncCall(msg));
QTextStream(stdout) << i18n("Shared text: %1", parser.value(QStringLiteral("share-text"))) << Qt::endl; QTextStream(stdout) << i18n("Shared text: %1", parser.value(QStringLiteral("share-text"))) << Qt::endl;
} else if (parser.isSet(QStringLiteral("lock")) || parser.isSet(QStringLiteral("unlock"))) { } else if (parser.isSet(QStringLiteral("lock")) || parser.isSet(QStringLiteral("unlock"))) {
@ -280,7 +280,7 @@ int main(int argc, char **argv)
QStringLiteral("sendPing")); QStringLiteral("sendPing"));
if (parser.isSet(QStringLiteral("ping-msg"))) { if (parser.isSet(QStringLiteral("ping-msg"))) {
QString message = parser.value(QStringLiteral("ping-msg")); QString message = parser.value(QStringLiteral("ping-msg"));
msg.setArguments(QVariantList() << message); msg.setArguments(QVariantList{message});
} }
blockOnReply(QDBusConnection::sessionBus().asyncCall(msg)); blockOnReply(QDBusConnection::sessionBus().asyncCall(msg));
} else if (parser.isSet(QStringLiteral("send-sms"))) { } else if (parser.isSet(QStringLiteral("send-sms"))) {

View file

@ -55,7 +55,7 @@ public:
notification->setText( notification->setText(
i18n("Pairing request from %1\nKey: %2...", device->name().toHtmlEscaped(), QString::fromUtf8(device->verificationKey().left(8)))); i18n("Pairing request from %1\nKey: %2...", device->name().toHtmlEscaped(), QString::fromUtf8(device->verificationKey().left(8))));
notification->setDefaultAction(i18n("Open")); notification->setDefaultAction(i18n("Open"));
notification->setActions(QStringList() << i18n("Accept") << i18n("Reject") << i18n("View key")); notification->setActions(QStringList{i18n("Accept"), i18n("Reject"), i18n("View key")});
connect(notification, &KNotification::action1Activated, device, &Device::acceptPairing); connect(notification, &KNotification::action1Activated, device, &Device::acceptPairing);
connect(notification, &KNotification::action2Activated, device, &Device::cancelPairing); connect(notification, &KNotification::action2Activated, device, &Device::cancelPairing);
QString deviceId = device->id(); QString deviceId = device->id();

View file

@ -83,7 +83,7 @@ void SendFileItemAction::sendFile()
QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/share"), QStringLiteral("/modules/kdeconnect/devices/") + id + QStringLiteral("/share"),
QStringLiteral("org.kde.kdeconnect.device.share"), QStringLiteral("org.kde.kdeconnect.device.share"),
QStringLiteral("shareUrl")); QStringLiteral("shareUrl"));
msg.setArguments(QVariantList() << url.toString()); msg.setArguments(QVariantList{url.toString()});
QDBusConnection::sessionBus().asyncCall(msg); QDBusConnection::sessionBus().asyncCall(msg);
} }
} }

View file

@ -90,7 +90,7 @@ RunCommandConfig::RunCommandConfig(QObject *parent, const KPluginMetaData &data,
m_entriesModel = new QStandardItemModel(this); m_entriesModel = new QStandardItemModel(this);
table->setModel(m_entriesModel); table->setModel(m_entriesModel);
m_entriesModel->setHorizontalHeaderLabels(QStringList() << i18n("Name") << i18n("Command")); m_entriesModel->setHorizontalHeaderLabels(QStringList{i18n("Name"), i18n("Command")});
} }
void RunCommandConfig::exportCommands() void RunCommandConfig::exportCommands()

View file

@ -227,9 +227,9 @@ void Mounter::unmount(bool finished)
// Free mount point (won't always succeed if the path is in use) // Free mount point (won't always succeed if the path is in use)
#if defined(HAVE_FUSERMOUNT) #if defined(HAVE_FUSERMOUNT)
KProcess::execute(QStringList() << QStringLiteral("fusermount") << QStringLiteral("-u") << m_mountPoint, 10000); KProcess::execute(QStringList{QStringLiteral("fusermount"), QStringLiteral("-u"), m_mountPoint}, 10000);
#else #else
KProcess::execute(QStringList() << QStringLiteral("umount") << m_mountPoint, 10000); KProcess::execute(QStringList{QStringLiteral("umount"), m_mountPoint}, 10000);
#endif #endif
m_proc = nullptr; m_proc = nullptr;
} }