0e57a7beef
This commit includes two big changes, alongside other smaller tweaks. 1) Update the internal QTextDocument of the text component directly 2) Use QPlainTextEdit, which supports HTML & is designed for long text 3) Use QString's arg function for formatting strings Fix 1 significantly improves realtime performance when adding lines individually, to the point that the UI no longer freezes if the viewer is open and the log is being spammed. It also improves initial launch speed when there's a large amount of text already in the file. Reference: https://stackoverflow.com/a/54501760/2763321 Fix 2 completely eliminates delay when opening the viewer, regardless of how many lines are already in the log file. For a standard log after OBS launch, this cuts opening time from about 2 seconds to half a second. For anything longer than 1,000 lines, the UI no longer freezes, and the viewer (& its contents) open within half a second. Reference: https://stackoverflow.com/a/17466240/2763321
24 lines
390 B
C++
24 lines
390 B
C++
#pragma once
|
|
|
|
#include <QDialog>
|
|
#include <QPlainTextEdit>
|
|
#include "obs-app.hpp"
|
|
|
|
class OBSLogViewer : public QDialog {
|
|
Q_OBJECT
|
|
|
|
QPointer<QPlainTextEdit> textArea;
|
|
|
|
void InitLog();
|
|
|
|
private slots:
|
|
void AddLine(int type, const QString &text);
|
|
void ClearText();
|
|
void ToggleShowStartup(bool checked);
|
|
void OpenFile();
|
|
|
|
public:
|
|
OBSLogViewer(QWidget *parent = 0);
|
|
~OBSLogViewer();
|
|
};
|