-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
freemountain
authored and
freemountain
committed
Nov 28, 2016
1 parent
715368e
commit ab4c756
Showing
21 changed files
with
477 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef LOGSOURCE_H | ||
#define LOGSOURCE_H | ||
|
||
#include <QObject> | ||
|
||
class LogSource | ||
{ | ||
public: | ||
//virtual ~LogSource(){} | ||
|
||
signals: | ||
virtual void log(QString msg, QString topic = "log") = 0; | ||
}; | ||
|
||
//Q_DECLARE_INTERFACE(LogSource, "LogSource") | ||
|
||
|
||
#endif // LOGSOURCE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "quarkdebugger.h" | ||
|
||
#include <QTextStream> | ||
#include <QJsonDocument> | ||
#include <QDebug> | ||
|
||
QuarkDebugger::QuarkDebugger(QObject *parent) : QObject(parent) | ||
{ | ||
this->qmlEngine = new QQmlApplicationEngine(this); | ||
this->qmlEngine->load(QUrl("qrc:/src/qml/Debugger.qml")); | ||
|
||
QObject* obj = this->qmlEngine->rootObjects().at(0); | ||
this->window = qobject_cast<QQuickWindow *>(obj); | ||
connect(this, SIGNAL(_logMsg(QVariant, QVariant)), this->window, SLOT(appendLogLine(QVariant, QVariant))); | ||
} | ||
|
||
void QuarkDebugger::attachLogSource(LogSource *source, QString topic) { | ||
connect(dynamic_cast<QObject*>(source), SIGNAL(log(QString, QString)), this, SLOT(printLine(QString, QString))); | ||
} | ||
|
||
void QuarkDebugger::attach(QuarkProcess *proc) { | ||
connect(proc, &QuarkProcess::value, [this](const QJsonValue &val) { | ||
QJsonDocument doc = QJsonDocument::fromVariant(val.toVariant()); | ||
printLine(doc.toJson(), "_debugger value"); | ||
}); | ||
|
||
connect(proc, &QuarkProcess::action, [this](const QString &type, const QJsonValue &payload, const QuarkProcess::Source &source) { | ||
QJsonDocument doc = QJsonDocument::fromVariant(payload.toVariant()); | ||
printLine(payload.toString(), "_debugger action: " + type ); | ||
}); | ||
|
||
connect(proc, &QuarkProcess::log, [this](const QString &msg, const QString &topic) { | ||
printLine(msg , topic); | ||
}); | ||
} | ||
|
||
void QuarkDebugger::printLine(QString msg, QString topic) { | ||
fprintf(stderr, "%s: %s\n", topic.toStdString().c_str(), msg.toStdString().c_str()); | ||
emit _logMsg(QVariant(msg), QVariant(topic)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#ifndef QUARKDEBUGGER_H | ||
#define QUARKDEBUGGER_H | ||
#include <QObject> | ||
#include <QQmlApplicationEngine> | ||
#include <QQuickWindow> | ||
#include <QVariant> | ||
|
||
#include "logsource.h" | ||
#include "quarkprocess.h" | ||
|
||
class QuarkDebugger : public QObject | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit QuarkDebugger(QObject *parent = 0); | ||
void attachLogSource(LogSource* source, QString topic = "log"); | ||
void attach(QuarkProcess* proc); | ||
|
||
|
||
private: | ||
QQmlApplicationEngine* qmlEngine; | ||
QQuickWindow* window; | ||
|
||
public slots: | ||
void printLine(QString msg, QString topic = "log"); | ||
|
||
signals: | ||
void _logMsg(QVariant msg, QVariant topic); | ||
}; | ||
|
||
#endif // QUARKDEBUGGER_H |
Oops, something went wrong.