-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathconsolewindow.cpp
More file actions
58 lines (49 loc) · 1.56 KB
/
Copy pathconsolewindow.cpp
File metadata and controls
58 lines (49 loc) · 1.56 KB
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
#include "consolewindow.h"
#include "debugger.h"
#include "settings.h"
#include <QPushButton>
#include <QPlainTextEdit>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QScrollBar>
#include <QTextCursor>
#include <QApplication>
#include <QLabel>
#include <QFile>
#include <QDebug>
extern Debugger *dbg;
ConsoleWindow::ConsoleWindow(QWidget *parent)
: QFrame(parent)
{
setObjectName("Console");
setFrameStyle(QFrame::Panel | QFrame::Raised);
setLineWidth(4);
QVBoxLayout *layout = new QVBoxLayout;
layout->setSpacing(5);
layout->setContentsMargins(10, 10, 10, 10);
QHBoxLayout *commandLayout = new QHBoxLayout;
QLabel *label = new QLabel(tr("debugger command"));
label->setStyleSheet("font-family: " + ebe["variable_font"].toString());
commandLayout->addWidget(label);
commandLine = new QLineEdit(this);
commandLayout->addWidget(commandLine);
textEdit = new QPlainTextEdit(this);
layout->addWidget(textEdit);
layout->addLayout(commandLayout);
setLayout(layout);
scrollBar = textEdit->verticalScrollBar();
connect(dbg, SIGNAL(log(QString)), this, SLOT(log(QString)));
connect(commandLine, SIGNAL(returnPressed()), this, SLOT(sendCommand()));
connect(this, SIGNAL(doCommand(QString)), dbg, SLOT(doCommand(QString)));
}
void ConsoleWindow::log(QString s)
{
//qDebug() << "logging" << s;
textEdit->textCursor().insertText(s + '\n');
scrollBar->setValue(textEdit->document()->lineCount() - 1);
}
void ConsoleWindow::sendCommand()
{
emit doCommand(commandLine->text());
}