Skip to content

Commit

Permalink
终端控件优化
Browse files Browse the repository at this point in the history
  • Loading branch information
SKiars committed Jul 24, 2019
1 parent ac359f8 commit a4a5ab3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions SerialTool/src/views/terminal/qvterminal/qvterminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ void QVTerminal::setFormat(const QVTCharFormat &format)
QFontMetrics fm(*_format.font());
_cw = fm.boundingRect('M').width();
_ch = fm.height();
_cascent = fm.ascent();
}

bool QVTerminal::event(QEvent *event)
Expand Down Expand Up @@ -317,8 +318,7 @@ void QVTerminal::paintEvent(QPaintEvent */* paintEvent */)

p.fillRect(viewport()->rect(), QColor(0x23, 0x26, 0x29));

QPoint pos;
pos.setY(0);
QPoint pos(0, 0);

int firstLine = verticalScrollBar()->value() / _ch;
int lastLine = viewport()->size().height() / _ch + firstLine;
Expand All @@ -338,8 +338,8 @@ void QVTerminal::paintEvent(QPaintEvent */* paintEvent */)
pos.setX(0);
for (auto vtc : _layout->lineAt(l).chars()) {
p.setPen(pos == curPos ? vtc.background() : vtc.foreground());
p.drawText(QRect(pos, QSize(_cw, _ch)), Qt::AlignCenter, vtc.c());
p.setBrush(QBrush());
p.drawText(pos.x(), pos.y() + _cascent, vtc.c());
//p.setBrush(QBrush());
//p.drawRect(QRect(pos, QSize(_cw, _ch)));
pos.setX(pos.x() + _cw);
}
Expand Down
3 changes: 1 addition & 2 deletions SerialTool/src/views/terminal/qvterminal/qvterminal.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ protected slots:
// cursor
QVTCharFormat _format;
QVTCharFormat _curentFormat;
int _cw;
int _ch;
int _cw, _ch, _cascent;
QPoint _cursorPos;
QTimer _cursorTimer;
bool _cvisible;
Expand Down

0 comments on commit a4a5ab3

Please sign in to comment.