Skip to content

Commit a4a5ab3

Browse files
author
SKiars
committed
终端控件优化
1 parent ac359f8 commit a4a5ab3

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

SerialTool/src/views/terminal/qvterminal/qvterminal.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ void QVTerminal::setFormat(const QVTCharFormat &format)
259259
QFontMetrics fm(*_format.font());
260260
_cw = fm.boundingRect('M').width();
261261
_ch = fm.height();
262+
_cascent = fm.ascent();
262263
}
263264

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

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

320-
QPoint pos;
321-
pos.setY(0);
321+
QPoint pos(0, 0);
322322

323323
int firstLine = verticalScrollBar()->value() / _ch;
324324
int lastLine = viewport()->size().height() / _ch + firstLine;
@@ -338,8 +338,8 @@ void QVTerminal::paintEvent(QPaintEvent */* paintEvent */)
338338
pos.setX(0);
339339
for (auto vtc : _layout->lineAt(l).chars()) {
340340
p.setPen(pos == curPos ? vtc.background() : vtc.foreground());
341-
p.drawText(QRect(pos, QSize(_cw, _ch)), Qt::AlignCenter, vtc.c());
342-
p.setBrush(QBrush());
341+
p.drawText(pos.x(), pos.y() + _cascent, vtc.c());
342+
//p.setBrush(QBrush());
343343
//p.drawRect(QRect(pos, QSize(_cw, _ch)));
344344
pos.setX(pos.x() + _cw);
345345
}

SerialTool/src/views/terminal/qvterminal/qvterminal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ protected slots:
6262
// cursor
6363
QVTCharFormat _format;
6464
QVTCharFormat _curentFormat;
65-
int _cw;
66-
int _ch;
65+
int _cw, _ch, _cascent;
6766
QPoint _cursorPos;
6867
QTimer _cursorTimer;
6968
bool _cvisible;

0 commit comments

Comments
 (0)