From a026713201282bbef313a36d146da7084ac17c7e Mon Sep 17 00:00:00 2001 From: kirbylife Date: Thu, 4 Apr 2024 01:40:00 -0600 Subject: [PATCH] Add option to restore the old icon --- .gitignore | 1 + Makefile | 2 +- changelog.txt | 3 ++- qml/Main.qml | 11 +++++++++++ src/main.py | 15 ++++++++++++++- 5 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9b1960e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +output/ \ No newline at end of file diff --git a/Makefile b/Makefile index ce47c92..1484a93 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ sourcePath:=$(shell pwd) output:=$(sourcePath)/output dependencies=$(shell for file in `cat dependencies.txt`;do echo "-d "$${file};done;) version:=0.5.0 -iteration:=0 +iteration:=25 fpmExec:=$(shell echo "$${FPM_BIN:=fpm}") all: clean build-tmp rpm-i686 rpm-jolla rpm-aarch64 diff --git a/changelog.txt b/changelog.txt index e6a0978..72b4a2f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,10 +1,11 @@ -*Mon Feb 13 2023 kirbylife 0.5.0-7 +*Thu Apr 04 2024 kirbylife 0.5.0-25 - Add SVG support - Improve performance - Add resize slider - Fix irregluar size of icons on the main grid - Add the option to search a better icon directly on the html page - Improve a bit the logging +- Add the option to restore the old icon *Mon Feb 13 2023 kirbylife 0.4.5-5 - Add aarch64 support diff --git a/qml/Main.qml b/qml/Main.qml index 34a4c7a..99f1db2 100644 --- a/qml/Main.qml +++ b/qml/Main.qml @@ -43,6 +43,17 @@ Page { MenuItem { text: attrs.Name } + MenuItem { + text: "Restore the old icon" + onClicked: { + py.addImportPath(Qt.resolvedUrl("../src")) + py.importModule("main", function(){ + py.call("main.restore_icon", [attrs], function(success) { + if(success) mainList.reload(); + }) + }) + } + } } } diff --git a/src/main.py b/src/main.py index 4caff76..6123034 100644 --- a/src/main.py +++ b/src/main.py @@ -188,7 +188,7 @@ def sailify(raw_str, pattern, size) -> str: return "data:image/png;base64," + output_base64.decode() def backup_icon(app): - if not os.path.exists(app["path"] + "backup"): + if not os.path.exists(app["path"] + "_backup"): backup_path = app["path"] + "_backup" shutil.copyfile(app["path"], backup_path) logging.info("Icon backed up on: " + backup_path) @@ -201,3 +201,16 @@ def save_icon(app): f.write(new_content) logging.info("Icon saved on: " + app["path"]) return True + +def restore_icon(app): + if "old_icon" not in app: + return False + + app["Icon"] = app["old_icon"] + del app["old_icon"] + + new_content = deparse_file(app) + with open(app["path"], "w") as f: + f.write(new_content) + logging.info("Icon saved on: " + app["path"]) + return True