Add README

master
kirbylife 2021-05-10 15:12:10 -05:00
parent 53e1c9046a
commit e28f6b731c
3 changed files with 48 additions and 39 deletions

View File

@ -1,38 +1,22 @@
Sailfish Python
# Muchkin icons
==============
Make your webapps icons in the app box look better with the rest of your native apps by choosing whether the corners are rounded or pointed
this is a pyotherside based app template for sailfish os. I simply cant get my head around the way rpm packages are built,so i found an alternative Way using fpm
https://github.com/jordansissel/fpm
## Dependencies
- SailfishOS (tested in SailfishOS 4 with an Xperia XA2)
- [Python3-numpy](https://openrepos.net/content/nobodyinperson/python3-numpy)
- [Python3-pillow](https://openrepos.net/content/birdzhang/python3-pillow)
Build Dependencies:
------------------
this package are needed to build/install the package:
## Build dependencies
- [fpm](https://github.com/jordansissel/fpm)
fpm -- to package a a root tree from a temporary directory to a rpm package
## Build your own RPM package
1. Clone the repository: `git clone https://gitlab.com/kirbylife/harbour-muchkin`
1. Go to the directory: `cd harbour-muchkin`
1. Build the package: `make rpm-jolla`
1. the .rpm file will be on `/tmp/fpm-jolla/`
## Make Commands:
use these make commands to build/install your app for testing:
`make make-virt`
builds your package, and installs it on your Sailfish Emulator on localhost:2223, considering your Sailfish-SDK is installed at ~/SailfishOS
`make make-jolla-wifi [jolla_wifi_ip=jolla]`
builds your package, and installs it on your jolla phone, considering your development PC is authorized for root ssh login on the phone and it is found in your dns-space as "jolla"
`make make-jolla-usb [jolla_usb_ip=192.168.2.15]`
builds your package, and installs it on your jolla phone, considering your development PC is authorized for root ssh login on the phone, and connected via usb development mode set your jollas ip like above.
## Adding dependencies:
a basic set of dependencies for python3 apps are already added to dependencies.txt, but you can still add other ones to the list.
##Adding python Modules:
all python Modules in pyPackages (suffixed correctly) are included in the package.
I like to keep both an armv7l and a x86 version in pyPackages , and package the one with the corresponding $(arch)-suffix at packaging. Select the package version within the qml code. I had success using pip wheel to build these packages directly on the jolla phone(armv7hl)/sailfish emulator(x86) and unpacking them to pyPackages. As an example, pillow (Python Imaging Library) is included in the repo.
## Renaming your App:
`/renamep.py "my-new-appname"`
## TO-DO
- [ ] TO-DO list
Contributors are welcome :)

View File

@ -24,6 +24,10 @@ Page {
model: ListModel {
id: gridItems
ListElement {
idCell: 0
activated: true
}
ListElement {
idCell: 1
activated: true
@ -36,10 +40,6 @@ Page {
idCell: 3
activated: true
}
ListElement {
idCell: 4
activated: true
}
}
delegate: GridItem {
@ -49,8 +49,8 @@ Page {
iconEditor.corners[idCell] = activated
py.importModule("main", function(){
console.log(typeof icon.source);
py.call("main.sailify", [icon.source.toString(), iconEditor.corners], function(result){
icon.source = resource
py.call("main.sailify", [iconEditor.attrs.Icon.toString().toString(), iconEditor.corners], function(result){
icon.source = result
})
})
}
@ -62,19 +62,35 @@ Page {
anchors.top: header.bottom
width: parent.width
height: width
source: attrs.Icon
// source: attrs.Icon
}
Button {
anchors.top: icon.bottom
anchors.horizontalCenter: parent.horizontalCenter
anchors.topMargin: 10
text: "Save"
onClicked: {
iconEditor.attrs.Icon = icon.source.toString()
py.importModule("main", function(){
py.call("main.save_icon", [iconEditor.attrs], function(result){
if(result){
pageStack.navigateBack(PageStackAction.Animated)
}
})
})
}
}
Python {
id: py
Component.onCompleted: {
py.addImportPath(Qt.resolvedUrl("../src"));
py.importModule("main", function(){
py.call("main.sailify", [iconEditor.attrs.Icon.toString(), [1, 1, 1, 1]], function(result){
icon.source = result
})
})
}
}
}

View File

@ -5,6 +5,7 @@ from glob import glob
import numpy as np
import base64
import os
import shutil
def base64_to_img(base64_bytes: bytes) -> Image:
img_bytes = base64.b64decode(base64_bytes)
@ -91,6 +92,14 @@ def sailify(raw_str, pattern):
output_base64 = base64.b64encode(output_data)
return "data:image/png;base64," + output_base64.decode()
def save_icon(app):
if not os.path.exists(app["path"] + "backup"):
shutil.copyfile(app["path"], app["path"] + "_backup")
new_content = deparse_file(app)
with open(app["path"], "w") as f:
f.write(new_content)
return True
def main():
import shutil