9#ifndef MCRL2_GUI_QT_TOOL_H
10#define MCRL2_GUI_QT_TOOL_H
14#include <QApplication>
16#include <QDesktopServices>
25#include "mcrl2/utilities/logger.h"
26#include "mcrl2/utilities/platform.h"
27#include "mcrl2/utilities/toolset_version.h"
29#ifdef MCRL2_PLATFORM_WINDOWS
33namespace mcrl2::gui::qt
51 HelpMenu(QMainWindow* window,
const std::string& name,
const std::string& author,
const std::string& description,
const std::string& manualUrl):
61 m_actionContents.setText(
"&Contents");
62 m_actionContents.setShortcut(QString(
"F1"));
63 connect(&m_actionContents, SIGNAL(triggered()),
this, SLOT(showContents()));
65 m_actionAbout.setText(
"&About");
66 connect(&m_actionAbout, SIGNAL(triggered()),
this, SLOT(showAbout()));
69 addAction(&m_actionContents);
70 window->addAction(&m_actionContents);
72 addAction(&m_actionAbout);
97void myMessageOutput(QtMsgType type,
const QMessageLogContext &context,
const QString &msg)
99 QByteArray localMsg = msg.toLocal8Bit();
103 fprintf(stderr,
"Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
107 fprintf(stderr,
"Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
111 fprintf(stderr,
"Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
115 fprintf(stderr,
"Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
119 fprintf(stderr,
"Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
124template <
typename Tool>
136 const std::string& author,
137 const std::string& what_is,
138 const std::string& tool_description,
139 const std::string& about_description,
140 const std::string& manual_url,
141 std::string known_issues =
""
153#ifdef MCRL2_PLATFORM_WINDOWS
154 if (GetConsoleWindow() == 0)
156 if (AttachConsole(ATTACH_PARENT_PROCESS) == 0)
164 return Tool::execute(argc, argv);
169#ifdef MCRL2_PLATFORM_WINDOWS
171 qputenv(
"QT_QPA_PLATFORM",
"windows:darkmode=0");
180 qInstallMessageHandler(myMessageOutput);
181 m_application = std::make_unique<QApplication>(argc, argv);
182#ifdef MCRL2_PLATFORM_WINDOWS
183 m_application->setStyle(
"windowsvista");
188 mCRL2log(mcrl2::log::log_level_t::error) <<
"Creating QApplication failed." << std::endl;
196 HelpMenu menu(&window, m_name, m_author, m_about_description, m_manual_url);
197 window.menuBar()->addAction(menu.menuAction());
198 window.menuBar()->setNativeMenuBar(
true);
200 return m_application->exec() == 0;
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)