GUI development
This commit is contained in:
@@ -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():
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user