diff --git a/src/platform/qt/CMakeLists.txt b/src/platform/qt/CMakeLists.txt index bd1edadfd..4399bfcfb 100644 --- a/src/platform/qt/CMakeLists.txt +++ b/src/platform/qt/CMakeLists.txt @@ -109,6 +109,7 @@ set(SOURCE_FILES LogController.cpp LogConfigModel.cpp LogView.cpp + LogWidget.cpp MapView.cpp MemoryDump.cpp MemoryModel.cpp diff --git a/src/platform/qt/DebuggerConsole.cpp b/src/platform/qt/DebuggerConsole.cpp index 0a4beb909..a0fd266ac 100644 --- a/src/platform/qt/DebuggerConsole.cpp +++ b/src/platform/qt/DebuggerConsole.cpp @@ -8,7 +8,7 @@ #include "DebuggerConsoleController.h" #include "GBAApp.h" -#include +#include using namespace QGBA; @@ -19,23 +19,16 @@ DebuggerConsole::DebuggerConsole(DebuggerConsoleController* controller, QWidget* m_ui.setupUi(this); m_ui.prompt->installEventFilter(this); - m_ui.log->setFont(GBAApp::app()->monospaceFont()); m_ui.prompt->setFont(GBAApp::app()->monospaceFont()); connect(m_ui.prompt, &QLineEdit::returnPressed, this, &DebuggerConsole::postLine); - connect(controller, &DebuggerConsoleController::log, this, &DebuggerConsole::log); + connect(controller, &DebuggerConsoleController::log, m_ui.log, &LogWidget::log); connect(m_ui.breakpoint, &QAbstractButton::clicked, controller, &DebuggerController::attach); connect(m_ui.breakpoint, &QAbstractButton::clicked, controller, &DebuggerController::breakInto); controller->historyLoad(); } -void DebuggerConsole::log(const QString& line) { - m_ui.log->moveCursor(QTextCursor::End); - m_ui.log->insertPlainText(line); - m_ui.log->verticalScrollBar()->setValue(m_ui.log->verticalScrollBar()->maximum()); -} - void DebuggerConsole::postLine() { m_consoleController->attach(); QString line = m_ui.prompt->text(); @@ -44,7 +37,7 @@ void DebuggerConsole::postLine() { m_consoleController->enterLine(QString("\n")); } else { m_historyOffset = 0; - log(QString("> %1\n").arg(line)); + m_ui.log->log(QString("> %1\n").arg(line)); m_consoleController->enterLine(line); } } diff --git a/src/platform/qt/DebuggerConsole.h b/src/platform/qt/DebuggerConsole.h index d13ef4a13..f98635a68 100644 --- a/src/platform/qt/DebuggerConsole.h +++ b/src/platform/qt/DebuggerConsole.h @@ -18,7 +18,6 @@ public: DebuggerConsole(DebuggerConsoleController* controller, QWidget* parent = nullptr); private slots: - void log(const QString&); void postLine(); protected: diff --git a/src/platform/qt/DebuggerConsole.ui b/src/platform/qt/DebuggerConsole.ui index 4199e1e83..5cfe6512c 100644 --- a/src/platform/qt/DebuggerConsole.ui +++ b/src/platform/qt/DebuggerConsole.ui @@ -29,7 +29,7 @@ - + true @@ -37,6 +37,13 @@ + + + QGBA::LogWidget + QPlainTextEdit +
LogWidget.h
+
+
diff --git a/src/platform/qt/LogWidget.cpp b/src/platform/qt/LogWidget.cpp new file mode 100644 index 000000000..136df178c --- /dev/null +++ b/src/platform/qt/LogWidget.cpp @@ -0,0 +1,24 @@ +/* Copyright (c) 2013-2022 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "LogWidget.h" + +#include "GBAApp.h" + +#include + +using namespace QGBA; + +LogWidget::LogWidget(QWidget* parent) + : QTextEdit(parent) +{ + setFont(GBAApp::app()->monospaceFont()); +} + +void LogWidget::log(const QString& line) { + moveCursor(QTextCursor::End); + insertPlainText(line); + verticalScrollBar()->setValue(verticalScrollBar()->maximum()); +} diff --git a/src/platform/qt/LogWidget.h b/src/platform/qt/LogWidget.h new file mode 100644 index 000000000..700f7aaf6 --- /dev/null +++ b/src/platform/qt/LogWidget.h @@ -0,0 +1,20 @@ +/* Copyright (c) 2013-2022 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#pragma once + +#include + +namespace QGBA { + +class LogWidget : public QTextEdit { +public: + LogWidget(QWidget* parent = nullptr); + +public slots: + void log(const QString&); +}; + +}