From 9a443cda41285ed83fa374252e2b0441e5b9c00f Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Wed, 5 Dec 2018 16:38:02 -0500 Subject: [PATCH] Simplify sending glabels-batch output to stdout. (#27) --- glabels-batch/main.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/glabels-batch/main.cpp b/glabels-batch/main.cpp index 3a8b4e0..e857f44 100644 --- a/glabels-batch/main.cpp +++ b/glabels-batch/main.cpp @@ -39,6 +39,20 @@ #include +namespace +{ + +#if defined(Q_OS_WIN) + const QString STDOUT_FILENAME = "CON:"; +#elif defined(Q_OS_LINUX) + const QString STDOUT_FILENAME = "/dev/stdout"; +#else + const QString STDOUT_FILENAME = "/dev/stdout"; +#endif + +} + + int main( int argc, char **argv ) { QGuiApplication app( argc, argv ); @@ -84,7 +98,7 @@ int main( int argc, char **argv ) QPrinterInfo::defaultPrinterName() }, {{"o","output"}, - QCoreApplication::translate( "main", "Set output filename to . (Default=\"output.pdf\")" ), + QCoreApplication::translate( "main", "Set output filename to . Set to \"-\" for stdout. (Default=\"output.pdf\")" ), QCoreApplication::translate( "main", "filename" ), "output.pdf" }, @@ -147,8 +161,13 @@ int main( int argc, char **argv ) } else if ( parser.isSet("output") ) { - qDebug() << "Batch mode. output =" << parser.value("output"); - printer.setOutputFileName( parser.value("output") ); + QString outputFilename = parser.value("output"); + if ( outputFilename == "-" ) + { + outputFilename = STDOUT_FILENAME; + } + qDebug() << "Batch mode. output =" << outputFilename; + printer.setOutputFileName( outputFilename ); } else {