logger
This commit is contained in:
@@ -7,6 +7,11 @@
|
||||
#include <wincon.h>
|
||||
#endif
|
||||
|
||||
#include <QAction>
|
||||
#include <QLayout>
|
||||
#include <QString>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include "common/logging/backend.h"
|
||||
#include "yuzu/debugger/console.h"
|
||||
#include "yuzu/uisettings.h"
|
||||
@@ -46,4 +51,59 @@ void ToggleConsole() {
|
||||
SetColorConsoleBackendEnabled(UISettings::values.show_console.GetValue());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
GameLogOuput::GameLogOuput(QWidget* parent)
|
||||
: QWidget(parent, Qt::Dialog) {
|
||||
setObjectName(QStringLiteral("Game Log Output"));
|
||||
setWindowTitle(tr("Game Log Output"));
|
||||
resize(500, 350);
|
||||
setMinimumSize(500, 350);
|
||||
// Remove the "?" button from the titlebar and enable the maximize button
|
||||
setWindowFlags((windowFlags() & ~Qt::WindowContextHelpButtonHint) |
|
||||
Qt::WindowMaximizeButtonHint);
|
||||
|
||||
log_output = new QPlainTextEdit(this);
|
||||
log_output->setReadOnly(true);
|
||||
QLayout* layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addWidget(log_output);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void GameLogOuput::AppendMessage(const QString& text) {
|
||||
std::scoped_lock lock{mutex};
|
||||
if (log_output) {
|
||||
log_output->appendPlainText(std::move(text));
|
||||
}
|
||||
// Scrolls to the bottom
|
||||
//log_output->verticalScrollBar()->setValue(
|
||||
// log_output->verticalScrollBar()->maximum());
|
||||
}
|
||||
|
||||
QAction* GameLogOuput::toggleViewAction() {
|
||||
if (toggle_view_action == nullptr) {
|
||||
toggle_view_action = new QAction(tr("&Game Log Ouput"), this);
|
||||
toggle_view_action->setCheckable(true);
|
||||
toggle_view_action->setChecked(isVisible());
|
||||
connect(toggle_view_action, &QAction::toggled, this, &GameLogOuput::setVisible);
|
||||
}
|
||||
|
||||
return toggle_view_action;
|
||||
}
|
||||
|
||||
void GameLogOuput::showEvent(QShowEvent* ev) {
|
||||
if (toggle_view_action) {
|
||||
toggle_view_action->setChecked(isVisible());
|
||||
}
|
||||
QWidget::showEvent(ev);
|
||||
}
|
||||
|
||||
void GameLogOuput::hideEvent(QHideEvent* ev) {
|
||||
if (toggle_view_action) {
|
||||
toggle_view_action->setChecked(isVisible());
|
||||
}
|
||||
QWidget::hideEvent(ev);
|
||||
}
|
||||
|
||||
} // namespace Debugger
|
||||
|
@@ -3,6 +3,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
namespace Core::HID {
|
||||
class HIDCore;
|
||||
} // namespace Core::HID
|
||||
|
||||
namespace Debugger {
|
||||
|
||||
/**
|
||||
@@ -10,4 +19,25 @@ namespace Debugger {
|
||||
* get a real qt logging window which would work for all platforms.
|
||||
*/
|
||||
void ToggleConsole();
|
||||
|
||||
class GameLogOuput : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GameLogOuput(QWidget* parent = nullptr);
|
||||
|
||||
void AppendMessage(const QString& text);
|
||||
|
||||
/// Returns a QAction that can be used to toggle visibility of this dialog.
|
||||
QAction* toggleViewAction();
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* ev) override;
|
||||
void hideEvent(QHideEvent* ev) override;
|
||||
|
||||
private:
|
||||
std::mutex mutex;
|
||||
QAction* toggle_view_action = nullptr;
|
||||
QPlainTextEdit* log_output = nullptr;
|
||||
};
|
||||
} // namespace Debugger
|
@@ -1248,6 +1248,10 @@ void GMainWindow::InitializeDebugWidgets() {
|
||||
controller_dialog->hide();
|
||||
debug_menu->addAction(controller_dialog->toggleViewAction());
|
||||
|
||||
game_log_ouput_widget = new Debugger::GameLogOuput(this);
|
||||
game_log_ouput_widget->hide();
|
||||
debug_menu->addAction(game_log_ouput_widget->toggleViewAction());
|
||||
|
||||
connect(this, &GMainWindow::EmulationStarting, waitTreeWidget,
|
||||
&WaitTreeWidget::OnEmulationStarting);
|
||||
connect(this, &GMainWindow::EmulationStopping, waitTreeWidget,
|
||||
@@ -1876,6 +1880,11 @@ void GMainWindow::BootGame(const QString& filename, u64 program_id, std::size_t
|
||||
render_window->Exit();
|
||||
});
|
||||
|
||||
// Register an Exit callback such that Core can exit the currently running application.
|
||||
system->RegisterGameLogCallback([this](std::string text) {
|
||||
game_log_ouput_widget->AppendMessage(QString::fromStdString(text));
|
||||
});
|
||||
|
||||
connect(render_window, &GRenderWindow::Closed, this, &GMainWindow::OnStopGame);
|
||||
connect(render_window, &GRenderWindow::MouseActivity, this, &GMainWindow::OnMouseActivity);
|
||||
// BlockingQueuedConnection is important here, it makes sure we've finished refreshing our views
|
||||
|
@@ -72,6 +72,10 @@ struct KeyboardInitializeParameters;
|
||||
struct ProfileSelectParameters;
|
||||
} // namespace Core::Frontend
|
||||
|
||||
namespace Debugger {
|
||||
class GameLogOuput;
|
||||
}
|
||||
|
||||
namespace DiscordRPC {
|
||||
class DiscordInterface;
|
||||
}
|
||||
@@ -468,6 +472,7 @@ private:
|
||||
MicroProfileDialog* microProfileDialog;
|
||||
WaitTreeWidget* waitTreeWidget;
|
||||
ControllerDialog* controller_dialog;
|
||||
Debugger::GameLogOuput* game_log_ouput_widget;
|
||||
|
||||
QAction* actions_recent_files[max_recent_files_item];
|
||||
|
||||
|
Reference in New Issue
Block a user