src/platform/qt/LogView.h (view raw)
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
13namespace QGBA {
14
15class LogController;
16
17class LogView : public QWidget {
18Q_OBJECT
19
20public:
21 LogView(LogController* log, QWidget* parent = nullptr);
22
23signals:
24 void levelsEnabled(int levels);
25 void levelsDisabled(int levels);
26
27public slots:
28 void postLog(int level, int category, const QString& log);
29 void setLevels(int levels);
30 void clear();
31
32private slots:
33 void setMaxLines(int);
34
35protected:
36 virtual void paintEvent(QPaintEvent*) override;
37
38private:
39 static const int DEFAULT_LINE_LIMIT = 1000;
40
41 Ui::LogView m_ui;
42 int m_lines = 0;
43 int m_lineLimit = DEFAULT_LINE_LIMIT;
44 QQueue<QString> m_pendingLines;
45
46 void setLevel(int level, bool);
47
48 void clearLine();
49};
50
51}