maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   Help me to code for Sailfish OS (https://talk.maemo.org/showthread.php?t=100817)

coderus 2019-08-20 16:28

Help me to code for Sailfish OS
 
Decided to create one super-thread for all the questions about Sailfish OS coding.

You can post random questions about coding here and help others to code.

Sailfish OS only.

catbus 2019-08-21 17:32

Re: Help me to code for Sailfish OS
 
Hep

Well... I can start with newbie question...:

There is very good software for N9 and now it's source is available github under GPL3... So it is possible port to Sailfish OS... Is there any easy tools for doing that?

Yes. I have installed SDK for N9 before and one time to Sailfish too... But don't have any clue how different UI-things are, what to change etc...

Link to that software -> https://github.com/baleboy/timesheet

Thanks.

I use this everyday and one reason why still use N9 and not Sailfish -phone.

--

coderus 2019-08-21 18:08

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by catbus (Post 1559397)
Hep

Well... I can start with newbie question...:

There is very good software for N9 and now it's source is available github under GPL3... So it is possible port to Sailfish OS... Is there any easy tools for doing that?

Yes. I have installed SDK for N9 before and one time to Sailfish too... But don't have any clue how different UI-things are, what to change etc...

Link to that software -> https://github.com/baleboy/timesheet

Thanks.

I use this everyday and one reason why still use N9 and not Sailfish -phone.

--

No easy port qt4 -> qt5, but absolutely doable

catbus 2019-08-21 19:31

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1559398)
No easy port qt4 -> qt5, but absolutely doable

Thanks...

Can you give me little more guidance or is it better use Google? Or just forget and wait if someone else will do it?

Fuzzillogic 2019-08-21 22:22

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by catbus (Post 1559402)
Thanks...

Can you give me little more guidance or is it better use Google? Or just forget and wait if someone else will do it?

The UI-stuff, that is the QtQuick QML code, is conceptually nearly identical on Harmattan and SailfishOS, but will probably require a bit more rework, as the components on SFOS have different names, properties, features, etc. Still, most components probably have equivalents, so that is doable as well.

And of course it's not better to use Google. Try duckduckgo :P

Zero Six 2019-08-22 02:47

Re: Help me to code for Sailfish OS
 
1. do you have example of simple way to get current GPS location.
2. is it possible from native apps to call android share menu? if yes, how?
thank you

coderus 2019-08-22 09:24

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by Zero Six (Post 1559405)
1. do you have example of simple way to get current GPS location.
2. is it possible from native apps to call android share menu? if yes, how?
thank you

1. https://sailfishdev.tumblr.com/post/...with-one-click
2. https://openrepos.net/content/coderu...dalvik-control

levone1 2019-08-26 11:54

Re: Help me to code for Sailfish OS
 
Thanks for this thread - my questions are continual ...
One thing I'm wondering about atm is the newer ApplicationWallpaper.qml. I previously could edit this file pretty easily to customize the bg of apps by just changing "...(0, 0, 0, .65)" line to whatever rgb and opacity values I want. Now, (starting with 3.0, I think), the opacity value still applies as expected, but the color values don't. It seems like it's only black, no matter what rgb values you enter. I figured it has something to do with the other info in the file, (like "effect: "glass" overlayColor: Theme.colorScheme === Theme.DarkOnLight", etc), but I have tweaked with no results. I also get the sense that the ApplicationWindow file plays a role, but it's a bigger file, and can't tell what most of it is referring to...

coderus 2019-08-26 18:18

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by levone1 (Post 1559507)
Thanks for this thread - my questions are continual ...
One thing I'm wondering about atm is the newer ApplicationWallpaper.qml. I previously could edit this file pretty easily to customize the bg of apps by just changing "...(0, 0, 0, .65)" line to whatever rgb and opacity values I want. Now, (starting with 3.0, I think), the opacity value still applies as expected, but the color values don't. It seems like it's only black, no matter what rgb values you enter. I figured it has something to do with the other info in the file, (like "effect: "glass" overlayColor: Theme.colorScheme === Theme.DarkOnLight", etc), but I have tweaked with no results. I also get the sense that the ApplicationWindow file plays a role, but it's a bigger file, and can't tell what most of it is referring to...

please explain what is ApplicationWallpaper.qml and where it located? and example of your previous mods

levone1 2019-08-26 19:57

Re: Help me to code for Sailfish OS
 
1 Attachment(s)
/usr/share/lipstick-jolla-home-qt/compositor/ApplicationWallpaper.qml;
previous mod shown in screenshot, from this thread - https://together.jolla.com/question/...odding-system/

I think I remember ApplicationWindow qml is in /usr/lib/qt5/qml/Sailfish/Silica/private

coderus 2019-08-26 21:04

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by levone1 (Post 1559528)
/usr/share/lipstick-jolla-home-qt/compositor/ApplicationWallpaper.qml;
previous mod shown in screenshot, from this thread - https://together.jolla.com/question/...odding-system/

I think I remember ApplicationWindow qml is in /usr/lib/qt5/qml/Sailfish/Silica/private

what you saying is just works for me:
Code:

import QtQuick 2.2
import Sailfish.Silica 1.0
import org.nemomobile.lipstick 0.1

Wallpaper {
    id: wallpaper

    // All properties are applied to the rasterized texture. Changing it
    // means updating the texture and is thus very expensive. So don't go
    // animating them.
    textureSize: Qt.size(isLegacyWallpaper ? Screen.width : Screen.height, Screen.height)
//    effect: "glass"
    overlayColor: Theme.colorScheme === Theme.DarkOnLight
                  ? Qt.rgba(1.0, 1.0, 1.0, 0.35)
//                  : Qt.rgba(0.0, 0.0, 0.0, 0.6)
                  : Qt.rgba(0.18, 0.21, 0.24, 1.0)
    source: Theme.backgroundImage
}


levone1 2019-08-26 21:55

Re: Help me to code for Sailfish OS
 
2 Attachment(s)
Quote:

Originally Posted by coderus (Post 1559538)
what you saying is just works for me:
Code:

import QtQuick 2.2
import Sailfish.Silica 1.0
import org.nemomobile.lipstick 0.1

Wallpaper {
    id: wallpaper

    // All properties are applied to the rasterized texture. Changing it
    // means updating the texture and is thus very expensive. So don't go
    // animating them.
    textureSize: Qt.size(isLegacyWallpaper ? Screen.width : Screen.height, Screen.height)
//    effect: "glass"
    overlayColor: Theme.colorScheme === Theme.DarkOnLight
                  ? Qt.rgba(1.0, 1.0, 1.0, 0.35)
//                  : Qt.rgba(0.0, 0.0, 0.0, 0.6)
                  : Qt.rgba(0.18, 0.21, 0.24, 1.0)
    source: Theme.backgroundImage
}


And you get a colored bg?

For me, the 1.0 opacity works properly, but the bg ends up being black. 121518 rgb color should be a flat, dark navy-bluish color, (like the previous screenshot). Also, I can tell something's funny, because when I slowly swipe from the side, (as if to peek), it goes straight from black to totally transparent, with no fade, (whereas the normal behavior is a steady fade from the open app to the home screen)

levone1 2019-08-26 23:49

Re: Help me to code for Sailfish OS
 
screenshot came out funky in last attachment - in reality it was a solid black background on the settings app...

coderus 2019-08-27 07:56

Re: Help me to code for Sailfish OS
 
1 Attachment(s)
as i said works like you described, check attach

levone1 2019-08-27 09:28

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1559553)
as i said works like you described, check attach

strange - maybe one of my other mods is tripping it up (GlassBackground ?)...
Thanks

bobsikus 2019-09-10 08:00

Re: Help me to code for Sailfish OS
 
Hello guys, about coding, I have latest SDK 2.2.4. When I try to debug with gdb everything seems to work, except I does not have loaded correct symbols. Unfortunately there is a LOT of information about gdb, but I do not undestand them completely..

I can easily reproduce the problem and the memory address is always the same, journactl points to libQt5Quick.so.5.6.3
Code:

segfault at 4 ip 6fae6efa sp 77ae7c30 error 4 in libQt5Quick.so.5.6.3[6fa05000+264000]
Sep 09 16:27:59 SailfishEmul kernel: Code: e0 01 e9 a8 fe ff ff 90 8d b4 26 00 00 00 00 90 55 89 e5 57 56 53 e8 a5 57 f2 ff 81 c3 15 c1 25 00 83 ec 5c 8b 7d 08 8b 45 0c <8b> 77 04 39 46 74 0f 84 7f 02 00 00 85 c0 74 1e 8b 45 0c 8d 76 00

unfortunately then SDK doesn't show anything more specific, which should lead me somewhere, or at least I'm too dumb to understand it :) :
Code:

0x6fb90efa    8b 77 04    mov  0x4 (%edi),%esi
I would like to know step by step for idiots how to properly set up loading symbols in SDK, on emulator, wherever it is needed.

Thank you a lot

juiceme 2019-09-10 08:20

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by bobsikus (Post 1560116)
Hello guys, about coding, I have latest SDK 2.2.4. When I try to debug with gdb everything seems to work, except I does not have loaded correct symbols. Unfortunately there is a LOT of information about gdb, but I do not undestand them completely..

If the symbols are stripped there's probably a debuginfo rpm to install them.
What's the component that you are missing symbols on?

bobsikus 2019-09-10 08:44

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by juiceme (Post 1560121)
If the symbols are stripped there's probably a debuginfo rpm to install them.
What's the component that you are missing symbols on?

unfortunately, code is not originally my own, it is former Dax's WebPirate, I am still using the app, but closing tabs in tab segment's view sometimes crash the app and it annoys me. I would like to repair it if possible and with Dax's agreement publish it later on.

Where could I find out on which component it is failing ? From what I have said it seems to be QtQuick 2.6 (it was 2.2 before, same crash)

Fuzzillogic 2019-09-17 19:03

Re: Help me to code for Sailfish OS
 
I'm trying to listen for a call from a specific phone number to act upon. It seems almost trivial to make in QtQuick, analogous to how PhoneHook handles it:

QML:
Code:

DBusInterface {
    id:              activeCall
    service:        'org.nemomobile.voicecall'
    path:            '/calls/active'
    iface:          'org.nemomobile.voicecall.VoiceCall'
    signalsEnabled:  true

    function lineIdChanged() {
        console.log("Got: " + activeCall.getProperty("lineId"));
    }
}

Yet, this doesn't work. Possibly because that path doesn't exist until an call becomes active. I have a work around, by first listening for a active call, then rebinding the VoiceCall interface from above:

Code:

DBusInterface {
    service:        'org.nemomobile.voicecall'
    path:            '/'
    iface:          'org.nemomobile.voicecall.VoiceCallManager'
    signalsEnabled:  true

    function activeVoiceCallChanged() {
        activeCall.path = "/calls/active";
        if (activeCall.getProperty("isIncoming")) {
        …
        }
    }
}

The magic here is in the activeCall.path = "/calls/active";.

But this method is ugly, and isn't reliable because it seems the (correct) lineId isn't always immediately available when an incoming call arrives.

So, is this a bug in the DBusInterface plug-in, or am I missing something?

Fuzzillogic 2019-09-20 21:07

Re: Help me to code for Sailfish OS
 
To follow up my own question: I just noticed PhoneHook uses the empty string as service, whereas I used org.nemomobile.voicecall. According to the Qt documentation: "The arguments service and path can be empty, denoting a connection to any signal of the (interface, name) pair, from any remote application."

So, I tried to use

Code:

DBusInterface {
    id:              activeCall
    service:        ''
    path:            '/calls/active'
    iface:          'org.nemomobile.voicecall.VoiceCall'
    signalsEnabled:  true

    function lineIdChanged() {
        console.log("Got: " + activeCall.getProperty("lineId"));
    }
}

but this didn't seem to make a difference.

Also, DBusInterface has an undocumented property watchServiceStatus. This however seems irrelevant, as the service org.nemomobile.voicecall is already available, just not the /calls/active path.

coderus 2019-09-21 19:55

Re: Help me to code for Sailfish OS
 
Fuzzillogic, why you dont c++ this stuff?

Fuzzillogic 2019-09-21 23:33

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1560507)
Fuzzillogic, why you dont c++ this stuff?

Because my C++ knowledge is almost non-existent. And still, why doesn't this work?

coderus 2019-09-22 09:31

Re: Help me to code for Sailfish OS
 
is phonehook using qml for this? can you point me to code?

Fuzzillogic 2019-09-22 10:54

Re: Help me to code for Sailfish OS
 
Phonehook uses C++/Qt for this. Source. But as far as I can gather, this dbus connection there is set up at a time the /calls/active path doesn't exist. That path only exists when there actually is an active call. It seems the Qt-code can handle this, but Nemo's DBusInterface can't.

popipo 2019-10-08 13:55

Re: Help me to code for Sailfish OS
 
Is it possible to copy selected text in SilicaWebView to the clipboard? The text is in an iframe, so I cannot do this by injecting JavaScript.

coderus 2019-10-08 14:08

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by popipo (Post 1560949)
Is it possible to copy selected text in SilicaWebView to the clipboard? The text is in an iframe, so I cannot do this by injecting JavaScript.

no idea actually, but you can check if webcat / webpirate have such feature or not

BGK 2019-10-10 15:28

Re: Help me to code for Sailfish OS
 
Hi out there!

Being a total newbie with nearly every part of the SFOS development universe (i.e. Silica, QML, qt, Python, C++ - I did some webdev with SQL, HTML, PHP, JavaScript, ect. in the past), I would like to create a SFOS-app to control some hardware devices.

The latter can done by WIFI and web-APIs (mostly sending HTTP-POSTs and caring for JSON responses) for which there are open source libraries available in Python and JavaScript (many of them using Node.js). The app should provide a simple GUI to control the devices (some buttons) and to display device states at last.

After reading a lot and taking my first steps with the SFOS IDE, a few questions remain yet:

1. Which way would you go: Qt Quick including Python libraries or Qt Quick (QML only?) including JavaScript libraries? And why would you do so?

2. How do I integrate avalible Python- or JavaScript libraries into my own projects correctly (especially JS-libs using Node.js) and what has to be taken care of doing so?

3. What do I have to take into account regarding the licenses of the libraries?

4. As SFOS (unfortunately) is a not very widespread plattform, I consider publishing the app for other plattforms (iOS, Android), too (starting with the sailfish version using the SFOS IDE). How can this be achieved in the most effective way?

Thanks in advance and greetings,

BGK

robthebold 2019-10-11 02:44

Re: Help me to code for Sailfish OS
 
I've been learning these things myself . . .

There are a couple of Python with QML sample apps on github that might or might not still compile.

Also, tIDE comes with a sample called Decitude that might be helpful. This one definitely will run on the latest sailfish.

BGK 2019-10-13 19:31

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by robthebold (Post 1561005)
I've been learning these things myself . . .

That's why I love TMO! ;) Thanks for sharing your experience and your helpful links!

bobsikus 2019-10-15 06:22

Re: Help me to code for Sailfish OS
 
1 Attachment(s)
Quote:

Originally Posted by bobsikus (Post 1560116)
Hello guys, about coding, I have latest SDK 2.2.4. When I try to debug with gdb everything seems to work, except I does not have loaded correct symbols. Unfortunately there is a LOT of information about gdb, but I do not undestand them completely..

I can easily reproduce the problem and the memory address is always the same, journactl points to libQt5Quick.so.5.6.3
Code:

segfault at 4 ip 6fae6efa sp 77ae7c30 error 4 in libQt5Quick.so.5.6.3[6fa05000+264000]
Sep 09 16:27:59 SailfishEmul kernel: Code: e0 01 e9 a8 fe ff ff 90 8d b4 26 00 00 00 00 90 55 89 e5 57 56 53 e8 a5 57 f2 ff 81 c3 15 c1 25 00 83 ec 5c 8b 7d 08 8b 45 0c <8b> 77 04 39 46 74 0f 84 7f 02 00 00 85 c0 74 1e 8b 45 0c 8d 76 00

unfortunately then SDK doesn't show anything more specific, which should lead me somewhere, or at least I'm too dumb to understand it :) :
Code:

0x6fb90efa    8b 77 04    mov  0x4 (%edi),%esi
I would like to know step by step for idiots how to properly set up loading symbols in SDK, on emulator, wherever it is needed.

Thank you a lot

Hello guys, I have actually found the error even without debugger. But I have another question, might be stupid, but did not find any feasable answer in docs. WebPirate has its navigationbar on the bottom, to the top of this bar is anchored two things, one was already there before, one I have added. Problem is height, when I anchor bottom of (originally there were tabviewdialogs which shows various things) SilicaListView to the top of the navigationbar, height basically cannot be changed. If I specify height, f.e. by dividing original navigationbar height (or even if by real number) height is actually the same, but its bottom moves under the bar, so it more or less shows the height content how it was supposed to be calculated.. How to proceed to calculate height from the bottom ? does z-index matter (navigationbar has z-index different then other elements)? Thank you

EDIT: Well I have overlooked it, at https://doc.qt.io/qt-5/qml-qtquick-listview.html
Quote:

By default, a vertical ListView sets flickableDirection to Flickable.Vertical, and a horizontal ListView sets it to Flickable.Horizontal. Furthermore, a vertical ListView only calculates (estimates) the contentHeight, and a horizontal ListView only calculates the contentWidth. The other dimension is set to -1.
so it seems like it is not possible to do so, if anyone know how can be height managed, let me know please :)

EDIT2: since these buttons are not anyhow dynamic I have recreated SilicaListView and ListItems to Row and Rectangles and it fits.

BGK 2019-10-20 21:03

Re: Help me to code for Sailfish OS
 
1 Attachment(s)
Three more questions:

1. I would like to navigate from the first page of an app (page 1) to another by swiping left (page 2).
GPSInfo does this by using a timer which creates the pageStack.pushAttached element of the second page.
Is there another / more elegant way to achieve this behaviour of changing from one to another page?

2. Is it possible to navigate from one pages button (page 1) to another page (page 3) and scroll this one to a specific item (for example a label) in the middle of this page (like anchors in HTML)?

3. Is it possible to use QLM's transform.matrix4x4 within sailfish apps to transform this element (for example to mirror a text field vertically)?

coderus 2019-10-21 12:44

Re: Help me to code for Sailfish OS
 
1. PageStack is stack, it's linear. You should have a page under your depth to go lower.
2. You can pass any arguments to a page you pushing to. Process it inside page to scroll
3. You can use transform property: https://doc.qt.io/qt-5/qml-qtquick-i...transform-prop

BGK 2019-10-21 18:56

Re: Help me to code for Sailfish OS
 
Thanks for your helpful tips, coderus!

Quote:

Originally Posted by coderus (Post 1561141)
1. PageStack is stack, it's linear. You should have a page under your depth to go lower.

Navigating the stack backwards is clear (and easy). It's the possibility to navigate "forward" from page 1 to page 2 (without the need of a button, just swiping) which I'm looking for. ;)

Quote:

Originally Posted by coderus (Post 1561141)
2. You can pass any arguments to a page you pushing to. Process it inside page to scroll

Passing the "scroll-to-item" to page 3 was exactly what I thought of. But how to scroll the page?

Quote:

Originally Posted by coderus (Post 1561141)

Wonderful! Exactly what I was searching for!

coderus 2019-10-21 19:17

Re: Help me to code for Sailfish OS
 
1. okay, then attachedPage is your choice. Or use a Dialog instead of a Page and set acceptDestination
2. By using https://doc.qt.io/qt-5/qml-qtquick-l...AtIndex-method

BGK 2019-10-21 20:31

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1561150)
1. okay, then attachedPage is your choice. Or use a Dialog instead of a Page and set acceptDestination

I'll go for attachedPage. GPSInfo uses a timer to call attachedPage. What could be the reason for that (wouldn't be Component.onCompleted an easier way)?

Quote:

Originally Posted by coderus (Post 1561150)

Thanks a lot!

coderus 2019-10-21 20:34

Re: Help me to code for Sailfish OS
 
There could be problems with transitions., Try it out and see. New API introduced pageStack.completeAnimation() method, which is probably you want to call before pageStack.pushAttached

kuba77 2019-11-02 22:56

Re: Help me to code for Sailfish OS
 
How to work with images? I want to create app like this or this... so I need to choose image(s) from gallery and save it somewhere in the app - to local database?

coderus 2019-11-03 07:18

Re: Help me to code for Sailfish OS
 
I think this code should still work: https://bitbucket.org/mitakuuluu/mit...atarPicker.qml

Markkyboy 2019-11-12 18:41

Re: Help me to code for Sailfish OS
 
Hi,

How to add a short vibration to a Rectangle Button?,

thanks, . .

Ancelad 2019-11-12 19:04

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by Markkyboy (Post 1561892)
Hi,

How to add a short vibration to a Rectangle Button?,

thanks, . .

Code:

import QtFeedback 5.0

HapticsEffect {
        id: activeEffect
        duration: 500 // in ms
        intensity: 0.2 // from 0 to 1 with 0.1 step-size
        running: button.pressed
}
Button {
        id: button
        width: text.width
        text: "Test"                                       
        anchors.horizontalCenter: parent.horizontalCenter
        onClicked: activeEffect.start()         
}



All times are GMT. The time now is 09:06.

vBulletin® Version 3.8.8