2017-06-25 17:40:01 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QDockWidget>
|
|
|
|
|
|
|
|
#include <mutex>
|
2019-08-30 22:15:03 +00:00
|
|
|
#include <string>
|
2017-06-25 17:40:01 +00:00
|
|
|
|
2019-08-31 18:27:15 +00:00
|
|
|
#include "Common/FixedSizeQueue.h"
|
2017-06-25 17:40:01 +00:00
|
|
|
#include "Common/Logging/LogManager.h"
|
|
|
|
|
|
|
|
class QCheckBox;
|
2017-09-20 11:18:36 +00:00
|
|
|
class QCloseEvent;
|
2017-06-25 17:40:01 +00:00
|
|
|
class QComboBox;
|
2019-08-30 21:55:40 +00:00
|
|
|
class QPlainTextEdit;
|
2017-06-25 17:40:01 +00:00
|
|
|
class QPushButton;
|
|
|
|
class QTimer;
|
|
|
|
|
2017-08-27 22:10:06 +00:00
|
|
|
class LogWidget final : public QDockWidget, LogListener
|
2017-06-25 17:40:01 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2017-08-27 22:10:06 +00:00
|
|
|
explicit LogWidget(QWidget* parent = nullptr);
|
|
|
|
~LogWidget();
|
2017-06-25 17:40:01 +00:00
|
|
|
|
2017-09-20 11:18:36 +00:00
|
|
|
protected:
|
|
|
|
void closeEvent(QCloseEvent*) override;
|
|
|
|
|
2017-06-25 17:40:01 +00:00
|
|
|
private:
|
|
|
|
void UpdateLog();
|
|
|
|
void UpdateFont();
|
|
|
|
void CreateWidgets();
|
|
|
|
void ConnectWidgets();
|
|
|
|
void LoadSettings();
|
|
|
|
void SaveSettings();
|
|
|
|
|
|
|
|
void Log(LogTypes::LOG_LEVELS level, const char* text) override;
|
|
|
|
|
|
|
|
// Log
|
|
|
|
QCheckBox* m_log_wrap;
|
|
|
|
QComboBox* m_log_font;
|
|
|
|
QPushButton* m_log_clear;
|
2019-08-30 21:55:40 +00:00
|
|
|
QPlainTextEdit* m_log_text;
|
2017-06-25 17:40:01 +00:00
|
|
|
|
|
|
|
QTimer* m_timer;
|
|
|
|
|
2019-08-30 22:15:03 +00:00
|
|
|
using LogEntry = std::pair<std::string, LogTypes::LOG_LEVELS>;
|
|
|
|
|
2019-08-31 18:27:15 +00:00
|
|
|
// Maximum number of lines to show in log viewer
|
|
|
|
static constexpr int MAX_LOG_LINES = 5000;
|
|
|
|
|
2017-06-25 17:40:01 +00:00
|
|
|
std::mutex m_log_mutex;
|
2019-08-31 18:27:15 +00:00
|
|
|
FixedSizeQueue<LogEntry, MAX_LOG_LINES> m_log_ring_buffer;
|
2017-06-25 17:40:01 +00:00
|
|
|
};
|