From 9676366a5c34ce7f22623002af2b41c1c478e382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Pereira?= Date: Mon, 18 Nov 2024 10:39:00 +0000 Subject: [PATCH 1/6] Use character literals --- src/mat/defemailclientmatcommand.cpp | 2 +- src/mat/deffilemanagermatcommand.cpp | 2 +- src/mat/defterminalmatcommand.cpp | 2 +- src/mat/defwebbrowsermatcommand.cpp | 2 +- src/mat/matcommandmanager.cpp | 4 ++-- src/mat/qtxdg-mat.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mat/defemailclientmatcommand.cpp b/src/mat/defemailclientmatcommand.cpp index 8f635a3..2de8393 100644 --- a/src/mat/defemailclientmatcommand.cpp +++ b/src/mat/defemailclientmatcommand.cpp @@ -90,7 +90,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefEm if (isDefEmailClientNameSet && !posArgs.empty()) { *errorMessage = QSL("Extra arguments given: "); - errorMessage->append(posArgs.join(QLatin1Char(','))); + errorMessage->append(posArgs.join(u',')); return CommandLineError; } diff --git a/src/mat/deffilemanagermatcommand.cpp b/src/mat/deffilemanagermatcommand.cpp index d0deb19..3662edb 100644 --- a/src/mat/deffilemanagermatcommand.cpp +++ b/src/mat/deffilemanagermatcommand.cpp @@ -90,7 +90,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefFi if (isDefFileManagerNameSet && !posArgs.empty()) { *errorMessage = QSL("Extra arguments given: "); - errorMessage->append(posArgs.join(QLatin1Char(','))); + errorMessage->append(posArgs.join(u',')); return CommandLineError; } diff --git a/src/mat/defterminalmatcommand.cpp b/src/mat/defterminalmatcommand.cpp index 4f4107b..3bba6af 100644 --- a/src/mat/defterminalmatcommand.cpp +++ b/src/mat/defterminalmatcommand.cpp @@ -91,7 +91,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefTe if (isDefTerminalNameSet && !posArgs.empty()) { *errorMessage = QSL("Extra arguments given: "); - errorMessage->append(posArgs.join(QLatin1Char(','))); + errorMessage->append(posArgs.join(u',')); return CommandLineError; } diff --git a/src/mat/defwebbrowsermatcommand.cpp b/src/mat/defwebbrowsermatcommand.cpp index 6506ece..a7f01ed 100644 --- a/src/mat/defwebbrowsermatcommand.cpp +++ b/src/mat/defwebbrowsermatcommand.cpp @@ -90,7 +90,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefWe if (isDefWebBrowserNameSet && !posArgs.empty()) { *errorMessage = QSL("Extra arguments given: "); - errorMessage->append(posArgs.join(QLatin1Char(','))); + errorMessage->append(posArgs.join(u',')); return CommandLineError; } diff --git a/src/mat/matcommandmanager.cpp b/src/mat/matcommandmanager.cpp index 1abe9b1..aee7740 100644 --- a/src/mat/matcommandmanager.cpp +++ b/src/mat/matcommandmanager.cpp @@ -57,8 +57,8 @@ QString MatCommandManager::descriptionsHelpText() const longestName += 2; // account for the inital dobule space for (const auto *cmd : std::as_const(mCommands)) { QString ptext = doubleSpace + cmd->name(); - ptext = ptext.leftJustified(longestName, QL1C(' ')); - ptext += doubleSpace + cmd->description() + QL1C('\n'); + ptext = ptext.leftJustified(longestName, u' '); + ptext += doubleSpace + cmd->description() + u'\n'; text.append(ptext); } return text; diff --git a/src/mat/qtxdg-mat.cpp b/src/mat/qtxdg-mat.cpp index 672c59c..bbc9bf1 100644 --- a/src/mat/qtxdg-mat.cpp +++ b/src/mat/qtxdg-mat.cpp @@ -41,7 +41,7 @@ extern void Q_CORE_EXPORT qt_call_post_routines(); [[noreturn]] void showHelp(const QString &parserHelp, const QString &commandsDescription, int exitCode) { QString text; - const QLatin1Char nl('\n'); + const auto nl(u'\n'); text.append(parserHelp); text.append(nl); From 6816dc207db2c6e9b3504b59cd08fa235c6e51e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Pereira?= Date: Mon, 18 Nov 2024 11:34:21 +0000 Subject: [PATCH 2/6] Use QLatin1StringView Making heavy use of the ""_L1 operator. Less clutter. Use of the QL1S macro dropped. No need for it anymore. Note: For the sake of review simplicity every string using Latin1 was converted although some can benefit from QStringLiteral improved capabilities on repeated data sharing. --- src/mat/defappmatcommand.cpp | 10 ++++++---- src/mat/defemailclientmatcommand.cpp | 8 +++++--- src/mat/deffilemanagermatcommand.cpp | 8 +++++--- src/mat/defterminalmatcommand.cpp | 8 +++++--- src/mat/defwebbrowsermatcommand.cpp | 8 +++++--- src/mat/matcommandmanager.cpp | 3 ++- src/mat/mimetypematcommand.cpp | 12 +++++++----- src/mat/openmatcommand.cpp | 10 ++++++---- 8 files changed, 41 insertions(+), 26 deletions(-) diff --git a/src/mat/defappmatcommand.cpp b/src/mat/defappmatcommand.cpp index 6c5beb2..8028bea 100644 --- a/src/mat/defappmatcommand.cpp +++ b/src/mat/defappmatcommand.cpp @@ -32,6 +32,8 @@ #include +using namespace Qt::Literals::StringLiterals; + enum DefAppCommandMode { CommandModeGetDefApp, CommandModeSetDefApp @@ -48,9 +50,9 @@ struct DefAppData { static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefAppData *data, QString *errorMessage) { parser->clearPositionalArguments(); - parser->setApplicationDescription(QL1S("Get/Set the default application for a mimetype")); + parser->setApplicationDescription("Get/Set the default application for a mimetype"_L1); - parser->addPositionalArgument(QL1S("defapp"), QSL("mimetype(s)"), + parser->addPositionalArgument("defapp"_L1, QSL("mimetype(s)"), QCoreApplication::tr("[mimetype(s)...]")); const QCommandLineOption defAppNameOption(QStringList() << QSL("s") << QSL("set"), @@ -106,8 +108,8 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefAp } DefAppMatCommand::DefAppMatCommand(QCommandLineParser *parser) - : MatCommandInterface(QL1S("defapp"), - QL1S("Get/Set the default application for a mimetype"), + : MatCommandInterface("defapp"_L1, + "Get/Set the default application for a mimetype"_L1, parser) { Q_CHECK_PTR(parser); diff --git a/src/mat/defemailclientmatcommand.cpp b/src/mat/defemailclientmatcommand.cpp index 2de8393..ab262c5 100644 --- a/src/mat/defemailclientmatcommand.cpp +++ b/src/mat/defemailclientmatcommand.cpp @@ -34,6 +34,8 @@ #include +using namespace Qt::Literals::StringLiterals; + enum DefEmailClientCommandMode { CommandModeGetDefEmailClient, CommandModeSetDefEmailClient, @@ -50,9 +52,9 @@ struct DefEmailClientData { static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefEmailClientData *data, QString *errorMessage) { parser->clearPositionalArguments(); - parser->setApplicationDescription(QL1S("Get/Set the default email client")); + parser->setApplicationDescription("Get/Set the default email client"_L1); - parser->addPositionalArgument(QL1S("def-email-client"), QL1S()); + parser->addPositionalArgument("def-email-client"_L1, ""_L1); const QCommandLineOption defEmailClientNameOption(QStringList() << QSL("s") << QSL("set"), QSL("Email Client to be set as default"), QSL("email client")); @@ -115,7 +117,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefEm } DefEmailClientMatCommand::DefEmailClientMatCommand(QCommandLineParser *parser) - : MatCommandInterface(QL1S("def-email-client"), + : MatCommandInterface("def-email-client"_L1, QSL("Get/Set the default email client"), parser) { diff --git a/src/mat/deffilemanagermatcommand.cpp b/src/mat/deffilemanagermatcommand.cpp index 3662edb..9f93437 100644 --- a/src/mat/deffilemanagermatcommand.cpp +++ b/src/mat/deffilemanagermatcommand.cpp @@ -34,6 +34,8 @@ #include +using namespace Qt::Literals::StringLiterals; + enum DefFileManagerCommandMode { CommandModeGetDefFileManager, CommandModeSetDefFileManager, @@ -50,9 +52,9 @@ struct DefFileManagerData { static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefFileManagerData *data, QString *errorMessage) { parser->clearPositionalArguments(); - parser->setApplicationDescription(QL1S("Get/Set the default file manager")); + parser->setApplicationDescription("Get/Set the default file manager"_L1); - parser->addPositionalArgument(QL1S("def-file-manager"), QL1S()); + parser->addPositionalArgument("def-file-manager"_L1, ""_L1); const QCommandLineOption defFileManagerNameOption(QStringList() << QSL("s") << QSL("set"), QSL("File Manager to be set as default"), QSL("file manager")); @@ -115,7 +117,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefFi } DefFileManagerMatCommand::DefFileManagerMatCommand(QCommandLineParser *parser) - : MatCommandInterface(QL1S("def-file-manager"), + : MatCommandInterface("def-file-manager"_L1, QSL("Get/Set the default file manager"), parser) { diff --git a/src/mat/defterminalmatcommand.cpp b/src/mat/defterminalmatcommand.cpp index 3bba6af..f43c755 100644 --- a/src/mat/defterminalmatcommand.cpp +++ b/src/mat/defterminalmatcommand.cpp @@ -35,6 +35,8 @@ #include +using namespace Qt::Literals::StringLiterals; + enum DefTerminalCommandMode { CommandModeGetDefTerminal, CommandModeSetDefTerminal, @@ -51,9 +53,9 @@ struct DefTerminalData { static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefTerminalData *data, QString *errorMessage) { parser->clearPositionalArguments(); - parser->setApplicationDescription(QL1S("Get/Set the default terminal")); + parser->setApplicationDescription("Get/Set the default terminal"_L1); - parser->addPositionalArgument(QL1S("def-terminal"), QL1S()); + parser->addPositionalArgument("def-terminal"_L1, ""_L1); const QCommandLineOption defTerminalNameOption(QStringList() << QSL("s") << QSL("set"), QSL("Terminal to be set as default"), QSL("terminal")); @@ -116,7 +118,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefTe } DefTerminalMatCommand::DefTerminalMatCommand(QCommandLineParser *parser) - : MatCommandInterface(QL1S("def-terminal"), + : MatCommandInterface("def-terminal"_L1, QSL("Get/Set the default terminal"), parser) { diff --git a/src/mat/defwebbrowsermatcommand.cpp b/src/mat/defwebbrowsermatcommand.cpp index a7f01ed..7dd99ca 100644 --- a/src/mat/defwebbrowsermatcommand.cpp +++ b/src/mat/defwebbrowsermatcommand.cpp @@ -34,6 +34,8 @@ #include +using namespace Qt::Literals::StringLiterals; + enum DefWebBrowserCommandMode { CommandModeGetDefWebBrowser, CommandModeSetDefWebBrowser, @@ -50,9 +52,9 @@ struct DefWebBrowserData { static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefWebBrowserData *data, QString *errorMessage) { parser->clearPositionalArguments(); - parser->setApplicationDescription(QL1S("Get/Set the default web browser")); + parser->setApplicationDescription("Get/Set the default web browser"_L1); - parser->addPositionalArgument(QL1S("def-web-browser"), QL1S()); + parser->addPositionalArgument("def-web-browser"_L1, ""_L1); const QCommandLineOption defWebBrowserNameOption(QStringList() << QSL("s") << QSL("set"), QSL("Web Browser to be set as default"), QSL("web bowser")); @@ -115,7 +117,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefWe } DefWebBrowserMatCommand::DefWebBrowserMatCommand(QCommandLineParser *parser) - : MatCommandInterface(QL1S("def-web-browser"), + : MatCommandInterface("def-web-browser"_L1, QSL("Get/Set the default web browser"), parser) { diff --git a/src/mat/matcommandmanager.cpp b/src/mat/matcommandmanager.cpp index aee7740..f170b06 100644 --- a/src/mat/matcommandmanager.cpp +++ b/src/mat/matcommandmanager.cpp @@ -26,6 +26,7 @@ #include +using namespace Qt::Literals::StringLiterals; MatCommandManager::MatCommandManager() = default; @@ -49,7 +50,7 @@ QString MatCommandManager::descriptionsHelpText() const { QString text; int longestName = 0; - const QLatin1String doubleSpace(" "); + const auto doubleSpace = " "_L1; for (const auto *cmd : std::as_const(mCommands)) { longestName = qMax(longestName, cmd->name().size()); diff --git a/src/mat/mimetypematcommand.cpp b/src/mat/mimetypematcommand.cpp index f413483..37393a5 100644 --- a/src/mat/mimetypematcommand.cpp +++ b/src/mat/mimetypematcommand.cpp @@ -37,9 +37,11 @@ #include +using namespace Qt::Literals::StringLiterals; + MimeTypeMatCommand::MimeTypeMatCommand(QCommandLineParser *parser) - : MatCommandInterface(QL1S("mimetype"), - QL1S("Determines a file (mime)type"), + : MatCommandInterface("mimetype"_L1, + "Determines a file (mime)type"_L1, parser) { } @@ -49,9 +51,9 @@ MimeTypeMatCommand::~MimeTypeMatCommand() = default; static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, QString *file, QString *errorMessage) { parser->clearPositionalArguments(); - parser->setApplicationDescription(QL1S("Determines a file (mime)type")); + parser->setApplicationDescription("Determines a file (mime)type"_L1); - parser->addPositionalArgument(QL1S("mimetype"), QSL("file | URL"), + parser->addPositionalArgument("mimetype"_L1, QSL("file | URL"), QCoreApplication::tr("[file | URL]")); const QCommandLineOption helpOption = parser->addHelpOption(); @@ -117,7 +119,7 @@ int MimeTypeMatCommand::run(const QStringList &arguments) if (scheme.isEmpty()) { isLocalFile = true; localFilename = file; - } else if (scheme == QL1S("file")) { + } else if (scheme == "file"_L1) { isLocalFile = true; localFilename = QUrl(file).toLocalFile(); } diff --git a/src/mat/openmatcommand.cpp b/src/mat/openmatcommand.cpp index 4cefc9d..369ffec 100644 --- a/src/mat/openmatcommand.cpp +++ b/src/mat/openmatcommand.cpp @@ -38,8 +38,10 @@ #include +using namespace Qt::Literals::StringLiterals; + OpenMatCommand::OpenMatCommand(QCommandLineParser *parser) - : MatCommandInterface(QL1S("open"), + : MatCommandInterface("open"_L1, QSL("Open files with the default application"), parser) { @@ -50,9 +52,9 @@ OpenMatCommand::~OpenMatCommand() = default; static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, QStringList *files, QString *errorMessage) { parser->clearPositionalArguments(); - parser->setApplicationDescription(QL1S("Open files with the default application")); + parser->setApplicationDescription("Open files with the default application"_L1); - parser->addPositionalArgument(QL1S("open"), QSL("files | URLs"), + parser->addPositionalArgument("open"_L1, QSL("files | URLs"), QCoreApplication::tr("[files | URLs]")); const QCommandLineOption helpOption = parser->addHelpOption(); @@ -119,7 +121,7 @@ int OpenMatCommand::run(const QStringList &arguments) if (scheme.isEmpty()) { isLocalFile = true; localFilename = urlString; - } else if (scheme == QL1S("file")) { + } else if (scheme == "file"_L1) { isLocalFile = true; localFilename = QUrl(urlString).toLocalFile(); } From 7fb27b52f456acd87bcb47892729037f2ec5b596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Pereira?= Date: Mon, 18 Nov 2024 14:13:56 +0000 Subject: [PATCH 3/6] Use StringLiterals operator ""_s Less cluttered code. Dropped QLS macro use. --- src/mat/defappmatcommand.cpp | 22 +++++++++++----------- src/mat/defemailclientmatcommand.cpp | 24 ++++++++++++------------ src/mat/deffilemanagermatcommand.cpp | 24 ++++++++++++------------ src/mat/defterminalmatcommand.cpp | 24 ++++++++++++------------ src/mat/defwebbrowsermatcommand.cpp | 24 ++++++++++++------------ src/mat/mimetypematcommand.cpp | 12 ++++++------ src/mat/openmatcommand.cpp | 14 +++++++------- src/mat/qtxdg-mat.cpp | 18 ++++++++++-------- 8 files changed, 82 insertions(+), 80 deletions(-) diff --git a/src/mat/defappmatcommand.cpp b/src/mat/defappmatcommand.cpp index 8028bea..30f4706 100644 --- a/src/mat/defappmatcommand.cpp +++ b/src/mat/defappmatcommand.cpp @@ -52,11 +52,11 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefAp parser->clearPositionalArguments(); parser->setApplicationDescription("Get/Set the default application for a mimetype"_L1); - parser->addPositionalArgument("defapp"_L1, QSL("mimetype(s)"), + parser->addPositionalArgument("defapp"_L1, u"mimetype(s)"_s, QCoreApplication::tr("[mimetype(s)...]")); - const QCommandLineOption defAppNameOption(QStringList() << QSL("s") << QSL("set"), - QSL("Application to be set as default"), QSL("app name")); + const QCommandLineOption defAppNameOption(QStringList() << u"s"_s << u"set"_s, + u"Application to be set as default"_s, u"app name"_s); parser->addOption(defAppNameOption); const QCommandLineOption helpOption = parser->addHelpOption(); @@ -71,7 +71,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefAp return CommandLineVersionRequested; } - if (parser->isSet(helpOption) || parser->isSet(QSL("help-all"))) { + if (parser->isSet(helpOption) || parser->isSet(u"help-all"_s)) { return CommandLineHelpRequested; } @@ -82,21 +82,21 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefAp defAppName = parser->value(defAppNameOption); if (isDefAppNameSet && defAppName.isEmpty()) { - *errorMessage = QSL("No application name"); + *errorMessage = u"No application name"_s; return CommandLineError; } QStringList mimeTypes = parser->positionalArguments(); if (mimeTypes.size() < 2) { - *errorMessage = QSL("MimeType missing"); + *errorMessage = u"MimeType missing"_s; return CommandLineError; } mimeTypes.removeAt(0); if (!isDefAppNameSet && mimeTypes.size() > 1) { - *errorMessage = QSL("Only one mimeType, please"); + *errorMessage = u"Only one mimeType, please"_s; return CommandLineError; } @@ -150,22 +150,22 @@ int DefAppMatCommand::run(const QStringList & /*arguments*/) std::cout << qPrintable(XdgDesktopFile::id(defApp->fileName())) << "\n"; delete defApp; } else { -// std::cout << qPrintable(QSL("No default application for '%1'\n").arg(mimeType)); +// std::cout << qPrintable(u"No default application for '%1'\n"_s.arg(mimeType)); } } else { // Set default App XdgDesktopFile app; if (!app.load(data.defAppName)) { - std::cerr << qPrintable(QSL("Could not find find '%1'\n").arg(data.defAppName)); + std::cerr << qPrintable(u"Could not find find '%1'\n"_s.arg(data.defAppName)); return EXIT_FAILURE; } XdgMimeApps apps; for (const QString &mimeType : std::as_const(data.mimeTypes)) { if (!apps.setDefaultApp(mimeType, app)) { - std::cerr << qPrintable(QSL("Could not set '%1' as default for '%2'\n").arg(app.fileName(), mimeType)); + std::cerr << qPrintable(u"Could not set '%1' as default for '%2'\n"_s.arg(app.fileName(), mimeType)); success = false; } else { - std::cout << qPrintable(QSL("Set '%1' as default for '%2'\n").arg(app.fileName(), mimeType)); + std::cout << qPrintable(u"Set '%1' as default for '%2'\n"_s.arg(app.fileName(), mimeType)); } } } diff --git a/src/mat/defemailclientmatcommand.cpp b/src/mat/defemailclientmatcommand.cpp index ab262c5..7312477 100644 --- a/src/mat/defemailclientmatcommand.cpp +++ b/src/mat/defemailclientmatcommand.cpp @@ -56,11 +56,11 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefEm parser->addPositionalArgument("def-email-client"_L1, ""_L1); - const QCommandLineOption defEmailClientNameOption(QStringList() << QSL("s") << QSL("set"), - QSL("Email Client to be set as default"), QSL("email client")); + const QCommandLineOption defEmailClientNameOption(QStringList() << u"s"_s << u"set"_s, + u"Email Client to be set as default"_s, u"email client"_s); - const QCommandLineOption listAvailableOption(QStringList() << QSL("l") << QSL("list-available"), - QSL("List available email clients")); + const QCommandLineOption listAvailableOption(QStringList() << u"l"_s << u"list-available"_s, + u"List available email clients"_s); parser->addOption(defEmailClientNameOption); parser->addOption(listAvailableOption); @@ -76,7 +76,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefEm return CommandLineVersionRequested; } - if (parser->isSet(helpOption) || parser->isSet(QSL("help-all"))) { + if (parser->isSet(helpOption) || parser->isSet(u"help-all"_s)) { return CommandLineHelpRequested; } @@ -91,18 +91,18 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefEm posArgs.removeAt(0); if (isDefEmailClientNameSet && !posArgs.empty()) { - *errorMessage = QSL("Extra arguments given: "); + *errorMessage = u"Extra arguments given: "_s; errorMessage->append(posArgs.join(u',')); return CommandLineError; } if (!isDefEmailClientNameSet && !posArgs.empty()) { - *errorMessage = QSL("To set the default email client use the -s/--set option"); + *errorMessage = u"To set the default email client use the -s/--set option"_s; return CommandLineError; } if (isListAvailableSet && (isDefEmailClientNameSet || !posArgs.empty())) { - *errorMessage = QSL("list-available can't be used with other options and doesn't take arguments"); + *errorMessage = u"list-available can't be used with other options and doesn't take arguments"_s; return CommandLineError; } @@ -118,7 +118,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefEm DefEmailClientMatCommand::DefEmailClientMatCommand(QCommandLineParser *parser) : MatCommandInterface("def-email-client"_L1, - QSL("Get/Set the default email client"), + u"Get/Set the default email client"_s, parser) { Q_CHECK_PTR(parser); @@ -169,13 +169,13 @@ int DefEmailClientMatCommand::run(const QStringList & /*arguments*/) XdgDesktopFile toSetDefEmailClient; if (toSetDefEmailClient.load(data.defEmailClientName)) { if (XdgDefaultApps::setEmailClient(toSetDefEmailClient)) { - std::cout << qPrintable(QSL("Set '%1' as the default email client\n").arg(toSetDefEmailClient.fileName())); + std::cout << qPrintable(u"Set '%1' as the default email client\n"_s.arg(toSetDefEmailClient.fileName())); } else { - std::cerr << qPrintable(QSL("Could not set '%1' as the default email client\n").arg(toSetDefEmailClient.fileName())); + std::cerr << qPrintable(u"Could not set '%1' as the default email client\n"_s.arg(toSetDefEmailClient.fileName())); success = false; } } else { // could not load application file - std::cerr << qPrintable(QSL("Could not find find '%1'\n").arg(data.defEmailClientName)); + std::cerr << qPrintable(u"Could not find find '%1'\n"_s.arg(data.defEmailClientName)); success = false; } } diff --git a/src/mat/deffilemanagermatcommand.cpp b/src/mat/deffilemanagermatcommand.cpp index 9f93437..6d4e6cc 100644 --- a/src/mat/deffilemanagermatcommand.cpp +++ b/src/mat/deffilemanagermatcommand.cpp @@ -56,11 +56,11 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefFi parser->addPositionalArgument("def-file-manager"_L1, ""_L1); - const QCommandLineOption defFileManagerNameOption(QStringList() << QSL("s") << QSL("set"), - QSL("File Manager to be set as default"), QSL("file manager")); + const QCommandLineOption defFileManagerNameOption(QStringList() << u"s"_s << u"set"_s, + u"File Manager to be set as default"_s, u"file manager"_s); - const QCommandLineOption listAvailableOption(QStringList() << QSL("l") << QSL("list-available"), - QSL("List available file managers")); + const QCommandLineOption listAvailableOption(QStringList() << u"l"_s << u"list-available"_s, + u"List available file managers"_s); parser->addOption(defFileManagerNameOption); parser->addOption(listAvailableOption); @@ -76,7 +76,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefFi return CommandLineVersionRequested; } - if (parser->isSet(helpOption) || parser->isSet(QSL("help-all"))) { + if (parser->isSet(helpOption) || parser->isSet(u"help-all"_s)) { return CommandLineHelpRequested; } @@ -91,18 +91,18 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefFi posArgs.removeAt(0); if (isDefFileManagerNameSet && !posArgs.empty()) { - *errorMessage = QSL("Extra arguments given: "); + *errorMessage = u"Extra arguments given: "_s; errorMessage->append(posArgs.join(u',')); return CommandLineError; } if (!isDefFileManagerNameSet && !posArgs.empty()) { - *errorMessage = QSL("To set the default file manager use the -s/--set option"); + *errorMessage = u"To set the default file manager use the -s/--set option"_s; return CommandLineError; } if (isListAvailableSet && (isDefFileManagerNameSet || !posArgs.empty())) { - *errorMessage = QSL("list-available can't be used with other options and doesn't take arguments"); + *errorMessage = u"list-available can't be used with other options and doesn't take arguments"_s; return CommandLineError; } @@ -118,7 +118,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefFi DefFileManagerMatCommand::DefFileManagerMatCommand(QCommandLineParser *parser) : MatCommandInterface("def-file-manager"_L1, - QSL("Get/Set the default file manager"), + u"Get/Set the default file manager"_s, parser) { Q_CHECK_PTR(parser); @@ -169,13 +169,13 @@ int DefFileManagerMatCommand::run(const QStringList & /*arguments*/) XdgDesktopFile toSetDefFileManager; if (toSetDefFileManager.load(data.defFileManagerName)) { if (XdgDefaultApps::setFileManager(toSetDefFileManager)) { - std::cout << qPrintable(QSL("Set '%1' as the default file manager\n").arg(toSetDefFileManager.fileName())); + std::cout << qPrintable(u"Set '%1' as the default file manager\n"_s.arg(toSetDefFileManager.fileName())); } else { - std::cerr << qPrintable(QSL("Could not set '%1' as the default file manager\n").arg(toSetDefFileManager.fileName())); + std::cerr << qPrintable(u"Could not set '%1' as the default file manager\n"_s.arg(toSetDefFileManager.fileName())); success = false; } } else { // could not load application file - std::cerr << qPrintable(QSL("Could not find find '%1'\n").arg(data.defFileManagerName)); + std::cerr << qPrintable(u"Could not find find '%1'\n"_s.arg(data.defFileManagerName)); success = false; } } diff --git a/src/mat/defterminalmatcommand.cpp b/src/mat/defterminalmatcommand.cpp index f43c755..5f5c66c 100644 --- a/src/mat/defterminalmatcommand.cpp +++ b/src/mat/defterminalmatcommand.cpp @@ -57,11 +57,11 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefTe parser->addPositionalArgument("def-terminal"_L1, ""_L1); - const QCommandLineOption defTerminalNameOption(QStringList() << QSL("s") << QSL("set"), - QSL("Terminal to be set as default"), QSL("terminal")); + const QCommandLineOption defTerminalNameOption(QStringList() << u"s"_s << u"set"_s, + u"Terminal to be set as default"_s, u"terminal"_s); - const QCommandLineOption listAvailableOption(QStringList() << QSL("l") << QSL("list-available"), - QSL("List available terminals")); + const QCommandLineOption listAvailableOption(QStringList() << u"l"_s << u"list-available"_s, + u"List available terminals"_s); parser->addOption(defTerminalNameOption); parser->addOption(listAvailableOption); @@ -77,7 +77,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefTe return CommandLineVersionRequested; } - if (parser->isSet(helpOption) || parser->isSet(QSL("help-all"))) { + if (parser->isSet(helpOption) || parser->isSet(u"help-all"_s)) { return CommandLineHelpRequested; } @@ -92,18 +92,18 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefTe posArgs.removeAt(0); if (isDefTerminalNameSet && !posArgs.empty()) { - *errorMessage = QSL("Extra arguments given: "); + *errorMessage = u"Extra arguments given: "_s; errorMessage->append(posArgs.join(u',')); return CommandLineError; } if (!isDefTerminalNameSet && !posArgs.empty()) { - *errorMessage = QSL("To set the default terminal use the -s/--set option"); + *errorMessage = u"To set the default terminal use the -s/--set option"_s; return CommandLineError; } if (isListAvailableSet && (isDefTerminalNameSet || !posArgs.empty())) { - *errorMessage = QSL("list-available can't be used with other options and doesn't take arguments"); + *errorMessage = u"list-available can't be used with other options and doesn't take arguments"_s; return CommandLineError; } @@ -119,7 +119,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefTe DefTerminalMatCommand::DefTerminalMatCommand(QCommandLineParser *parser) : MatCommandInterface("def-terminal"_L1, - QSL("Get/Set the default terminal"), + u"Get/Set the default terminal"_s, parser) { Q_CHECK_PTR(parser); @@ -173,13 +173,13 @@ int DefTerminalMatCommand::run(const QStringList & /*arguments*/) XdgDesktopFile toSetDefTerminal; if (toSetDefTerminal.load(data.defTerminalName)) { if (XdgDefaultApps::setTerminal(toSetDefTerminal)) { - std::cout << qPrintable(QSL("Set '%1' as the default terminal\n").arg(toSetDefTerminal.fileName())); + std::cout << qPrintable(u"Set '%1' as the default terminal\n"_s.arg(toSetDefTerminal.fileName())); } else { - std::cerr << qPrintable(QSL("Could not set '%1' as the default terminal\n").arg(toSetDefTerminal.fileName())); + std::cerr << qPrintable(u"Could not set '%1' as the default terminal\n"_s.arg(toSetDefTerminal.fileName())); success = false; } } else { // could not load application file - std::cerr << qPrintable(QSL("Could not find find '%1'\n").arg(data.defTerminalName)); + std::cerr << qPrintable(u"Could not find find '%1'\n"_s.arg(data.defTerminalName)); success = false; } } diff --git a/src/mat/defwebbrowsermatcommand.cpp b/src/mat/defwebbrowsermatcommand.cpp index 7dd99ca..12c8fe7 100644 --- a/src/mat/defwebbrowsermatcommand.cpp +++ b/src/mat/defwebbrowsermatcommand.cpp @@ -56,11 +56,11 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefWe parser->addPositionalArgument("def-web-browser"_L1, ""_L1); - const QCommandLineOption defWebBrowserNameOption(QStringList() << QSL("s") << QSL("set"), - QSL("Web Browser to be set as default"), QSL("web bowser")); + const QCommandLineOption defWebBrowserNameOption(QStringList() << u"s"_s << u"set"_s, + u"Web Browser to be set as default"_s, u"web bowser"_s); - const QCommandLineOption listAvailableOption(QStringList() << QSL("l") << QSL("list-available"), - QSL("List available web browsers")); + const QCommandLineOption listAvailableOption(QStringList() << u"l"_s << u"list-available"_s, + u"List available web browsers"_s); parser->addOption(defWebBrowserNameOption); parser->addOption(listAvailableOption); @@ -76,7 +76,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefWe return CommandLineVersionRequested; } - if (parser->isSet(helpOption) || parser->isSet(QSL("help-all"))) { + if (parser->isSet(helpOption) || parser->isSet(u"help-all"_s)) { return CommandLineHelpRequested; } @@ -91,18 +91,18 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefWe posArgs.removeAt(0); if (isDefWebBrowserNameSet && !posArgs.empty()) { - *errorMessage = QSL("Extra arguments given: "); + *errorMessage = u"Extra arguments given: "_s; errorMessage->append(posArgs.join(u',')); return CommandLineError; } if (!isDefWebBrowserNameSet && !posArgs.empty()) { - *errorMessage = QSL("To set the default browser use the -s/--set option"); + *errorMessage = u"To set the default browser use the -s/--set option"_s; return CommandLineError; } if (isListAvailableSet && (isDefWebBrowserNameSet || !posArgs.empty())) { - *errorMessage = QSL("list-available can't be used with other options and doesn't take arguments"); + *errorMessage = u"list-available can't be used with other options and doesn't take arguments"_s; return CommandLineError; } @@ -118,7 +118,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefWe DefWebBrowserMatCommand::DefWebBrowserMatCommand(QCommandLineParser *parser) : MatCommandInterface("def-web-browser"_L1, - QSL("Get/Set the default web browser"), + u"Get/Set the default web browser"_s, parser) { Q_CHECK_PTR(parser); @@ -169,13 +169,13 @@ int DefWebBrowserMatCommand::run(const QStringList & /*arguments*/) XdgDesktopFile toSetDefWebBrowser; if (toSetDefWebBrowser.load(data.defWebBrowserName)) { if (XdgDefaultApps::setWebBrowser(toSetDefWebBrowser)) { - std::cout << qPrintable(QSL("Set '%1' as the default web browser\n").arg(toSetDefWebBrowser.fileName())); + std::cout << qPrintable(u"Set '%1' as the default web browser\n"_s.arg(toSetDefWebBrowser.fileName())); } else { - std::cerr << qPrintable(QSL("Could not set '%1' as the default web browser\n").arg(toSetDefWebBrowser.fileName())); + std::cerr << qPrintable(u"Could not set '%1' as the default web browser\n"_s.arg(toSetDefWebBrowser.fileName())); success = false; } } else { // could not load application file - std::cerr << qPrintable(QSL("Could not find find '%1'\n").arg(data.defWebBrowserName)); + std::cerr << qPrintable(u"Could not find find '%1'\n"_s.arg(data.defWebBrowserName)); success = false; } } diff --git a/src/mat/mimetypematcommand.cpp b/src/mat/mimetypematcommand.cpp index 37393a5..ed15add 100644 --- a/src/mat/mimetypematcommand.cpp +++ b/src/mat/mimetypematcommand.cpp @@ -53,7 +53,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, QStri parser->clearPositionalArguments(); parser->setApplicationDescription("Determines a file (mime)type"_L1); - parser->addPositionalArgument("mimetype"_L1, QSL("file | URL"), + parser->addPositionalArgument("mimetype"_L1, u"file | URL"_s, QCoreApplication::tr("[file | URL]")); const QCommandLineOption helpOption = parser->addHelpOption(); @@ -68,20 +68,20 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, QStri return CommandLineVersionRequested; } - if (parser->isSet(helpOption) || parser->isSet(QSL("help-all"))) { + if (parser->isSet(helpOption) || parser->isSet(u"help-all"_s)) { return CommandLineHelpRequested; } QStringList fs = parser->positionalArguments(); if (fs.size() < 2) { - *errorMessage = QSL("No file given"); + *errorMessage = u"No file given"_s; return CommandLineError; } fs.removeAt(0); if (fs.size() > 1) { - *errorMessage = QSL("Only one file, please"); + *errorMessage = u"Only one file, please"_s; return CommandLineError; } *file = fs.at(0); @@ -127,7 +127,7 @@ int MimeTypeMatCommand::run(const QStringList &arguments) if (isLocalFile) { const QFileInfo info(file); if (!info.exists(localFilename)) { - std::cerr << qPrintable(QSL("Cannot access '%1': No such file or directory\n").arg(file)); + std::cerr << qPrintable(u"Cannot access '%1': No such file or directory\n"_s.arg(file)); return EXIT_FAILURE; } else { QMimeDatabase mimeDb; @@ -136,7 +136,7 @@ int MimeTypeMatCommand::run(const QStringList &arguments) return EXIT_SUCCESS; } } else { // not a local file - std::cerr << qPrintable(QSL("Can't handle '%1': '%2' scheme not supported\n").arg(file, scheme)); + std::cerr << qPrintable(u"Can't handle '%1': '%2' scheme not supported\n"_s.arg(file, scheme)); return EXIT_FAILURE; } } diff --git a/src/mat/openmatcommand.cpp b/src/mat/openmatcommand.cpp index 369ffec..4863e18 100644 --- a/src/mat/openmatcommand.cpp +++ b/src/mat/openmatcommand.cpp @@ -42,7 +42,7 @@ using namespace Qt::Literals::StringLiterals; OpenMatCommand::OpenMatCommand(QCommandLineParser *parser) : MatCommandInterface("open"_L1, - QSL("Open files with the default application"), + u"Open files with the default application"_s, parser) { } @@ -54,7 +54,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, QStri parser->clearPositionalArguments(); parser->setApplicationDescription("Open files with the default application"_L1); - parser->addPositionalArgument("open"_L1, QSL("files | URLs"), + parser->addPositionalArgument("open"_L1, u"files | URLs"_s, QCoreApplication::tr("[files | URLs]")); const QCommandLineOption helpOption = parser->addHelpOption(); @@ -69,13 +69,13 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, QStri return CommandLineVersionRequested; } - if (parser->isSet(helpOption) || parser->isSet(QSL("help-all"))) { + if (parser->isSet(helpOption) || parser->isSet(u"help-all"_s)) { return CommandLineHelpRequested; } QStringList fs = parser->positionalArguments(); if (fs.size() < 2) { - *errorMessage = QSL("No file or URL given"); + *errorMessage = u"No file or URL given"_s; return CommandLineError; } @@ -129,7 +129,7 @@ int OpenMatCommand::run(const QStringList &arguments) if (isLocalFile) { const QFileInfo f (localFilename); if (!f.exists()) { - std::cerr << qPrintable(QSL("Cannot access %1: No such file or directory\n").arg(urlString)); + std::cerr << qPrintable(u"Cannot access %1: No such file or directory\n"_s.arg(urlString)); break; } else { const QMimeType mimeType = mimeDb.mimeTypeForFile(f); @@ -143,13 +143,13 @@ int OpenMatCommand::run(const QStringList &arguments) if (df) { // default app found if (!df->startDetached(isLocalFile ? localFilename : urlString)) { std::cerr << qPrintable( - QSL("Error while running the default application (%1) for %2\n").arg(df->name(), urlString)); + u"Error while running the default application (%1) for %2\n"_s.arg(df->name(), urlString)); success = false; } delete df; df = nullptr; } else { // no default app found - std::cout << qPrintable(QSL("No default application for '%1'\n").arg(urlString)); + std::cout << qPrintable(u"No default application for '%1'\n"_s.arg(urlString)); } } return success ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/src/mat/qtxdg-mat.cpp b/src/mat/qtxdg-mat.cpp index bbc9bf1..af1152b 100644 --- a/src/mat/qtxdg-mat.cpp +++ b/src/mat/qtxdg-mat.cpp @@ -34,6 +34,8 @@ #include #include +using namespace Qt::Literals::StringLiterals; + extern void Q_CORE_EXPORT qt_call_post_routines(); [[noreturn]] void showHelp(const QString &parserHelp, const QString &commandsDescription, int exitCode = 0); @@ -58,16 +60,16 @@ int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); int runResult = 0; - app.setApplicationName(QSL("qtxdg-mat")); - app.setApplicationVersion(QSL(QTXDG_TOOLS_VERSION)); - app.setOrganizationName(QSL("LXQt")); - app.setOrganizationDomain(QSL("lxqt.org")); + app.setApplicationName(u"qtxdg-mat"_s); + app.setApplicationVersion(QStringLiteral(QTXDG_TOOLS_VERSION)); + app.setOrganizationName(u"LXQt"_s); + app.setOrganizationDomain(u"lxqt.org"_s); QCommandLineParser parser; - parser.setApplicationDescription(QSL("QtXdg MimeApps Tool")); + parser.setApplicationDescription(u"QtXdg MimeApps Tool"_s); - parser.addPositionalArgument(QSL("command"), - QSL("Command to execute.")); + parser.addPositionalArgument(u"command"_s, + u"Command to execute."_s); QScopedPointer manager(new MatCommandManager()); @@ -99,7 +101,7 @@ int main(int argc, char *argv[]) const QCommandLineOption helpOption = parser.addHelpOption(); const QCommandLineOption versionOption = parser.addVersionOption(); parser.parse(QCoreApplication::arguments()); - if (parser.isSet(helpOption) || parser.isSet(QSL("help-all"))) { + if (parser.isSet(helpOption) || parser.isSet(u"help-all"_s)) { showHelp(parser.helpText(), manager->descriptionsHelpText(), EXIT_SUCCESS); Q_UNREACHABLE(); } From dfdfd1c8f42eb3b7bc01ae245ffee92075b66ce2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Pereira?= Date: Mon, 18 Nov 2024 16:03:28 +0000 Subject: [PATCH 4/6] Make use of QStringLiteral data sharing capabilities QStringLiteral can now share data with the same content. --- src/mat/defappmatcommand.cpp | 8 ++++---- src/mat/defemailclientmatcommand.cpp | 6 +++--- src/mat/deffilemanagermatcommand.cpp | 6 +++--- src/mat/defterminalmatcommand.cpp | 6 +++--- src/mat/defwebbrowsermatcommand.cpp | 6 +++--- src/mat/mimetypematcommand.cpp | 8 ++++---- src/mat/openmatcommand.cpp | 6 +++--- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/mat/defappmatcommand.cpp b/src/mat/defappmatcommand.cpp index 30f4706..fa97bde 100644 --- a/src/mat/defappmatcommand.cpp +++ b/src/mat/defappmatcommand.cpp @@ -50,9 +50,9 @@ struct DefAppData { static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefAppData *data, QString *errorMessage) { parser->clearPositionalArguments(); - parser->setApplicationDescription("Get/Set the default application for a mimetype"_L1); + parser->setApplicationDescription(u"Get/Set the default application for a mimetype"_s); - parser->addPositionalArgument("defapp"_L1, u"mimetype(s)"_s, + parser->addPositionalArgument(u"defapp"_s, u"mimetype(s)"_s, QCoreApplication::tr("[mimetype(s)...]")); const QCommandLineOption defAppNameOption(QStringList() << u"s"_s << u"set"_s, @@ -108,8 +108,8 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefAp } DefAppMatCommand::DefAppMatCommand(QCommandLineParser *parser) - : MatCommandInterface("defapp"_L1, - "Get/Set the default application for a mimetype"_L1, + : MatCommandInterface(u"defapp"_s, + u"Get/Set the default application for a mimetype"_s, parser) { Q_CHECK_PTR(parser); diff --git a/src/mat/defemailclientmatcommand.cpp b/src/mat/defemailclientmatcommand.cpp index 7312477..89b30d7 100644 --- a/src/mat/defemailclientmatcommand.cpp +++ b/src/mat/defemailclientmatcommand.cpp @@ -52,9 +52,9 @@ struct DefEmailClientData { static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefEmailClientData *data, QString *errorMessage) { parser->clearPositionalArguments(); - parser->setApplicationDescription("Get/Set the default email client"_L1); + parser->setApplicationDescription(u"Get/Set the default email client"_s); - parser->addPositionalArgument("def-email-client"_L1, ""_L1); + parser->addPositionalArgument(u"def-email-client"_s, ""_L1); const QCommandLineOption defEmailClientNameOption(QStringList() << u"s"_s << u"set"_s, u"Email Client to be set as default"_s, u"email client"_s); @@ -117,7 +117,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefEm } DefEmailClientMatCommand::DefEmailClientMatCommand(QCommandLineParser *parser) - : MatCommandInterface("def-email-client"_L1, + : MatCommandInterface(u"def-email-client"_s, u"Get/Set the default email client"_s, parser) { diff --git a/src/mat/deffilemanagermatcommand.cpp b/src/mat/deffilemanagermatcommand.cpp index 6d4e6cc..3144293 100644 --- a/src/mat/deffilemanagermatcommand.cpp +++ b/src/mat/deffilemanagermatcommand.cpp @@ -52,9 +52,9 @@ struct DefFileManagerData { static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefFileManagerData *data, QString *errorMessage) { parser->clearPositionalArguments(); - parser->setApplicationDescription("Get/Set the default file manager"_L1); + parser->setApplicationDescription(u"Get/Set the default file manager"_s); - parser->addPositionalArgument("def-file-manager"_L1, ""_L1); + parser->addPositionalArgument(u"def-file-manager"_s, ""_L1); const QCommandLineOption defFileManagerNameOption(QStringList() << u"s"_s << u"set"_s, u"File Manager to be set as default"_s, u"file manager"_s); @@ -117,7 +117,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefFi } DefFileManagerMatCommand::DefFileManagerMatCommand(QCommandLineParser *parser) - : MatCommandInterface("def-file-manager"_L1, + : MatCommandInterface(u"def-file-manager"_s, u"Get/Set the default file manager"_s, parser) { diff --git a/src/mat/defterminalmatcommand.cpp b/src/mat/defterminalmatcommand.cpp index 5f5c66c..8fea7da 100644 --- a/src/mat/defterminalmatcommand.cpp +++ b/src/mat/defterminalmatcommand.cpp @@ -53,9 +53,9 @@ struct DefTerminalData { static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefTerminalData *data, QString *errorMessage) { parser->clearPositionalArguments(); - parser->setApplicationDescription("Get/Set the default terminal"_L1); + parser->setApplicationDescription(u"Get/Set the default terminal"_s); - parser->addPositionalArgument("def-terminal"_L1, ""_L1); + parser->addPositionalArgument(u"def-terminal"_s, ""_L1); const QCommandLineOption defTerminalNameOption(QStringList() << u"s"_s << u"set"_s, u"Terminal to be set as default"_s, u"terminal"_s); @@ -118,7 +118,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefTe } DefTerminalMatCommand::DefTerminalMatCommand(QCommandLineParser *parser) - : MatCommandInterface("def-terminal"_L1, + : MatCommandInterface(u"def-terminal"_s, u"Get/Set the default terminal"_s, parser) { diff --git a/src/mat/defwebbrowsermatcommand.cpp b/src/mat/defwebbrowsermatcommand.cpp index 12c8fe7..9f6764e 100644 --- a/src/mat/defwebbrowsermatcommand.cpp +++ b/src/mat/defwebbrowsermatcommand.cpp @@ -52,9 +52,9 @@ struct DefWebBrowserData { static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefWebBrowserData *data, QString *errorMessage) { parser->clearPositionalArguments(); - parser->setApplicationDescription("Get/Set the default web browser"_L1); + parser->setApplicationDescription(u"Get/Set the default web browser"_s); - parser->addPositionalArgument("def-web-browser"_L1, ""_L1); + parser->addPositionalArgument(u"def-web-browser"_s, ""_L1); const QCommandLineOption defWebBrowserNameOption(QStringList() << u"s"_s << u"set"_s, u"Web Browser to be set as default"_s, u"web bowser"_s); @@ -117,7 +117,7 @@ static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, DefWe } DefWebBrowserMatCommand::DefWebBrowserMatCommand(QCommandLineParser *parser) - : MatCommandInterface("def-web-browser"_L1, + : MatCommandInterface(u"def-web-browser"_s, u"Get/Set the default web browser"_s, parser) { diff --git a/src/mat/mimetypematcommand.cpp b/src/mat/mimetypematcommand.cpp index ed15add..1195ed2 100644 --- a/src/mat/mimetypematcommand.cpp +++ b/src/mat/mimetypematcommand.cpp @@ -40,8 +40,8 @@ using namespace Qt::Literals::StringLiterals; MimeTypeMatCommand::MimeTypeMatCommand(QCommandLineParser *parser) - : MatCommandInterface("mimetype"_L1, - "Determines a file (mime)type"_L1, + : MatCommandInterface(u"mimetype"_s, + u"Determines a file (mime)type"_s, parser) { } @@ -51,9 +51,9 @@ MimeTypeMatCommand::~MimeTypeMatCommand() = default; static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, QString *file, QString *errorMessage) { parser->clearPositionalArguments(); - parser->setApplicationDescription("Determines a file (mime)type"_L1); + parser->setApplicationDescription(u"Determines a file (mime)type"_s); - parser->addPositionalArgument("mimetype"_L1, u"file | URL"_s, + parser->addPositionalArgument(u"mimetype"_s, u"file | URL"_s, QCoreApplication::tr("[file | URL]")); const QCommandLineOption helpOption = parser->addHelpOption(); diff --git a/src/mat/openmatcommand.cpp b/src/mat/openmatcommand.cpp index 4863e18..760853c 100644 --- a/src/mat/openmatcommand.cpp +++ b/src/mat/openmatcommand.cpp @@ -41,7 +41,7 @@ using namespace Qt::Literals::StringLiterals; OpenMatCommand::OpenMatCommand(QCommandLineParser *parser) - : MatCommandInterface("open"_L1, + : MatCommandInterface(u"open"_s, u"Open files with the default application"_s, parser) { @@ -52,9 +52,9 @@ OpenMatCommand::~OpenMatCommand() = default; static CommandLineParseResult parseCommandLine(QCommandLineParser *parser, QStringList *files, QString *errorMessage) { parser->clearPositionalArguments(); - parser->setApplicationDescription("Open files with the default application"_L1); + parser->setApplicationDescription(u"Open files with the default application"_s); - parser->addPositionalArgument("open"_L1, u"files | URLs"_s, + parser->addPositionalArgument(u"open"_s, u"files | URLs"_s, QCoreApplication::tr("[files | URLs]")); const QCommandLineOption helpOption = parser->addHelpOption(); From 81d99c2a00def607c8662e09d5666980aa1c456c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Pereira?= Date: Mon, 18 Nov 2024 22:32:30 +0000 Subject: [PATCH 5/6] Remove xdgmacros header usage --- src/mat/defappmatcommand.cpp | 1 - src/mat/defemailclientmatcommand.cpp | 1 - src/mat/deffilemanagermatcommand.cpp | 1 - src/mat/defterminalmatcommand.cpp | 1 - src/mat/defwebbrowsermatcommand.cpp | 1 - src/mat/matcommandinterface.cpp | 2 -- src/mat/matcommandmanager.cpp | 2 -- src/mat/mimetypematcommand.cpp | 1 - src/mat/openmatcommand.cpp | 1 - src/mat/qtxdg-mat.cpp | 2 -- 10 files changed, 13 deletions(-) diff --git a/src/mat/defappmatcommand.cpp b/src/mat/defappmatcommand.cpp index fa97bde..5dff106 100644 --- a/src/mat/defappmatcommand.cpp +++ b/src/mat/defappmatcommand.cpp @@ -22,7 +22,6 @@ #include "matglobals.h" #include "xdgdesktopfile.h" -#include "xdgmacros.h" #include "xdgmimeapps.h" #include diff --git a/src/mat/defemailclientmatcommand.cpp b/src/mat/defemailclientmatcommand.cpp index 89b30d7..f6624a1 100644 --- a/src/mat/defemailclientmatcommand.cpp +++ b/src/mat/defemailclientmatcommand.cpp @@ -21,7 +21,6 @@ #include "defemailclientmatcommand.h" #include "matglobals.h" -#include "xdgmacros.h" #include "xdgdefaultapps.h" #include "xdgdesktopfile.h" diff --git a/src/mat/deffilemanagermatcommand.cpp b/src/mat/deffilemanagermatcommand.cpp index 3144293..48dfb67 100644 --- a/src/mat/deffilemanagermatcommand.cpp +++ b/src/mat/deffilemanagermatcommand.cpp @@ -21,7 +21,6 @@ #include "deffilemanagermatcommand.h" #include "matglobals.h" -#include "xdgmacros.h" #include "xdgdefaultapps.h" #include "xdgdesktopfile.h" diff --git a/src/mat/defterminalmatcommand.cpp b/src/mat/defterminalmatcommand.cpp index 8fea7da..9290aa3 100644 --- a/src/mat/defterminalmatcommand.cpp +++ b/src/mat/defterminalmatcommand.cpp @@ -21,7 +21,6 @@ #include "defterminalmatcommand.h" #include "matglobals.h" -#include "xdgmacros.h" #include "xdgdefaultapps.h" #include "xdgdesktopfile.h" diff --git a/src/mat/defwebbrowsermatcommand.cpp b/src/mat/defwebbrowsermatcommand.cpp index 9f6764e..ce947dd 100644 --- a/src/mat/defwebbrowsermatcommand.cpp +++ b/src/mat/defwebbrowsermatcommand.cpp @@ -21,7 +21,6 @@ #include "defwebbrowsermatcommand.h" #include "matglobals.h" -#include "xdgmacros.h" #include "xdgdefaultapps.h" #include "xdgdesktopfile.h" diff --git a/src/mat/matcommandinterface.cpp b/src/mat/matcommandinterface.cpp index 7408eac..57382bc 100644 --- a/src/mat/matcommandinterface.cpp +++ b/src/mat/matcommandinterface.cpp @@ -20,8 +20,6 @@ #include "matcommandinterface.h" -#include "xdgmacros.h" - #include MatCommandInterface::MatCommandInterface(const QString &name, const QString &description, QCommandLineParser *parser) diff --git a/src/mat/matcommandmanager.cpp b/src/mat/matcommandmanager.cpp index f170b06..f9ec9fa 100644 --- a/src/mat/matcommandmanager.cpp +++ b/src/mat/matcommandmanager.cpp @@ -20,8 +20,6 @@ #include "matcommandmanager.h" -#include "xdgmacros.h" - #include "matcommandinterface.h" #include diff --git a/src/mat/mimetypematcommand.cpp b/src/mat/mimetypematcommand.cpp index 1195ed2..8ba0942 100644 --- a/src/mat/mimetypematcommand.cpp +++ b/src/mat/mimetypematcommand.cpp @@ -20,7 +20,6 @@ #include "mimetypematcommand.h" #include "matglobals.h" -#include "xdgmacros.h" #include "xdgdesktopfile.h" #include "xdgmimeapps.h" diff --git a/src/mat/openmatcommand.cpp b/src/mat/openmatcommand.cpp index 760853c..ba7021e 100644 --- a/src/mat/openmatcommand.cpp +++ b/src/mat/openmatcommand.cpp @@ -21,7 +21,6 @@ #include "openmatcommand.h" #include "matglobals.h" -#include "xdgmacros.h" #include "xdgdesktopfile.h" #include "xdgmimeapps.h" diff --git a/src/mat/qtxdg-mat.cpp b/src/mat/qtxdg-mat.cpp index af1152b..e8b8fa0 100644 --- a/src/mat/qtxdg-mat.cpp +++ b/src/mat/qtxdg-mat.cpp @@ -27,8 +27,6 @@ #include "deffilemanagermatcommand.h" #include "defterminalmatcommand.h" -#include "xdgmacros.h" - #include #include #include From 86b353e0d0da56be4dbd5f36d747db1854ab1fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Pereira?= Date: Fri, 22 Nov 2024 15:20:26 +0000 Subject: [PATCH 6/6] Drop QString::fromLatin() where possible --- src/mat/openmatcommand.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mat/openmatcommand.cpp b/src/mat/openmatcommand.cpp index ba7021e..dc01bb1 100644 --- a/src/mat/openmatcommand.cpp +++ b/src/mat/openmatcommand.cpp @@ -135,7 +135,7 @@ int OpenMatCommand::run(const QStringList &arguments) df = appsDb.defaultApp(mimeType.name()); } } else { // not a local file - const QString contentType = QString::fromLatin1("x-scheme-handler/%1").arg(scheme); + const QString contentType = u"x-scheme-handler/%1"_s.arg(scheme); df = appsDb.defaultApp(contentType); }