Fast QML UI prototyping for platforms WITHOUT Qt/QtQuick support - - PowerPoint PPT Presentation

fast qml ui prototyping for platforms without qt qtquick
SMART_READER_LITE
LIVE PREVIEW

Fast QML UI prototyping for platforms WITHOUT Qt/QtQuick support - - PowerPoint PPT Presentation

Fast QML UI prototyping for platforms WITHOUT Qt/QtQuick support Attila Csipa @achipa Qt DevDays Berlin, 08.10.2013 Session content What (Fast UI Prototyping without QtQuick) Why do it? Why NOT do it? How to do it? Case


slide-1
SLIDE 1

Attila Csipa @achipa Qt DevDays Berlin, 08.10.2013

Fast QML UI prototyping for platforms WITHOUT Qt/QtQuick support

slide-2
SLIDE 2
  • What (Fast UI Prototyping without QtQuick)
  • Why do it?
  • Why NOT do it?
  • How to do it?
  • Case study – Nokia Asha
  • Case study – Console UI

Session content

slide-3
SLIDE 3
  • Terse, but readable syntax
  • Declarative UI
  • Quick iteration cycles

QtQuick + QML = Declarative + terse syntax + quick iteration However, not all platforms have (good) Qt(Quick) support

Fast UI development

slide-4
SLIDE 4

Policy

  • No interpreted/dynamic code
  • No V8/JS engine
  • Because someone

said “NO”

I want QtQuick, but…

The swimsuit police checking the length of a suit, 1922

slide-5
SLIDE 5

No hardware accelerated OpenGL (ES) capability (or drivers)

  • A hard requirement for QtQuick 2.x

I want QtQuick, but...

A bicycle with 12 rockets mounted on the back wheel. ~1930s

slide-6
SLIDE 6
  • Resource limitations
  • Not enough memory
  • Not enough bandwidth
  • Not enough disk space
  • Not enough…

I want QtQuick, but...

Cheese “sandwich” served on the Sao Paolo – Manaus TAM flight

slide-7
SLIDE 7
  • No native look and feel
  • No native QtQuick-based component set
  • No Integration with target platform

I want QtQuick, but…

slide-8
SLIDE 8
  • Business angle
  • Technology angle
  • Development angle

So why do it?

slide-9
SLIDE 9
  • Gazillion of non-Qt(Quick) capable devices
  • A lot of those without UI prototyping tools
  • Foot in the door! (follow-up projects)
  • Accessibility (where not yet covered by Qt)
  • (For fame and glory)

Why do it?

Business angle

slide-10
SLIDE 10
  • Minimize resource usage in case of remote UIs
  • Be able to chose UI tech best suited for user interaction
  • State of Qt port on target platform not a showstopper
  • Multi-UI applications
  • Usable both locally with a GUI, and remotely (via telnet/SSH)

Why do it?

Tech angle

slide-11
SLIDE 11
  • Reuse knowledge of QML
  • Complement lacking IDEs with QtCreator
  • Syntax highlighting, autocomplete, help, potentially debugging
  • Single language interface between developer & designer
  • Less people need to know platform specifics
  • Faster (less painful?)

design iterations

Why do it?

Development angle

Helmet test, ca 1912

slide-12
SLIDE 12
  • Maintenance burden
  • Hard to upstream
  • Flexibility
  • There is a reason QtQuick(2)

exists, we are talking primarily about PROTOTYPING

  • “World doesn’t need

another piece of crap”

Dan Dodge, Qt DevDays QNX Keynote

Why not do it?

The last four couples standing in a dance marathon. Chicago, c. 1930

slide-13
SLIDE 13
  • Workflow
  • Prerequisites
  • Advantages
  • Disadvantages
  • Problem Domain

The approaches – analysis

slide-14
SLIDE 14
  • Roll your own (QtQuick)
  • Client side QML
  • Code Generation
  • [your idea here – the previous ones are just examples!]

Think out of the box!

Example approaches

slide-15
SLIDE 15

QML Types Provided By The QtQml Module The QtQml module provides the definition and implementation of various convenience types which can be used with the QML language, including some elementary QML types which can provide the basis for further extensions to the QML language. The QtQml module provides the QtObject and Component object types which may be used in QML documents. These types are non-visual and provide building-blocks for extensions to QML. Workflow – simple, exactly the same as with QtCreator and QtQuick!

Approach #1 Roll your own

slide-16
SLIDE 16
  • Prerequisites
  • Qt on target platform, with functional QtQml
  • Advantages:
  • Leverage JavaScript and bindings via Qt
  • Easy event handling (signals/slots)
  • QML debugging from QtCreator
  • Disadvantages:
  • Requires Qt and QtQml on target platform

Approach #1 Roll your own

slide-17
SLIDE 17
  • Suitable for simple problem domains
  • Text/console mode
  • CDK/ncurses interface
  • Custom hardware (LED magic!)
  • Beagleboard, blinkenlights

Roll your own

Applicable problem domain

Projekt Blinkenlights, Berlin, 2001 - view from Berliner Fernsehturm Photo by Tim Pritlove

slide-18
SLIDE 18
  • Create QML in QtCreator
  • Run
  • Strip import statements and any JS
  • Deploy resulting QML file sync with device
  • Via File system or
  • Via Network protocol/socket
  • Application on device (re)loads QML and constructs UI
  • Feels almost like live-editing!
  • If you do want live-editing, you will need to save state/values!
  • Rinse and repeat

Approach #2 Client side QML

slide-19
SLIDE 19
  • Prerequisites
  • Shared data channel to client (network, storage…)
  • Implemented (or wrapped) component toolkit
  • Advantages
  • Does not require Qt on target platform at all!
  • Disadvantages
  • Only for really basic UIs
  • Lot of work (as no code reuse can happen)
  • No JavaScript or bindings
  • Difficult to debug
  • Very good understanding of target platform required

Approach #2 Client side QML

slide-20
SLIDE 20
  • Platforms with no Qt support
  • Static UI design (no JS!)
  • Mockups

Client side QML

Applicable problem domain

slide-21
SLIDE 21

public v public void

  • id constructUI(final byte[] JSONdata) {

) { JSONObject o;

  • ;

try { try {

  • = new JSONObject(new String(JSONdata));

)); } } ca catch ( tch (JS JSONE NExc xcep eption tion ex ex) { { L.e L.e("bytes are not a JSON object", "featURL", ex); return null; } try { try { final JSONObject feed = ((JSONObject) o).getJSONObject(“ApplicationWindow"); en entries tries = = o.getJSO

  • .getJSONArray

NArray(“Options"); for (int int i = 0; = 0; i < < entries.length(); (); i++) { ++) { final final JSONObje JSONObject ct m = entries.getJSONObject(i); ); final String OptionLabel = = m.getJSONObject(“Option").get(“text”); displayable.addCommands(new Command(OptionLabel, , Command.ITEM, 1)); } if ( if (en entr tries.l ies.len engt gth() () > > 1) 1) displayable.addCommandListener(this); } catch (JSONException e) { L.e L.e("JSON no ApplicationWindow", "featURL", e); } }

Client side QML

Example: Java ME with Tantalum

slide-22
SLIDE 22
  • Create QML in QtCreator
  • Run
  • Component output constructs source code based on QML
  • ApplicationWindow (or QtCreator platform plugin) compiles code
  • Packaging
  • Deploy to device/simulator
  • Execute on device (if possible)
  • Live-edit-like development possible, like in previous case

(if code can be loaded dynamically on target platform)

  • Rinse and repeat

Approach #3 Code generation

slide-23
SLIDE 23
  • Prerequisites
  • Qt and target platform *TOOLS* running on same device
  • Advantages
  • Customizability
  • Disadvantages
  • JavaScript and a suitable binding availability not guaranteed
  • Complexity
  • Maintenance burden

Approach #3 Code generation

slide-24
SLIDE 24
  • Platforms with no Qt support at all
  • Light logic can be included, client platform permitting
  • Simple bindings can be simulated
  • JavaScript may or may not be present

Code generation is in effect… … source-code level (de)serialization!

Code generation

Applicable problem domain

slide-25
SLIDE 25

Nokia Asha Software Platform

Case Study #1

slide-26
SLIDE 26

Series40 (which is NOT Symbian)

A Coca Cola company delivery truck in Knoxville, 1909.

First device in 1999, the Nokia 7110 (but don’t worry, Qt is actually 4 years older ;)

slide-27
SLIDE 27

1.5 billion devices by January 2012 650 million active (plenty of even touch devices) Freemium and ads DO work

A few years later…

North London Derby between Arsenal and Tottenham Hotspur at Highbury, 1934

slide-28
SLIDE 28

But the world changed

Women on motorcycles in Great Britain, 1930s

slide-29
SLIDE 29

= Series40 Hardware adaptation + Smarterphone middleware + Swipe UI

New Nokia Asha

slide-30
SLIDE 30
  • Nokia Asha SDK 1.0 (Java ME)
  • Java ME MIDP 2.1, CLDC 1.1
  • Optional JSRs
  • Nokia APIs
  • Max JAR file size: 5 Mb
  • Max Java Heap: 3 Mb
  • Nokia Asha web app tools 3.0.0
  • Xpress Web App Builder 1.0

Nokia Asha Developer Offering

slide-31
SLIDE 31

Feeling resource constrained yet?

Under 8 megs of application RAM, no native code, no OpenGL

slide-32
SLIDE 32

What is Qt doing in this story?

…let’s take a closer look before we jump to conclusions

Train wreck at Montparnasse Station. Paris, 1895.

slide-33
SLIDE 33

Canvas LCDUI LWUIT

Understanding Java ME UI

slide-34
SLIDE 34

The key: native look and feel

36

slide-35
SLIDE 35
  • High-level components
  • Nokia UI API
  • Asha look & feel
  • No customizability
  • (except CustomItem)

LCDUI

slide-36
SLIDE 36

Simplicity can be an advantage

Displayable Screen Canvas With chrome Full screen Alert List Form TextBox Choice Group Date Field Text Field Gauge String Item Image Item Custom Item Spacer Implicit choice Exclusive choice Multiple choice

slide-37
SLIDE 37

Which approach to use?

Case study #1 Nokia Asha

  • Custom components
  • No Qt/QtQml
  • No native look and feel
  • Too large memory footprint
  • Slow JavaScript performance
  • Code generation
  • Java ME has no reflection (or classloaders)
  • Still, possible with application reloads
  • Client side QML
  • JSON parser exists (f.ex as part of Tantalum)
  • Native look and feel, even fairly simple with LCDUI
slide-38
SLIDE 38

… For

  • rm for
  • rm = new Form(“Hello world”);

Ima mage e im imag age = n nul ull; l; try ry { im imag age e = = Ima mage ge.c .cre reate teIm Imag age(f (fil ile) e); } cat atch h (Nul ullPo Poin inte terE rExce cept ptio ion npe pe) ) { Sy Syst stem em.o .out. t.pr prin intl tln(" ("No No f file le n nam ame e spe peci cifi fied" d"); ); } cat atch h (IOE OExce cept ptio ion ioe

  • e)

) { Sy Syst stem em.o .out. t.pr prin intl tln(" ("Im Imag age n not

  • t f

fou

  • und:

d: " " + + fi file le); ); } for

  • rm.a

.app ppen end(“First!”); for

  • rm.a

.app ppen end(i (ima mage ge); ); for

  • rm.a

.add ddCo Comma mand nd(Com

  • mman

ands ds.B .BACK CK); ); form.setCommandListener(this); Dis ispla lay. y.ge getDi Disp spla lay(t (thi his) s).se setC tCur urre rent nt(li list st); ); …

3 classes… 6 methods… 260 lines of code…

LCDUI (Java ME) vs QML

imp mpor

  • rt com
  • m.n

.noki kia. a.as asha ha.lc lcdu dui 1.0 .0 App ppli licat atio ionW nWind ndow

  • w {

For

  • rm {

{ header: “Hello World!” St Stri ring ngIt Item { text: “First!” } } Image { src: “hello.png” } Op Opti tion

  • ns:

s: [ Opt ptio ion { { text: “Back” typ ype: : BA BACK CK } ] } }

…That’s all!

slide-39
SLIDE 39

The first successful run

Annie Edison Taylor The first person to survive going over Niagara Falls in a barrel, in 1901

slide-40
SLIDE 40

Raspberry PI Qt-enabled Linux distros available ARM11 + OpenGL ES + X-Bee Radio module Superior LOS range – up to 48km 9600 bps data rate

Case study #2 Embedded Remote Sensing

slide-41
SLIDE 41
  • Command line interfaces – Console UIs
  • Interfaces based on [n|pd]curses or Newt, CDK, NDK++
  • Pretty old, none declarative – scripted at best (dialog)
  • …but still useful…

CONNECT 9600

slide-42
SLIDE 42
  • Low resource usage
  • Bandwidth

(ideal for SSH)

  • Memory
  • Distributable size

Also a bit resource constrained

Cheese “sandwich” served on the Sao Paolo – Manaus TAM flight

slide-43
SLIDE 43
  • Short for Curses Development Kit

http://www.tldp.org/HOWTO/NCURSES-Programming-HOWTO/tools.html

19.1.3. Conclusion All in all, CDK is a well-written package of widgets, which if used properly can form a strong frame work for developing complex GUI.

Let’s pick a toolkit – CDK

slide-44
SLIDE 44

21 curses-rendered (text mode) widgets

Console UI – CDK

Alphalist Button Buttonbox Calendar Dialog Entry Field File Viewer File Selector Scale Slider Graph Histogram Item List Label Matrix Marquee Pulldown Menu Template

slide-45
SLIDE 45

Console UI – CDK

slide-46
SLIDE 46

Which approach to use?

Case study #2 Embedded remote sensing solution

  • Custom components
  • Qt/QtQml present
  • Widgets present (CDK)
  • Simple enough UI for memory/JS considerations
  • Platform does not have a “native look and feel” = our choice
  • Code generation
  • Large number of configurable widgets = complexity
  • No JavaScript
  • Client side QML
  • Large number of configurable widgets
  • More effort than custom components
  • JSON parser exists
slide-47
SLIDE 47

CDK DKSC SCREE EEN N *cd cdks kscr cree een; CDK DKLA LABEL EL * *de demo;

  • ;

WIN INDO DOW * *cu curs rsesW sWin in; ; con

  • nst

st ch char ar * *mes esg[4] 4]; ; cur urse sesWi Win = = ini nits tscr cr () (); cdk dksc scree een = = ini nitC tCDK DKSc Scree een (cu curs rses esWi Win); ); ini nitC tCDKC KCol

  • lor
  • r ()

(); mes esg[0 [0] ] = = "< "</5> 5><# <#UL UL>< ><#HL HL(3 (30) 0)><# <#UR UR>" >"; mes esg[1 [1] ] = = "< "</5> 5><# <#VL VL(1 (10)> )>He Hell llo W Wor

  • rld

ld!< !<#VL VL(1 (10)> )>"; "; mes esg[2 [2] ] = = "< "</5> 5><# <#LL LL>< ><#HL HL(3 (30) 0)><# <#LR LR>" >"; ; dem emo

  • =

= new ewCD CDKLa Labe bel (cd cdks kscr cree een, , CDK DKpar aram amVa Value ue (& (&par arams ms, , 'X 'X', , CE CENT NTER ER), ), CDK DKpar aram amVa Value ue (& (&par arams ms, , 'Y 'Y', , CE CENT NTER ER), ), (CD CDK_C _CST STRI RING2 G2) ) me mesg sg, 3 3, CDK DKpar aram amVa Value ue (& (&par arams ms, , 'N 'N', , TR TRUE UE), ), CDK DKpar aram amVa Value ue (& (&par arams ms, , 'S 'S', , TR TRUE UE)); )); set etCD CDKLa Labe belB lBack ckgr grou

  • und

ndAtt ttri rib (de demo mo, , CO COLOR OR_P _PAI AIR ( (2) 2)); );

CDK (native) vs QML

imp mpor

  • rt org

rg.c .cdk. k.wi widg dget ets 1.0 .0 App ppli licat atio ionW nWind ndow

  • w {

Lab abel l { an anch chor

  • rs

s { ho hori rizo zonta talc lcen ente ter: : pa pare rent. t.ho hori rizo zonta talc lcen enter er ve vert rtic icalcen ente ter: : pa pare rent nt.ve vert rtic ical alcen ente ter } wi widt dth: h: 30 height: 10 text: “Hello World!” bo bord rder er: : tru rue bo bord rder erco color

  • r:

: 5 co colo lor: r: 2 } }

slide-48
SLIDE 48
  • The Web
  • Android (via declarative XML)
  • Windows 8 (via XAML)
  • [Favorite hardcore platform here]

Potential targets

Men shaving, ~1940s

slide-49
SLIDE 49

It’s not about what platform Qt supports… …It’s about where you can take Qt with you

Takeaway

slide-50
SLIDE 50

Questions?

Fast QML UI prototyping for platforms WITHOUT Qt/QtQuick support

Thank you!

Attila Csipa @achipa All images from @HistoricalPics or WikiMedia Commons under CC BY-(NC)-SA