aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp
diff options
context:
space:
mode:
authorq5sys <jt@obs-sec.com>2017-06-14 14:29:25 -0400
committerq5sys <jt@obs-sec.com>2017-06-14 14:29:25 -0400
commit9fb40bfc3c9a5b1877fdfdf65b307c690ea860d9 (patch)
treeb537499f575194ed4525bec104297ea06d3bd401 /src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp
parentMerge branch 'master' of http://github.com/trueos/lumina (diff)
downloadlumina-9fb40bfc3c9a5b1877fdfdf65b307c690ea860d9.tar.gz
lumina-9fb40bfc3c9a5b1877fdfdf65b307c690ea860d9.tar.bz2
lumina-9fb40bfc3c9a5b1877fdfdf65b307c690ea860d9.zip
fix font size bug for line sizes
Diffstat (limited to 'src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp')
-rw-r--r--src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp b/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp
index a1b77732..865798e2 100644
--- a/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp
+++ b/src-qt5/desktop-utils/lumina-textedit/PlainTextEditor.cpp
@@ -134,8 +134,10 @@ int PlainTextEditor::LNWWidth(){
int lines = this->blockCount();
if(lines<1){ lines = 1; }
int chars = 1;
+ qDebug() << "point 1" << this->document()->defaultFont();
while(lines>=10){ chars++; lines/=10; }
- return (this->fontMetrics().width("9")*chars); //make sure to add a tiny bit of padding
+ QFontMetrics metrics(this->document()->defaultFont());
+ return (metrics.width("9")*chars); //make sure to add a tiny bit of padding
}
void PlainTextEditor::paintLNW(QPaintEvent *ev){
@@ -146,12 +148,20 @@ void PlainTextEditor::paintLNW(QPaintEvent *ev){
QTextBlock block = this->firstVisibleBlock();
int bTop = blockBoundingGeometry(block).translated(contentOffset()).top();
int bBottom;
+// QFont font = P.font();
+// font.setPointSize(this->document()->defaultFont().pointSize());
+ P.setFont(this->document()->defaultFont());
//Now loop over the blocks (lines) and write in the numbers
+ QFontMetrics metrics(this->document()->defaultFont());
+ qDebug() << "point 2" << this->document()->defaultFont();
P.setPen(Qt::black); //setup the font color
while(block.isValid() && bTop<=ev->rect().bottom()){ //ensure block below top of viewport
bBottom = bTop+blockBoundingRect(block).height();
if(block.isVisible() && bBottom >= ev->rect().top()){ //ensure block above bottom of viewport
- P.drawText(0,bTop, LNW->width(), this->fontMetrics().height(), Qt::AlignRight, QString::number(block.blockNumber()+1) );
+ P.drawText(0,bTop, LNW->width(), metrics.height(), Qt::AlignRight, QString::number(block.blockNumber()+1) );
+ qDebug() << "bTop" << bTop;
+ qDebug() << "LNW->width()" << LNW->width();
+ qDebug() << "metrics.height()" << metrics.height();
}
//Go to the next block
block = block.next();
@@ -333,3 +343,7 @@ void PlainTextEditor::resizeEvent(QResizeEvent *ev){
QRect cGeom = this->contentsRect();
LNW->setGeometry( QRect(cGeom.left(), cGeom.top(), LNWWidth(), cGeom.height()) );
}
+
+void PlainTextEditor::updateLNW(){
+ LNW_updateWidth();
+}
bgstack15