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)

Markkyboy 2020-04-21 08:23

Re: Help me to code for Sailfish OS
 
Hi, I need to install rpmrebuild to continue messing about with building/editing apps. I would like to install it to '/home/nemo' not 'root'. How do i install to '/home/nemo'?, thanks

coderus 2020-04-21 09:09

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by Markkyboy (Post 1567014)
Hi, I need to install rpmrebuild to continue messing about with building/editing apps. I would like to install it to '/home/nemo' not 'root'. How do i install to '/home/nemo'?, thanks

cant understadnd what you mean. please explain what you trying to do

Markkyboy 2020-04-21 09:29

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1567015)
cant understadnd what you mean. please explain what you trying to do

For many years, my rpmbuild folder resided in /home/nemo, these were set up manually. I reset my device recently and forgot to make a copy of the rpmbuild directory, so all is lost.

Rather than set up those folders manually in /home/nemo, I want to install rpmbuild to home/nemo, so that when I build apps, I find my RPMs in /home/nemo/rpmbuild/* instead of the root rpmbuild directory.

coderus 2020-04-21 09:46

Re: Help me to code for Sailfish OS
 
you can use macroses

https://docs.fedoraproject.org/en-US..._build_process

Markkyboy 2020-04-21 09:51

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1567017)

Thanks for the reminder!!, I had a macro file in /home/nemo but forgot to back it up, damn!, I knew something was missing!

Could you remind me of what I need to put in the file?

Thanks for the link regarding RPMMacros ~ I'm just unsure of the contents of the macro file...?

I found some notes I'd made referring to macro files, but did not list the macro file contents :(

coderus 2020-04-21 10:09

Re: Help me to code for Sailfish OS
 
_rpmdir iirc

Markkyboy 2020-04-21 10:18

Re: Help me to code for Sailfish OS
 
Okay, thanks, I will google/play around and work it out.

Meanwhile, I'm going round to punch my neighbours lights out and his fkin dogs, for repeated fkin barking!, day and fkin night!, for fkin months!, bsstsds! ...I've asked nicely several times, enough is enough!, I may not be back and may end up languishing in a Spanish prison for assault!

Regards

Markkyboy 2020-04-21 16:41

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1567021)
_rpmdir iirc

Thanks coderus, sorted.
  1. make a file in `/home/nemo`
  2. name it `.rpmmacros`
  3. add `%_topdir /home/nemo/rpmbuild`

That's it, get building!, I just ran a build and the resulting file was found in 'rpmbuild/RPMS/noarch' as expected.

Directions on 'how to' taken from here; http://ftp.rpm.org/max-rpm/s1-rpm-an...uild-area.html

Morc 2020-04-22 19:06

Re: Help me to code for Sailfish OS
 
I've been thinking about trying to port SDL app to Sailfish OS. Is that achievable? Because i have a SDL app source, i firstly modified it to use libSDL2 but i'm having problems on importing SDL.h libs in it as i might also need source for SDL. Does anyone know what could help me?

Halftux 2020-04-22 19:24

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by Morc (Post 1567054)
Because i have a SDL app source, i firstly modified it to use libSDL2 but i'm having problems on importing SDL.h libs in it as i might also need source for SDL. Does anyone know what could help me?

You need to install the development packages:

SDL2-devel
SDL2_gfx-devel
SDL2_image-devel
SDL2_mixer-devel
SDL2_net-devel
SDL2_sound-devel
SDL2_ttf-devel

But don't now if it is still valid, names could have changed.

coderus 2020-04-22 20:05

Re: Help me to code for Sailfish OS
 
there a lot of opensource SDL apps and games in openrepos you can check for inspiration

Morc 2020-04-23 08:33

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by Halftux (Post 1567055)
You need to install the development packages:

SDL2-devel
SDL2_gfx-devel
SDL2_image-devel
SDL2_mixer-devel
SDL2_net-devel
SDL2_sound-devel
SDL2_ttf-devel

But don't now if it is still valid, names could have changed.


Thanks, thanks so much! It compiled now and i only have to fix touch and also possibly orientation. I don't really know now how, but i'll maybe find something.

Morc 2020-04-25 18:23

Re: Help me to code for Sailfish OS
 
I've been thinking, as i fixed my SDL app to work now with touch, how can i put it to rpm format with .desktop and icon like creating an app in Qt Creator?

coderus 2020-04-25 18:29

Re: Help me to code for Sailfish OS
 
you can always RTFM: https://sailfishos.org/wiki/Tutorial...kages_manually

rrijken1973 2020-06-24 05:42

Re: Help me to code for Sailfish OS
 
how difficult is it to port an open source android app to sailfish? Not a lot of apps available so as this has not been done yet, I guess very difficult?

For example, porting over K9 email or even a better browser....

juiceme 2020-06-24 06:00

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by rrijken1973 (Post 1568019)
how difficult is it to port an open source android app to sailfish? Not a lot of apps available so as this has not been done yet, I guess very difficult?

For example, porting over K9 email or even a better browser....

Unless the android app has been created with a cross-platform toolkit (I think there are some that have been done that way?) it is fairly difficult.

The difficulty lies in the fact that Android applications are implemented with their own UI framework and the insides of the applications is done in java, and on Sailfish the UI framework is Silica and QT while the program logic is (usually) c++.

It is most often easier to implement the whole shebang from scratch than try porting.

peterleinchen 2020-06-24 11:45

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by juiceme (Post 1568020)
...
It is most often easier to implement the whole shebang from scratch than try porting.

Or, even more easier, install aliendalvik and the Android app :eek:
(duck'n'cover)

levone1 2020-07-09 21:27

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1559337)
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.

Question for you, (or anyone)...
If I modify a system qml, (say "glassBackground.qml", for example), then I can't apply any patch that works with that file, (I guess the patch script detects that the file was changed, and assumes some other patch is applied). Is there any way to reset that info, and cause the patch to apply anyway? I notice in Patchmanager log, that there is a line that says, "apply patch anyway? no". Can that be overridden?
Thanks

coderus 2020-07-09 21:29

Re: Help me to code for Sailfish OS
 
no-no. open patch file in text editor and look. it matches lines before and after lines to be changed. if you change these matches then patch cannot be applied.

levone1 2020-07-09 21:36

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1568242)
no-no. open patch file in text editor and look. it matches lines before and after lines to be changed. if you change these matches then patch cannot be applied.

Oh - so if I change the file first, then install the patch, it should work... I'll check it out...

juiceme 2020-07-10 08:11

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by levone1 (Post 1568243)
Oh - so if I change the file first, then install the patch, it should work... I'll check it out...

It depends on what the change is; patchmanager just applies patches with "standard" unix patch utility which can apply hunks if the changes done to the file are not touching the same lines and it can still detect the correct place to apply the hunk.

The way to learn is to read the file and see what changes the patch is making, just like @coderus said. :)

Markkyboy 2020-08-22 10:48

Re: Help me to code for Sailfish OS
 
Hi all,

I've made myself a basic weather application, it uses the OpenWeatherMap.org API for data.

I would like to know how to enter my Weather API URL to my `weather.js` file using Dialog, but I'm unsure how to do it. I have played around with the example from Jolla, but I don't know quite what I'm doing......help! :)

The weather.js file uses XmlHttpRequest to fetch the data.

Code:

function requestWeatherData(cntr) {
    var xhr = new XMLHttpRequest;
    xhr.open("GET", `MY API KEY AND ID HERE`);
    xhr.onreadystatechange = function () {
        if (xhr.readyState === XMLHttpRequest.DONE) {
            cntr.weatherData = JSON.parse(xhr.responseText)
        }
    }
    xhr.send();
}

thanks,

Thoke 2020-08-23 08:50

Re: Help me to code for Sailfish OS
 
is your API key embedded to url? Then you can just do this:

Code:

let url = 'https.//www.example.com?api_key=' + API_key;
the key might need to be converted to string, perhaps. Also need to check what name the API key has, it might not be api_key like in the url.

I would then use fetch api to get the response:

Code:

let response = await fetch(url);
let data = await response.json();

// parse data here


Fuzzillogic 2020-08-23 14:42

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by Thoke (Post 1568874)
I would then use fetch api to get the response:

Is the fetch API present in SFOS's ancient Qt version? The async await-construct isn't, I found out the hard way a few months ago. Native Promises are neither, by the way.

Thoke 2020-08-23 17:24

Re: Help me to code for Sailfish OS
 
Ah, right. Didn't know that. I suggested fetch because it's so easy. Let me check how to do it with xmlhttprequest...

Thoke 2020-08-23 18:53

Re: Help me to code for Sailfish OS
 
Found from here: https://openweathermap.org/forecast5#call

Code:

api.openweathermap.org/data/2.5/forecast?zip={zip code},{country code}&appid={your api key}
so you can contstruct your url as per my previous suggestion.

EDIT: I had to check, but XMLHttpRequest doesn't allow cross-site requests, so it wont work without modifications. With a short look, it seems there's CORS and JSONP to circumvent the restriction, but I don't know if they're supported on SFOS, and this is also something I have no experience implementing.

I would try it anyways, though. Maybe there's no restrictions when using it when you are not actually doing this js stuff with a browser attached.

rob_kouw 2020-08-26 09:01

Re: Help me to code for Sailfish OS
 
1 Attachment(s)
Is there a way to force a ListModel to refresh, when the database records have been changed?

I have a page, where the ListModel is filled by a JS function getting a SELECT from a SQLite database. It is a list of letters, with a possible value, e.g. A="3", B="".
After some experiments with TextFields I chose for Buttons. Then a Dialog opens, where the value can be changed.

However, after the change, the Button does not show the new value of the letter. Can I force an update? Maybe by a signal from the PageStack that the current page has become visible again?

The Button is now configured like:
Code:

Button {
        height: Theme.itemSizeMedium
        preferredWidth: Theme.buttonWidthLarge
        anchors.horizontalCenter: parent.horizontalCenter
        text: letter + " = " + (lettervalue === "" ? "<?>" : lettervalue) + qsTr(". Click to change")
        onClicked: {
                generic.lettEdit  = letter
                pageStack.push(Qt.resolvedUrl("LetterPage.qml"),
                                          {"lettervalue": lettervalue})
                listModelLett.updateLett();
        }
}


coderus 2020-08-26 23:47

Re: Help me to code for Sailfish OS
 
how do you work with model?

rob_kouw 2020-08-28 09:27

Re: Help me to code for Sailfish OS
 
Thanks for helping, coderus!

The simplified code looks like this.

Code:

import QtQuick 2.0
import Sailfish.Silica 1.0
import "../scripts/Database.js" as Database

Page {
    id: thisWayptPage

    ListModel {
        id: listModelLett

        function updateLett()
        {
            listModelLett.clear();
            var lettrs = Database.getLettersWP(generic.wpId);
            for (var i = 0; i < lettrs.length; ++i) {
                listModelLett.append(lettrs[i]);
            }
        }
    }

    Component.onCompleted: listModelLett.updateLett();

    SilicaFlickable {

        PageHeader { ... }

        Column {

            TextArea { ... }

            Repeater {
                model: listModelLett

                ListItem {

                    Button {
                        text: letter + qsTr(". Click to change")
                        onClicked: {
                            pageStack.push(Qt.resolvedUrl("LetterPage.qml"),
                                          {"letterid": letterid})
                        }
                    }
                }
            }
        }
    }
}

I took the ListModel from the app BudgetBook. The database function just reads the records from the table, in order to fill the ListModel.

On clicking the button, the Dialog in "LetterPage.qml" provides the possibility to enter a value for the letter. Then onDone, the value is stored in the database. After the pop() I don't know how to update the ListModel from the updated database.

This morning I thought of a work-around, but a proper method would be nice.

rob_kouw 2020-08-28 13:03

Re: Help me to code for Sailfish OS
 
Hm. Work-around is not working.

coderus 2020-08-28 22:56

Re: Help me to code for Sailfish OS
 
i dont know a way to do this in pure qml without c++ code

rob_kouw 2020-08-31 15:10

Re: Help me to code for Sailfish OS
 
2 Attachment(s)
Alright. Well, I looked at c++ and didn't know how to implement it. So I just leave it for now.

Another question then. The first page looks awful in Landscape. It seems the height is still as high as in Portrait. One level deeper is normal behavior, but one level deeper it is also strange.

First page is here: https://github.com/cow-n-berg/harbou...CachesPage.qml

I think I don't mess around with any height, only for the ListItem. How can it happen?

Markkyboy 2020-09-01 10:43

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by rob_kouw (Post 1569012)
Alright. Well, I looked at c++ and didn't know how to implement it. So I just leave it for now.

First page is here: https://github.com/cow-n-berg/harbou...CachesPage.qml

I think I don't mess around with any height, only for the ListItem. How can it happen?

I note from your CachesPage.qml you have set allowedOrientations to Portrait only, perhaps to add Landscape also. I'm not sure if this will fix the problem, but it can't be helping.

rob_kouw 2020-09-01 20:35

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by Markkyboy (Post 1569018)
I note from your CachesPage.qml you have set allowedOrientations to Portrait only, perhaps to add Landscape also. I'm not sure if this will fix the problem, but it can't be helping.

Thanks for helping! Right, I decided to limit this CachesPage to Portrait, after I wrote the question above. Apologies for the miscommunication.

Markkyboy 2020-09-01 21:16

Re: Help me to code for Sailfish OS
 
I have a similar problem with landscape with regard to positioning items.

This is editing directly on the device not in SDK, where I know Lipstick is not allowed.

A few years back, we could do the following for rotating items when in landscape;

HTML Code:

import QtQuick 2.0
import Sailfish.Silica 1.0
import Sailfish.Lipstick 1.0 <----- import Lipstick
import "weather.js" as WeatherData

Grid {
    id: labels

    property bool rotated: {    <----add this
        Lipstick.compositor.topmostWindowOrientation &
        (Qt.LandscapeOrientation | Qt.InvertedLandscapeOrientation)
    }

    rows: 2
    columns: 2

    // rotated ? landscape : portrait
    rowSpacing: rotated ? 270 : 580    < -----and adjust this with the 'rotated' property
    columnSpacing: rotated ? 500 : 170

    anchors.centerIn: parent

The above is just a snippet to show the added code which used to work in nearly any file, but now it is not working. I get the following error;

Code:

[W] unknown:10 - file:///usr/share/wind-dash/qml/pages/Labels.qml:10: ReferenceError: Lipstick is not defined
Has something changed?, how can I work around this?, I would like my grid of labels to change position when the app is viewed in landscape.

coderus 2020-09-01 21:35

Re: Help me to code for Sailfish OS
 
you want rotation but dont want to rotate page? use rotation sensor.

Markkyboy 2020-09-01 21:54

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1569033)
you want rotation but don't want to rotate page? use rotation sensor.

are you replying to me coderus?

coderus 2020-09-01 21:54

Re: Help me to code for Sailfish OS
 
correct [10 chars]

Markkyboy 2020-09-01 21:57

Re: Help me to code for Sailfish OS
 
Quote:

Originally Posted by coderus (Post 1569035)
correct [10 chars]

then you totally misunderstand my question. I did not include any information about page rotation as my app already rotates to landscape.

The problem is, my row and column spacings are not changing position when turned to landscape. The code I posted previously allowed me to do just that, now it does not work.

Markkyboy 2020-09-02 16:14

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

I've found another way to achieve my goal.

I took a good look in `/usr/lib/qt5/qml/Sailfish/Lipstick` and found some code pertaining to rotation/rotating items; `isLandscape` does the job, so the code now looks like this;

Code:

import QtQuick 2.0
import Sailfish.Silica 1.0
import "weather.js" as WeatherData

Grid {
    id: labels
    rows: 2
    columns: 2

    rowSpacing: isLandscape ? 270 : 580
    columnSpacing: isLandscape ? 500 : 170

    anchors.centerIn: parent

No need for import statements or additional properties, time to tidy up other aspects of this 'wind dashboard'.


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

vBulletin® Version 3.8.8