diff --git a/horsygui.py b/horsygui.py index 62e21bb..7514da9 100644 --- a/horsygui.py +++ b/horsygui.py @@ -15,6 +15,10 @@ ui = gui.Ui_MainWindow() ui.setupUi(MainWindow) MainWindow.show() +UiMainWindow = QtWidgets.QMainWindow() +login_ui = gui.Ui_LoginWindow() +login_ui.setupUi(UiMainWindow) + # Functions def refresh_gui(): @@ -90,7 +94,8 @@ def get_source_gui(): def upload_gui(): from modules.uploader import upload - upload(True, ui) + upload(True, ui, login_ui) + # Run functions on startup installed_apps() diff --git a/modules/auth.py b/modules/auth.py index 0acfc6d..af5d262 100644 --- a/modules/auth.py +++ b/modules/auth.py @@ -2,7 +2,7 @@ import json import modules.vars as horsy_vars -def get_auth(): +def get_auth(is_gui=False, login_ui=None): with open(horsy_vars.horsypath + 'config.cfg') as f: config = json.load(f) @@ -12,16 +12,29 @@ def get_auth(): else: raise Exception('No auth found') except: - print('[!] No auth found, please login first') - print('email') - email = input('> ') - print('password') - password = input('> ') - config['auth'] = {'email': email, 'password': password} + if not is_gui: + print('[!] No auth found, please login first') + print('email') + email = input('> ') + print('password') + password = input('> ') + config['auth'] = {'email': email, 'password': password} + with open(horsy_vars.horsypath + 'config.cfg', 'w') as f: + json.dump(config, f) + print('[OK] Auth created') + return config['auth'] + else: + login_ui.show() + login_ui.login_button.clicked.connect(lambda: get_auth(login_ui=login_ui)) + + +def get_gui_auth(login_ui): + with open(horsy_vars.horsypath + 'config.cfg') as f: + config = json.load(f) + if login_ui.email_box.text() != '' and login_ui.password_box.text() != '': with open(horsy_vars.horsypath + 'config.cfg', 'w') as f: + config['auth'] = {'email': login_ui.email_box.text(), 'password': login_ui.password_box.text()} json.dump(config, f) - print('[OK] Auth created') - return config['auth'] def del_auth(): diff --git a/modules/gui.py b/modules/gui.py index 3869dff..289e367 100644 --- a/modules/gui.py +++ b/modules/gui.py @@ -676,6 +676,77 @@ class Ui_MainWindow(object): self.horsy_text_lefttop.setText(_translate("MainWindow", "horsy")) +class Ui_LoginWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(292, 200) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth()) + MainWindow.setSizePolicy(sizePolicy) + MainWindow.setMinimumSize(QtCore.QSize(292, 200)) + MainWindow.setMaximumSize(QtCore.QSize(292, 200)) + MainWindow.setFocusPolicy(QtCore.Qt.NoFocus) + MainWindow.setContextMenuPolicy(QtCore.Qt.NoContextMenu) + MainWindow.setWindowOpacity(0.98) + MainWindow.setStyleSheet("QWidget{\n" + " background-color: rgb(30, 30, 30);\n" + "}\n" + "") + MainWindow.setDockOptions(QtWidgets.QMainWindow.AllowTabbedDocks | QtWidgets.QMainWindow.AnimatedDocks) + self.centralwidget = QtWidgets.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + self.login_button = QtWidgets.QPushButton(self.centralwidget) + self.login_button.setEnabled(True) + self.login_button.setGeometry(QtCore.QRect(70, 140, 151, 50)) + self.login_button.setMinimumSize(QtCore.QSize(0, 50)) + self.login_button.setStyleSheet("QPushButton {\n" + " color: rgb(204, 204, 204);\n" + " border-width: 1px;\n" + " border-radius:6px;\n" + " border-style: solid;\n" + " background-color: rgb(28, 30, 33);\n" + " border-color: rgb(66, 143, 225);\n" + "}\n" + "QPushButton:hover{\n" + " border-width: 2px;\n" + "}\n" + "QPushButton:pressed{\n" + " background-color: rgb(50, 60, 63);\n" + "}\n" + "QPushButton:disabled{\n" + " border-width: 0px;\n" + " background-color: rgb(92, 99, 109);\n" + "}") + self.login_button.setObjectName("login_button") + self.email_box = QtWidgets.QLineEdit(self.centralwidget) + self.email_box.setGeometry(QtCore.QRect(20, 20, 251, 51)) + self.email_box.setStyleSheet("background-color: rgb(74, 76, 83);\n" + "border-radius: 5px; \n" + "color: rgb(242, 242, 242);") + self.email_box.setObjectName("email_box") + self.password_box = QtWidgets.QLineEdit(self.centralwidget) + self.password_box.setGeometry(QtCore.QRect(20, 80, 251, 51)) + self.password_box.setStyleSheet("background-color: rgb(74, 76, 83);\n" + "border-radius: 5px; \n" + "color: rgb(242, 242, 242);") + self.password_box.setInputMask("") + self.password_box.setEchoMode(QtWidgets.QLineEdit.PasswordEchoOnEdit) + self.password_box.setObjectName("password_box") + MainWindow.setCentralWidget(self.centralwidget) + + self.retranslateUi(MainWindow) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + _translate = QtCore.QCoreApplication.translate + MainWindow.setWindowTitle(_translate("MainWindow", "Log in")) + self.login_button.setText(_translate("MainWindow", "Log in")) + self.email_box.setPlaceholderText(_translate("MainWindow", "email")) + self.password_box.setPlaceholderText(_translate("MainWindow", "Password")) + + if __name__ == "__main__": import sys diff --git a/modules/uploader.py b/modules/uploader.py index 081c142..1fcaf11 100644 --- a/modules/uploader.py +++ b/modules/uploader.py @@ -16,7 +16,7 @@ def urlmatch(s): return re.match("^https?://.*.(?:zip|exe)$", s) is not None -def upload(is_gui=False, ui=None): +def upload(is_gui=False, ui=None, login_ui=None): if not is_gui: print('Welcome to the uploader') print('Before starting, please make sure you have done your project and [blink]uploaded[/] it to any hosting ' @@ -93,7 +93,7 @@ def upload(is_gui=False, ui=None): } else: - auth = get_auth() + auth = get_auth(is_gui) project_name = ui.packagename_box.text() if not matches(project_name) or len(project_name) > 64 or len(project_name) < 3: diff --git a/uis/horsy_login.py b/uis/horsy_login.py new file mode 100644 index 0000000..7622eef --- /dev/null +++ b/uis/horsy_login.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'D:\RAZNOE\prgrming\horsy\Source\client\uis\horsy_login.ui' +# +# Created by: PyQt5 UI code generator 5.15.6 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(292, 200) + sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth()) + MainWindow.setSizePolicy(sizePolicy) + MainWindow.setMinimumSize(QtCore.QSize(292, 200)) + MainWindow.setMaximumSize(QtCore.QSize(292, 200)) + MainWindow.setFocusPolicy(QtCore.Qt.NoFocus) + MainWindow.setContextMenuPolicy(QtCore.Qt.NoContextMenu) + MainWindow.setWindowOpacity(0.98) + MainWindow.setStyleSheet("QWidget{\n" +" background-color: rgb(30, 30, 30);\n" +"}\n" +"") + MainWindow.setDockOptions(QtWidgets.QMainWindow.AllowTabbedDocks|QtWidgets.QMainWindow.AnimatedDocks) + self.centralwidget = QtWidgets.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + self.login_button = QtWidgets.QPushButton(self.centralwidget) + self.login_button.setEnabled(True) + self.login_button.setGeometry(QtCore.QRect(70, 140, 151, 50)) + self.login_button.setMinimumSize(QtCore.QSize(0, 50)) + self.login_button.setStyleSheet("QPushButton {\n" +" color: rgb(204, 204, 204);\n" +" border-width: 1px;\n" +" border-radius:6px;\n" +" border-style: solid;\n" +" background-color: rgb(28, 30, 33);\n" +" border-color: rgb(66, 143, 225);\n" +"}\n" +"QPushButton:hover{\n" +" border-width: 2px;\n" +"}\n" +"QPushButton:pressed{\n" +" background-color: rgb(50, 60, 63);\n" +"}\n" +"QPushButton:disabled{\n" +" border-width: 0px;\n" +" background-color: rgb(92, 99, 109);\n" +"}") + self.login_button.setObjectName("login_button") + self.email_box = QtWidgets.QLineEdit(self.centralwidget) + self.email_box.setGeometry(QtCore.QRect(20, 20, 251, 51)) + self.email_box.setStyleSheet("background-color: rgb(74, 76, 83);\n" +"border-radius: 5px; \n" +"color: rgb(242, 242, 242);") + self.email_box.setObjectName("email_box") + self.password_box = QtWidgets.QLineEdit(self.centralwidget) + self.password_box.setGeometry(QtCore.QRect(20, 80, 251, 51)) + self.password_box.setStyleSheet("background-color: rgb(74, 76, 83);\n" +"border-radius: 5px; \n" +"color: rgb(242, 242, 242);") + self.password_box.setInputMask("") + self.password_box.setEchoMode(QtWidgets.QLineEdit.PasswordEchoOnEdit) + self.password_box.setObjectName("password_box") + MainWindow.setCentralWidget(self.centralwidget) + + self.retranslateUi(MainWindow) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + _translate = QtCore.QCoreApplication.translate + MainWindow.setWindowTitle(_translate("MainWindow", "Log in")) + self.login_button.setText(_translate("MainWindow", "Log in")) + self.email_box.setPlaceholderText(_translate("MainWindow", "email")) + self.password_box.setPlaceholderText(_translate("MainWindow", "Password")) + + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + MainWindow = QtWidgets.QMainWindow() + ui = Ui_MainWindow() + ui.setupUi(MainWindow) + MainWindow.show() + sys.exit(app.exec_()) diff --git a/uis/horsy_login.ui b/uis/horsy_login.ui new file mode 100644 index 0000000..9ab61e8 --- /dev/null +++ b/uis/horsy_login.ui @@ -0,0 +1,141 @@ + + + MainWindow + + + + 0 + 0 + 292 + 200 + + + + + 0 + 0 + + + + + 292 + 200 + + + + + 292 + 200 + + + + Qt::NoFocus + + + Qt::NoContextMenu + + + Log in + + + 0.980000000000000 + + + QWidget{ + background-color: rgb(30, 30, 30); +} + + + + QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks + + + + + true + + + + 70 + 140 + 151 + 50 + + + + + 0 + 50 + + + + QPushButton { + color: rgb(204, 204, 204); + border-width: 1px; + border-radius:6px; + border-style: solid; + background-color: rgb(28, 30, 33); + border-color: rgb(66, 143, 225); +} +QPushButton:hover{ + border-width: 2px; +} +QPushButton:pressed{ + background-color: rgb(50, 60, 63); +} +QPushButton:disabled{ + border-width: 0px; + background-color: rgb(92, 99, 109); +} + + + Log in + + + + + + 20 + 20 + 251 + 51 + + + + background-color: rgb(74, 76, 83); +border-radius: 5px; +color: rgb(242, 242, 242); + + + email + + + + + + 20 + 80 + 251 + 51 + + + + background-color: rgb(74, 76, 83); +border-radius: 5px; +color: rgb(242, 242, 242); + + + + + + QLineEdit::PasswordEchoOnEdit + + + Password + + + + + + +