1 /* Copyright (c) 2013-2015 Jeffrey Pfau 2 * 3 * This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 #pragma once 7 8 #include <QQueue> 9 #include <QWidget> 10 11 #include "ui_LogView.h" 12 13 namespace QGBA { 14 15 class LogController; 16 class Window; 17 18 class LogView : public QWidget { 19 Q_OBJECT 20 21 public: 22 LogView(LogController* log, Window* window, QWidget* parent = nullptr); 23 24 signals: 25 void levelsEnabled(int levels); 26 void levelsDisabled(int levels); 27 28 public slots: 29 void postLog(int level, int category, const QString& log); 30 void setLevels(int levels); 31 void clear(); 32 33 private slots: 34 void setMaxLines(int); 35 36 protected: 37 virtual void paintEvent(QPaintEvent*) override; 38 39 private: 40 static const int DEFAULT_LINE_LIMIT = 1000; 41 42 Ui::LogView m_ui; 43 int m_lines = 0; 44 int m_lineLimit = DEFAULT_LINE_LIMIT; 45 QQueue<QString> m_pendingLines; 46 47 void setLevel(int level, bool); 48 49 void clearLine(); 50 }; 51 52 } 53