Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Office
Calligra
Commits
cd03501c
Commit
cd03501c
authored
Nov 10, 2014
by
Jarosław Staniek
Browse files
Fix position of the Calligra logo based on height of the main menu
BUG:340767 FIXED-IN:2.8.7 REVIEW:121088
parent
772adfb8
Changes
3
Hide whitespace changes
Inline
Side-by-side
kexi/main/KexiMenuWidget.cpp
View file @
cd03501c
/* This file is part of the KDE project
Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
Copyright (C) 2011-201
3
Jarosław Staniek <staniek@kde.org>
Copyright (C) 2011-201
4
Jarosław Staniek <staniek@kde.org>
Based on qmenu.cpp from Qt 4.7
...
...
@@ -63,7 +63,8 @@
#include
<QDesktopServices>
#include
<QUrl>
const
int
logoBottomMargin
=
84
-
12
;
const
int
calligraLogoPixmapInternalWidth
=
100
;
const
int
calligraLogoPixmapInternalHeight
=
71
;
const
char
calligraUrl
[]
=
"http://www.calligra.org"
;
// from oxygenhelper.cpp:
...
...
@@ -2098,11 +2099,69 @@ void KexiMenuWidgetPrivate::updateLogoPixmap()
calligraLogoPixmap
=
QPixmap
(
calligraLogo
);
}
int
KexiMenuWidgetPrivate
::
bottomOfLastItem
()
const
{
if
(
actionRects
.
isEmpty
())
{
return
0
;
}
return
actionRects
.
last
().
bottom
();
}
/* Logo's pixmap is consisted of logo and some glow (cutted-off vertically).
(without the glow the math would be simpler)
+--------+ +
| glow | |--- glowHeight - cutOffGlow
| +----+ | +
| |logo| | |--- calligraLogoPixmapInternalHeight
| +----+ | +
| glow | |--- glowHeight - cutOffGlow
+--------+ +
*/
const
int
glowHeight
=
64
;
const
int
cutOffGlow
=
12
;
const
int
spacingAfterLastItem
=
10
;
//! @return distance between bottom border of the logo and bottom border of the entire menu widget
int
KexiMenuWidgetPrivate
::
logoBottomMargin
()
const
{
/*
+----------------+
| Menu item 1 | |
| ... | |
| Last menu item | | q->height()
+----------------+ <--- bottomOfLastItem() |
| | |--- spacingAfterLastItem |
+----------------+
| glow |
| +----+ |
| |logo| |
| +----+ | +
| glow | |--- bottomMargin
+----------------+ +
*/
int
bottomMargin
=
glowHeight
-
cutOffGlow
;
if
((
q
->
height
()
-
bottomMargin
-
calligraLogoPixmapInternalHeight
-
cutOffGlow
)
<=
(
bottomOfLastItem
()
+
spacingAfterLastItem
))
{
/* Special case when the last menu item would cover the logo: keep the logo below
+----------------+
| +----+ |
| |logo| |
+----------------+ |--- bottomMargin (can be 0 or negative)
| */
bottomMargin
=
q
->
height
()
-
bottomOfLastItem
()
-
spacingAfterLastItem
-
cutOffGlow
-
calligraLogoPixmapInternalHeight
;
}
return
bottomMargin
;
}
void
KexiMenuWidgetPrivate
::
updateLogo
()
{
const
QRect
logoRect
((
q
->
width
()
-
2
-
100
)
/
2
,
q
->
height
()
-
logoBottomMargin
-
71
-
12
,
100
,
71
);
const
QRect
logoRect
((
q
->
width
()
-
2
-
calligraLogoPixmapInternalWidth
)
/
2
,
q
->
height
()
-
logoBottomMargin
()
-
calligraLogoPixmapInternalHeight
-
cutOffGlow
,
calligraLogoPixmapInternalWidth
,
calligraLogoPixmapInternalHeight
);
if
(
!
clickableLogoArea
)
{
updateLogoPixmap
();
clickableLogoArea
=
new
ClickableLogoArea
(
q
);
...
...
@@ -2314,6 +2373,7 @@ void KexiMenuWidget::paintEvent(QPaintEvent *e)
QColor
textColor
;
textColor
=
palette
().
color
(
QPalette
::
Base
);
p
.
setPen
(
QPen
(
textColor
));
const
int
logoBottomMargin
=
d
->
logoBottomMargin
();
p
.
drawText
(
0
,
height
()
-
logoBottomMargin
+
1
,
width
(),
logoBottomMargin
-
1
,
Qt
::
AlignHCenter
|
Qt
::
AlignTop
,
QLatin1String
(
Kexi
::
versionString
()));
...
...
@@ -2326,7 +2386,8 @@ void KexiMenuWidget::paintEvent(QPaintEvent *e)
// logo
p
.
drawPixmap
((
width
()
-
d
->
calligraLogoPixmap
.
width
())
/
2
,
height
()
-
d
->
calligraLogoPixmap
.
height
()
-
20
,
height
()
-
logoBottomMargin
-
d
->
calligraLogoPixmap
.
height
()
+
calligraLogoPixmapInternalHeight
-
20
,
d
->
calligraLogoPixmap
);
}
...
...
@@ -2472,7 +2533,9 @@ KexiMenuWidget::event(QEvent *e)
}
d
->
itemsDirty
=
1
;
d
->
updateActionRects
();
break
;
}
d
->
updateLogo
();
break
;
}
case
QEvent
::
Show
:
d
->
mouseDown
=
0
;
d
->
updateActionRects
();
...
...
kexi/main/KexiMenuWidget.h
View file @
cd03501c
/* This file is part of the KDE project
Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
Copyright (C) 2011 Jarosław Staniek <staniek@kde.org>
Copyright (C) 2011
-2014
Jarosław Staniek <staniek@kde.org>
Based on qmenu.h from Qt 4.7
...
...
kexi/main/KexiMenuWidget_p.h
View file @
cd03501c
...
...
@@ -271,6 +271,9 @@ public:
bool
bespin
;
bool
qtcurve
;
//! @return y coordinate of bottom margin of last menu item
int
bottomOfLastItem
()
const
;
int
logoBottomMargin
()
const
;
void
updateLogo
();
void
updateLogoPixmap
();
QPixmap
calligraLogoPixmap
;
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment