Active Topics

 


Reply
Thread Tools
velox's Avatar
Posts: 394 | Thanked: 1,341 times | Joined on Dec 2009
#1
(tldr: partly somewhat technical stuff, partly me blabbering on about submenus and ninjablocks)

Since my previous Phone died a few weeks ago (back to N900 for me) and the next one is apparently somewhere in a Warehouse in Finland*, I thought I'd put my insomnia to good use and take the Sailfish SDK for a spin. I do quite a bit of Javascript stuff, so I try to code most of it to included JS files.

After half a night of poking here and there, I've got some rudimentary excuse for a NinjaBlocks app running (it controls 433Mhz actuators and the Block's rgb/rgb8 LEDs), but I could not figure out how to append Items to a PullDownMenu dynamically from Javascript.

When I "onPressAndHold" an Actuator's SilicaListView Item (which, in real life, might correspond to a wall socket command, like 'switch on living room light 1'), I add or remove a favourite (right now via LocalStorage SQL, which on first glance does not seem to be that persistent, at least for SDK deployments – alternatives are always welcome, if you'd like to share).

I really would like those favourite Items to be available in the "Pulley" PullDownMenu, but I have not figured out how to feed a Model (which is pretty easy to manipulate from JS, perfect for me) there – funny, because for SilicaListView it just did what I wanted instantly without me needing a clue about… anything, to be honest.
Have I missed something really obvious? It surely seems like it.

Also, what should be the expected outcome of a long press on a List Item in your opinion? Should there be a sub section popping out containing more options? Should I push a whole new Page to the Stack?
I feel that functionally a ContextMenu could suffice, but it's rather limited in displaying information like that appropriately, because it would have to tell the user the name, current state (enabled/disabled) and that you can actually toggle it. (Am I wrong? Please correct me!)

A normal click on those Items triggers the action directly, and I wouldn't want to complicate this primary function. That's why I immediately went for long click. If this is against best practices – well, I'm about a day into this whole topic and ready for suggestions.

Thanks




*) Fingers crossed.
 
w00t's Avatar
Posts: 1,055 | Thanked: 4,107 times | Joined on Oct 2009 @ Norway
#2
Originally Posted by velox View Post
I add or remove a favourite (right now via LocalStorage SQL, which on first glance does not seem to be that persistent, at least for SDK deployments – alternatives are always welcome, if you'd like to share).
What does QQmlEngine:fflineStoragePath give you?

There was a bug in Qt[1] that we fixed a while ago that may have caused this. I'm not yet sure if it made it to SDK releases.

1: https://codereview.qt-project.org/#change,67498
__________________
i'm a Qt expert and former Jolla sailor (forever sailing, in spirit).
if you like, read more about me.
if you find me entertaining, or useful, thank me. if you don't, then tell me why.
 

The Following User Says Thank You to w00t For This Useful Post:
Posts: 4 | Thanked: 45 times | Joined on Dec 2013
#3
Originally Posted by velox View Post
I really would like those favourite Items to be available in the "Pulley" PullDownMenu, but I have not figured out how to feed a Model (which is pretty easy to manipulate from JS, perfect for me) there – funny, because for SilicaListView it just did what I wanted instantly without me needing a clue about… anything, to be honest.
Have I missed something really obvious? It surely seems like it.
Maybe it's not obvious, but at least it's easy

Code:
PullDownMenu {
    Repeater {
        model: 4

        MenuItem {
            text: "Item #" + model.index
        }
    }
}
The "4" in this example can be any QML model type (http://qt-project.org/doc/qt-5.1/qtq...ew.html#models). In a quick test, changing the value updates the menu, at least as long as the menu isn't currently open.

Originally Posted by velox View Post
Also, what should be the expected outcome of a long press on a List Item in your opinion? Should there be a sub section popping out containing more options? Should I push a whole new Page to the Stack?
I feel that functionally a ContextMenu could suffice, but it's rather limited in displaying information like that appropriately, because it would have to tell the user the name, current state (enabled/disabled) and that you can actually toggle it. (Am I wrong? Please correct me!)
The convention in our UI is to highlight the item that the context menu is open for (using highlightBackgroundColor as its background, and highlightColor for text), and for context menu items to be verbs ("Enable", "Disable"). That seems like enough to show that you can toggle it. Maybe the current state should be part of the delegate itself, maybe by using the secondary text color?
 

The Following 4 Users Say Thank You to jbrooks For This Useful Post:
qwazix's Avatar
Moderator | Posts: 2,622 | Thanked: 5,447 times | Joined on Jan 2010
#4
Wow! A ninjablocks app for sailfish! If you plan to open source it I might spend some time with it, time permitting.
__________________
Proud coding competition 2012 winner: ρcam
My other apps: speedcrunch N9 N900 Jolla –– contactlaunch –– timenow

Nemo UX blog: Grog
My website: qwazix.com
My job: oob
 

The Following 2 Users Say Thank You to qwazix For This Useful Post:
velox's Avatar
Posts: 394 | Thanked: 1,341 times | Joined on Dec 2009
#5
Great Responses, you're awesome!

Originally Posted by w00t View Post
What does QQmlEngine:fflineStoragePath give you?
Will get the chance to check tonight, thanks! I can not rule out that was just me messing about with the VMs, because I have not noticed something strange afterwards.

Originally Posted by jbrooks View Post
Maybe it's not obvious, but at least it's easy
Ah, that was what I've been looking for, thanks a lot! Somehow I stayed oblivious of the "Repeater" Item. Might have been quite late.

Originally Posted by jbrooks View Post
Maybe the current state should be part of the delegate itself, maybe by using the secondary text color?
In the current state (oh, actually that already made it on to the screenshot above), favourites get a slightly brighter text color, perhaps I'll just leave it at that for now, correcting the colors to not be hardcoded. Primary/Secondary text color sounds much more reasonable. Later on, some Items may have additional settings/inputs – I may resort to opening a new Page then. Thanks again, your whole reply is most helpful.

Originally Posted by qwazix View Post
Wow! A ninjablocks app for sailfish! If you plan to open source it I might spend some time with it, time permitting.
It's basically a slightly modified Version (can't use node request, obviously) of the node.js api and loads of commented out stuff that I tried, plus my user_access_token hardcoded in there. That should at least be configurable (if not replaced with real authentication) before I can show anyone. Other than this and the horrible code quality, I see no reason not to share this. Will ping you, if I get to it – thanks for your offer. Great to see it could be interesting or at some point even useful to someone else!
 

The Following User Says Thank You to velox For This Useful Post:
Reply

Tags
javascript, jolla, pulldownmenu, silica


 
Forum Jump


All times are GMT. The time now is 19:28.