Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Q
qtquickcontrols-nemo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
NemoMobile
qtquickcontrols-nemo
Commits
c4206d08
Commit
c4206d08
authored
Apr 07, 2017
by
Chupligin Sergey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Sizing] add density independence pixel sizes
parent
415dc3a3
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
135 additions
and
47 deletions
+135
-47
ButtonRow.qml
src/controls/ButtonRow.qml
+5
-5
qquicknemocontrolsextensionplugin.cpp
src/controls/qquicknemocontrolsextensionplugin.cpp
+1
-2
sizing.cpp
src/controls/sizing.cpp
+67
-7
sizing.h
src/controls/sizing.h
+33
-3
ButtonStyle.qml
src/styles/ButtonStyle.qml
+2
-2
CheckBoxStyle.qml
src/styles/CheckBoxStyle.qml
+8
-9
GrooveStyle.qml
src/styles/GrooveStyle.qml
+2
-2
MenuBarStyle.qml
src/styles/MenuBarStyle.qml
+2
-2
SliderStyle.qml
src/styles/SliderStyle.qml
+7
-7
TextFieldStyle.qml
src/styles/TextFieldStyle.qml
+3
-3
ToolBarStyle.qml
src/styles/ToolBarStyle.qml
+2
-2
ToolButtonStyle.qml
src/styles/ToolButtonStyle.qml
+3
-3
No files found.
src/controls/ButtonRow.qml
View file @
c4206d08
...
@@ -36,7 +36,7 @@ Rectangle {
...
@@ -36,7 +36,7 @@ Rectangle {
id
:
main
id
:
main
width
:
childrenRect
.
width
width
:
childrenRect
.
width
color
:
"
#313131
"
color
:
"
#313131
"
height
:
4
*
mm
height
:
size
.
dp
(
40
)
property
ListModel
model
:
ListModel
{}
property
ListModel
model
:
ListModel
{}
property
bool
enabled
:
true
property
bool
enabled
:
true
property
int
currentIndex
:
-
1
property
int
currentIndex
:
-
1
...
@@ -51,10 +51,10 @@ Rectangle {
...
@@ -51,10 +51,10 @@ Rectangle {
Rectangle
{
Rectangle
{
id
:
selecter
id
:
selecter
x
:
rowElement
.
children
[
main
.
currentIndex
].
x
||
0
x
:
rowElement
.
children
[
main
.
currentIndex
].
x
||
0
y
:
-
0.5
*
mm
y
:
size
.
dp
(
-
5
)
width
:
rowElement
.
children
[
main
.
currentIndex
].
width
||
0
width
:
rowElement
.
children
[
main
.
currentIndex
].
width
||
0
height
:
5
*
mm
height
:
size
.
dp
(
50
)
color
:
"
#0091e5
"
color
:
"
#0091e5
"
visible
:
main
.
currentIndex
>
-
1
visible
:
main
.
currentIndex
>
-
1
...
@@ -74,10 +74,10 @@ Rectangle {
...
@@ -74,10 +74,10 @@ Rectangle {
model
:
main
.
model
model
:
main
.
model
delegate
:
Rectangle
{
delegate
:
Rectangle
{
id
:
rowItem
id
:
rowItem
height
:
5
*
mm
height
:
size
.
dp
(
50
)
width
:
text
.
width
+
(
text
.
width
/
name
.
length
*
2
)
width
:
text
.
width
+
(
text
.
width
/
name
.
length
*
2
)
y
:
-
0.5
*
mm
y
:
size
.
dp
(
-
5
)
color
:
"
transparent
"
color
:
"
transparent
"
MouseArea
{
MouseArea
{
...
...
src/controls/qquicknemocontrolsextensionplugin.cpp
View file @
c4206d08
...
@@ -53,8 +53,7 @@ void QQuickNemoControlsExtensionPlugin::initializeEngine(QQmlEngine *engine, con
...
@@ -53,8 +53,7 @@ void QQuickNemoControlsExtensionPlugin::initializeEngine(QQmlEngine *engine, con
QQmlExtensionPlugin
::
initializeEngine
(
engine
,
uri
);
QQmlExtensionPlugin
::
initializeEngine
(
engine
,
uri
);
QQmlContext
*
context
=
engine
->
rootContext
();
QQmlContext
*
context
=
engine
->
rootContext
();
context
->
setContextProperty
(
"size"
,
sizing
);
context
->
setContextProperty
(
"mm"
,
sizing
->
getScaleFactor
());
engine
->
addImageProvider
(
QLatin1String
(
"theme"
),
new
NemoImageProvider
);
engine
->
addImageProvider
(
QLatin1String
(
"theme"
),
new
NemoImageProvider
);
}
}
...
...
src/controls/sizing.cpp
View file @
c4206d08
...
@@ -7,7 +7,10 @@
...
@@ -7,7 +7,10 @@
Sizing
::
Sizing
(
QObject
*
parent
)
:
QObject
(
parent
)
Sizing
::
Sizing
(
QObject
*
parent
)
:
QObject
(
parent
)
{
{
m_valid
=
false
;
m_valid
=
false
;
m_scale_factor
=
10
;
m_mm_factor
=
10
;
m_dp_factor
=
1
;
m_densitie
=
mdpi
;
m_p_height
=
qgetenv
(
"QT_QPA_EGLFS_PHYSICAL_HEIGHT"
).
toInt
();
m_p_height
=
qgetenv
(
"QT_QPA_EGLFS_PHYSICAL_HEIGHT"
).
toInt
();
m_p_width
=
qgetenv
(
"QT_QPA_EGLFS_PHYSICAL_WIDTH"
).
toInt
();
m_p_width
=
qgetenv
(
"QT_QPA_EGLFS_PHYSICAL_WIDTH"
).
toInt
();
...
@@ -17,9 +20,32 @@ Sizing::Sizing(QObject *parent) : QObject(parent)
...
@@ -17,9 +20,32 @@ Sizing::Sizing(QObject *parent) : QObject(parent)
m_height
=
screen
->
size
().
height
();
m_height
=
screen
->
size
().
height
();
m_width
=
screen
->
size
().
width
();
m_width
=
screen
->
size
().
width
();
m_dpi
=
screen
->
physicalDotsPerInch
();
qDebug
()
<<
"DPI is "
<<
m_dpi
;
if
(
m_dpi
<
140
){
m_densitie
=
ldpi
;
}
else
if
(
m_dpi
>=
140
&&
m_dpi
<
200
){
//~160dpi
m_densitie
=
mdpi
;
}
else
if
(
m_dpi
>=
200
&&
m_dpi
<
280
){
//~240dpi
m_densitie
=
hdpi
;
}
else
if
(
m_dpi
>=
280
&&
m_dpi
<
400
){
//~320dpi
m_densitie
=
xhdpi
;
}
else
if
(
m_dpi
>=
400
&&
m_dpi
<
560
){
//~480dpi
m_densitie
=
xxhdpi
;
}
else
{
m_densitie
=
xxxhdpi
;
}
if
(
m_p_height
>
0
&&
m_p_width
>
0
){
if
(
m_p_height
>
0
&&
m_p_width
>
0
){
m_valid
=
true
;
m_valid
=
true
;
scaleFactor
();
setMmScaleFactor
();
setDpScaleFactor
();
}
else
{
}
else
{
if
(
m_p_height
==
0
){
if
(
m_p_height
==
0
){
qWarning
(
"QT_QPA_EGLFS_PHYSICAL_HEIGHT is not set!"
);
qWarning
(
"QT_QPA_EGLFS_PHYSICAL_HEIGHT is not set!"
);
...
@@ -28,18 +54,52 @@ Sizing::Sizing(QObject *parent) : QObject(parent)
...
@@ -28,18 +54,52 @@ Sizing::Sizing(QObject *parent) : QObject(parent)
if
(
m_p_width
==
0
){
if
(
m_p_width
==
0
){
qWarning
(
"QT_QPA_EGLFS_PHYSICAL_WIDTH is not set!"
);
qWarning
(
"QT_QPA_EGLFS_PHYSICAL_WIDTH is not set!"
);
}
}
qWarning
(
"Device mm sizing don`t work"
);
qWarning
(
"Device sizing don`t work"
);
}
}
}
}
void
Sizing
::
scaleFactor
()
void
Sizing
::
s
etMmS
caleFactor
()
{
{
if
(
m_p_width
!=
0
){
if
(
m_p_width
!=
0
){
m_
scale
_factor
=
m_width
/
m_p_width
;
m_
mm
_factor
=
m_width
/
m_p_width
;
}
}
qDebug
()
<<
"
Scale factor is "
<<
m_scale
_factor
;
qDebug
()
<<
"
MM scale factor is "
<<
m_mm
_factor
;
}
}
void
Sizing
::
setDpScaleFactor
()
{
switch
(
m_densitie
)
{
case
ldpi
:
m_dp_factor
=
0.75
;
break
;
case
mdpi
:
m_dp_factor
=
1
;
break
;
case
hdpi
:
m_dp_factor
=
1.5
;
break
;
case
xhdpi
:
m_dp_factor
=
2
;
break
;
case
xxhdpi
:
m_dp_factor
=
3
;
break
;
case
xxxhdpi
:
m_dp_factor
=
4
;
break
;
default:
m_dp_factor
=
1
;
break
;
}
}
float
Sizing
::
mm
(
float
value
)
{
return
value
*
m_mm_factor
;
}
float
Sizing
::
dp
(
float
value
)
{
return
value
*
m_dp_factor
;
}
src/controls/sizing.h
View file @
c4206d08
...
@@ -3,25 +3,55 @@
...
@@ -3,25 +3,55 @@
#include <QObject>
#include <QObject>
#ifndef Q_ENUM
#define Q_ENUM(x) Q_ENUMS(x)
#endif
class
Sizing
:
public
QObject
class
Sizing
:
public
QObject
{
{
Q_OBJECT
Q_OBJECT
public:
public:
explicit
Sizing
(
QObject
*
parent
=
0
);
explicit
Sizing
(
QObject
*
parent
=
0
);
enum
Densitie
{
ldpi
,
mdpi
,
hdpi
,
xhdpi
,
xxhdpi
,
xxxhdpi
};
Q_ENUM
(
Densities
)
bool
isValid
(){
return
m_valid
;}
bool
isValid
(){
return
m_valid
;}
int
getScaleFactor
(){
return
m_scale_factor
;}
float
getMmScaleFactor
(){
return
m_mm_factor
;}
float
getDpScaleFactor
(){
return
m_dp_factor
;}
Densitie
getDensitie
();
Q_INVOKABLE
float
mm
(
float
value
);
Q_INVOKABLE
float
dp
(
float
value
);
private:
private:
bool
m_valid
;
bool
m_valid
;
int
m_p_width
;
int
m_p_width
;
int
m_p_height
;
int
m_p_height
;
int
m_width
;
int
m_width
;
int
m_height
;
int
m_height
;
int
m_scale_factor
;
float
m_mm_factor
;
float
m_dp_factor
;
qreal
m_dpi
;
Densitie
m_densitie
;
void
setMmScaleFactor
();
void
setDpScaleFactor
();
void
scaleFactor
();
};
};
#endif // SIZING_H
#endif // SIZING_H
src/styles/ButtonStyle.qml
View file @
c4206d08
...
@@ -30,8 +30,8 @@ ButtonStyle {
...
@@ -30,8 +30,8 @@ ButtonStyle {
// The background of the button.
// The background of the button.
background
:
Rectangle
{
background
:
Rectangle
{
implicitWidth
:
24
*
mm
implicitWidth
:
size
.
dp
(
240
)
implicitHeight
:
5
*
mm
implicitHeight
:
size
.
dp
(
50
)
clip
:
true
clip
:
true
color
:
control
.
primary
?
Theme
.
primaryButton
.
background
color
:
control
.
primary
?
Theme
.
primaryButton
.
background
:
Theme
.
button
.
background
:
Theme
.
button
.
background
...
...
src/styles/CheckBoxStyle.qml
View file @
c4206d08
...
@@ -39,21 +39,21 @@ CheckBoxStyle {
...
@@ -39,21 +39,21 @@ CheckBoxStyle {
indicator
:
Rectangle
{
indicator
:
Rectangle
{
id
:
background
id
:
background
color
:
"
transparent
"
color
:
"
transparent
"
implicitWidth
:
7.2
*
mm
implicitWidth
:
size
.
dp
(
72
)
implicitHeight
:
3.2
*
mm
implicitHeight
:
size
.
dp
(
32
)
Rectangle
{
Rectangle
{
id
:
back1
id
:
back1
implicitWidth
:
7.2
*
mm
implicitWidth
:
size
.
dp
(
72
)
implicitHeight
:
2.8
*
mm
implicitHeight
:
size
.
dp
(
28
)
color
:
Theme
.
checkbox
.
back1
color
:
Theme
.
checkbox
.
back1
anchors.centerIn
:
parent
anchors.centerIn
:
parent
}
}
Rectangle
{
Rectangle
{
id
:
back2
id
:
back2
implicitWidth
:
7.2
*
mm
implicitWidth
:
size
.
dp
(
72
)
implicitHeight
:
2.8
*
mm
implicitHeight
:
size
.
dp
(
28
)
color
:
Theme
.
checkbox
.
back2
color
:
Theme
.
checkbox
.
back2
anchors.centerIn
:
parent
anchors.centerIn
:
parent
}
}
...
@@ -73,14 +73,13 @@ CheckBoxStyle {
...
@@ -73,14 +73,13 @@ CheckBoxStyle {
}
else
{
}
else
{
anim2
.
restart
()
anim2
.
restart
()
}
}
}
}
}
}
Component.onCompleted
:
{
Component.onCompleted
:
{
back1
.
opacity
=
control
.
checked
?
1
:
0
back1
.
opacity
=
control
.
checked
?
1
:
0
back2
.
opacity
=
control
.
checked
?
0
:
1
back2
.
opacity
=
control
.
checked
?
0
:
1
ball
.
x
=
control
.
checked
?
3.2
*
mm
:
0
ball
.
x
=
control
.
checked
?
size
.
dp
(
32
)
:
0
}
}
SequentialAnimation
{
SequentialAnimation
{
...
@@ -89,7 +88,7 @@ CheckBoxStyle {
...
@@ -89,7 +88,7 @@ CheckBoxStyle {
NumberAnimation
{
NumberAnimation
{
target
:
ball
target
:
ball
property
:
"
x
"
property
:
"
x
"
to
:
3.2
*
mm
to
:
size
.
dp
(
32
)
duration
:
120
duration
:
120
}
}
NumberAnimation
{
NumberAnimation
{
...
...
src/styles/GrooveStyle.qml
View file @
c4206d08
...
@@ -22,8 +22,8 @@ import QtQuick.Controls.Styles.Nemo 1.0
...
@@ -22,8 +22,8 @@ import QtQuick.Controls.Styles.Nemo 1.0
Component
{
Component
{
Rectangle
{
Rectangle
{
implicitHeight
:
1.6
*
mm
implicitHeight
:
size
.
dp
(
16
)
implicitWidth
:
44
*
mm
implicitWidth
:
size
.
dp
(
440
)
color
:
Theme
.
groove
.
background
color
:
Theme
.
groove
.
background
Rectangle
{
Rectangle
{
antialiasing
:
true
antialiasing
:
true
...
...
src/styles/MenuBarStyle.qml
View file @
c4206d08
...
@@ -59,8 +59,8 @@ Style {
...
@@ -59,8 +59,8 @@ Style {
}
}
property
Component
menuItem
:
Rectangle
{
property
Component
menuItem
:
Rectangle
{
width
:
text
.
width
+
1
.2
*
mm
width
:
text
.
width
+
1
2
height
:
text
.
height
+
0.4
*
mm
height
:
text
.
height
+
4
color
:
sunken
?
"
#49d
"
:
__backgroundColor
color
:
sunken
?
"
#49d
"
:
__backgroundColor
SystemPalette
{
id
:
syspal
}
SystemPalette
{
id
:
syspal
}
...
...
src/styles/SliderStyle.qml
View file @
c4206d08
...
@@ -29,9 +29,9 @@ SliderStyle{
...
@@ -29,9 +29,9 @@ SliderStyle{
color
:
"
black
"
color
:
"
black
"
border.color
:
"
#0091e5
"
border.color
:
"
#0091e5
"
border.width
:
2
border.width
:
2
implicitWidth
:
3.4
*
mm
implicitWidth
:
size
.
dp
(
34
)
implicitHeight
:
3.4
*
mm
implicitHeight
:
size
.
dp
(
34
)
radius
:
1.6
*
mm
radius
:
size
.
dp
(
16
)
visible
:
control
.
enabled
visible
:
control
.
enabled
Text
{
Text
{
...
@@ -46,8 +46,8 @@ SliderStyle{
...
@@ -46,8 +46,8 @@ SliderStyle{
groove
:
Rectangle
{
groove
:
Rectangle
{
id
:
grove
id
:
grove
implicitHeight
:
1.6
*
mm
implicitHeight
:
size
.
dp
(
16
)
implicitWidth
:
44
*
mm
implicitWidth
:
size
.
dp
(
440
)
color
:
"
#313131
"
color
:
"
#313131
"
z
:
1
z
:
1
Rectangle
{
Rectangle
{
...
@@ -72,9 +72,9 @@ SliderStyle{
...
@@ -72,9 +72,9 @@ SliderStyle{
verticalCenter
:
dataLine
.
verticalCenter
verticalCenter
:
dataLine
.
verticalCenter
}
}
source
:
"
images/slider-handle-left.svg
"
source
:
"
images/slider-handle-left.svg
"
height
:
3.4
*
mm
height
:
size
.
dp
(
34
)
visible
:
control
.
enabled
visible
:
control
.
enabled
width
:
(
styleData
.
handlePosition
>
8
*
mm
)
?
8
*
mm
:
styleData
.
handlePosition
width
:
(
styleData
.
handlePosition
>
size
.
dp
(
80
))
?
size
.
dp
(
80
)
:
styleData
.
handlePosition
sourceSize.width
:
width
sourceSize.width
:
width
sourceSize.height
:
height
sourceSize.height
:
height
}
}
...
...
src/styles/TextFieldStyle.qml
View file @
c4206d08
...
@@ -25,11 +25,11 @@ TextFieldStyle {
...
@@ -25,11 +25,11 @@ TextFieldStyle {
selectedTextColor
:
Theme
.
textField
.
selectedTextColor
selectedTextColor
:
Theme
.
textField
.
selectedTextColor
selectionColor
:
Theme
.
textField
.
selectionColor
selectionColor
:
Theme
.
textField
.
selectionColor
textColor
:
Theme
.
textField
.
selectedTextColor
textColor
:
Theme
.
textField
.
selectedTextColor
font.pointSize
:
1.4
*
mm
font.pointSize
:
size
.
dp
(
14
)
font.family
:
Theme
.
textField
.
font
font.family
:
Theme
.
textField
.
font
background
:
Item
{
background
:
Item
{
anchors.leftMargin
:
1.6
*
mm
anchors.leftMargin
:
size
.
dp
(
16
)
anchors.rightMargin
:
1.6
*
mm
anchors.rightMargin
:
size
.
dp
(
16
)
opacity
:
control
.
enabled
?
1
:
0.6
opacity
:
control
.
enabled
?
1
:
0.6
Image
{
Image
{
anchors.fill
:
parent
anchors.fill
:
parent
...
...
src/styles/ToolBarStyle.qml
View file @
c4206d08
...
@@ -28,8 +28,8 @@ Style {
...
@@ -28,8 +28,8 @@ Style {
padding.bottom
:
3
padding.bottom
:
3
property
Component
panel
:
Item
{
property
Component
panel
:
Item
{
implicitHeight
:
7.5
*
mm
implicitHeight
:
size
.
dp
(
75
)
implicitWidth
:
40
*
mm
implicitWidth
:
size
.
dp
(
40
)
Rectangle
{
Rectangle
{
anchors.fill
:
parent
anchors.fill
:
parent
color
:
Theme
.
toolBar
.
background
color
:
Theme
.
toolBar
.
background
...
...
src/styles/ToolButtonStyle.qml
View file @
c4206d08
...
@@ -31,8 +31,8 @@ Style {
...
@@ -31,8 +31,8 @@ Style {
id
:
styleitem
id
:
styleitem
//TODO: Maybe we want to add a descriptive text at the bottom of the icon?
//TODO: Maybe we want to add a descriptive text at the bottom of the icon?
implicitWidth
:
5
*
mm
implicitWidth
:
size
.
dp
(
50
)
implicitHeight
:
5
*
mm
implicitHeight
:
size
.
dp
(
50
)
opacity
:
control
.
pressed
?
0.5
:
1
opacity
:
control
.
pressed
?
0.5
:
1
...
@@ -47,7 +47,7 @@ Style {
...
@@ -47,7 +47,7 @@ Style {
id
:
icon
id
:
icon
anchors.fill
:
parent
anchors.fill
:
parent
fillMode
:
Image
.
PreserveAspectFit
fillMode
:
Image
.
PreserveAspectFit
anchors.margins
:
0.8
*
mm
anchors.margins
:
size
.
dp
(
8
)
source
:
control
.
iconSource
source
:
control
.
iconSource
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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