all repos — mgba @ e0a6af087e83d79b53ad5352511c7e02c557b93f

mGBA Game Boy Advance Emulator

src/platform/qt/LogController.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#ifndef QGBA_LOG_CONTROLLER
 7#define QGBA_LOG_CONTROLLER
 8
 9#include <QObject>
10#include <QStringList>
11
12extern "C" {
13#include "gba/gba.h"
14}
15
16namespace QGBA {
17
18class LogController : public QObject {
19Q_OBJECT
20
21private:
22	class Stream {
23	public:
24		Stream(LogController* controller, int level);
25		~Stream();
26
27		Stream& operator<<(const QString&);
28
29	private:
30		int m_level;
31		LogController* m_log;
32
33		QStringList m_queue;
34	};
35
36public:
37	LogController(int levels, QObject* parent = nullptr);
38
39	int levels() const { return m_logLevel; }
40
41	Stream operator()(int level);
42
43	static QString toString(int level);
44
45signals:
46	void logPosted(int level, const QString& log);
47	void levelsSet(int levels);
48	void levelsEnabled(int levels);
49	void levelsDisabled(int levels);
50
51public slots:
52	void postLog(int level, const QString& string);
53	void setLevels(int levels);
54	void enableLevels(int levels);
55	void disableLevels(int levels);
56
57private:
58	int m_logLevel;
59};
60
61}
62
63#endif