GUI development
This commit is contained in:
18
horsygui.py
18
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)
|
||||
|
||||
|
||||
|
||||
@@ -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[/]")
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user