Skip to content

Commit

Permalink
WIP8
Browse files Browse the repository at this point in the history
  • Loading branch information
HuguesDelorme committed Jul 24, 2023
1 parent 84be6be commit 168fa97
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
7 changes: 3 additions & 4 deletions src/app/command_system_information.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/app/commands_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/app/commands_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
9 changes: 5 additions & 4 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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<QCoreApplication> ptrApp(
isAppCliMode ? new QCoreApplication(argc, argv) : new QApplication(argc, argv)
);
Expand All @@ -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
Expand Down

0 comments on commit 168fa97

Please sign in to comment.