Now you edit the original icon and not the edited previously
parent
01ba24b8e1
commit
a2821886f1
|
@ -47,7 +47,7 @@ Page {
|
|||
activated = !activated
|
||||
iconEditor.corners[idCell] = activated
|
||||
py.importModule("main", function(){
|
||||
py.call("main.sailify", [iconEditor.attrs.Icon.toString().toString(), iconEditor.corners], function(result){
|
||||
py.call("main.sailify", [(iconEditor.attrs.old_icon || iconEditor.attrs.Icon).toString(), iconEditor.corners], function(result){
|
||||
icon.source = result
|
||||
})
|
||||
})
|
||||
|
@ -68,6 +68,7 @@ Page {
|
|||
anchors.topMargin: 10
|
||||
text: "Save"
|
||||
onClicked: {
|
||||
iconEditor.attrs.old_icon = iconEditor.attrs.Icon.toString()
|
||||
iconEditor.attrs.Icon = icon.source.toString()
|
||||
py.importModule("main", function(){
|
||||
py.call("main.save_icon", [iconEditor.attrs], function(result){
|
||||
|
@ -86,7 +87,7 @@ Page {
|
|||
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){
|
||||
py.call("main.sailify", [(iconEditor.attrs.old_icon || iconEditor.attrs.Icon).toString(), [1, 1, 1, 1]], function(result){
|
||||
icon.source = result
|
||||
})
|
||||
})
|
||||
|
|
|
@ -22,7 +22,6 @@ def avg_colors(img):
|
|||
pixel = img.getpixel((x, y))
|
||||
if pixel[-1] > 0: # Doesn't count the transparent pixels
|
||||
counter[pixel] += 1
|
||||
print(counter.most_common(4))
|
||||
return counter.most_common(1)[0][0]
|
||||
|
||||
def add_background(img: Image, bg_tuple: tuple) -> Image:
|
||||
|
@ -92,9 +91,11 @@ def sailify(raw_str, pattern):
|
|||
output_base64 = base64.b64encode(output_data)
|
||||
return "data:image/png;base64," + output_base64.decode()
|
||||
|
||||
def save_icon(app):
|
||||
def backup_icon(app):
|
||||
if not os.path.exists(app["path"] + "backup"):
|
||||
shutil.copyfile(app["path"], app["path"] + "_backup")
|
||||
|
||||
def save_icon(app):
|
||||
new_content = deparse_file(app)
|
||||
with open(app["path"], "w") as f:
|
||||
f.write(new_content)
|
||||
|
|
Loading…
Reference in New Issue