mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-13 10:18:15 +02:00
display all log data on load
This commit is contained in:
parent
5a27ded669
commit
cc6f7ed4cc
7 changed files with 29 additions and 13 deletions
|
@ -87,7 +87,7 @@ const float MIRROR_REARVIEW_BODY_DISTANCE = 1.f;
|
|||
|
||||
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
|
||||
fprintf(stdout, "%s", message.toLocal8Bit().constData());
|
||||
Menu::getInstance()->appendLogLine(message.toLocal8Bit().constData());
|
||||
LogDisplay::instance.addMessage(message.toLocal8Bit().constData());
|
||||
}
|
||||
|
||||
Application::Application(int& argc, char** argv, timeval &startup_time) :
|
||||
|
@ -153,9 +153,10 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
|
|||
QFontDatabase::addApplicationFont(resourcesPath + "/styles/Inconsolata.otf");
|
||||
_window->setWindowTitle("Interface");
|
||||
|
||||
qInstallMessageHandler(messageHandler);
|
||||
|
||||
// call Menu getInstance static method to set up the menu
|
||||
_window->setMenuBar(Menu::getInstance());
|
||||
qInstallMessageHandler(messageHandler);
|
||||
|
||||
qDebug( "[VERSION] Build sequence: %i", BUILD_VERSION);
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ void LogDisplay::setCharacterSize(unsigned width, unsigned height) {
|
|||
|
||||
void LogDisplay::addMessage(const char* ptr) {
|
||||
|
||||
emit logReceived(ptr);
|
||||
pthread_mutex_lock(& _mutex);
|
||||
|
||||
// T-pipe, if requested
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
|
||||
#include "ui/TextRenderer.h"
|
||||
|
||||
class LogDisplay {
|
||||
class LogDisplay : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
static LogDisplay instance;
|
||||
|
@ -43,6 +44,12 @@ public:
|
|||
static unsigned const LINE_BUFFER_SIZE = 256; // number of lines that are buffered
|
||||
static unsigned const MAX_MESSAGE_LENGTH = 512; // maximum number of characters for a message
|
||||
|
||||
char** getLogData() { return _lines; };
|
||||
char** getLastLinePos() { return _lastLinePos; }
|
||||
|
||||
signals:
|
||||
void logReceived(QString message);
|
||||
|
||||
private:
|
||||
// use static 'instance' to access the single instance
|
||||
LogDisplay();
|
||||
|
|
|
@ -1014,12 +1014,6 @@ void Menu::pasteToVoxel() {
|
|||
sendFakeEnterEvent();
|
||||
}
|
||||
|
||||
void Menu::appendLogLine(QString logLine) {
|
||||
if (_logDialog) {
|
||||
_logDialog->appendLogLine(logLine);
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::showLogDialog() {
|
||||
if (! _logDialog) {
|
||||
_logDialog = new LogDialog(Application::getInstance()->getGLWidget());
|
||||
|
|
|
@ -49,7 +49,6 @@ public:
|
|||
void triggerOption(const QString& menuOption);
|
||||
QAction* getActionForOption(const QString& menuOption);
|
||||
bool isVoxelModeActionChecked();
|
||||
void appendLogLine(QString logLine);
|
||||
|
||||
float getAudioJitterBufferSamples() const { return _audioJitterBufferSamples; }
|
||||
float getFieldOfView() const { return _fieldOfView; }
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "SharedUtil.h"
|
||||
#include "ui/LogDialog.h"
|
||||
#include "LogDisplay.h"
|
||||
|
||||
#define INITIAL_WIDTH_RATIO 0.3
|
||||
#define INITIAL_HEIGHT_RATIO 0.6
|
||||
|
@ -37,7 +38,7 @@ LogDialog::LogDialog(QWidget* parent) :
|
|||
|
||||
QDesktopWidget* desktop = new QDesktopWidget();
|
||||
QRect screen = desktop->screenGeometry();
|
||||
resize((int)(screen.width() * INITIAL_WIDTH_RATIO), (int)(screen.height() * INITIAL_HEIGHT_RATIO));
|
||||
resize(static_cast<int>(screen.width() * INITIAL_WIDTH_RATIO), static_cast<int>(screen.height() * INITIAL_HEIGHT_RATIO));
|
||||
move(screen.center() - rect().center());
|
||||
delete desktop;
|
||||
}
|
||||
|
@ -49,6 +50,18 @@ LogDialog::~LogDialog() {
|
|||
|
||||
void LogDialog::showEvent(QShowEvent *e) {
|
||||
_logTextBox->clear();
|
||||
pthread_mutex_lock(& _mutex);
|
||||
char** _lines = LogDisplay::instance.getLogData();
|
||||
char** _lastLinePos = LogDisplay::instance.getLastLinePos();
|
||||
|
||||
int i = 0;
|
||||
while (_lines[i] != *_lastLinePos) {
|
||||
appendLogLine(_lines[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
connect(&LogDisplay::instance, &LogDisplay::logReceived, this, &LogDialog::appendLogLine);
|
||||
pthread_mutex_unlock(& _mutex);
|
||||
}
|
||||
|
||||
void LogDialog::resizeEvent(QResizeEvent *e) {
|
||||
|
@ -63,7 +76,7 @@ void LogDialog::appendLogLine(QString logLine) {
|
|||
}
|
||||
|
||||
void LogDialog::reject() {
|
||||
this->QDialog::close();
|
||||
close();
|
||||
}
|
||||
|
||||
void LogDialog::closeEvent(QCloseEvent* event) {
|
||||
|
|
|
@ -18,13 +18,13 @@ class LogDialog : public QDialog {
|
|||
public:
|
||||
LogDialog(QWidget* parent);
|
||||
~LogDialog();
|
||||
void appendLogLine(QString logLine);
|
||||
|
||||
signals:
|
||||
void closed();
|
||||
|
||||
public slots:
|
||||
void reject();
|
||||
void appendLogLine(QString logLine);
|
||||
|
||||
protected:
|
||||
// Emits a 'closed' signal when this dialog is closed.
|
||||
|
@ -34,6 +34,7 @@ protected:
|
|||
|
||||
private:
|
||||
QPlainTextEdit* _logTextBox;
|
||||
pthread_mutex_t _mutex;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue