Commit c9dc0c37 authored by Aleksi Suomalainen's avatar Aleksi Suomalainen Committed by GitHub

Merge pull request #48 from eekkelund/iconSizeLauncher

[Controls] Add Theme.iconLauncherSize
parents 051e2f9c dc222d6c
...@@ -22,6 +22,30 @@ Sizing::Sizing(QObject *parent) : QObject(parent) ...@@ -22,6 +22,30 @@ Sizing::Sizing(QObject *parent) : QObject(parent)
m_dpi = screen->physicalDotsPerInch(); m_dpi = screen->physicalDotsPerInch();
int largerSide;
qDebug() << "Height: " << m_height << "Width: " << m_width;
if(m_height > m_width) {
largerSide = m_width;
} else {
largerSide = m_height;
}
if(largerSide > 2160){
//>2160
m_launcher_icon_size = 256;
}else if (largerSide > 1080){
//1081-2160
m_launcher_icon_size = 128;
}else if(largerSide > 720){
//721-1080
m_launcher_icon_size = 108;
}else {
//>720
m_launcher_icon_size = 86;
}
qDebug() << "DPI is " << m_dpi; qDebug() << "DPI is " << m_dpi;
if(m_dpi < 140){ if(m_dpi < 140){
......
...@@ -32,6 +32,8 @@ public: ...@@ -32,6 +32,8 @@ 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;}
int getLauncherIconSize(){return m_launcher_icon_size;}
Densitie getDensitie(); Densitie getDensitie();
Q_INVOKABLE float mm(float value); Q_INVOKABLE float mm(float value);
...@@ -49,6 +51,8 @@ private: ...@@ -49,6 +51,8 @@ private:
int m_width; int m_width;
int m_height; int m_height;
int m_launcher_icon_size;
float m_mm_factor; float m_mm_factor;
float m_dp_factor; float m_dp_factor;
......
...@@ -10,6 +10,7 @@ Theme::Theme(QObject *parent) : QObject(parent) ...@@ -10,6 +10,7 @@ Theme::Theme(QObject *parent) : QObject(parent)
{ {
Sizing *size = new Sizing; Sizing *size = new Sizing;
m_dp = size->getDpScaleFactor(); m_dp = size->getDpScaleFactor();
m_iconSizeLauncher = size->getLauncherIconSize();
//Load defaults //Load defaults
m_itemWidthLarge = 320*m_dp; m_itemWidthLarge = 320*m_dp;
m_itemWidthMedium = 240*m_dp; m_itemWidthMedium = 240*m_dp;
...@@ -67,6 +68,14 @@ bool Theme::loadTheme(QString fileName) ...@@ -67,6 +68,14 @@ bool Theme::loadTheme(QString fileName)
QJsonDocument t = QJsonDocument::fromJson(themeJsonString.toUtf8()); QJsonDocument t = QJsonDocument::fromJson(themeJsonString.toUtf8());
QJsonObject theme = t.object(); QJsonObject theme = t.object();
if(theme.value("iconSizeLauncher").toString().toFloat() != 0 &&
theme.value("iconSizeLauncher").toString().toFloat() != m_iconSizeLauncher)
{
m_iconSizeLauncher = theme.value("iconSizeLauncher").toString().toFloat();
emit iconSizeLauncherChanged();
updated = true;
}
if(theme.value("itemWidthLarge").toString().toFloat() != 0 && if(theme.value("itemWidthLarge").toString().toFloat() != 0 &&
theme.value("itemWidthLarge").toString().toFloat() != m_itemWidthLarge) theme.value("itemWidthLarge").toString().toFloat() != m_itemWidthLarge)
{ {
......
...@@ -7,6 +7,8 @@ class Theme : public QObject ...@@ -7,6 +7,8 @@ class Theme : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(qreal iconSizeLauncher READ iconSizeLauncher NOTIFY iconSizeLauncherChanged)
Q_PROPERTY(qreal itemWidthLarge READ itemWidthLarge NOTIFY itemWidthLargeChanged) Q_PROPERTY(qreal itemWidthLarge READ itemWidthLarge NOTIFY itemWidthLargeChanged)
Q_PROPERTY(qreal itemWidthMedium READ itemWidthMedium NOTIFY itemWidthMediumChanged) Q_PROPERTY(qreal itemWidthMedium READ itemWidthMedium NOTIFY itemWidthMediumChanged)
Q_PROPERTY(qreal itemWidthSmall READ itemWidthSmall NOTIFY itemWidthSmallChanged) Q_PROPERTY(qreal itemWidthSmall READ itemWidthSmall NOTIFY itemWidthSmallChanged)
...@@ -81,6 +83,8 @@ public: ...@@ -81,6 +83,8 @@ public:
QString backgroundColor(){return m_backgroundColor;} QString backgroundColor(){return m_backgroundColor;}
QString backgroundAccentColor(){return m_backgroundAccentColor;} QString backgroundAccentColor(){return m_backgroundAccentColor;}
qreal iconSizeLauncher() {return m_iconSizeLauncher;}
signals: signals:
void themeUpdate(); void themeUpdate();
...@@ -118,9 +122,13 @@ signals: ...@@ -118,9 +122,13 @@ signals:
void backgroundColorChanged(); void backgroundColorChanged();
void backgroundAccentColorChanged(); void backgroundAccentColorChanged();
void iconSizeLauncherChanged();
public slots: public slots:
private: private:
qreal m_iconSizeLauncher; //86 or 108 or 128 or 256
qreal m_itemWidthLarge; //320 qreal m_itemWidthLarge; //320
qreal m_itemWidthMedium; //240 qreal m_itemWidthMedium; //240
qreal m_itemWidthSmall; //120 qreal m_itemWidthSmall; //120
......
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