2017-06-25 11:40:01 -06:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-06-25 11:40:01 -06:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QDockWidget>
|
|
|
|
|
|
|
|
#include <mutex>
|
2019-08-30 16:15:03 -06:00
|
|
|
#include <string>
|
2017-06-25 11:40:01 -06:00
|
|
|
|
2019-08-31 12:27:15 -06:00
|
|
|
#include "Common/FixedSizeQueue.h"
|
2017-06-25 11:40:01 -06:00
|
|
|
#include "Common/Logging/LogManager.h"
|
|
|
|
|
|
|
|
class QCheckBox;
|
2017-09-20 05:18:36 -06:00
|
|
|
class QCloseEvent;
|
2017-06-25 11:40:01 -06:00
|
|
|
class QComboBox;
|
2019-08-30 15:55:40 -06:00
|
|
|
class QPlainTextEdit;
|
2017-06-25 11:40:01 -06:00
|
|
|
class QPushButton;
|
|
|
|
class QTimer;
|
|
|
|
|
2019-11-28 02:19:24 -07:00
|
|
|
class LogWidget final : public QDockWidget, Common::Log::LogListener
|
2017-06-25 11:40:01 -06:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-08-27 16:10:06 -06:00
|
|
|
explicit LogWidget(QWidget* parent = nullptr);
|
|
|
|
~LogWidget();
|
2017-06-25 11:40:01 -06:00
|
|
|
|
2017-09-20 05:18:36 -06:00
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent*) override;
|
|
|
|
|
2017-06-25 11:40:01 -06:00
|
|
|
private:
|
|
|
|
void UpdateLog();
|
|
|
|
void UpdateFont();
|
|
|
|
void CreateWidgets();
|
|
|
|
void ConnectWidgets();
|
|
|
|
void LoadSettings();
|
|
|
|
void SaveSettings();
|
|
|
|
|
2021-10-21 13:11:07 -06:00
|
|
|
void Log(Common::Log::LogLevel level, const char* text) override;
|
2017-06-25 11:40:01 -06:00
|
|
|
|
|
|
|
// Log
|
|
|
|
QCheckBox* m_log_wrap;
|
|
|
|
QComboBox* m_log_font;
|
|
|
|
QPushButton* m_log_clear;
|
2019-08-30 15:55:40 -06:00
|
|
|
QPlainTextEdit* m_log_text;
|
2017-06-25 11:40:01 -06:00
|
|
|
|
|
|
|
QTimer* m_timer;
|
|
|
|
|
2021-10-21 13:11:07 -06:00
|
|
|
using LogEntry = std::pair<std::string, Common::Log::LogLevel>;
|
2019-08-30 16:15:03 -06:00
|
|
|
|
2019-08-31 12:27:15 -06:00
|
|
|
// Maximum number of lines to show in log viewer
|
|
|
|
static constexpr int MAX_LOG_LINES = 5000;
|
|
|
|
|
2017-06-25 11:40:01 -06:00
|
|
|
std::mutex m_log_mutex;
|
2019-08-31 12:27:15 -06:00
|
|
|
FixedSizeQueue<LogEntry, MAX_LOG_LINES> m_log_ring_buffer;
|
2017-06-25 11:40:01 -06:00
|
|
|
};
|