Commit 42a25f7b authored by Chupligin Sergey's avatar Chupligin Sergey

[Sizing] add simple sizing class

parent 156318cb
Name: qt5-qtquickcontrols-nemo
Summary: Nemomobile Qt Quick Controls
Version: 5.1.3
Version: 5.2.0
Release: nemo1
Group: Qt/Qt
License: LGPLv2.1 with exception or GPLv3
......
......@@ -34,7 +34,8 @@ HEADERS += \
qquickfilteringmousearea.h \
nemoimageprovider.h \
themedaemon/mlocalthemedaemonclient.h \
themedaemon/mabstractthemedaemonclient.h
themedaemon/mabstractthemedaemonclient.h \
sizing.h
SOURCES += \
qquicknemocontrolsextensionplugin.cpp \
......@@ -44,7 +45,8 @@ SOURCES += \
qquickfilteringmousearea.cpp \
nemoimageprovider.cpp \
themedaemon/mlocalthemedaemonclient.cpp \
themedaemon/mabstractthemedaemonclient.cpp
themedaemon/mabstractthemedaemonclient.cpp \
sizing.cpp
target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
......
......@@ -25,6 +25,7 @@
#include "nemopage.h"
#include "qquickfilteringmousearea.h"
#include "nemoimageprovider.h"
#include "sizing.h"
QQuickNemoControlsExtensionPlugin::QQuickNemoControlsExtensionPlugin(QObject *parent) :
QQmlExtensionPlugin(parent)
......@@ -48,7 +49,13 @@ void QQuickNemoControlsExtensionPlugin::registerTypes(const char *uri)
void QQuickNemoControlsExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
{
Sizing *sizing = new Sizing();
QQmlExtensionPlugin::initializeEngine(engine,uri);
QQmlContext* context = engine->rootContext();
context->setContextProperty("mm",sizing->getScaleFactor());
engine->addImageProvider(QLatin1String("theme"), new NemoImageProvider);
}
#include "sizing.h"
#include <QScreen>
#include <QDebug>
#include <QGuiApplication>
Sizing::Sizing(QObject *parent) : QObject(parent)
{
m_valid = false;
m_scale_factor = 10;
m_p_height = qgetenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT").toInt();
m_p_width = qgetenv("QT_QPA_EGLFS_PHYSICAL_WIDTH").toInt();
QScreen *screen = QGuiApplication::primaryScreen();
m_height = screen->size().height();
m_width = screen->size().width();
if(m_p_height > 0 && m_p_width >0){
m_valid = true;
scaleFactor();
}else{
if(m_p_height == 0){
qWarning("QT_QPA_EGLFS_PHYSICAL_HEIGHT is not set!");
}
if(m_p_width == 0){
qWarning("QT_QPA_EGLFS_PHYSICAL_WIDTH is not set!");
}
qWarning("Device sizing don`t work");
}
}
void Sizing::scaleFactor()
{
if(m_p_width != 0){
m_scale_factor = m_width/m_p_width;
}
qDebug() << "Scale factor is " << m_scale_factor;
}
#ifndef SIZING_H
#define SIZING_H
#include <QObject>
class Sizing : public QObject
{
Q_OBJECT
public:
explicit Sizing(QObject *parent = 0);
bool isValid(){return m_valid;}
int getScaleFactor(){return m_scale_factor;}
private:
bool m_valid;
int m_p_width;
int m_p_height;
int m_width;
int m_height;
int m_scale_factor;
void scaleFactor();
};
#endif // SIZING_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