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
4fccc627
Commit
4fccc627
authored
7 years ago
by
Konstantinos Sideris
Browse files
Options
Downloads
Patches
Plain Diff
Fix full screen image viewer on macOS sierra
parent
93e8297b
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/ImageOverlayDialog.h
+2
-6
2 additions, 6 deletions
include/ImageOverlayDialog.h
src/ImageOverlayDialog.cc
+15
-21
15 additions, 21 deletions
src/ImageOverlayDialog.cc
with
17 additions
and
27 deletions
include/ImageOverlayDialog.h
+
2
−
6
View file @
4fccc627
...
...
@@ -21,14 +21,12 @@
#include
<QMouseEvent>
#include
<QPixmap>
class
ImageOverlayDialog
:
public
Q
Dialog
class
ImageOverlayDialog
:
public
Q
Widget
{
Q_OBJECT
public:
ImageOverlayDialog
(
QPixmap
image
,
QWidget
*
parent
=
nullptr
);
void
reject
()
override
;
protected:
void
mousePressEvent
(
QMouseEvent
*
event
)
override
;
void
paintEvent
(
QPaintEvent
*
event
)
override
;
...
...
@@ -36,9 +34,6 @@ protected:
signals:
void
closing
();
private
slots
:
void
closeDialog
();
private:
void
scaleImage
(
int
width
,
int
height
);
...
...
@@ -47,4 +42,5 @@ private:
QRect
content_
;
QRect
close_button_
;
QRect
screen_
;
};
This diff is collapsed.
Click to expand it.
src/ImageOverlayDialog.cc
+
15
−
21
View file @
4fccc627
...
...
@@ -15,43 +15,37 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include
<QApplication>
#include
<QDebug>
#include
<QDesktopWidget>
#include
<QPainter>
#include
<QScreen>
#include
<QTimer>
#include
"ImageOverlayDialog.h"
ImageOverlayDialog
::
ImageOverlayDialog
(
QPixmap
image
,
QWidget
*
parent
)
:
Q
Dialog
{
parent
}
:
Q
Widget
{
parent
}
,
originalImage_
{
image
}
{
setMouseTracking
(
true
);
set
Modal
(
false
);
set
Parent
(
0
);
setWindowFlags
(
windowFlags
()
|
Qt
::
FramelessWindowHint
);
setAttribute
(
Qt
::
WA_NoSystemBackground
,
true
);
setAttribute
(
Qt
::
WA_TranslucentBackground
,
true
);
setAttribute
(
Qt
::
WA_DeleteOnClose
,
true
);
setWindowState
(
Qt
::
WindowFullScreen
);
connect
(
this
,
SIGNAL
(
closing
()),
this
,
SLOT
(
closeDialog
()));
}
screen_
=
QApplication
::
desktop
()
->
availableGeometry
();
void
ImageOverlayDialog
::
reject
()
{
// needed on macOS to recover the main menu after the dialog is closed(!)
// also affects KDE/Plasma. XXX: There may be a better way of resetting the
// window state than this...
setWindowState
(
Qt
::
WindowNoState
);
move
(
QApplication
::
desktop
()
->
mapToGlobal
(
screen_
.
topLeft
()));
resize
(
screen_
.
size
());
QDialog
::
reject
();
}
connect
(
this
,
SIGNAL
(
closing
()),
this
,
SLOT
(
close
()));
void
ImageOverlayDialog
::
closeDialog
()
{
QTimer
::
singleShot
(
100
,
this
,
&
ImageOverlayDialog
::
reject
);
raise
();
}
// TODO: Move this into Utils
...
...
@@ -87,15 +81,15 @@ void ImageOverlayDialog::paintEvent(QPaintEvent *event)
painter
.
setRenderHint
(
QPainter
::
Antialiasing
);
// Full screen overlay.
painter
.
fillRect
(
rec
t
(),
QColor
(
55
,
55
,
55
,
170
));
painter
.
fillRect
(
QRect
(
0
,
0
,
screen_
.
width
(),
screen_
.
heigh
t
()
)
,
QColor
(
55
,
55
,
55
,
170
));
// Left and Right margins
int
outer_margin
=
rect
()
.
width
()
*
0.12
;
int
outer_margin
=
screen_
.
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
();
int
max_width
=
screen_
.
width
()
-
2
*
outer_margin
;
int
max_height
=
screen_
.
height
();
scaleImage
(
max_width
,
max_height
);
...
...
@@ -103,7 +97,7 @@ void ImageOverlayDialog::paintEvent(QPaintEvent *event)
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
);
close_button_
=
QRect
(
screen_
.
width
()
-
margin
-
buttonSize
,
margin
,
buttonSize
,
buttonSize
);
// Draw main content_.
painter
.
drawPixmap
(
content_
,
image_
);
...
...
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