From ed20c3082d4fd5e90703e4d6c37093dcecb5cfd1 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Thu, 20 Nov 2014 16:28:31 +0100 Subject: sketch in the client/resource model --- common/console.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ common/console.h | 20 ++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 common/console.cpp create mode 100644 common/console.h (limited to 'common') diff --git a/common/console.cpp b/common/console.cpp new file mode 100644 index 0000000..4ed7960 --- /dev/null +++ b/common/console.cpp @@ -0,0 +1,48 @@ +#include "console.h" + +#include +#include +#include + +static Console *s_console = 0; + +Console *Console::main() +{ + if (!s_console) { + s_console = new Console("Stupido!"); + } + return s_console; +} + +Console::Console(const QString &title) + : QWidget(0) +{ + s_console = this; + resize(1000, 1500); + + QVBoxLayout *topLayout = new QVBoxLayout(this); + + QLabel *titleLabel = new QLabel(this); + titleLabel->setText(title); + QFont font = titleLabel->font(); + font.setWeight(QFont::Bold); + titleLabel->setFont(font); + titleLabel->setAlignment(Qt::AlignCenter); + + m_textDisplay = new QTextBrowser(this); + + topLayout->addWidget(titleLabel); + topLayout->addWidget(m_textDisplay, 10); + + show(); +} + +Console::~Console() +{ + +} + +void Console::log(const QString &message) +{ + m_textDisplay->append(message); +} diff --git a/common/console.h b/common/console.h new file mode 100644 index 0000000..d504fb1 --- /dev/null +++ b/common/console.h @@ -0,0 +1,20 @@ +#pragma once + +#include + +class QTextBrowser; + +class Console : public QWidget +{ + Q_OBJECT +public: + static Console *main(); + Console(const QString &title); + ~Console(); + + void log(const QString &message); + +private: + QTextBrowser *m_textDisplay; + static Console *s_output; +}; \ No newline at end of file -- cgit v1.2.3