all repos — mgba @ 24a579044f2789698b7e051f2861b09ae78c7449

mGBA Game Boy Advance Emulator

Ability to adjust line limit
Jeffrey Pfau jeffrey@endrift.com
Mon, 13 Oct 2014 02:56:08 -0700
commit

24a579044f2789698b7e051f2861b09ae78c7449

parent

d3a4c027e452c4e5ad2e1cceea3b2a68985a6487

3 files changed, 39 insertions(+), 2 deletions(-)

jump to
M src/platform/qt/LogView.cppsrc/platform/qt/LogView.cpp

@@ -17,8 +17,10 @@ connect(m_ui.levelError, SIGNAL(toggled(bool)), this, SLOT(setLevelError(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.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_lines = 0; + m_ui.maxLines->setValue(DEFAULT_LINE_LIMIT); } void LogView::postLog(int level, const QString& log) {

@@ -27,13 +29,14 @@ return;

} m_ui.view->appendPlainText(QString("%1:\t%2").arg(toString(level)).arg(log)); ++m_lines; - if (m_lines > LINE_LIMIT) { + if (m_lines > m_lineLimit) { clearLine(); } } void LogView::clear() { m_ui.view->clear(); + m_lines = 0; } void LogView::setLevelDebug(bool set) {

@@ -43,6 +46,7 @@ } else {

clearLevel(GBA_LOG_DEBUG); } } + void LogView::setLevelStub(bool set) { if (set) { setLevel(GBA_LOG_STUB);

@@ -50,6 +54,7 @@ } else {

clearLevel(GBA_LOG_STUB); } } + void LogView::setLevelInfo(bool set) { if (set) { setLevel(GBA_LOG_INFO);

@@ -57,6 +62,7 @@ } else {

clearLevel(GBA_LOG_INFO); } } + void LogView::setLevelWarn(bool set) { if (set) { setLevel(GBA_LOG_WARN);

@@ -64,6 +70,7 @@ } else {

clearLevel(GBA_LOG_WARN); } } + void LogView::setLevelError(bool set) { if (set) { setLevel(GBA_LOG_ERROR);

@@ -71,6 +78,7 @@ } else {

clearLevel(GBA_LOG_ERROR); } } + void LogView::setLevelFatal(bool set) { if (set) { setLevel(GBA_LOG_FATAL);

@@ -78,11 +86,19 @@ } else {

clearLevel(GBA_LOG_FATAL); } } + void LogView::setLevelGameError(bool set) { if (set) { setLevel(GBA_LOG_GAME_ERROR); } else { clearLevel(GBA_LOG_GAME_ERROR); + } +} + +void LogView::setMaxLines(int limit) { + m_lineLimit = limit; + while (m_lines > m_lineLimit) { + clearLine(); } }
M src/platform/qt/LogView.hsrc/platform/qt/LogView.h

@@ -30,12 +30,15 @@ void setLevelError(bool);

void setLevelFatal(bool); void setLevelGameError(bool); + void setMaxLines(int); + private: - static const int LINE_LIMIT = 1000; + static const int DEFAULT_LINE_LIMIT = 1000; Ui::LogView m_ui; int m_logLevel; int m_lines; + int m_lineLimit; static QString toString(int level); void setLevel(int level) { m_logLevel |= level; }
M src/platform/qt/LogView.uisrc/platform/qt/LogView.ui

@@ -131,6 +131,24 @@ <string>Clear</string>

</property> </widget> </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> </item> <item>