From 148670647166f23873438e052e09b5a4c23d47f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Fern=C3=A1ndez?= Date: Fri, 13 Jul 2018 03:27:09 +0200 Subject: [PATCH] [fix two simple, announced main.cpp bugs] 1. log qDebug et al to stdout 2. use 'noquote' for qDebug --- app/main.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 28c71e1..2a422fd 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -1,3 +1,5 @@ +#include + #include #include @@ -23,8 +25,20 @@ QString getNamedArgument(QStringList args, QString name) return getNamedArgument(args, name, ""); } +void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) +{ + (void) type; + (void) context; + std::cout << msg.toStdString() << std::endl; +} + + int main(int argc, char *argv[]) { + // Install message handler + qInstallMessageHandler(messageHandler); + + // Some environmental variable are necessary on certain platforms. // This disables QT appmenu under Ubuntu, which is not working with QML apps. @@ -51,10 +65,9 @@ int main(int argc, char *argv[]) // Manage command line arguments from the cpp side QStringList args = app.arguments(); - if (args.contains("-h") || args.contains("--help")) { - // BUG: This usage help text goes to stderr, should go to stdout. - // BUG: First line of output is surrounded by double quotes. - qDebug() << "Usage: " + args.at(0) + " [--default-settings] [--workdir ] [--program ] [-p|--profile ] [--fullscreen] [-h|--help]"; + if (args.contains("-h") || args.contains("--help")) + { + qDebug().noquote() << "Usage: " + args.at(0) + " [--default-settings] [--workdir ] [--program ] [-p|--profile ] [--fullscreen] [-h|--help]"; qDebug() << " --default-settings Run cool-retro-term with the default settings"; qDebug() << " --workdir Change working directory to 'dir'"; qDebug() << " -e Command to execute. This option will catch all following arguments, so use it as the last option."; -- 2.52.0