~ubuntu-sdk-team/ubuntu-ui-toolkit/staging

« back to all changes in this revision

Viewing changes to tests/unit/custom_qpa/qcustomintegration.cpp

  • Committer: Tarmac
  • Author(s): Gerry Boland, Michał Sawicz, Albert Astals Cid, Daniel d'Andrada
  • Date: 2016-04-23 19:05:01 UTC
  • mfrom: (1000.56.117 dynamic-grid-unit)
  • Revision ID: tarmac-20160423190501-4512h90kulq1taoz
Enable dynamic changing of grid units instigated by the shell. Fixes: https://bugs.launchpad.net/bugs/1573532.

Approved by ubuntu-sdk-build-bot, Christian Dywan.

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include <QtGui/private/qguiapplication_p.h>
38
38
#include <qpa/qplatformwindow.h>
39
39
#include <qpa/qplatformfontdatabase.h>
 
40
#include <qpa/qplatformnativeinterface.h>
40
41
 
41
42
#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
42
43
 
43
44
static const char devicePixelRatioEnvironmentVariable[] = "QT_DEVICE_PIXEL_RATIO";
44
45
 
 
46
class QCustomNativeInterface : public QPlatformNativeInterface
 
47
{
 
48
    Q_OBJECT
 
49
public:
 
50
    QVariant windowProperty(QPlatformWindow */*window*/, const QString &name) const override
 
51
    {
 
52
        if (name == QStringLiteral("scale"))
 
53
            return m_scale;
 
54
 
 
55
        return QVariant();
 
56
    }
 
57
 
 
58
    Q_INVOKABLE void changeScale(float scale)
 
59
    {
 
60
        m_scale = scale;
 
61
        Q_EMIT windowPropertyChanged(nullptr, "scale");
 
62
    }
 
63
 
 
64
private:
 
65
    float m_scale = 1;
 
66
};
 
67
 
45
68
QCustomScreen::QCustomScreen()
46
69
    : mDepth(32), mFormat(QImage::Format_ARGB32_Premultiplied), mDpr(1.0)
47
70
{
55
78
}
56
79
 
57
80
QCustomIntegration::QCustomIntegration()
 
81
 : m_nativeInterface(new QCustomNativeInterface())
58
82
{
59
83
    QCustomScreen *mPrimaryScreen = new QCustomScreen();
60
84
 
65
89
    screenAdded(mPrimaryScreen);
66
90
}
67
91
 
 
92
QCustomIntegration::~QCustomIntegration()
 
93
{
 
94
    delete m_nativeInterface;
 
95
}
 
96
 
68
97
bool QCustomIntegration::hasCapability(QPlatformIntegration::Capability cap) const
69
98
{
70
99
    switch (cap) {
88
117
    return new DummyFontDatabase;
89
118
}
90
119
 
 
120
QPlatformNativeInterface *QCustomIntegration::nativeInterface() const
 
121
{
 
122
    return m_nativeInterface;
 
123
}
91
124
 
92
125
QPlatformWindow *QCustomIntegration::createPlatformWindow(QWindow *window) const
93
126
{
110
143
{
111
144
    return static_cast<QCustomIntegration *>(QGuiApplicationPrivate::platformIntegration());
112
145
}
 
146
 
 
147
#include "qcustomintegration.moc"
 
 
b'\\ No newline at end of file'