diff --git a/tools/ld-analyse/main.cpp b/tools/ld-analyse/main.cpp index 5def2b4e8..9b345843a 100644 --- a/tools/ld-analyse/main.cpp +++ b/tools/ld-analyse/main.cpp @@ -53,10 +53,8 @@ int main(int argc, char *argv[]) parser.addHelpOption(); parser.addVersionOption(); - // Option to show debug (-d) - QCommandLineOption showDebugOption(QStringList() << "d" << "debug", - QCoreApplication::translate("main", "Show debug")); - parser.addOption(showDebugOption); + // Add the standard debug options --debug and --quiet + addStandardDebugOptions(parser); // Positional argument to specify input video file parser.addPositionalArgument("input", QCoreApplication::translate("main", "Specify input TBC file")); @@ -64,11 +62,8 @@ int main(int argc, char *argv[]) // Process the command line arguments given by the user parser.process(a); - // Get the configured settings from the parser - bool isDebugOn = parser.isSet(showDebugOption); - - // Process the command line options - if (isDebugOn) setDebug(true); else setDebug(false); + // Standard logging options + processStandardDebugOptions(parser); // Get the arguments from the parser QString inputFileName; diff --git a/tools/ld-chroma-decoder/main.cpp b/tools/ld-chroma-decoder/main.cpp index b9e37b8f7..184e7c6b5 100644 --- a/tools/ld-chroma-decoder/main.cpp +++ b/tools/ld-chroma-decoder/main.cpp @@ -120,10 +120,8 @@ int main(int argc, char *argv[]) // -- General options -- - // Option to show debug (-d) - QCommandLineOption showDebugOption(QStringList() << "d" << "debug", - QCoreApplication::translate("main", "Show debug")); - parser.addOption(showDebugOption); + // Add the standard debug options --debug and --quiet + addStandardDebugOptions(parser); // Option to specify a different JSON input file QCommandLineOption inputJsonOption(QStringList() << "input-json", @@ -153,11 +151,6 @@ int main(int argc, char *argv[]) QCoreApplication::translate("main", "Output in black and white")); parser.addOption(setBwModeOption); - // Option to set quiet mode (-q) - QCommandLineOption setQuietOption(QStringList() << "q" << "quiet", - QCoreApplication::translate("main", "Suppress info and warning messages")); - parser.addOption(setQuietOption); - // Option to select which decoder to use (-f) QCommandLineOption decoderOption(QStringList() << "f" << "decoder", QCoreApplication::translate("main", "Decoder to use (pal2d, transform2d, transform3d, ntsc2d, ntsc3d, mono; default automatic)"), @@ -224,9 +217,8 @@ int main(int argc, char *argv[]) // Process the command line options and arguments given by the user parser.process(a); - // Get the debug options from the parser - if (parser.isSet(showDebugOption)) setDebug(true); else setDebug(false); - if (parser.isSet(setQuietOption)) setQuiet(true); else setQuiet(false); + // Standard logging options + processStandardDebugOptions(parser); // Get the arguments from the parser QString inputFileName; diff --git a/tools/ld-diffdod/main.cpp b/tools/ld-diffdod/main.cpp index f46d3125b..746dc233b 100644 --- a/tools/ld-diffdod/main.cpp +++ b/tools/ld-diffdod/main.cpp @@ -53,10 +53,8 @@ int main(int argc, char *argv[]) parser.addHelpOption(); parser.addVersionOption(); - // Option to show debug (-d / --debug) - QCommandLineOption showDebugOption(QStringList() << "d" << "debug", - QCoreApplication::translate("main", "Show debug")); - parser.addOption(showDebugOption); + // Add the standard debug options --debug and --quiet + addStandardDebugOptions(parser); // Option to reverse the field order (-r / --reverse) QCommandLineOption setReverseOption(QStringList() << "r" << "reverse", @@ -92,14 +90,13 @@ int main(int argc, char *argv[]) // Process the command line options and arguments given by the user parser.process(a); + // Standard logging options + processStandardDebugOptions(parser); + // Get the options from the parser - bool isDebugOn = parser.isSet(showDebugOption); bool reverse = parser.isSet(setReverseOption); bool lumaClip = parser.isSet(setLumaOption); - // Process the command line options - if (isDebugOn) setDebug(true); else setDebug(false); - QVector inputFilenames; QStringList positionalArguments = parser.positionalArguments(); diff --git a/tools/ld-dropout-correct/main.cpp b/tools/ld-dropout-correct/main.cpp index 617604bd1..3d296fd84 100644 --- a/tools/ld-dropout-correct/main.cpp +++ b/tools/ld-dropout-correct/main.cpp @@ -55,10 +55,8 @@ int main(int argc, char *argv[]) parser.addHelpOption(); parser.addVersionOption(); - // Option to show debug (-d) - QCommandLineOption showDebugOption(QStringList() << "d" << "debug", - QCoreApplication::translate("main", "Show debug")); - parser.addOption(showDebugOption); + // Add the standard debug options --debug and --quiet + addStandardDebugOptions(parser); // Option to specify a different JSON input file QCommandLineOption inputJsonOption(QStringList() << "input-json", @@ -105,8 +103,10 @@ int main(int argc, char *argv[]) // Process the command line options and arguments given by the user ----------------------------------------------- parser.process(a); + // Standard logging options + processStandardDebugOptions(parser); + // Get the options from the parser - bool isDebugOn = parser.isSet(showDebugOption); bool reverse = parser.isSet(setReverseOption); bool intraField = parser.isSet(setIntrafieldOption); bool overCorrect = parser.isSet(setOverCorrectOption); @@ -188,9 +188,6 @@ int main(int argc, char *argv[]) } } - // Process the command line options - if (isDebugOn) setDebug(true); else setDebug(false); - // Metadata filename for output TBC QString outputJsonFilename = outputFilename + ".json"; if (parser.isSet(outputJsonOption)) { diff --git a/tools/ld-export-metadata/main.cpp b/tools/ld-export-metadata/main.cpp index d1c83820f..20793aaf8 100644 --- a/tools/ld-export-metadata/main.cpp +++ b/tools/ld-export-metadata/main.cpp @@ -58,15 +58,8 @@ int main(int argc, char *argv[]) // -- General options -- - // Option to show debug (-d) - QCommandLineOption showDebugOption({"d", "debug"}, - QCoreApplication::translate("main", "Show debug")); - parser.addOption(showDebugOption); - - // Option to set quiet mode (-q) - QCommandLineOption setQuietOption({"q", "quiet"}, - QCoreApplication::translate("main", "Suppress info and warning messages")); - parser.addOption(setQuietOption); + // Add the standard debug options --debug and --quiet + addStandardDebugOptions(parser); // -- Output types -- @@ -93,9 +86,8 @@ int main(int argc, char *argv[]) // Process the command line options and arguments given by the user parser.process(a); - // Get the options from the parser - if (parser.isSet(showDebugOption)) setDebug(true); else setDebug(false); - if (parser.isSet(setQuietOption)) setQuiet(true); else setQuiet(false); + // Standard logging options + processStandardDebugOptions(parser); // Get the arguments from the parser QString inputFileName; diff --git a/tools/ld-lds-converter/main.cpp b/tools/ld-lds-converter/main.cpp index 07c9f923d..249960bf0 100644 --- a/tools/ld-lds-converter/main.cpp +++ b/tools/ld-lds-converter/main.cpp @@ -53,10 +53,8 @@ int main(int argc, char *argv[]) parser.addHelpOption(); parser.addVersionOption(); - // Option to show debug (-d) - QCommandLineOption showDebugOption(QStringList() << "d" << "debug", - QCoreApplication::translate("main", "Show debug")); - parser.addOption(showDebugOption); + // Add the standard debug options --debug and --quiet + addStandardDebugOptions(parser); // Option to specify input video file (-i) QCommandLineOption sourceVideoFileOption(QStringList() << "i" << "input", @@ -83,16 +81,15 @@ int main(int argc, char *argv[]) // Process the command line arguments given by the user parser.process(a); + // Standard logging options + processStandardDebugOptions(parser); + // Get the configured settings from the parser - bool isDebugOn = parser.isSet(showDebugOption); bool isUnpacking = parser.isSet(showUnpackOption); bool isPacking = parser.isSet(showPackOption); QString inputFileName = parser.value(sourceVideoFileOption); QString outputFileName = parser.value(targetVideoFileOption); - // Process the command line options - if (isDebugOn) setDebug(true); else setDebug(false); - bool modeUnpack = true; if (isPacking) modeUnpack = false; diff --git a/tools/ld-process-efm/main.cpp b/tools/ld-process-efm/main.cpp index e712a6155..476780c71 100644 --- a/tools/ld-process-efm/main.cpp +++ b/tools/ld-process-efm/main.cpp @@ -53,12 +53,10 @@ int main(int argc, char *argv[]) parser.addHelpOption(); parser.addVersionOption(); - // Option to show debug (-d / --debug) - QCommandLineOption showDebugOption(QStringList() << "d" << "debug", - QCoreApplication::translate("main", "Show debug")); - parser.addOption(showDebugOption); + // Add the standard debug options --debug and --quiet + addStandardDebugOptions(parser); - // Option to show debug (-d / --debug) + // Option to run in non-interactive mode (-n / --noninteractive) QCommandLineOption nonInteractiveOption(QStringList() << "n" << "noninteractive", QCoreApplication::translate("main", "Run in non-interactive mode")); parser.addOption(nonInteractiveOption); @@ -74,13 +72,12 @@ int main(int argc, char *argv[]) // Process the command line options and arguments given by the user parser.process(a); + // Standard logging options + processStandardDebugOptions(parser); + // Get the options from the parser - bool isDebugOn = parser.isSet(showDebugOption); bool isNonInteractiveOn = parser.isSet(nonInteractiveOption); - // Process the command line options - if (isDebugOn) setDebug(true); else setDebug(false); - // Get the arguments from the parser QString inputEfmFilename; QString outputAudioFilename; @@ -100,7 +97,7 @@ int main(int argc, char *argv[]) } // Start the GUI application - MainWindow w(isDebugOn, isNonInteractiveOn, outputAudioFilename); + MainWindow w(getDebugState(), isNonInteractiveOn, outputAudioFilename); if (!inputEfmFilename.isEmpty()) { // Load the file to decode if (!w.loadInputEfmFile(inputEfmFilename)) { diff --git a/tools/ld-process-vbi/main.cpp b/tools/ld-process-vbi/main.cpp index 2f1d50549..8bba39437 100644 --- a/tools/ld-process-vbi/main.cpp +++ b/tools/ld-process-vbi/main.cpp @@ -54,10 +54,8 @@ int main(int argc, char *argv[]) parser.addHelpOption(); parser.addVersionOption(); - // Option to show debug (-d) - QCommandLineOption showDebugOption(QStringList() << "d" << "debug", - QCoreApplication::translate("main", "Show debug")); - parser.addOption(showDebugOption); + // Add the standard debug options --debug and --quiet + addStandardDebugOptions(parser); // Option to specify a different JSON input file QCommandLineOption inputJsonOption(QStringList() << "input-json", @@ -88,8 +86,10 @@ int main(int argc, char *argv[]) // Process the command line options and arguments given by the user parser.process(a); + // Standard logging options + processStandardDebugOptions(parser); + // Get the options from the parser - bool isDebugOn = parser.isSet(showDebugOption); bool noBackup = parser.isSet(showNoBackupOption); qint32 maxThreads = QThread::idealThreadCount(); @@ -114,9 +114,6 @@ int main(int argc, char *argv[]) return -1; } - // Process the command line options - if (isDebugOn) setDebug(true); else setDebug(false); - // Work out the metadata filenames QString inputJsonFilename = inputFilename + ".json"; if (parser.isSet(inputJsonOption)) { diff --git a/tools/library/tbc/logging.cpp b/tools/library/tbc/logging.cpp index 357aa4ea9..592f0663b 100644 --- a/tools/library/tbc/logging.cpp +++ b/tools/library/tbc/logging.cpp @@ -130,3 +130,9 @@ void processStandardDebugOptions(QCommandLineParser &parser) if (parser.isSet(showDebugOption)) setDebug(true); else setDebug(false); if (parser.isSet(setQuietOption)) setQuiet(true); else setQuiet(false); } + +// Method to get the current debug logging state +bool getDebugState() +{ + return showDebug; +} diff --git a/tools/library/tbc/logging.h b/tools/library/tbc/logging.h index 4bdffe8a4..abf02eba0 100644 --- a/tools/library/tbc/logging.h +++ b/tools/library/tbc/logging.h @@ -39,5 +39,6 @@ void openDebugFile(QString filename); void closeDebugFile(void); void addStandardDebugOptions(QCommandLineParser &parser); void processStandardDebugOptions(QCommandLineParser &parser); +bool getDebugState(); #endif // LOGGING_H