This repository has been archived by the owner on May 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConsoleWidget.h
88 lines (68 loc) · 1.7 KB
/
ConsoleWidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#pragma once
#include "RefreshableWidget.h"
#include <QPainter>
#include "StyleContainer.h"
#include <QKeyEvent>
#include "ConsoleScollBar.h"
#include <QMessageBox>
#include <QVector>
#include <QTimer>
#include <QMouseEvent>
#include <QWheelEvent>
//#include "StringQueueThread.h"
#include <QMutex>
#include <QFontMetrics>
#include <QSet>
class ConsoleWidget : public RefreshableWidget
{
Q_OBJECT
public:
ConsoleWidget(QWidget *parent = Q_NULLPTR);
~ConsoleWidget();
private:
QString strInput;
ConsoleScollBar* scoller = nullptr;
//StringQueueThread* sThread = nullptr;
enum class LineState {
Input,
Output,
Error
};
QVector<QPair<QString, LineState>> lines;
QVector<QPair<QString, LineState>> lineSplit;
QMutex linesMutex;
QStringList commandTemp;
QString eLineTemp;
int currentTemp = -1;
void doString(QString command);
void reSplit();
void goDown();
int currentTopLine = 0;
int cursorPlace = 0;
bool showCursor = true;
QTimer curTimer;
QTimer refreshTimer;
const QString inputMask = ">> ";
const QString outputMask = "<< ";
bool haveChange = false;
QSet<int> lineSet;
protected:
void paintEvent(QPaintEvent* event)override;
void keyPressEvent(QKeyEvent* event)override;
void resizeAll()override;
void wheelEvent(QWheelEvent* event)override;
void showEvent(QShowEvent* event)override;
void hideEvent(QHideEvent* event)override;
void closeEvent(QCloseEvent* event)override;
public slots:
void on_luaMessage(QString message);
void on_luaError(QString message);
void on_luaClear();
private slots:
void on_ScollValueChanged(double sp, double ep);
void on_timerTimeOut();
void on_WheelChanged(int delta);
void on_refreshTimeOut();
signals:
void command(QString command);
};