Get the output when running kdeconnectd from the console on Windows

This commit is contained in:
Albert Vaca Cintora 2023-06-27 23:50:47 +02:00
parent beb7e94cbb
commit 1ba446d1c5

View file

@ -14,6 +14,10 @@
#include <QStandardPaths> #include <QStandardPaths>
#include <QTimer> #include <QTimer>
#ifdef Q_OS_WIN
#include <Windows.h>
#endif
#include <KAboutData> #include <KAboutData>
#include <KDBusService> #include <KDBusService>
#include <KLocalizedString> #include <KLocalizedString>
@ -117,6 +121,14 @@ static void detectPlatform(int argc, char **argv)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#ifdef Q_OS_WIN
// If ran from a console, redirect the output there
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
}
#endif
detectPlatform(argc, argv); detectPlatform(argc, argv);
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);