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
57332553
Commit
57332553
authored
7 years ago
by
Konstantinos Sideris
Browse files
Options
Downloads
Patches
Plain Diff
Add full screen overlay for image display
parent
ec14e5e5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
CMakeLists.txt
+2
-0
2 additions, 0 deletions
CMakeLists.txt
include/ImageOverlayDialog.h
+44
-0
44 additions, 0 deletions
include/ImageOverlayDialog.h
src/ImageItem.cc
+6
-3
6 additions, 3 deletions
src/ImageItem.cc
src/ImageOverlayDialog.cc
+116
-0
116 additions, 0 deletions
src/ImageOverlayDialog.cc
with
168 additions
and
3 deletions
CMakeLists.txt
+
2
−
0
View file @
57332553
...
...
@@ -77,6 +77,7 @@ set(SRC_FILES
src/EmojiPickButton.cc
src/EmojiProvider.cc
src/ImageItem.cc
src/ImageOverlayDialog.cc
src/TimelineItem.cc
src/TimelineView.cc
src/TimelineViewManager.cc
...
...
@@ -129,6 +130,7 @@ qt5_wrap_cpp(MOC_HEADERS
include/EmojiPanel.h
include/EmojiPickButton.h
include/ImageItem.h
include/ImageOverlayDialog.h
include/TimelineItem.h
include/TimelineView.h
include/TimelineViewManager.h
...
...
This diff is collapsed.
Click to expand it.
include/ImageOverlayDialog.h
0 → 100644
+
44
−
0
View file @
57332553
/*
* nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IMAGE_OVERLAY_DIALOG_H
#define IMAGE_OVERLAY_DIALOG_H
#include
<QDialog>
#include
<QMouseEvent>
#include
<QPixmap>
class
ImageOverlayDialog
:
public
QDialog
{
Q_OBJECT
public:
ImageOverlayDialog
(
QPixmap
image
,
QWidget
*
parent
=
nullptr
);
protected:
void
mousePressEvent
(
QMouseEvent
*
event
)
override
;
void
paintEvent
(
QPaintEvent
*
event
)
override
;
private:
void
scaleImage
(
int
width
,
int
height
);
QPixmap
image_
;
QRect
content_
;
QRect
close_button_
;
};
#endif // IMAGE_OVERLAY_DIALOG_H
This diff is collapsed.
Click to expand it.
src/ImageItem.cc
+
6
−
3
View file @
57332553
...
...
@@ -23,6 +23,7 @@
#include
<QPixmap>
#include
"ImageItem.h"
#include
"ImageOverlayDialog.h"
ImageItem
::
ImageItem
(
QSharedPointer
<
MatrixClient
>
client
,
const
Event
&
event
,
const
QString
&
body
,
const
QUrl
&
url
,
QWidget
*
parent
)
:
QWidget
(
parent
)
...
...
@@ -121,10 +122,12 @@ void ImageItem::mousePressEvent(QMouseEvent *event)
auto
point
=
event
->
pos
();
// Click on the text box.
if
(
QRect
(
0
,
height_
-
bottom_height_
,
width_
,
bottom_height_
).
contains
(
point
))
if
(
QRect
(
0
,
height_
-
bottom_height_
,
width_
,
bottom_height_
).
contains
(
point
))
{
openUrl
();
else
qDebug
()
<<
"Opening image overlay. Not implemented yet."
;
}
else
{
auto
image_dialog
=
new
ImageOverlayDialog
(
image_
,
this
);
image_dialog
->
show
();
}
}
void
ImageItem
::
resizeEvent
(
QResizeEvent
*
event
)
...
...
This diff is collapsed.
Click to expand it.
src/ImageOverlayDialog.cc
0 → 100644
+
116
−
0
View file @
57332553
/*
* nheko Copyright (C) 2017 Konstantinos Sideris <siderisk@auth.gr>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include
<QDebug>
#include
<QPainter>
#include
"ImageOverlayDialog.h"
ImageOverlayDialog
::
ImageOverlayDialog
(
QPixmap
image
,
QWidget
*
parent
)
:
QDialog
{
parent
}
,
image_
{
image
}
{
setMouseTracking
(
true
);
setModal
(
false
);
setWindowFlags
(
windowFlags
()
|
Qt
::
FramelessWindowHint
);
setAttribute
(
Qt
::
WA_NoSystemBackground
,
true
);
setAttribute
(
Qt
::
WA_TranslucentBackground
,
true
);
setAttribute
(
Qt
::
WA_DeleteOnClose
,
true
);
setWindowState
(
Qt
::
WindowFullScreen
);
raise
();
}
// TODO: Move this into Utils
void
ImageOverlayDialog
::
scaleImage
(
int
max_width
,
int
max_height
)
{
if
(
image_
.
isNull
())
return
;
auto
width_ratio
=
(
double
)
max_width
/
(
double
)
image_
.
width
();
auto
height_ratio
=
(
double
)
max_height
/
(
double
)
image_
.
height
();
auto
min_aspect_ratio
=
std
::
min
(
width_ratio
,
height_ratio
);
int
final_width
=
0
;
int
final_height
=
0
;
if
(
min_aspect_ratio
>
1
)
{
final_width
=
image_
.
width
();
final_height
=
image_
.
height
();
}
else
{
final_width
=
image_
.
width
()
*
min_aspect_ratio
;
final_height
=
image_
.
height
()
*
min_aspect_ratio
;
}
image_
=
image_
.
scaled
(
final_width
,
final_height
,
Qt
::
IgnoreAspectRatio
,
Qt
::
SmoothTransformation
);
}
void
ImageOverlayDialog
::
paintEvent
(
QPaintEvent
*
event
)
{
Q_UNUSED
(
event
);
QPainter
painter
(
this
);
painter
.
setRenderHint
(
QPainter
::
Antialiasing
);
// Full screen overlay.
painter
.
fillRect
(
rect
(),
QColor
(
55
,
55
,
55
,
170
));
// Left and Right margins
int
outer_margin
=
rect
().
width
()
*
0.12
;
int
buttonSize
=
36
;
int
margin
=
outer_margin
*
0.1
;
int
max_width
=
rect
().
width
()
-
2
*
outer_margin
;
int
max_height
=
rect
().
height
();
scaleImage
(
max_width
,
max_height
);
int
diff_x
=
max_width
-
image_
.
width
();
int
diff_y
=
max_height
-
image_
.
height
();
content_
=
QRect
(
outer_margin
+
diff_x
/
2
,
diff_y
/
2
,
image_
.
width
(),
image_
.
height
());
close_button_
=
QRect
(
rect
().
width
()
-
margin
-
buttonSize
,
margin
,
buttonSize
,
buttonSize
);
// Draw main content_.
painter
.
drawPixmap
(
content_
,
image_
);
// Draw top right corner X.
QPen
pen
;
pen
.
setCapStyle
(
Qt
::
RoundCap
);
pen
.
setWidthF
(
5
);
pen
.
setColor
(
"gray"
);
auto
center
=
close_button_
.
center
();
painter
.
setPen
(
pen
);
painter
.
drawLine
(
center
-
QPointF
(
15
,
15
),
center
+
QPointF
(
15
,
15
));
painter
.
drawLine
(
center
+
QPointF
(
15
,
-
15
),
center
-
QPointF
(
15
,
-
15
));
}
void
ImageOverlayDialog
::
mousePressEvent
(
QMouseEvent
*
event
)
{
if
(
event
->
button
()
!=
Qt
::
LeftButton
)
return
;
// FIXME: The main window needs double click to regain focus.
if
(
close_button_
.
contains
(
event
->
pos
()))
close
();
}
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