Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
nheko
Commits
ece20dd9
Commit
ece20dd9
authored
7 years ago
by
Konstantinos Sideris
Browse files
Options
Downloads
Patches
Plain Diff
Add rounded corners to inline images
parent
32377dc0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/timeline/widgets/ImageItem.h
+3
-0
3 additions, 0 deletions
include/timeline/widgets/ImageItem.h
src/timeline/widgets/ImageItem.cc
+26
-15
26 additions, 15 deletions
src/timeline/widgets/ImageItem.cc
with
29 additions
and
15 deletions
include/timeline/widgets/ImageItem.h
+
3
−
0
View file @
ece20dd9
...
...
@@ -69,6 +69,9 @@ private:
int
bottom_height_
=
30
;
QRectF
textRegion_
;
QRectF
imageRegion_
;
mtx
::
events
::
RoomEvent
<
mtx
::
events
::
msg
::
Image
>
event_
;
QSharedPointer
<
MatrixClient
>
client_
;
...
...
This diff is collapsed.
Click to expand it.
src/timeline/widgets/ImageItem.cc
+
26
−
15
View file @
ece20dd9
...
...
@@ -22,6 +22,7 @@
#include
<QPainter>
#include
<QPixmap>
#include
"Config.h"
#include
"dialogs/ImageOverlay.h"
#include
"timeline/widgets/ImageItem.h"
...
...
@@ -156,10 +157,7 @@ ImageItem::mousePressEvent(QMouseEvent *event)
return
;
}
auto
point
=
event
->
pos
();
// Click on the text box.
if
(
QRect
(
0
,
height_
-
bottom_height_
,
width_
,
bottom_height_
).
contains
(
point
))
{
if
(
textRegion_
.
contains
(
event
->
pos
()))
{
openUrl
();
}
else
{
auto
image_dialog
=
new
dialogs
::
ImageOverlay
(
image_
,
this
);
...
...
@@ -184,37 +182,50 @@ ImageItem::paintEvent(QPaintEvent *event)
painter
.
setRenderHint
(
QPainter
::
Antialiasing
);
QFont
font
(
"Open Sans"
);
font
.
setPixelSize
(
12
);
font
.
setPixelSize
(
conf
::
fontSize
);
QFontMetrics
metrics
(
font
);
int
fontHeight
=
metrics
.
heigh
t
();
const
int
fontHeight
=
metrics
.
ascen
t
();
if
(
image_
.
isNull
())
{
int
height
=
fontHeight
+
10
;
QString
elidedText
=
metrics
.
elidedText
(
text_
,
Qt
::
ElideRight
,
max_width_
-
10
);
setFixedSize
(
metrics
.
width
(
elidedText
),
fontHeight
+
10
);
setFixedSize
(
metrics
.
width
(
elidedText
),
fontHeight
);
painter
.
setFont
(
font
);
painter
.
setPen
(
QPen
(
QColor
(
66
,
133
,
244
)));
painter
.
drawText
(
QPoint
(
0
,
height
/
2
+
2
),
elidedText
);
painter
.
drawText
(
QPoint
(
0
,
fontHeight
),
elidedText
);
return
;
}
painter
.
fillRect
(
QRect
(
0
,
0
,
width_
,
height_
),
scaled_image_
);
imageRegion_
=
QRectF
(
0
,
0
,
width_
,
height_
);
QPainterPath
path
;
path
.
addRoundedRect
(
imageRegion_
,
5
,
5
);
painter
.
setPen
(
Qt
::
NoPen
);
painter
.
fillPath
(
path
,
scaled_image_
);
painter
.
drawPath
(
path
);
// Bottom text section
if
(
underMouse
())
{
// Bottom text section
painter
.
fillRect
(
QRect
(
0
,
height_
-
bottom_height_
,
width_
,
bottom_height_
),
QBrush
(
QColor
(
33
,
33
,
33
,
128
)));
const
int
textBoxHeight
=
2
*
fontHeight
;
textRegion_
=
QRectF
(
0
,
height_
-
textBoxHeight
,
width_
,
textBoxHeight
);
QPainterPath
textPath
;
textPath
.
addRoundedRect
(
textRegion_
,
0
,
0
);
painter
.
fillPath
(
textPath
,
QColor
(
40
,
40
,
40
,
140
));
QString
elidedText
=
metrics
.
elidedText
(
text_
,
Qt
::
ElideRight
,
width_
-
10
);
font
.
setWeight
(
80
);
painter
.
setFont
(
font
);
painter
.
setPen
(
QPen
(
QColor
(
"white"
)));
painter
.
drawText
(
QPoint
(
5
,
height_
-
fontHeight
/
2
),
elidedText
);
textRegion_
.
adjust
(
5
,
0
,
5
,
0
);
painter
.
drawText
(
textRegion_
,
Qt
::
AlignVCenter
,
elidedText
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment