From 4ff2de0567dceb07c528e4b2c2d9646762037c8a Mon Sep 17 00:00:00 2001 From: fourtf Date: Sat, 13 Mar 2021 12:14:40 +0100 Subject: [PATCH] now attaches to parent console on windows --- chatterino.pro | 2 ++ src/common/Args.cpp | 13 ++++++++++++- src/common/Args.hpp | 1 + src/main.cpp | 8 ++++++++ 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/chatterino.pro b/chatterino.pro index aca8aa2d9..97afa8ac9 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -232,6 +232,7 @@ SOURCES += \ src/singletons/TooltipPreviewImage.cpp \ src/singletons/Updates.cpp \ src/singletons/WindowManager.cpp \ + src/util/AttachToConsole.cpp \ src/util/Clipboard.cpp \ src/util/DebugCount.cpp \ src/util/FormatTime.cpp \ @@ -464,6 +465,7 @@ HEADERS += \ src/singletons/TooltipPreviewImage.hpp \ src/singletons/Updates.hpp \ src/singletons/WindowManager.hpp \ + src/util/AttachToConsole.hpp \ src/util/Clamp.hpp \ src/util/Clipboard.hpp \ src/util/CombinePath.hpp \ diff --git a/src/common/Args.cpp b/src/common/Args.cpp index 93fb8e697..364c1a919 100644 --- a/src/common/Args.cpp +++ b/src/common/Args.cpp @@ -7,6 +7,7 @@ #include "common/QLogging.hpp" #include "singletons/Paths.hpp" #include "singletons/WindowManager.hpp" +#include "util/AttachToConsole.hpp" #include "util/CombinePath.hpp" #include "widgets/Window.hpp" @@ -26,10 +27,17 @@ Args::Args(const QApplication &app) QCommandLineOption parentWindowOption("parent-window"); parentWindowOption.setFlags(QCommandLineOption::HiddenFromHelp); + // Verbose + QCommandLineOption verboseOption({{"v", "verbose"}, + "Attaches to the Console on windows, " + "allowing you to see debug output."}); + crashRecoveryOption.setFlags(QCommandLineOption::HiddenFromHelp); + parser.addOptions({ {{"V", "version"}, "Displays version information."}, crashRecoveryOption, parentWindowOption, + verboseOption, }); parser.addOption(QCommandLineOption( {"c", "channels"}, @@ -46,6 +54,7 @@ Args::Args(const QApplication &app) if (parser.isSet("help")) { + attachToConsole(); qInfo().noquote() << parser.helpText(); ::exit(EXIT_SUCCESS); } @@ -60,7 +69,9 @@ Args::Args(const QApplication &app) this->applyCustomChannelLayout(parser.value("c")); } - this->printVersion = parser.isSet("v"); + this->verbose = parser.isSet(verboseOption); + + this->printVersion = parser.isSet("V"); this->crashRecovery = parser.isSet("crash-recovery"); } diff --git a/src/common/Args.hpp b/src/common/Args.hpp index 3f925ecb4..80c37ebbb 100644 --- a/src/common/Args.hpp +++ b/src/common/Args.hpp @@ -17,6 +17,7 @@ public: bool shouldRunBrowserExtensionHost{}; bool dontSaveSettings{}; boost::optional customChannelLayout; + bool verbose{}; private: void applyCustomChannelLayout(const QString &argValue); diff --git a/src/main.cpp b/src/main.cpp index e43b05a3b..04b1f189d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,6 +15,7 @@ #include "providers/twitch/api/Kraken.hpp" #include "singletons/Paths.hpp" #include "singletons/Settings.hpp" +#include "util/AttachToConsole.hpp" #include "util/IncognitoBrowser.hpp" using namespace chatterino; @@ -63,6 +64,8 @@ int main(int argc, char **argv) } else if (getArgs().printVersion) { + attachToConsole(); + auto version = Version::instance(); qInfo().noquote() << QString("%1 (commit %2%3)") .arg(version.fullVersion()) @@ -73,6 +76,11 @@ int main(int argc, char **argv) } else { + if (getArgs().verbose) + { + attachToConsole(); + } + IvrApi::initialize(); Helix::initialize(); Kraken::initialize();