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
2121 const int NO_CURRENT_HISTORY_COMMAND = -1;
2222 const int MAX_HISTORY_SIZE = 64;
2323
24−const QString ACTIVE_PROMPT_STYLESHEET = "color: rgb(0, 0, 255);";
25−const QString INACTIVE_PROMPT_STYLESHEET = "color: rgba(0, 0, 0, 0.5);";
26−const QString COMMAND_STYLE = "color: rgb(30, 141, 255);";
24+const QString COMMAND_STYLE = "color: rgb(38, 106, 155);";
2725
28−const QString RESULT_ERROR_STYLE = "color: rgb(255, 0, 0);";
29−const QString RESULT_SUCCESS_STYLE = "color: rgb(160, 160, 160);";
26+const QString RESULT_SUCCESS_STYLE = "color: rgb(103, 115, 115);";
27+const QString RESULT_ERROR_STYLE = "color: rgb(209, 59, 34);";
3028
31−const QString GUTTER_ERROR = "<pre style=\"color: red;\">X</pre>";
32−const QString GUTTER_PREVIOUS_COMMAND = "<pre style=\"color: lightblue;\">&lt;</pre>";
29+const QString GUTTER_PREVIOUS_COMMAND = "<span style=\"color: rgb(87, 184, 187);\">&lt;</span>";
30+const QString GUTTER_ERROR = "<span style=\"color: rgb(209, 59, 34);\">X</span>";
3331
3432 JSConsole::JSConsole(QWidget* parent, ScriptEngine* scriptEngine) :
3533 QWidget(parent),
@@ -38,8 +36,15 @@ JSConsole::JSConsole(QWidget* parent, ScriptEngine* scriptEngine) : · 2 unmodified lines
3836 _commandHistory(),
3937 _scriptEngine(scriptEngine) {
4038
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+
4145 _ui->setupUi(this);
4246 _ui->promptTextEdit->setLineWrapMode(QTextEdit::NoWrap);
47+ _ui->promptTextEdit->setWordWrapMode(QTextOption::NoWrap);
4348 _ui->promptTextEdit->installEventFilter(this);
4449
4550 connect(_ui->scrollArea->verticalScrollBar(), SIGNAL(rangeChanged(int, int)), this, SLOT(scrollToBottom()));
@@ -54,7 +59,7 @@ JSConsole::JSConsole(QWidget* parent, ScriptEngine* scriptEngine) : · 8 unmodified lines
5459 this, SLOT(handleEvalutationFinished(QScriptValue, bool)));
5560 connect(_scriptEngine, SIGNAL(printedMessage(const QString&)), this, SLOT(handlePrint(const QString&)));
5661
57− setWindowOpacity(0.95);
62+ resizeTextInput();
5863 }
5964
6065 JSConsole::~JSConsole() {
@@ -68,9 +73,8 @@ void JSConsole::executeCommand(const QString& command) { · 7 unmodified lines
6873 }
6974
7075 _ui->promptTextEdit->setDisabled(true);
71− _ui->promptGutterLabel->setStyleSheet(INACTIVE_PROMPT_STYLESHEET);
7276
73− appendMessage(">", "<pre style='" + COMMAND_STYLE + "'>" + command.toHtmlEscaped() + "</pre>");
77+ appendMessage(">", "<span style='" + COMMAND_STYLE + "'>" + command.toHtmlEscaped() + "</span>");
7478
7579 QMetaObject::invokeMethod(_scriptEngine, "evaluate", Q_ARG(const QString&, command));
7680
@@ -79,7 +83,6 @@ void JSConsole::executeCommand(const QString& command) { · 2 unmodified lines
7983
8084 void JSConsole::handleEvalutationFinished(QScriptValue result, bool isException) {
8185 _ui->promptTextEdit->setDisabled(false);
82− _ui->promptGutterLabel->setStyleSheet(ACTIVE_PROMPT_STYLESHEET);
8386
8487 // Make sure focus is still on this window - some commands are blocking and can take awhile to execute.
8588 if (window()->isActiveWindow()) {
@@ -88,7 +91,7 @@ void JSConsole::handleEvalutationFinished(QScriptValue result, bool isException) · 2 unmodified lines
8891
8992 QString gutter = (isException || result.isError()) ? GUTTER_ERROR : GUTTER_PREVIOUS_COMMAND;
9093 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>";
9295 appendMessage(gutter, resultStr);
9396 }
9497
@@ -120,8 +123,7 @@ bool JSConsole::eventFilter(QObject* sender, QEvent* event) { · 25 unmodified lines
120123
121124 if (!command.isEmpty()) {
122125 QTextCursor cursor = _ui->promptTextEdit->textCursor();
123− cursor.select(QTextCursor::Document);
124− cursor.removeSelectedText();
126+ _ui->promptTextEdit->clear();
125127
126128 executeCommand(command);
127129 }
@@ -175,7 +177,7 @@ void JSConsole::resetCurrentCommandHistory() { · 47 unmodified lines
175177 }
176178
177179 void JSConsole::resizeTextInput() {
178− _ui->promptTextEdit->setMaximumHeight(_ui->promptTextEdit->document()->size().height());
180+ _ui->promptTextEdit->setFixedHeight(_ui->promptTextEdit->document()->size().height());
179181 _ui->promptTextEdit->updateGeometry();
180182 }
181183
@@ -205,10 +207,8 @@ void JSConsole::appendMessage(const QString& gutter, const QString& message) { · 23 unmodified lines
205207 gutterLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
206208 messageLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
207209
208− QFont font("Courier New");
209− font.setStyleHint(QFont::Monospace);
210− gutterLabel->setFont(font);
211− messageLabel->setFont(font);
210+ gutterLabel->setStyleSheet("font-size: 14px; font-family: Inconsolata, Lucida Console, Andale Mono, Monaco;");
211+ messageLabel->setStyleSheet("font-size: 14px; font-family: Inconsolata, Lucida Console, Andale Mono, Monaco;");
212212
213213 gutterLabel->setText(gutter);
214214 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