mirror of https://github.com/mgba-emu/mgba.git
Ability to adjust line limit
This commit is contained in:
parent
d3a4c027e4
commit
24a579044f
|
@ -17,8 +17,10 @@ LogView::LogView(QWidget* parent)
|
||||||
connect(m_ui.levelFatal, SIGNAL(toggled(bool)), this, SLOT(setLevelFatal(bool)));
|
connect(m_ui.levelFatal, SIGNAL(toggled(bool)), this, SLOT(setLevelFatal(bool)));
|
||||||
connect(m_ui.levelGameError, SIGNAL(toggled(bool)), this, SLOT(setLevelGameError(bool)));
|
connect(m_ui.levelGameError, SIGNAL(toggled(bool)), this, SLOT(setLevelGameError(bool)));
|
||||||
connect(m_ui.clear, SIGNAL(clicked()), this, SLOT(clear()));
|
connect(m_ui.clear, SIGNAL(clicked()), this, SLOT(clear()));
|
||||||
|
connect(m_ui.maxLines, SIGNAL(valueChanged(int)), this, SLOT(setMaxLines(int)));
|
||||||
m_logLevel = GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL;
|
m_logLevel = GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL;
|
||||||
m_lines = 0;
|
m_lines = 0;
|
||||||
|
m_ui.maxLines->setValue(DEFAULT_LINE_LIMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogView::postLog(int level, const QString& log) {
|
void LogView::postLog(int level, const QString& log) {
|
||||||
|
@ -27,13 +29,14 @@ void LogView::postLog(int level, const QString& log) {
|
||||||
}
|
}
|
||||||
m_ui.view->appendPlainText(QString("%1:\t%2").arg(toString(level)).arg(log));
|
m_ui.view->appendPlainText(QString("%1:\t%2").arg(toString(level)).arg(log));
|
||||||
++m_lines;
|
++m_lines;
|
||||||
if (m_lines > LINE_LIMIT) {
|
if (m_lines > m_lineLimit) {
|
||||||
clearLine();
|
clearLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogView::clear() {
|
void LogView::clear() {
|
||||||
m_ui.view->clear();
|
m_ui.view->clear();
|
||||||
|
m_lines = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogView::setLevelDebug(bool set) {
|
void LogView::setLevelDebug(bool set) {
|
||||||
|
@ -43,6 +46,7 @@ void LogView::setLevelDebug(bool set) {
|
||||||
clearLevel(GBA_LOG_DEBUG);
|
clearLevel(GBA_LOG_DEBUG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogView::setLevelStub(bool set) {
|
void LogView::setLevelStub(bool set) {
|
||||||
if (set) {
|
if (set) {
|
||||||
setLevel(GBA_LOG_STUB);
|
setLevel(GBA_LOG_STUB);
|
||||||
|
@ -50,6 +54,7 @@ void LogView::setLevelStub(bool set) {
|
||||||
clearLevel(GBA_LOG_STUB);
|
clearLevel(GBA_LOG_STUB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogView::setLevelInfo(bool set) {
|
void LogView::setLevelInfo(bool set) {
|
||||||
if (set) {
|
if (set) {
|
||||||
setLevel(GBA_LOG_INFO);
|
setLevel(GBA_LOG_INFO);
|
||||||
|
@ -57,6 +62,7 @@ void LogView::setLevelInfo(bool set) {
|
||||||
clearLevel(GBA_LOG_INFO);
|
clearLevel(GBA_LOG_INFO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogView::setLevelWarn(bool set) {
|
void LogView::setLevelWarn(bool set) {
|
||||||
if (set) {
|
if (set) {
|
||||||
setLevel(GBA_LOG_WARN);
|
setLevel(GBA_LOG_WARN);
|
||||||
|
@ -64,6 +70,7 @@ void LogView::setLevelWarn(bool set) {
|
||||||
clearLevel(GBA_LOG_WARN);
|
clearLevel(GBA_LOG_WARN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogView::setLevelError(bool set) {
|
void LogView::setLevelError(bool set) {
|
||||||
if (set) {
|
if (set) {
|
||||||
setLevel(GBA_LOG_ERROR);
|
setLevel(GBA_LOG_ERROR);
|
||||||
|
@ -71,6 +78,7 @@ void LogView::setLevelError(bool set) {
|
||||||
clearLevel(GBA_LOG_ERROR);
|
clearLevel(GBA_LOG_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogView::setLevelFatal(bool set) {
|
void LogView::setLevelFatal(bool set) {
|
||||||
if (set) {
|
if (set) {
|
||||||
setLevel(GBA_LOG_FATAL);
|
setLevel(GBA_LOG_FATAL);
|
||||||
|
@ -78,6 +86,7 @@ void LogView::setLevelFatal(bool set) {
|
||||||
clearLevel(GBA_LOG_FATAL);
|
clearLevel(GBA_LOG_FATAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogView::setLevelGameError(bool set) {
|
void LogView::setLevelGameError(bool set) {
|
||||||
if (set) {
|
if (set) {
|
||||||
setLevel(GBA_LOG_GAME_ERROR);
|
setLevel(GBA_LOG_GAME_ERROR);
|
||||||
|
@ -86,6 +95,13 @@ void LogView::setLevelGameError(bool set) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogView::setMaxLines(int limit) {
|
||||||
|
m_lineLimit = limit;
|
||||||
|
while (m_lines > m_lineLimit) {
|
||||||
|
clearLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString LogView::toString(int level) {
|
QString LogView::toString(int level) {
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case GBA_LOG_DEBUG:
|
case GBA_LOG_DEBUG:
|
||||||
|
|
|
@ -30,12 +30,15 @@ private slots:
|
||||||
void setLevelFatal(bool);
|
void setLevelFatal(bool);
|
||||||
void setLevelGameError(bool);
|
void setLevelGameError(bool);
|
||||||
|
|
||||||
|
void setMaxLines(int);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int LINE_LIMIT = 1000;
|
static const int DEFAULT_LINE_LIMIT = 1000;
|
||||||
|
|
||||||
Ui::LogView m_ui;
|
Ui::LogView m_ui;
|
||||||
int m_logLevel;
|
int m_logLevel;
|
||||||
int m_lines;
|
int m_lines;
|
||||||
|
int m_lineLimit;
|
||||||
|
|
||||||
static QString toString(int level);
|
static QString toString(int level);
|
||||||
void setLevel(int level) { m_logLevel |= level; }
|
void setLevel(int level) { m_logLevel |= level; }
|
||||||
|
|
|
@ -131,6 +131,24 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Max Lines</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="maxLines">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>9999</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
Loading…
Reference in New Issue