History

Update console style

Ryan Huffman committed 12 years ago

Commit 9af02691 parent b9248e02 files · +39 −19Browse files

Showing the changes to interface/src/ui/JSConsole.cpp (1 of 2 files). Show all

Unified · Split

interface/src/ui/JSConsole.cpp+19−19
@@ -21,15 +21,13 @@ · 20 unmodified lines
21const int NO_CURRENT_HISTORY_COMMAND = -1;21const int NO_CURRENT_HISTORY_COMMAND = -1;
22const int MAX_HISTORY_SIZE = 64;22const int MAX_HISTORY_SIZE = 64;
23 23
24const QString ACTIVE_PROMPT_STYLESHEET = "color: rgb(0, 0, 255);";24const QString COMMAND_STYLE = "color: rgb(38, 106, 155);";
25const QString INACTIVE_PROMPT_STYLESHEET = "color: rgba(0, 0, 0, 0.5);";
26const QString COMMAND_STYLE = "color: rgb(30, 141, 255);";
27 25
28const QString RESULT_ERROR_STYLE = "color: rgb(255, 0, 0);";26const QString RESULT_SUCCESS_STYLE = "color: rgb(103, 115, 115);";
29const QString RESULT_SUCCESS_STYLE = "color: rgb(160, 160, 160);";27const QString RESULT_ERROR_STYLE = "color: rgb(209, 59, 34);";
30 28
31const QString GUTTER_ERROR = "<pre style=\"color: red;\">X</pre>";29const QString GUTTER_PREVIOUS_COMMAND = "<span style=\"color: rgb(87, 184, 187);\">&lt;</span>";
32const QString GUTTER_PREVIOUS_COMMAND = "<pre style=\"color: lightblue;\">&lt;</pre>";30const QString GUTTER_ERROR = "<span style=\"color: rgb(209, 59, 34);\">X</span>";
33 31
34JSConsole::JSConsole(QWidget* parent, ScriptEngine* scriptEngine) :32JSConsole::JSConsole(QWidget* parent, ScriptEngine* scriptEngine) :
35 QWidget(parent),33 QWidget(parent),
@@ -38,8 +36,15 @@ JSConsole::JSConsole(QWidget* parent, ScriptEngine* scriptEngine) : · 2 unmodified lines
38 _commandHistory(),36 _commandHistory(),
39 _scriptEngine(scriptEngine) {37 _scriptEngine(scriptEngine) {
40 38
39 QFile styleSheet(Application::resourcesPath() + "styles/console.qss");
40 if (styleSheet.open(QIODevice::ReadOnly)) {
41 QDir::setCurrent(Application::resourcesPath());
42 setStyleSheet(styleSheet.readAll());
43 }
44
41 _ui->setupUi(this);45 _ui->setupUi(this);
42 _ui->promptTextEdit->setLineWrapMode(QTextEdit::NoWrap);46 _ui->promptTextEdit->setLineWrapMode(QTextEdit::NoWrap);
47 _ui->promptTextEdit->setWordWrapMode(QTextOption::NoWrap);
43 _ui->promptTextEdit->installEventFilter(this);48 _ui->promptTextEdit->installEventFilter(this);
44 49
45 connect(_ui->scrollArea->verticalScrollBar(), SIGNAL(rangeChanged(int, int)), this, SLOT(scrollToBottom()));50 connect(_ui->scrollArea->verticalScrollBar(), SIGNAL(rangeChanged(int, int)), this, SLOT(scrollToBottom()));
@@ -54,7 +59,7 @@ JSConsole::JSConsole(QWidget* parent, ScriptEngine* scriptEngine) : · 8 unmodified lines
54 this, SLOT(handleEvalutationFinished(QScriptValue, bool)));59 this, SLOT(handleEvalutationFinished(QScriptValue, bool)));
55 connect(_scriptEngine, SIGNAL(printedMessage(const QString&)), this, SLOT(handlePrint(const QString&)));60 connect(_scriptEngine, SIGNAL(printedMessage(const QString&)), this, SLOT(handlePrint(const QString&)));
56 61
57 setWindowOpacity(0.95);62 resizeTextInput();
58}63}
59 64
60JSConsole::~JSConsole() {65JSConsole::~JSConsole() {
@@ -68,9 +73,8 @@ void JSConsole::executeCommand(const QString& command) { · 7 unmodified lines
68 }73 }
69 74
70 _ui->promptTextEdit->setDisabled(true);75 _ui->promptTextEdit->setDisabled(true);
71 _ui->promptGutterLabel->setStyleSheet(INACTIVE_PROMPT_STYLESHEET);
72 76
73 appendMessage(">", "<pre style='" + COMMAND_STYLE + "'>" + command.toHtmlEscaped() + "</pre>");77 appendMessage(">", "<span style='" + COMMAND_STYLE + "'>" + command.toHtmlEscaped() + "</span>");
74 78
75 QMetaObject::invokeMethod(_scriptEngine, "evaluate", Q_ARG(const QString&, command));79 QMetaObject::invokeMethod(_scriptEngine, "evaluate", Q_ARG(const QString&, command));
76 80
@@ -79,7 +83,6 @@ void JSConsole::executeCommand(const QString& command) { · 2 unmodified lines
79 83
80void JSConsole::handleEvalutationFinished(QScriptValue result, bool isException) {84void JSConsole::handleEvalutationFinished(QScriptValue result, bool isException) {
81 _ui->promptTextEdit->setDisabled(false);85 _ui->promptTextEdit->setDisabled(false);
82 _ui->promptGutterLabel->setStyleSheet(ACTIVE_PROMPT_STYLESHEET);
83 86
84 // Make sure focus is still on this window - some commands are blocking and can take awhile to execute.87 // Make sure focus is still on this window - some commands are blocking and can take awhile to execute.
85 if (window()->isActiveWindow()) {88 if (window()->isActiveWindow()) {
@@ -88,7 +91,7 @@ void JSConsole::handleEvalutationFinished(QScriptValue result, bool isException) · 2 unmodified lines
88 91
89 QString gutter = (isException || result.isError()) ? GUTTER_ERROR : GUTTER_PREVIOUS_COMMAND;92 QString gutter = (isException || result.isError()) ? GUTTER_ERROR : GUTTER_PREVIOUS_COMMAND;
90 QString resultColor = (isException || result.isError()) ? RESULT_ERROR_STYLE : RESULT_SUCCESS_STYLE;93 QString resultColor = (isException || result.isError()) ? RESULT_ERROR_STYLE : RESULT_SUCCESS_STYLE;
91 QString resultStr = "<pre style='" + resultColor + "'>" + result.toString().toHtmlEscaped() + "</pre>";94 QString resultStr = "<span style='" + resultColor + "'>" + result.toString().toHtmlEscaped() + "</span>";
92 appendMessage(gutter, resultStr);95 appendMessage(gutter, resultStr);
93}96}
94 97
@@ -120,8 +123,7 @@ bool JSConsole::eventFilter(QObject* sender, QEvent* event) { · 25 unmodified lines
120 123
121 if (!command.isEmpty()) {124 if (!command.isEmpty()) {
122 QTextCursor cursor = _ui->promptTextEdit->textCursor();125 QTextCursor cursor = _ui->promptTextEdit->textCursor();
123 cursor.select(QTextCursor::Document);126 _ui->promptTextEdit->clear();
124 cursor.removeSelectedText();
125 127
126 executeCommand(command);128 executeCommand(command);
127 }129 }
@@ -175,7 +177,7 @@ void JSConsole::resetCurrentCommandHistory() { · 47 unmodified lines
175}177}
176 178
177void JSConsole::resizeTextInput() {179void JSConsole::resizeTextInput() {
178 _ui->promptTextEdit->setMaximumHeight(_ui->promptTextEdit->document()->size().height());180 _ui->promptTextEdit->setFixedHeight(_ui->promptTextEdit->document()->size().height());
179 _ui->promptTextEdit->updateGeometry();181 _ui->promptTextEdit->updateGeometry();
180}182}
181 183
@@ -205,10 +207,8 @@ void JSConsole::appendMessage(const QString& gutter, const QString& message) { · 23 unmodified lines
205 gutterLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);207 gutterLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
206 messageLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);208 messageLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
207 209
208 QFont font("Courier New");210 gutterLabel->setStyleSheet("font-size: 14px; font-family: Inconsolata, Lucida Console, Andale Mono, Monaco;");
209 font.setStyleHint(QFont::Monospace);211 messageLabel->setStyleSheet("font-size: 14px; font-family: Inconsolata, Lucida Console, Andale Mono, Monaco;");
210 gutterLabel->setFont(font);
211 messageLabel->setFont(font);
212 212
213 gutterLabel->setText(gutter);213 gutterLabel->setText(gutter);
214 messageLabel->setText(message);214 messageLabel->setText(message);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t