From ff3be0916ae61f76d5d4a03c7bb9b376fe6c1611 Mon Sep 17 00:00:00 2001 From: BarsTiger Date: Thu, 27 Jan 2022 21:24:54 +0200 Subject: [PATCH] GUI development --- horsygui.py | 18 +++++++++++++++--- modules/gui_manager.py | 2 +- modules/search.py | 25 +++++++++++++++++++++---- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/horsygui.py b/horsygui.py index b92c2f7..28c85f6 100644 --- a/horsygui.py +++ b/horsygui.py @@ -1,11 +1,8 @@ -import argparse -import os import sys import math from PyQt5 import QtCore, QtGui, QtWidgets import modules.gui as gui -from modules.console import cls # Initialize GUI if __name__ == "__main__": @@ -100,6 +97,19 @@ def get_source_gui(): except: return +def info_gui(): + from modules.search import info + try: + app_name = ui.search_table.currentItem().text() + if app_name == "": + return + else: + info = info(app_name, download_ui, UiDownloadWindow) + if info is not None: + gui.popup("Error", info) + except: + return + def upload_gui(): from modules.uploader import upload @@ -117,6 +127,8 @@ if __name__ == "__main__": ui.search_button.clicked.connect(search_gui) ui.install_button.clicked.connect(install_app) ui.source_button.clicked.connect(get_source_gui) + ui.info_button.clicked.connect(info_gui) + ui.search_table.itemDoubleClicked.connect(info_gui) ui.upload_button.clicked.connect(upload_gui) diff --git a/modules/gui_manager.py b/modules/gui_manager.py index 8c61a0d..4f9f6c4 100644 --- a/modules/gui_manager.py +++ b/modules/gui_manager.py @@ -140,7 +140,7 @@ def install(package): pass -def uninstall(package, is_gui=False): +def uninstall(package, login_ui=None, Ui_LoginWindow=None): if os.path.exists('{1}apps/{0}'.format(package, horsy_vars.horsypath)): os.system('rmdir /s /q "{1}apps/{0}"'.format(package, horsy_vars.horsypath)) print(f"[green][OK] Files deleted[/]") diff --git a/modules/search.py b/modules/search.py index b6a4570..a0a51bf 100644 --- a/modules/search.py +++ b/modules/search.py @@ -25,20 +25,20 @@ def search(query, is_gui=False): return ret_res -def info(package): +def info(package, download_ui=None, UiDownloadWindow=None): r = requests.get(f"{horsy_vars.protocol}{horsy_vars.server_url}/packages/json/{package}").text if r == "": print(f"[red]Package {package} not found[/]") - return + return f"Package {package} not found" try: r = json.loads(r) except: print("[red]Error with unsupported message[/]") - return + return "Error with unsupported message" try: if r["message"] == "Internal server error": print("[red]Internal server error[/]") - return + return "Internal server error" except: pass @@ -54,3 +54,20 @@ def info(package): "Keep in mind, developers can change the code after verification \n" "We [red]don't call you to trust this app[/], use it at your own risk \n" "but we recommend you more to install verified packages") + if download_ui is not None: + download_ui.logs_box.clear() + UiDownloadWindow.show() + download_ui.logs_box.append(f"{r['name']}{'✅' if r['verified'] else ''} by {r['authorName']}") + download_ui.logs_box.append(f"{r['description']}") + download_ui.logs_box.append(f"👍{r['likes']} | 👎{r['dislikes']}") + if not r['verified']: + download_ui.logs_box.append("This package is not verified by the horsy team. This means that it \n" + "can be unstable or it can be malware. Most packages have unverified\n" + "state, but use it at your own risk.") + else: + download_ui.logs_box.append("This package is verified by the horsy team! \n" + "Keep in mind, developers can change the code after verification \n" + "We don't call you to trust this app, use it at your own risk \n" + "but we recommend you more to install verified packages") + return None +