This commit is contained in:
Martin Rotter 2014-04-16 08:44:16 +02:00
parent 3d320bbaf1
commit ad3677f7ca
2 changed files with 29 additions and 27 deletions

View File

@ -46,6 +46,9 @@ FormUpdater::FormUpdater(QWidget *parent)
setWindowIcon(QIcon(APP_ICON_PATH));
moveToCenterAndResize();
connect(this, SIGNAL(debugMessageProduced(QtMsgType,QString)),
this, SLOT(consumeDebugMessage(QtMsgType,QString)));
}
FormUpdater::~FormUpdater() {
@ -108,14 +111,11 @@ void FormUpdater::executeMainApplication() {
}
}
void FormUpdater::triggerDebugMessageConsumption(QtMsgType type, const QString &message) {
emit debugMessageProduced(type, message);
}
#if QT_VERSION >= 0x050000
void FormUpdater::debugHandler(QtMsgType type,
const QMessageLogContext &placement,
const QString &message) {
#ifndef QT_NO_DEBUG_OUTPUT
Q_UNUSED(placement)
void FormUpdater::consumeDebugMessage(QtMsgType type, const QString &message) {
switch (type) {
case QtDebugMsg:
s_instance->printText(QString("DEBUG: %1").arg(message));
@ -136,6 +136,16 @@ void FormUpdater::debugHandler(QtMsgType type,
default:
break;
}
}
#if QT_VERSION >= 0x050000
void FormUpdater::debugHandler(QtMsgType type,
const QMessageLogContext &placement,
const QString &message) {
#ifndef QT_NO_DEBUG_OUTPUT
Q_UNUSED(placement)
s_instance->triggerDebugMessageConsumption(type, message);
#else
Q_UNUSED(type)
Q_UNUSED(placement)
@ -145,26 +155,7 @@ void FormUpdater::debugHandler(QtMsgType type,
#else
void FormUpdater::debugHandler(QtMsgType type, const char *message) {
#ifndef QT_NO_DEBUG_OUTPUT
switch (type) {
case QtDebugMsg:
s_instance->printText(QString("DEBUG: %1").arg(message));
break;
case QtWarningMsg:
s_instance->printText(QString("WARNING: %1").arg(message));
break;
case QtCriticalMsg:
s_instance->printText(QString("CRITICAL: %1").arg(message));
break;
case QtFatalMsg:
s_instance->printText(QString("FATAL: %1").arg(message));
qApp->exit(EXIT_FAILURE);
default:
break;
}
s_instance->triggerDebugMessageConsumption(type, QString(message));
#else
Q_UNUSED(type)
Q_UNUSED(message)

View File

@ -42,6 +42,9 @@ class FormUpdater : public QMainWindow {
bool doFinalCleanup();
void executeMainApplication();
// Used to trigger signal informaing about new debug message.
void triggerDebugMessageConsumption(QtMsgType type, const QString &message);
// Debug handlers for messages.
#if QT_VERSION >= 0x050000
static void debugHandler(QtMsgType type,
@ -52,6 +55,14 @@ class FormUpdater : public QMainWindow {
const char *message);
#endif
public slots:
// Should be always called on GUI thread which is enforced
// by signal/slot auto connection.
void consumeDebugMessage(QtMsgType type, const QString &message);
signals:
void debugMessageProduced(QtMsgType type, QString message);
protected:
// Catch the "press any key event" to exit the updater.
void keyPressEvent(QKeyEvent *event);