WSL/SLF GitLab Repository

Commit e476f5c7 authored by Mathias Bavay's avatar Mathias Bavay
Browse files

small improvement to the line numbering in the preview editor

parent a28adf00
...@@ -170,15 +170,15 @@ void PreviewEdit::dragMoveEvent(QDragMoveEvent *event) ...@@ -170,15 +170,15 @@ void PreviewEdit::dragMoveEvent(QDragMoveEvent *event)
int PreviewEdit::getSidePanelWidth() int PreviewEdit::getSidePanelWidth()
{ {
//since log10 returns 0 for numbers <10, add 1. For a nicer look, we add 0.5 char's width //since log10 returns 0 for numbers <10, add 1. For a nicer look, we add 0.5 char's width
const double digits = floor(log10(qMax(1, blockCount()))) + 1.5; const double digits = floor(log10(qMax(1, blockCount()))) + .5;
const int width = static_cast<int>(fontMetrics().boundingRect(QLatin1Char('0')).width() * digits); const int width = static_cast<int>(fontMetrics().boundingRect(QLatin1Char('M')).width() * digits);
return width; return width;
} }
void PreviewEdit::updateSidePanelWidth() void PreviewEdit::updateSidePanelWidth()
{ {
//we add a small margin between the line number and the line itself //we add a small margin between the line number and the line itself
const int margin_width = fontMetrics().boundingRect(QLatin1Char('0')).width() / 2; const int margin_width = fontMetrics().boundingRect(QLatin1Char('M')).width() / 2;
setViewportMargins(getSidePanelWidth()+margin_width, 0, 0, 0); setViewportMargins(getSidePanelWidth()+margin_width, 0, 0, 0);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment