Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-client-windows
Commits
2965014a
Commit
2965014a
authored
Jan 03, 2019
by
Andreas Traczyk
Browse files
ui: cleanup fonts and margins in account selection and smartlist
Change-Id: Ie05aff10c54eb60466668d24a8a72300d251febd
parent
39fa4d0b
Changes
6
Hide whitespace changes
Inline
Side-by-side
accountitemdelegate.cpp
View file @
2965014a
...
...
@@ -65,6 +65,7 @@ AccountItemDelegate::paint(QPainter* painter,
QFont
font
(
painter
->
font
());
font
.
setPointSize
(
fontSize_
);
QPen
pen
(
painter
->
pen
());
// is it the add account row?
...
...
@@ -82,7 +83,12 @@ AccountItemDelegate::paint(QPainter* painter,
opt
.
decorationPosition
=
QStyleOptionViewItem
::
Left
;
opt
.
decorationAlignment
=
Qt
::
AlignCenter
;
QRect
rectAvatar
(
dy_
+
rect
.
left
(),
rect
.
top
()
+
dy_
,
avatarSize_
,
avatarSize_
);
QRect
rectAvatar
(
leftPadding_
+
rect
.
left
(),
rect
.
top
()
+
topPadding_
,
avatarSize_
,
avatarSize_
);
drawDecoration
(
painter
,
opt
,
rectAvatar
,
QPixmap
::
fromImage
(
index
.
data
(
AccountListModel
::
Role
::
Picture
).
value
<
QImage
>
())
.
scaled
(
avatarSize_
,
avatarSize_
,
Qt
::
KeepAspectRatio
,
Qt
::
SmoothTransformation
));
...
...
@@ -102,8 +108,8 @@ AccountItemDelegate::paint(QPainter* painter,
painter
->
setPen
(
pen
);
QRect
rectTexts
(
dx
_
+
rect
.
left
()
+
dx
_
+
avatarSize_
,
rect
.
top
(),
QRect
rectTexts
(
leftPadding
_
+
rect
.
left
()
+
leftPadding
_
+
avatarSize_
,
rect
.
top
()
+
topPadding_
/
2
,
rect
.
width
(),
rect
.
height
()
/
2
);
...
...
@@ -112,13 +118,13 @@ AccountItemDelegate::paint(QPainter* painter,
if
(
name
.
isValid
())
{
font
.
setItalic
(
false
);
font
.
setBold
(
tru
e
);
font
.
setBold
(
fals
e
);
pen
.
setColor
(
RingTheme
::
lightBlack_
);
painter
->
setPen
(
pen
);
painter
->
setFont
(
font
);
QFontMetrics
fontMetrics
(
font
);
QString
nameStr
=
fontMetrics
.
elidedText
(
name
.
value
<
QString
>
(),
Qt
::
ElideRight
,
rectTexts
.
width
()
-
avatarSize_
-
dx_
);
rectTexts
.
width
()
-
avatarSize_
-
leftPadding_
-
rightPadding_
*
2
);
painter
->
drawText
(
rectTexts
,
Qt
::
AlignVCenter
|
Qt
::
AlignLeft
,
nameStr
);
}
...
...
@@ -134,9 +140,9 @@ AccountItemDelegate::paint(QPainter* painter,
QFontMetrics
fontMetrics
(
font
);
if
(
!
idStr
.
isNull
())
{
idStr
=
fontMetrics
.
elidedText
(
idStr
,
Qt
::
ElideRight
,
rectTexts
.
width
()
-
avatarSize_
-
dx
_
*
2
);
painter
->
drawText
(
QRect
(
dx
_
+
rect
.
left
()
+
dx
_
+
avatarSize_
,
rect
.
top
()
+
dy
_
*
3
,
rectTexts
.
width
()
-
avatarSize_
-
leftPadding_
-
rightPadding
_
*
2
);
painter
->
drawText
(
QRect
(
leftPadding
_
+
rect
.
left
()
+
leftPadding
_
+
avatarSize_
,
rect
.
top
()
+
topPadding
_
*
3
,
rect
.
width
(),
rect
.
height
()
/
2
),
Qt
::
AlignBottom
|
Qt
::
AlignLeft
,
idStr
);
...
...
accountitemdelegate.h
View file @
2965014a
...
...
@@ -33,8 +33,10 @@ protected:
private:
constexpr
static
int
fontSize_
=
10
;
const
QFont
font_
=
QFont
(
"Arial"
,
fontSize_
);
constexpr
static
int
dy_
=
6
;
constexpr
static
int
dx_
=
12
;
constexpr
static
int
topPadding_
=
6
;
constexpr
static
int
bottomPadding_
=
6
;
constexpr
static
int
leftPadding_
=
12
;
constexpr
static
int
rightPadding_
=
12
;
constexpr
static
int
avatarSize_
=
36
;
constexpr
static
int
cellHeight_
=
48
;
};
conversationitemdelegate.cpp
View file @
2965014a
...
...
@@ -28,6 +28,7 @@
#include
"ringthemeutils.h"
#include
"utils.h"
#include
"lrcinstance.h"
#include
"mainwindow.h"
#include
<ciso646>
...
...
@@ -126,7 +127,7 @@ ConversationItemDelegate::paint(QPainter* painter
using
namespace
lrc
::
api
;
auto
type
=
Utils
::
toEnum
<
profile
::
Type
>
(
index
.
data
(
static_cast
<
int
>
(
SmartListModel
::
Role
::
ContactType
)).
value
<
int
>
()
index
.
data
(
static_cast
<
int
>
(
SmartListModel
::
Role
::
ContactType
)).
value
<
int
>
()
);
switch
(
type
)
{
case
profile
::
Type
::
RING
:
...
...
@@ -165,15 +166,22 @@ ConversationItemDelegate::paintRingConversationItem(QPainter* painter,
QPen
pen
(
painter
->
pen
());
painter
->
setPen
(
pen
);
auto
leftMargin
=
dx_
+
sizeImage_
+
dx_
/
2
;
int
infoTextWidthModifier
=
0
;
auto
scalingRatio
=
MainWindow
::
instance
().
getCurrentScalingRatio
();
if
(
scalingRatio
>
1.0
)
{
font
.
setPointSize
(
fontSize_
-
1
);
infoTextWidthModifier
=
12
;
}
auto
leftMargin
=
dx_
+
sizeImage_
+
dx_
;
auto
rightMargin
=
dx_
;
auto
topMargin
=
0
;
auto
bottomMargin
=
12
;
auto
topMargin
=
4
;
auto
bottomMargin
=
8
;
QRect
rectName1
(
rect
.
left
()
+
leftMargin
,
rect
.
top
()
+
topMargin
,
rect
.
width
()
-
leftMargin
-
infoTextWidth_
,
rect
.
height
()
/
2
);
rect
.
width
()
-
leftMargin
-
infoTextWidth_
-
infoTextWidthModifier
,
rect
.
height
()
/
2
-
2
);
QRect
rectName2
(
rectName1
.
left
(),
rectName1
.
top
()
+
rectName1
.
height
(),
...
...
@@ -182,8 +190,8 @@ ConversationItemDelegate::paintRingConversationItem(QPainter* painter,
QRect
rectInfo1
(
rectName1
.
left
()
+
rectName1
.
width
(),
rect
.
top
()
+
topMargin
,
infoTextWidth_
-
rightMargin
,
rect
.
height
()
/
2
);
infoTextWidth_
-
rightMargin
+
infoTextWidthModifier
,
rect
.
height
()
/
2
-
2
);
QRect
rectInfo2
(
rectInfo1
.
left
(),
rectInfo1
.
top
()
+
rectInfo1
.
height
(),
...
...
@@ -196,7 +204,7 @@ ConversationItemDelegate::paintRingConversationItem(QPainter* painter,
QString
nameStr
=
index
.
data
(
static_cast
<
int
>
(
SmartListModel
::
Role
::
DisplayName
)).
value
<
QString
>
();
if
(
!
nameStr
.
isNull
())
{
font
.
setItalic
(
false
);
font
.
setBold
(
tru
e
);
font
.
setBold
(
fals
e
);
pen
.
setColor
(
RingTheme
::
lightBlack_
);
painter
->
setPen
(
pen
);
painter
->
setFont
(
font
);
...
...
@@ -276,18 +284,18 @@ ConversationItemDelegate::paintRingInviteConversationItem(QPainter* painter,
QPen
pen
(
painter
->
pen
());
painter
->
setPen
(
pen
);
auto
leftMargin
=
dx_
+
sizeImage_
+
dx_
/
2
;
auto
leftMargin
=
dx_
+
sizeImage_
+
dx_
;
auto
rightMargin
=
dx_
;
if
(
option
.
state
&
QStyle
::
State_MouseOver
)
{
rightMargin
=
infoTextWidth_
-
dx_
*
2
;
}
auto
topMargin
=
0
;
auto
bottomMargin
=
12
;
auto
topMargin
=
4
;
auto
bottomMargin
=
8
;
QRect
rectName1
(
rect
.
left
()
+
leftMargin
,
rect
.
top
()
+
topMargin
,
rect
.
width
()
-
leftMargin
-
rightMargin
,
rect
.
height
()
/
2
);
rect
.
height
()
/
2
-
2
);
QRect
rectName2
(
rectName1
.
left
(),
rectName1
.
top
()
+
rectName1
.
height
(),
...
...
@@ -300,7 +308,7 @@ ConversationItemDelegate::paintRingInviteConversationItem(QPainter* painter,
QString
nameStr
=
index
.
data
(
static_cast
<
int
>
(
SmartListModel
::
Role
::
DisplayName
)).
value
<
QString
>
();
if
(
!
nameStr
.
isNull
())
{
font
.
setItalic
(
false
);
font
.
setBold
(
tru
e
);
font
.
setBold
(
fals
e
);
pen
.
setColor
(
RingTheme
::
lightBlack_
);
painter
->
setPen
(
pen
);
painter
->
setFont
(
font
);
...
...
currentaccountcombobox.cpp
View file @
2965014a
...
...
@@ -75,7 +75,7 @@ CurrentAccountComboBox::paintEvent(QPaintEvent* e)
{
Q_UNUSED
(
e
);
QPoint
p
(
1
2
,
2
);
QPoint
avatarTopLeft
(
1
6
,
2
);
QPainter
painter
(
this
);
painter
.
setRenderHints
((
QPainter
::
Antialiasing
|
QPainter
::
TextAntialiasing
),
true
);
...
...
@@ -83,10 +83,6 @@ CurrentAccountComboBox::paintEvent(QPaintEvent* e)
opt
.
init
(
this
);
style
()
->
drawPrimitive
(
QStyle
::
PE_Widget
,
&
opt
,
&
painter
);
// create box in which to draw avatar and presence indicator
QRect
avatarRect
(
2
,
2
,
cellHeight_
,
cellHeight_
);
// [screen awareness]
QRect
comboBoxRect
(
cellHeight_
+
p
.
x
()
+
2
,
4
,
this
->
width
()
-
cellHeight_
+
p
.
x
(),
cellHeight_
-
10
);
// [screen awareness]
// define and set the two fonts
QFont
fontPrimary
=
painter
.
font
();
QFont
fontSecondary
=
painter
.
font
();
...
...
@@ -94,19 +90,18 @@ CurrentAccountComboBox::paintEvent(QPaintEvent* e)
fontPrimary
.
setPointSize
(
11
);
fontPrimary
.
setWeight
(
QFont
::
ExtraLight
);
fontSecondary
.
setPointSize
(
10
);
painter
.
setFont
(
fontPrimary
);
QFontMetrics
fontMetricPrimary
(
fontPrimary
);
QFontMetrics
fontMetricSecondary
(
fontSecondary
);
painter
.
drawPixmap
(
p
,
currentAccountAvatarImage_
);
painter
.
drawPixmap
(
avatarTopLeft
,
currentAccountAvatarImage_
);
// fill in presence indicator if account is registered
auto
accountStatus
=
LRCInstance
::
getCurrentAccountInfo
().
status
;
if
(
accountStatus
==
lrc
::
api
::
account
::
Status
::
REGISTERED
)
{
// paint the presence indicator circle
QPainterPath
outerCircle
,
innerCircle
;
QPointF
presenceCenter
(
40.0
+
p
.
x
(),
40.0
);
QPointF
presenceCenter
(
40.0
+
avatarTopLeft
.
x
(),
40.0
);
qreal
outerCircleRadius
=
cellHeight_
/
6.5
;
qreal
innerCircleRadius
=
outerCircleRadius
*
0.75
;
outerCircle
.
addEllipse
(
presenceCenter
,
outerCircleRadius
,
outerCircleRadius
);
...
...
@@ -115,9 +110,16 @@ CurrentAccountComboBox::paintEvent(QPaintEvent* e)
painter
.
fillPath
(
innerCircle
,
RingTheme
::
presenceGreen_
);
}
QRect
comboBoxRect
(
cellHeight_
+
avatarTopLeft
.
x
()
+
10
+
2
,
6
,
this
->
width
()
-
cellHeight_
,
cellHeight_
-
10
);
// [screen awareness]
// write primary and secondary account identifiers to combobox label
QString
primaryAccountID
=
QString
::
fromStdString
(
Utils
::
bestNameForAccount
(
LRCInstance
::
getCurrentAccountInfo
()));
painter
.
setPen
(
Qt
::
black
);
painter
.
setFont
(
fontPrimary
);
painter
.
setPen
(
RingTheme
::
lightBlack_
);
primaryAccountID
=
fontMetricPrimary
.
elidedText
(
primaryAccountID
,
Qt
::
ElideRight
,
comboBoxRect
.
width
()
-
elidConst
-
(
popupPresent
?
0
:
2
*
gearSize_
));
painter
.
drawText
(
comboBoxRect
,
Qt
::
AlignLeft
,
primaryAccountID
);
...
...
mainwindow.cpp
View file @
2965014a
...
...
@@ -350,16 +350,21 @@ MainWindow::show()
QMainWindow
::
show
();
disconnect
(
screenChangedConnection_
);
screenChangedConnection_
=
connect
(
windowHandle
(),
&
QWindow
::
screenChanged
,
[
this
](
QScreen
*
screen
)
{
Q_UNUSED
(
screen
);
adjustSize
();
updateGeometry
();
update
();
// a little delay won't hurt ;)
QTimer
::
singleShot
(
100
,
this
,
[
this
]
{
qobject_cast
<
NavWidget
*>
(
ui
->
navStack
->
currentWidget
())
->
updateCustomUI
();
});
this
,
&
MainWindow
::
slotScreenChanged
);
}
void
MainWindow
::
slotScreenChanged
(
QScreen
*
screen
)
{
Q_UNUSED
(
screen
);
adjustSize
();
updateGeometry
();
update
();
currentScalingRatio_
=
screen
->
logicalDotsPerInchX
()
/
96
;
// a little delay won't hurt ;)
QTimer
::
singleShot
(
100
,
this
,
[
this
]
{
qobject_cast
<
NavWidget
*>
(
ui
->
navStack
->
currentWidget
())
->
updateCustomUI
();
});
}
...
...
@@ -369,3 +374,9 @@ MainWindow::resizeEvent(QResizeEvent* event)
Q_UNUSED
(
event
);
qobject_cast
<
NavWidget
*>
(
ui
->
navStack
->
currentWidget
())
->
updateCustomUI
();
}
float
MainWindow
::
getCurrentScalingRatio
()
{
return
currentScalingRatio_
;
}
\ No newline at end of file
mainwindow.h
View file @
2965014a
...
...
@@ -53,8 +53,8 @@ public:
}
void
createThumbBar
();
bool
init
();
void
show
();
float
getCurrentScalingRatio
();
protected:
bool
nativeEvent
(
const
QByteArray
&
eventType
,
void
*
message
,
long
*
result
);
...
...
@@ -70,6 +70,7 @@ private slots:
void
onIncomingCall
(
Call
*
call
);
void
switchNormalMaximize
();
void
notificationClicked
();
void
slotScreenChanged
(
QScreen
*
screen
);
private:
explicit
MainWindow
(
QWidget
*
parent
=
0
);
...
...
@@ -79,6 +80,7 @@ private:
ScreenEnum
lastScr_
;
int
lastAccountCount_
;
Qt
::
WindowFlags
flags_
;
float
currentScalingRatio_
;
void
readSettingsFromRegistry
();
...
...
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