| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#ifndef CONSOLE_H |
| 24 |
#define CONSOLE_H |
| 25 |
|
| 26 |
#include <QTextEdit> |
| 27 |
#include <QDockWidget> |
| 28 |
#include <QtGui> |
| 29 |
|
| 30 |
|
| 31 |
class Console : public QTextEdit |
| 32 |
{ |
| 33 |
Q_OBJECT |
| 34 |
public: |
| 35 |
Console(QWidget *parent = 0); |
| 36 |
|
| 37 |
virtual ~Console(); |
| 38 |
|
| 39 |
virtual void setDefaultFont(QFont font); |
| 40 |
virtual void setColors(QColor textColor, QColor bgColor); |
| 41 |
void scrollToEnd(); |
| 42 |
void setKeyRepeatMode(bool repeat); |
| 43 |
|
| 44 |
|
| 45 |
QList<int> errorLines; |
| 46 |
QStringList errorTexts; |
| 47 |
|
| 48 |
public slots: |
| 49 |
virtual void appendMessage(QString msg); |
| 50 |
void reset(); |
| 51 |
|
| 52 |
protected: |
| 53 |
virtual void contextMenuEvent(QContextMenuEvent *event); |
| 54 |
virtual void keyPressEvent(QKeyEvent *event); |
| 55 |
virtual void keyReleaseEvent(QKeyEvent *event); |
| 56 |
|
| 57 |
bool error; |
| 58 |
bool errorLine; |
| 59 |
QString errorLineText; |
| 60 |
QString messageLine; |
| 61 |
QColor m_textColor; |
| 62 |
QColor m_bgColor; |
| 63 |
QColor m_warningColor; |
| 64 |
QColor m_errorColor; |
| 65 |
|
| 66 |
bool m_repeatKeys; |
| 67 |
QMutex consoleLock; |
| 68 |
|
| 69 |
QRegularExpression rxerr; |
| 70 |
|
| 71 |
signals: |
| 72 |
void keyPressed(int key); |
| 73 |
void keyReleased(int key); |
| 74 |
void logMessage(QString msg); |
| 75 |
}; |
| 76 |
|
| 77 |
class DockConsole : public QDockWidget |
| 78 |
{ |
| 79 |
Q_OBJECT |
| 80 |
public: |
| 81 |
DockConsole(QWidget * parent); |
| 82 |
~DockConsole(); |
| 83 |
void copy(); |
| 84 |
bool widgetHasFocus(); |
| 85 |
void appendMessage(QString msg); |
| 86 |
|
| 87 |
public slots: |
| 88 |
|
| 89 |
protected: |
| 90 |
virtual void closeEvent(QCloseEvent * event); |
| 91 |
|
| 92 |
private: |
| 93 |
Console *text; |
| 94 |
signals: |
| 95 |
void Close(bool visible); |
| 96 |
}; |
| 97 |
|
| 98 |
class ConsoleWidget : public Console |
| 99 |
{ |
| 100 |
Q_OBJECT |
| 101 |
public: |
| 102 |
ConsoleWidget(QWidget * parent = 0): Console(parent) |
| 103 |
{ |
| 104 |
setReadOnly(true); |
| 105 |
setFontItalic(false); |
| 106 |
#ifdef Q_OS_MACOS |
| 107 |
document()->setDefaultFont(QFont("Courier New", 10)); |
| 108 |
#else |
| 109 |
document()->setDefaultFont(QFont("Courier New", 7)); |
| 110 |
#endif |
| 111 |
|
| 112 |
} |
| 113 |
|
| 114 |
~ConsoleWidget() {;} |
| 115 |
|
| 116 |
virtual void setWidgetGeometry(int x,int y,int width,int height); |
| 117 |
protected: |
| 118 |
|
| 119 |
|
| 120 |
signals: |
| 121 |
|
| 122 |
|
| 123 |
}; |
| 124 |
|
| 125 |
#endif |