Commit af6f5fdc authored by eekkelund's avatar eekkelund

[Scaling] Recalculate scaling ratio based on reference device, N9. Recalculate...

[Scaling] Recalculate scaling ratio based on reference device, N9. Recalculate font scaling ratio and adjust fontSizes according to that
parent 21e4efa0
...@@ -11,35 +11,34 @@ Sizing::Sizing(QObject *parent) : QObject(parent) ...@@ -11,35 +11,34 @@ Sizing::Sizing(QObject *parent) : QObject(parent)
m_dp_factor = 1; m_dp_factor = 1;
m_densitie = mdpi; m_densitie = mdpi;
qreal refHeight = 854.; //N9
qreal refWidth = 480.; //N9
qreal refDpi = 251; //N9
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();
QScreen *screen = QGuiApplication::primaryScreen(); QScreen *screen = QGuiApplication::primaryScreen();
m_height = screen->size().height();
m_width = screen->size().width();
m_dpi = screen->physicalDotsPerInch(); m_height = qMax(screen->size().width(), screen->size().height());
m_width = qMin(screen->size().width(), screen->size().height());
int largerSide; m_dpi = screen->physicalDotsPerInch();
m_scaleRatio = qMin(m_height/refHeight, m_width/refWidth);
m_fontRatio = floor(m_scaleRatio*10) /10; //qMin(m_height*refDpi/(m_dpi*refHeight), m_width*refDpi/(m_dpi*refWidth))*10)/10;
qDebug() << "Height: " << m_height << "Width: " << m_width; qDebug() << "Height: " << m_height << "Width: " << m_width;
qDebug() << "Scale ratio: " << m_scaleRatio << " Font: " << m_fontRatio;
if(m_height > m_width) { if(m_width >= 2160){
largerSide = m_width;
} else {
largerSide = m_height;
}
if(largerSide > 2160){
//>2160 //>2160
m_launcher_icon_size = 256; m_launcher_icon_size = 256;
}else if (largerSide > 1080){ }else if (m_width >= 1080){
//1081-2160 //1080-2159
m_launcher_icon_size = 128; m_launcher_icon_size = 128;
}else if(largerSide > 720){ }else if(m_width >= 720){
//721-1080 //720-1079
m_launcher_icon_size = 108; m_launcher_icon_size = 108;
}else { }else {
//>720 //>720
...@@ -130,6 +129,11 @@ float Sizing::dp(float value) ...@@ -130,6 +129,11 @@ float Sizing::dp(float value)
return value*m_dp_factor; return value*m_dp_factor;
} }
float Sizing::ratio(float value)
{
return floor(value*m_scaleRatio);
}
void Sizing::setMmScaleFactor(float value) void Sizing::setMmScaleFactor(float value)
{ {
...@@ -152,3 +156,15 @@ void Sizing::setDpScaleFactor(float value) ...@@ -152,3 +156,15 @@ void Sizing::setDpScaleFactor(float value)
m_dp_factor = value; m_dp_factor = value;
} }
} }
void Sizing::setScaleRatio(qreal scaleRatio)
{
if(scaleRatio != 0)
m_scaleRatio = scaleRatio;
}
void Sizing::setFontRatio(qreal fontRatio)
{
if(fontRatio !=0 )
m_fontRatio = fontRatio;
}
...@@ -31,6 +31,9 @@ public: ...@@ -31,6 +31,9 @@ public:
float getMmScaleFactor(){return m_mm_factor;} float getMmScaleFactor(){return m_mm_factor;}
float getDpScaleFactor(){return m_dp_factor;} float getDpScaleFactor(){return m_dp_factor;}
qreal getScaleRatio(){return m_scaleRatio;}
qreal getFontRatio(){return m_fontRatio;}
int getLauncherIconSize(){return m_launcher_icon_size;} int getLauncherIconSize(){return m_launcher_icon_size;}
...@@ -38,10 +41,15 @@ public: ...@@ -38,10 +41,15 @@ public:
Q_INVOKABLE float mm(float value); Q_INVOKABLE float mm(float value);
Q_INVOKABLE float dp(float value); Q_INVOKABLE float dp(float value);
Q_INVOKABLE float ratio(float value);
Q_INVOKABLE void setMmScaleFactor(float value); Q_INVOKABLE void setMmScaleFactor(float value);
Q_INVOKABLE void setDpScaleFactor(float value); Q_INVOKABLE void setDpScaleFactor(float value);
Q_INVOKABLE void setScaleRatio(qreal scaleRatio);
void setFontRatio(qreal fontRatio);
private: private:
bool m_valid; bool m_valid;
...@@ -50,6 +58,8 @@ private: ...@@ -50,6 +58,8 @@ private:
int m_width; int m_width;
int m_height; int m_height;
qreal m_scaleRatio;
qreal m_fontRatio;
int m_launcher_icon_size; int m_launcher_icon_size;
......
This diff is collapsed.
...@@ -147,11 +147,11 @@ private: ...@@ -147,11 +147,11 @@ private:
qreal m_itemSpacingSmall; //10 qreal m_itemSpacingSmall; //10
qreal m_itemSpacingExtraSmall; //8 qreal m_itemSpacingExtraSmall; //8
int m_fontSizeExtraLarge; //50 int m_fontSizeExtraLarge; //44
int m_fontSizeLarge; //40 int m_fontSizeLarge; //35
int m_fontSizeMedium; //32 int m_fontSizeMedium; //28
int m_fontSizeSmall; //26 int m_fontSizeSmall; //24
int m_fontSizeTiny; //18 int m_fontSizeTiny; //16
int m_fontWeightLarge; //63 int m_fontWeightLarge; //63
int m_fontWeightMedium; //25 int m_fontWeightMedium; //25
QString m_fontFamily; //??? QString m_fontFamily; //???
...@@ -164,6 +164,8 @@ private: ...@@ -164,6 +164,8 @@ private:
QString m_backgroundAccentColor; //#ffffff QString m_backgroundAccentColor; //#ffffff
qreal m_dp; qreal m_dp;
qreal m_scaleRatio;
qreal m_fontRatio;
}; };
#endif // THEME_H #endif // THEME_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment