- enhancement: adjust the appearance of problem case's input/output/expected control
This commit is contained in:
parent
fb18a1f1a3
commit
cfdbdca812
3
NEWS.md
3
NEWS.md
|
@ -1,3 +1,6 @@
|
||||||
|
Red Panda C++ Version 1.1.1
|
||||||
|
- enhancement: adjust the appearance of problem case's input/output/expected control
|
||||||
|
|
||||||
Red Panda C++ Version 1.1.0
|
Red Panda C++ Version 1.1.0
|
||||||
- enhancement: when ctrl+mouse cursor hovered an identifier or header name, use underline to highlight it
|
- enhancement: when ctrl+mouse cursor hovered an identifier or header name, use underline to highlight it
|
||||||
- enhancement: mark editor as modified, if the editing file is changed by other applications.
|
- enhancement: mark editor as modified, if the editing file is changed by other applications.
|
||||||
|
|
|
@ -10,7 +10,7 @@ isEmpty(APP_NAME) {
|
||||||
}
|
}
|
||||||
|
|
||||||
isEmpty(APP_VERSION) {
|
isEmpty(APP_VERSION) {
|
||||||
APP_VERSION=1.1.0
|
APP_VERSION=1.1.1
|
||||||
}
|
}
|
||||||
|
|
||||||
macos: {
|
macos: {
|
||||||
|
|
|
@ -107,7 +107,7 @@
|
||||||
"Gutter": {
|
"Gutter": {
|
||||||
"background": "#fff0f0f0",
|
"background": "#fff0f0f0",
|
||||||
"bold": false,
|
"bold": false,
|
||||||
"foreground": "#ff000000",
|
"foreground": "#ff004200",
|
||||||
"italic": false,
|
"italic": false,
|
||||||
"strikeout": false,
|
"strikeout": false,
|
||||||
"underlined": false
|
"underlined": false
|
||||||
|
|
|
@ -606,11 +606,45 @@ void MainWindow::updateEditorColorSchemes()
|
||||||
mCompletionPopup->setPalette(pal);
|
mCompletionPopup->setPalette(pal);
|
||||||
mHeaderCompletionPopup->setPalette(pal);
|
mHeaderCompletionPopup->setPalette(pal);
|
||||||
ui->classBrowser->setPalette(pal);
|
ui->classBrowser->setPalette(pal);
|
||||||
|
ui->txtProblemCaseInput->setPalette(pal);
|
||||||
|
ui->txtProblemCaseExpected->setPalette(pal);
|
||||||
|
ui->txtProblemCaseOutput->setPalette(pal);
|
||||||
} else {
|
} else {
|
||||||
QPalette pal = palette();
|
QPalette pal = palette();
|
||||||
mCompletionPopup->setPalette(pal);
|
mCompletionPopup->setPalette(pal);
|
||||||
mHeaderCompletionPopup->setPalette(pal);
|
mHeaderCompletionPopup->setPalette(pal);
|
||||||
ui->classBrowser->setPalette(pal);
|
ui->classBrowser->setPalette(pal);
|
||||||
|
ui->txtProblemCaseInput->setPalette(pal);
|
||||||
|
ui->txtProblemCaseExpected->setPalette(pal);
|
||||||
|
ui->txtProblemCaseOutput->setPalette(pal);
|
||||||
|
}
|
||||||
|
item = pColorManager->getItem(schemeName, COLOR_SCHEME_GUTTER);
|
||||||
|
if (item) {
|
||||||
|
ui->txtProblemCaseInput->setLineNumberAreaForeground(item->foreground());
|
||||||
|
ui->txtProblemCaseInput->setLineNumberAreaBackground(item->background());
|
||||||
|
ui->txtProblemCaseOutput->setLineNumberAreaForeground(item->foreground());
|
||||||
|
ui->txtProblemCaseOutput->setLineNumberAreaBackground(item->background());
|
||||||
|
ui->txtProblemCaseExpected->setLineNumberAreaForeground(item->foreground());
|
||||||
|
ui->txtProblemCaseExpected->setLineNumberAreaBackground(item->background());
|
||||||
|
} else {
|
||||||
|
QPalette pal = palette();
|
||||||
|
ui->txtProblemCaseInput->setLineNumberAreaForeground(pal.color(QPalette::ButtonText));
|
||||||
|
ui->txtProblemCaseInput->setLineNumberAreaBackground(pal.color(QPalette::Button));
|
||||||
|
ui->txtProblemCaseOutput->setLineNumberAreaForeground(pal.color(QPalette::ButtonText));
|
||||||
|
ui->txtProblemCaseOutput->setLineNumberAreaBackground(pal.color(QPalette::Button));
|
||||||
|
ui->txtProblemCaseExpected->setLineNumberAreaForeground(pal.color(QPalette::ButtonText));
|
||||||
|
ui->txtProblemCaseExpected->setLineNumberAreaBackground(pal.color(QPalette::Button));
|
||||||
|
}
|
||||||
|
item = pColorManager->getItem(schemeName, COLOR_SCHEME_GUTTER_ACTIVE_LINE);
|
||||||
|
if (item) {
|
||||||
|
ui->txtProblemCaseInput->setLineNumberAreaCurrentLine(item->foreground());
|
||||||
|
ui->txtProblemCaseOutput->setLineNumberAreaCurrentLine(item->foreground());
|
||||||
|
ui->txtProblemCaseExpected->setLineNumberAreaCurrentLine(item->foreground());
|
||||||
|
} else {
|
||||||
|
QPalette pal = palette();
|
||||||
|
ui->txtProblemCaseInput->setLineNumberAreaCurrentLine(pal.color(QPalette::ButtonText));
|
||||||
|
ui->txtProblemCaseOutput->setLineNumberAreaCurrentLine(pal.color(QPalette::ButtonText));
|
||||||
|
ui->txtProblemCaseExpected->setLineNumberAreaCurrentLine(pal.color(QPalette::ButtonText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,15 +18,15 @@
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
LineNumberTextEditor::LineNumberTextEditor(QWidget *parent)
|
LineNumberTextEditor::LineNumberTextEditor(QWidget *parent):QPlainTextEdit(parent)
|
||||||
{
|
{
|
||||||
lineNumberArea = new LineNumberArea(this);
|
lineNumberArea = new LineNumberArea(this);
|
||||||
|
|
||||||
connect(this, &LineNumberTextEditor::blockCountChanged, this, &LineNumberTextEditor::updateLineNumberAreaWidth);
|
connect(this, &LineNumberTextEditor::blockCountChanged, this, &LineNumberTextEditor::updateLineNumberAreaWidth);
|
||||||
connect(this, &LineNumberTextEditor::updateRequest, this, &LineNumberTextEditor::updateLineNumberArea);
|
connect(this, &LineNumberTextEditor::updateRequest, this, &LineNumberTextEditor::updateLineNumberArea);
|
||||||
//connect(this, &LineNumberTextEditor::cursorPositionChanged, this, &LineNumberTextEditor::highlightCurrentLine);
|
connect(this, &LineNumberTextEditor::cursorPositionChanged, this, &LineNumberTextEditor::highlightCurrentLine);
|
||||||
|
|
||||||
updateLineNumberAreaWidth(0);
|
updateLineNumberAreaWidth(0);
|
||||||
//highlightCurrentLine();
|
//highlightCurrentLine();
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ int LineNumberTextEditor::lineNumberAreaWidth()
|
||||||
++digits;
|
++digits;
|
||||||
}
|
}
|
||||||
|
|
||||||
int space = 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits;
|
int space = 10 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits;
|
||||||
|
|
||||||
return space;
|
return space;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,39 @@ void LineNumberTextEditor::updateLineNumberArea(const QRect &rect, int dy)
|
||||||
updateLineNumberAreaWidth(0);
|
updateLineNumberAreaWidth(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QColor &LineNumberTextEditor::lineNumberAreaCurrentLine() const
|
||||||
|
{
|
||||||
|
return mLineNumberAreaCurrentLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineNumberTextEditor::setLineNumberAreaCurrentLine(const QColor &newLineNumberAreaCurrentLine)
|
||||||
|
{
|
||||||
|
if (mLineNumberAreaCurrentLine == newLineNumberAreaCurrentLine)
|
||||||
|
return;
|
||||||
|
mLineNumberAreaCurrentLine = newLineNumberAreaCurrentLine;
|
||||||
|
emit lineNumberAreaCurrentLineChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
const QColor &LineNumberTextEditor::lineNumberAreaBackground() const
|
||||||
|
{
|
||||||
|
return mLineNumberAreaBackground;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineNumberTextEditor::setLineNumberAreaBackground(const QColor &newLineNumberAreaBackground)
|
||||||
|
{
|
||||||
|
mLineNumberAreaBackground = newLineNumberAreaBackground;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QColor &LineNumberTextEditor::lineNumberAreaForeground() const
|
||||||
|
{
|
||||||
|
return mLineNumberAreaForeground;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineNumberTextEditor::setLineNumberAreaForeground(const QColor &newLineNumberAreaForeground)
|
||||||
|
{
|
||||||
|
mLineNumberAreaForeground = newLineNumberAreaForeground;
|
||||||
|
}
|
||||||
|
|
||||||
void LineNumberTextEditor::resizeEvent(QResizeEvent *e)
|
void LineNumberTextEditor::resizeEvent(QResizeEvent *e)
|
||||||
{
|
{
|
||||||
QPlainTextEdit::resizeEvent(e);
|
QPlainTextEdit::resizeEvent(e);
|
||||||
|
@ -71,28 +104,32 @@ void LineNumberTextEditor::resizeEvent(QResizeEvent *e)
|
||||||
|
|
||||||
void LineNumberTextEditor::highlightCurrentLine()
|
void LineNumberTextEditor::highlightCurrentLine()
|
||||||
{
|
{
|
||||||
QList<QTextEdit::ExtraSelection> extraSelections;
|
lineNumberArea->update();
|
||||||
|
// QList<QTextEdit::ExtraSelection> extraSelections;
|
||||||
|
|
||||||
if (!isReadOnly()) {
|
// if (!isReadOnly()) {
|
||||||
QTextEdit::ExtraSelection selection;
|
// QTextEdit::ExtraSelection selection;
|
||||||
|
|
||||||
QColor lineColor = QColor(Qt::yellow).lighter(160);
|
// QColor lineColor = QColor(Qt::yellow).lighter(160);
|
||||||
|
|
||||||
selection.format.setBackground(lineColor);
|
// selection.format.setBackground(lineColor);
|
||||||
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
|
// selection.format.setProperty(QTextFormat::FullWidthSelection, true);
|
||||||
selection.cursor = textCursor();
|
// selection.cursor = textCursor();
|
||||||
selection.cursor.clearSelection();
|
// selection.cursor.clearSelection();
|
||||||
extraSelections.append(selection);
|
// extraSelections.append(selection);
|
||||||
}
|
// }
|
||||||
|
|
||||||
setExtraSelections(extraSelections);
|
// setExtraSelections(extraSelections);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineNumberTextEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
|
void LineNumberTextEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
QPainter painter(lineNumberArea);
|
QPainter painter(lineNumberArea);
|
||||||
painter.setFont(font());
|
painter.setFont(font());
|
||||||
painter.fillRect(event->rect(), palette().color(QPalette::Button));
|
if (isEnabled())
|
||||||
|
painter.fillRect(event->rect(), mLineNumberAreaBackground);
|
||||||
|
else
|
||||||
|
painter.fillRect(event->rect(), palette().color(QPalette::Disabled, QPalette::Button));
|
||||||
QTextBlock block = firstVisibleBlock();
|
QTextBlock block = firstVisibleBlock();
|
||||||
int blockNumber = block.blockNumber();
|
int blockNumber = block.blockNumber();
|
||||||
int top = qRound(blockBoundingGeometry(block).translated(contentOffset()).top());
|
int top = qRound(blockBoundingGeometry(block).translated(contentOffset()).top());
|
||||||
|
@ -100,8 +137,13 @@ void LineNumberTextEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
|
||||||
while (block.isValid() && top <= event->rect().bottom()) {
|
while (block.isValid() && top <= event->rect().bottom()) {
|
||||||
if (block.isVisible() && bottom >= event->rect().top()) {
|
if (block.isVisible() && bottom >= event->rect().top()) {
|
||||||
QString number = QString::number(blockNumber + 1);
|
QString number = QString::number(blockNumber + 1);
|
||||||
painter.setPen(palette().color(QPalette::ButtonText));
|
if (!isEnabled())
|
||||||
painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(),
|
painter.setPen(palette().color(QPalette::Disabled,QPalette::ButtonText));
|
||||||
|
else if (textCursor().blockNumber()==blockNumber)
|
||||||
|
painter.setPen(mLineNumberAreaCurrentLine);
|
||||||
|
else
|
||||||
|
painter.setPen(mLineNumberAreaForeground);
|
||||||
|
painter.drawText(5, top, lineNumberArea->width()-10, fontMetrics().height(),
|
||||||
Qt::AlignRight, number);
|
Qt::AlignRight, number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,18 @@ public:
|
||||||
void lineNumberAreaPaintEvent(QPaintEvent *event);
|
void lineNumberAreaPaintEvent(QPaintEvent *event);
|
||||||
int lineNumberAreaWidth();
|
int lineNumberAreaWidth();
|
||||||
|
|
||||||
|
const QColor &lineNumberAreaForeground() const;
|
||||||
|
void setLineNumberAreaForeground(const QColor &newLineNumberAreaForeground);
|
||||||
|
|
||||||
|
const QColor &lineNumberAreaBackground() const;
|
||||||
|
void setLineNumberAreaBackground(const QColor &newLineNumberAreaBackground);
|
||||||
|
|
||||||
|
const QColor &lineNumberAreaCurrentLine() const;
|
||||||
|
void setLineNumberAreaCurrentLine(const QColor &newLineNumberAreaCurrentLine);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void lineNumberAreaCurrentLineChanged();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
|
|
||||||
|
@ -38,6 +50,9 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *lineNumberArea;
|
QWidget *lineNumberArea;
|
||||||
|
QColor mLineNumberAreaForeground;
|
||||||
|
QColor mLineNumberAreaBackground;
|
||||||
|
QColor mLineNumberAreaCurrentLine;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LineNumberArea : public QWidget
|
class LineNumberArea : public QWidget
|
||||||
|
|
|
@ -23,7 +23,7 @@ SUBDIRS += \
|
||||||
|
|
||||||
APP_NAME = RedPandaCPP
|
APP_NAME = RedPandaCPP
|
||||||
|
|
||||||
APP_VERSION = 1.1.0
|
APP_VERSION = 1.1.1
|
||||||
|
|
||||||
linux: {
|
linux: {
|
||||||
isEmpty(PREFIX) {
|
isEmpty(PREFIX) {
|
||||||
|
|
Loading…
Reference in New Issue