WSL/SLF GitLab Repository
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
snow-models
inishell
Commits
e476f5c7
Commit
e476f5c7
authored
Mar 09, 2022
by
Mathias Bavay
Browse files
small improvement to the line numbering in the preview editor
parent
a28adf00
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/gui/PreviewEdit.cc
View file @
e476f5c7
...
@@ -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
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment