<reponame>the-gamecoders/TheGameHub<filename>src/signup.py
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'signup.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# 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
from PyQt5.QtWidgets import QMessageBox
import sqlite3
conn=sqlite3.connect('TheGameHub.db')
curs=conn.cursor()

class Ui_Dialog2(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(295, 275)
        Dialog.setStyleSheet("background-color: rgb(225, 255, 208);")
        self.formLayout = QtWidgets.QFormLayout(Dialog)
        self.formLayout.setContentsMargins(30, 30, 30, -1)
        self.formLayout.setHorizontalSpacing(20)
        self.formLayout.setVerticalSpacing(36)
        self.formLayout.setObjectName("formLayout")
        self.label_3 = QtWidgets.QLabel(Dialog)
        font = QtGui.QFont()
        font.setFamily("Comic Sans MS")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.label_3.setFont(font)
        self.label_3.setAlignment(QtCore.Qt.AlignCenter)
        self.label_3.setObjectName("label_3")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.SpanningRole, self.label_3)
        self.label = QtWidgets.QLabel(Dialog)
        font = QtGui.QFont()
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label)
        self.uname_line = QtWidgets.QLineEdit(Dialog)
        self.uname_line.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.uname_line.setText("")
        self.uname_line.setObjectName("uname_line")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.uname_line)
        self.label_2 = QtWidgets.QLabel(Dialog)
        font = QtGui.QFont()
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_2)
        self.password_line = QtWidgets.QLineEdit(Dialog)
        self.password_line.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.password_line.setText("")
        self.password_line.setEchoMode(QtWidgets.QLineEdit.Password)
        self.password_line.setObjectName("password_line")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.password_line)
        self.signup = QtWidgets.QPushButton(Dialog)
        font = QtGui.QFont()
        font.setPointSize(9)
        self.signup.setFont(font)
        self.signup.setStyleSheet("background-color: rgb(197, 198, 255);")
        self.signup.setObjectName("signup")
        self.formLayout.setWidget(3, QtWidgets.QFormLayout.SpanningRole, self.signup)

        self.signup.clicked.connect(self.insertData)
        
        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
        

    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "Sign Up"))
        self.label_3.setText(_translate("Dialog", "CREATE ACCOUNT"))
        self.label.setText(_translate("Dialog", "username:"))
        self.label_2.setText(_translate("Dialog", "password:"))
        self.signup.setText(_translate("Dialog", "sign up"))

    def insertData(self):
        username = self.uname_line.text()
        password = self.password_line.text()
        curs.execute('SELECT Username from Users;')
        users = curs.fetchall()
        user_list = []
        for i in users:
            for Name in i:
                user_list.append(Name)
        if username in user_list or len(username) == 0 or len(password) == 0:
            if username in user_list:
                msg = QMessageBox()
                msg.setWindowTitle("Warning")
                msg.setText("Username already taken!")
                msg.setIcon(QMessageBox.Warning)
                x=msg.exec()
                self.uname_line.setText("")
                self.password_line.setText("")
            if len(username) == 0 and len(password) == 0: 
                msg = QMessageBox()
                msg.setWindowTitle("Warning")
                msg.setText("please enter a username and password.")
                msg.setIcon(QMessageBox.Warning)
                x=msg.exec()
            elif len(username) == 0: 
                msg = QMessageBox()
                msg.setWindowTitle("Warning")
                msg.setText("please enter a username.")
                msg.setIcon(QMessageBox.Warning)
                x=msg.exec()
            elif len(password) == 0:
                msg = QMessageBox()
                msg.setWindowTitle("Warning")
                msg.setText("please enter password.")
                msg.setIcon(QMessageBox.Warning)
                x=msg.exec()
        else:
            curs.execute("INSERT INTO Users VALUES(?,?);",(username,password))
            conn.commit()
            msg1 = QMessageBox()
            msg1.setWindowTitle("Sign Up")
            msg1.setText('''Registered successfully.
Now you can Login!''')
            msg1.setIcon(QMessageBox.Information)
            x=msg1.exec()

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Dialog = QtWidgets.QDialog()
    ui = Ui_Dialog2()
    ui.setupUi(Dialog)
    Dialog.show()
    sys.exit(app.exec_())

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'signup.ui'
#
# Created by: PyQt5 UI code generator 5.15.1
#
# 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
from PyQt5.QtWidgets import QMessageBox
import sqlite3
conn=sqlite3.connect('TheGameHub.db')
curs=conn.cursor()

class Ui_Dialog2(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(295, 275)
        Dialog.setStyleSheet("background-color: rgb(225, 255, 208);")
        self.formLayout = QtWidgets.QFormLayout(Dialog)
        self.formLayout.setContentsMargins(30, 30, 30, -1)
        self.formLayout.setHorizontalSpacing(20)
        self.formLayout.setVerticalSpacing(36)
        self.formLayout.setObjectName("formLayout")
        self.label_3 = QtWidgets.QLabel(Dialog)
        font = QtGui.QFont()
        font.setFamily("Comic Sans MS")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.label_3.setFont(font)
        self.label_3.setAlignment(QtCore.Qt.AlignCenter)
        self.label_3.setObjectName("label_3")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.SpanningRole, self.label_3)
        self.label = QtWidgets.QLabel(Dialog)
        font = QtGui.QFont()
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label)
        self.uname_line = QtWidgets.QLineEdit(Dialog)
        self.uname_line.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.uname_line.setText("")
        self.uname_line.setObjectName("uname_line")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.uname_line)
        self.label_2 = QtWidgets.QLabel(Dialog)
        font = QtGui.QFont()
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label_2)
        self.password_line = QtWidgets.QLineEdit(Dialog)
        self.password_line.setStyleSheet("background-color: rgb(255, 255, 255);")
        self.password_line.setText("")
        self.password_line.setEchoMode(QtWidgets.QLineEdit.Password)
        self.password_line.setObjectName("password_line")
        self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.password_line)
        self.signup = QtWidgets.QPushButton(Dialog)
        font = QtGui.QFont()
        font.setPointSize(9)
        self.signup.setFont(font)
        self.signup.setStyleSheet("background-color: rgb(197, 198, 255);")
        self.signup.setObjectName("signup")
        self.formLayout.setWidget(3, QtWidgets.QFormLayout.SpanningRole, self.signup)

        self.signup.clicked.connect(self.insertData)
        
        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
        

    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "Sign Up"))
        self.label_3.setText(_translate("Dialog", "CREATE ACCOUNT"))
        self.label.setText(_translate("Dialog", "username:"))
        self.label_2.setText(_translate("Dialog", "password:"))
        self.signup.setText(_translate("Dialog", "sign up"))

    def insertData(self):
        username = self.uname_line.text()
        password = self.password_line.text()
        curs.execute('SELECT Username from Users;')
        users = curs.fetchall()
        user_list = []
        for i in users:
            for Name in i:
                user_list.append(Name)
        if username in user_list or len(username) == 0 or len(password) == 0:
            if username in user_list:
                msg = QMessageBox()
                msg.setWindowTitle("Warning")
                msg.setText("Username already taken!")
                msg.setIcon(QMessageBox.Warning)
                x=msg.exec()
                self.uname_line.setText("")
                self.password_line.setText("")
            if len(username) == 0 and len(password) == 0: 
                msg = QMessageBox()
                msg.setWindowTitle("Warning")
                msg.setText("please enter a username and password.")
                msg.setIcon(QMessageBox.Warning)
                x=msg.exec()
            elif len(username) == 0: 
                msg = QMessageBox()
                msg.setWindowTitle("Warning")
                msg.setText("please enter a username.")
                msg.setIcon(QMessageBox.Warning)
                x=msg.exec()
            elif len(password) == 0:
                msg = QMessageBox()
                msg.setWindowTitle("Warning")
                msg.setText("please enter password.")
                msg.setIcon(QMessageBox.Warning)
                x=msg.exec()
        else:
            curs.execute("INSERT INTO Users VALUES(?,?);",(username,password))
            conn.commit()
            msg1 = QMessageBox()
            msg1.setWindowTitle("Sign Up")
            msg1.setText('''Registered successfully.
Now you can Login!''')
            msg1.setIcon(QMessageBox.Information)
            x=msg1.exec()

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Dialog = QtWidgets.QDialog()
    ui = Ui_Dialog2()
    ui.setupUi(Dialog)
    Dialog.show()
    sys.exit(app.exec_())
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'signup.ui' # # Created by: PyQt5 UI code generator 5.15.1 # # 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. Registered successfully.
 Now you can Login!