From 168fa97a945b5f3355c110b52c504d8384fb1e4f Mon Sep 17 00:00:00 2001 From: Hugues Delorme Date: Mon, 24 Jul 2023 18:27:28 +0200 Subject: [PATCH] WIP8 --- src/app/command_system_information.cpp | 7 +++---- src/app/commands_api.cpp | 4 ++-- src/app/commands_api.h | 8 ++++---- src/app/main.cpp | 9 +++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/app/command_system_information.cpp b/src/app/command_system_information.cpp index 0e1089c5..6d7611ae 100644 --- a/src/app/command_system_information.cpp +++ b/src/app/command_system_information.cpp @@ -184,6 +184,7 @@ static void dumpOpenGlInfo(QTextStream& str) QString CommandSystemInformation::data() { + // Helper function returning unicode representation of a QChar object in the form "U+NNNN" auto fnStrUnicodeChar = [](const QChar& ch) { QString str; QTextStream ostr(&str); @@ -231,10 +232,8 @@ QString CommandSystemInformation::data() ostr << '\n' << "Environment:\n"; { const QProcessEnvironment sysEnv = QProcessEnvironment::systemEnvironment(); - for (const QString& key : sysEnv.keys()) { - if (key.startsWith('Q')) - ostr << indent << key << "=\"" << sysEnv.value(key) << "\"\n"; - } + for (const QString& key : sysEnv.keys()) + ostr << indent << key << "=\"" << sysEnv.value(key) << "\"\n"; } // Locales diff --git a/src/app/commands_api.cpp b/src/app/commands_api.cpp index d762a9fe..047cf4df 100644 --- a/src/app/commands_api.cpp +++ b/src/app/commands_api.cpp @@ -28,7 +28,7 @@ Command::Command(IAppContext* context) Application* Command::app() const { - return m_context->guiApp()->application().get(); + return m_context ? m_context->guiApp()->application().get() : nullptr; } GuiDocument* Command::currentGuiDocument() const @@ -39,7 +39,7 @@ GuiDocument* Command::currentGuiDocument() const int Command::currentDocumentIndex() const { - return this->context()->findDocumentIndex(this->currentDocument()); + return m_context ? m_context->findDocumentIndex(this->currentDocument()) : -1; } void Command::setCurrentDocument(const DocumentPtr& doc) diff --git a/src/app/commands_api.h b/src/app/commands_api.h index f34332bf..a7bb956b 100644 --- a/src/app/commands_api.h +++ b/src/app/commands_api.h @@ -73,10 +73,10 @@ class Command : public QObject { protected: Application* app() const; - GuiApplication* guiApp() const { return m_context->guiApp(); } - TaskManager* taskMgr() const { return m_context->taskMgr(); } - QWidget* widgetMain() const { return m_context->widgetMain(); } - Document::Identifier currentDocument() const { return m_context->currentDocument(); } + GuiApplication* guiApp() const { return m_context ? m_context->guiApp() : nullptr; } + TaskManager* taskMgr() const { return m_context ? m_context->taskMgr() : nullptr; } + QWidget* widgetMain() const { return m_context ? m_context->widgetMain() : nullptr; } + Document::Identifier currentDocument() const { return m_context ? m_context->currentDocument() : -1; } GuiDocument* currentGuiDocument() const; int currentDocumentIndex() const; diff --git a/src/app/main.cpp b/src/app/main.cpp index 523e5163..b5cdc268 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -499,8 +499,9 @@ static int runApp(QCoreApplication* qtApp) // Process CLI if (args.showSystemInformation) { - std::cout << Mayo::CommandSystemInformation::data().toStdString() << std::endl; - return 0; + CommandSystemInformation cmdSysInfo(nullptr); + cmdSysInfo.execute(); + return qtApp->exec(); } if (!args.listFilepathToExport.empty()) { @@ -594,7 +595,7 @@ int main(int argc, char* argv[]) QCoreApplication::setOrganizationDomain("www.fougue.pro"); QCoreApplication::setApplicationName("Mayo"); QCoreApplication::setApplicationVersion(QString::fromUtf8(Mayo::strVersion)); - const bool isAppCliMode = fnArgsContainAnyOf({ "-e", "--export", "-h", "--help", "-v", "--version", "--system-info" }); + const bool isAppCliMode = fnArgsContainAnyOf({ "-e", "--export", "-h", "--help", "-v", "--version" }); std::unique_ptr ptrApp( isAppCliMode ? new QCoreApplication(argc, argv) : new QApplication(argc, argv) ); @@ -608,7 +609,7 @@ int main(int argc, char* argv[]) #endif // Configure for CLI mode - if (isAppCliMode && fnArgsContainAnyOf({ "--system-info" })) { + if (isAppCliMode) { #if defined(Q_OS_WIN) && defined(NDEBUG) qAddPostRoutine(&Mayo::consoleSendEnterKey); // https://devblogs.microsoft.com/oldnewthing/20090101-00/?p=19643