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

from PyQt5 import QtCore, QtGui, QtWidgets
from socket import AF_INET, socket, SOCK_STREAM
from threading import Thread
import sys

class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(413, 694)
        Form.setWindowIcon(QtGui.QIcon('sndbtn2.png'))
        Form.setStyleSheet("*{\n"
"   background:#dfe3ee;\n"
"}")
        self.tabWidget = QtWidgets.QTabWidget(Form)
        self.tabWidget.setGeometry(QtCore.QRect(0, 0, 421, 701))
        font = QtGui.QFont()
        font.setFamily("HoloLens MDL2 Assets")
        font.setPointSize(10)
        font.setBold(False)
        font.setWeight(50)
        self.tabWidget.setFont(font)
        self.tabWidget.setStyleSheet("*{\n"
"   background:#8b9dc3;\n"
"}\n"
"\n"
"\n"
"QLineEdit\n"
"{\n"
"background: #dfe3ee;\n"
"border-radius:10px;\n"
"}\n"
"\n"
"QPushButton\n"
"{\n"
"background: #3b5998;\n"
"border-radius:15px;\n"
"}\n"
"\n"
"QListWidget\n"
"{\n"
"background: #dfe3ee;\n"
"border-radius:15px;\n"
"}\n"
"")
        self.tabWidget.setLocale(QtCore.QLocale(QtCore.QLocale.Turkish, QtCore.QLocale.Turkey))
        self.tabWidget.setObjectName("tabWidget")
        self.tab = QtWidgets.QWidget()
        self.tab.setObjectName("tab")
        self.label = QtWidgets.QLabel(self.tab)
        self.label.setGeometry(QtCore.QRect(10, 50, 81, 21))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(self.tab)
        self.label_2.setGeometry(QtCore.QRect(20, 80, 71, 21))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.lineEdit = QtWidgets.QLineEdit(self.tab)
        self.lineEdit.setGeometry(QtCore.QRect(90, 50, 141, 21))
        self.lineEdit.setObjectName("lineEdit")
        self.lineEdit_2 = QtWidgets.QLineEdit(self.tab)
        self.lineEdit_2.setGeometry(QtCore.QRect(90, 140, 141, 21))
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.pushButton = QtWidgets.QPushButton(self.tab)
        self.pushButton.setGeometry(QtCore.QRect(260, 120, 91, 41))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton.setFont(font)
        self.pushButton.setObjectName("pushButton")
        self.pushButton.clicked.connect(self.firstsend)
        self.label_3 = QtWidgets.QLabel(self.tab)
        self.label_3.setGeometry(QtCore.QRect(30, 110, 51, 21))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.label_4 = QtWidgets.QLabel(self.tab)
        self.label_4.setGeometry(QtCore.QRect(40, 140, 51, 20))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.lineEdit_3 = QtWidgets.QLineEdit(self.tab)
        self.lineEdit_3.setGeometry(QtCore.QRect(90, 80, 141, 21))
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.lineEdit_4 = QtWidgets.QLineEdit(self.tab)
        self.lineEdit_4.setGeometry(QtCore.QRect(90, 110, 141, 21))
        self.lineEdit_4.setObjectName("lineEdit_4")
        self.label_5 = QtWidgets.QLabel(self.tab)
        self.label_5.setGeometry(QtCore.QRect(40, 170, 241, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_5.setFont(font)
        self.label_5.setObjectName("label_5")
        self.label_6 = QtWidgets.QLabel(self.tab)
        self.label_6.setGeometry(QtCore.QRect(40, 290, 47, 21))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.label_6.setFont(font)
        self.label_6.setObjectName("label_6")
        self.label_7 = QtWidgets.QLabel(self.tab)
        self.label_7.setGeometry(QtCore.QRect(40, 320, 47, 21))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.label_7.setFont(font)
        self.label_7.setObjectName("label_7")
        self.label_8 = QtWidgets.QLabel(self.tab)
        self.label_8.setGeometry(QtCore.QRect(20, 350, 61, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_8.setFont(font)
        self.label_8.setObjectName("label_8")
        self.lineEdit_5 = QtWidgets.QLineEdit(self.tab)
        self.lineEdit_5.setGeometry(QtCore.QRect(100, 350, 141, 21))
        self.lineEdit_5.setObjectName("lineEdit_5")
        self.lineEdit_6 = QtWidgets.QLineEdit(self.tab)
        self.lineEdit_6.setGeometry(QtCore.QRect(100, 290, 141, 21))
        self.lineEdit_6.setObjectName("lineEdit_6")
        self.lineEdit_7 = QtWidgets.QLineEdit(self.tab)
        self.lineEdit_7.setGeometry(QtCore.QRect(100, 320, 141, 21))
        self.lineEdit_7.setObjectName("lineEdit_7")
        self.pushButton_2 = QtWidgets.QPushButton(self.tab)
        self.pushButton_2.setGeometry(QtCore.QRect(270, 330, 81, 41))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_2.setFont(font)
        self.pushButton_2.setObjectName("pushButton_2")
        self.label_9 = QtWidgets.QLabel(self.tab)
        self.label_9.setGeometry(QtCore.QRect(30, 380, 311, 31))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_9.setFont(font)
        self.label_9.setObjectName("label_9")
        self.label_10 = QtWidgets.QLabel(self.tab)
        self.label_10.setGeometry(QtCore.QRect(120, 260, 101, 21))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_10.setFont(font)
        self.label_10.setObjectName("label_10")
        self.label_11 = QtWidgets.QLabel(self.tab)
        self.label_11.setGeometry(QtCore.QRect(30, 400, 101, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_11.setFont(font)
        self.label_11.setObjectName("label_11")
        self.label_12 = QtWidgets.QLabel(self.tab)
        self.label_12.setGeometry(QtCore.QRect(10, 500, 171, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.label_12.setFont(font)
        self.label_12.setObjectName("label_12")
        self.label_13 = QtWidgets.QLabel(self.tab)
        self.label_13.setGeometry(QtCore.QRect(10, 520, 341, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_13.setFont(font)
        self.label_13.setObjectName("label_13")
        self.label_14 = QtWidgets.QLabel(self.tab)
        self.label_14.setGeometry(QtCore.QRect(10, 540, 341, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_14.setFont(font)
        self.label_14.setObjectName("label_14")
        self.label_15 = QtWidgets.QLabel(self.tab)
        self.label_15.setGeometry(QtCore.QRect(10, 560, 361, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_15.setFont(font)
        self.label_15.setObjectName("label_15")
        self.label_16 = QtWidgets.QLabel(self.tab)
        self.label_16.setGeometry(QtCore.QRect(10, 580, 351, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_16.setFont(font)
        self.label_16.setObjectName("label_16")
        self.label_17 = QtWidgets.QLabel(self.tab)
        self.label_17.setGeometry(QtCore.QRect(10, 587, 161, 31))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_17.setFont(font)
        self.label_17.setObjectName("label_17")
        self.label_20 = QtWidgets.QLabel(self.tab)
        self.label_20.setGeometry(QtCore.QRect(10, 620, 381, 31))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_20.setFont(font)
        self.label_20.setObjectName("label_20")
        self.label_20.raise_()
        self.label_17.raise_()
        self.label.raise_()
        self.label_2.raise_()
        self.lineEdit.raise_()
        self.lineEdit_2.raise_()
        self.pushButton.raise_()
        self.label_3.raise_()
        self.label_4.raise_()
        self.lineEdit_3.raise_()
        self.lineEdit_4.raise_()
        self.label_5.raise_()
        self.label_6.raise_()
        self.label_7.raise_()
        self.label_8.raise_()
        self.lineEdit_5.raise_()
        self.lineEdit_6.raise_()
        self.lineEdit_7.raise_()
        self.pushButton_2.raise_()
        self.label_9.raise_()
        self.label_10.raise_()
        self.label_11.raise_()
        self.label_12.raise_()
        self.label_13.raise_()
        self.label_14.raise_()
        self.label_15.raise_()
        self.label_16.raise_()
        self.tabWidget.addTab(self.tab, "")
        self.tab_2 = QtWidgets.QWidget()
        self.tab_2.setObjectName("tab_2")
        self.listWidget = QtWidgets.QListWidget(self.tab_2)
        self.listWidget.setGeometry(QtCore.QRect(10, 10, 281, 611))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.listWidget.setFont(font)
        self.listWidget.setObjectName("listWidget")
        self.lineEdit_8 = QtWidgets.QLineEdit(self.tab_2)
        self.lineEdit_8.setGeometry(QtCore.QRect(50, 630, 351, 31))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.lineEdit_8.setFont(font)
        self.lineEdit_8.setObjectName("lineEdit_8")
        self.lineEdit_8.returnPressed.connect(self.send)
        self.pushButton_3 = QtWidgets.QPushButton(self.tab_2)
        self.pushButton_3.setGeometry(QtCore.QRect(10, 630, 31, 31))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_3.setFont(font)
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton_3.clicked.connect(self.send)
        self.listWidget_2 = QtWidgets.QListWidget(self.tab_2)
        self.listWidget_2.setGeometry(QtCore.QRect(300, 30, 101, 281))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.listWidget_2.setFont(font)
        self.listWidget_2.setObjectName("listWidget_2")
        self.listWidget_3 = QtWidgets.QListWidget(self.tab_2)
        self.listWidget_3.setGeometry(QtCore.QRect(300, 320, 101, 281))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.listWidget_3.setFont(font)
        self.listWidget_3.setObjectName("listWidget_3")
        self.label_18 = QtWidgets.QLabel(self.tab_2)
        self.label_18.setGeometry(QtCore.QRect(320, 599, 61, 31))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.label_18.setFont(font)
        self.label_18.setObjectName("label_18")
        self.label_19 = QtWidgets.QLabel(self.tab_2)
        self.label_19.setGeometry(QtCore.QRect(320, 10, 71, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.label_19.setFont(font)
        self.label_19.setObjectName("label_19")
        self.label_18.raise_()
        self.listWidget.raise_()
        self.lineEdit_8.raise_()
        self.pushButton_3.raise_()
        self.listWidget_2.raise_()
        self.listWidget_3.raise_()
        self.label_19.raise_()
        self.tabWidget.addTab(self.tab_2, "")

        self.retranslateUi(Form)
        self.tabWidget.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(Form)

        HOST= "127.0.0.1"
        PORT= 25565
        self.BUFSIZ = 2048
        ADDR = (HOST, PORT)
        self.client_socket = socket(AF_INET, SOCK_STREAM)
        self.client_socket.connect(ADDR)
        client_socket = self.client_socket

        receive_thread = Thread(target=self.receive)
        receive_thread.start()

    def firstsend(self):
        self.firstmsg = self.lineEdit.text()
        self.client_socket.send(bytes(self.firstmsg, "utf8"))
        self.lineEdit.setText("")
        self.lineEdit_3.setText("")
        self.tabWidget.setCurrentIndex(1)


    def receive(self):
        self.roommsg = self.client_socket.recv(self.BUFSIZ).decode("utf8")
        self.listWidget_3.addItem(self.roommsg)
        self.usernamemsg = self.client_socket.recv(self.BUFSIZ).decode("utf8")
        self.listWidget_2.addItem(self.usernamemsg)
        while True:
            try:
                self.msg = self.client_socket.recv(self.BUFSIZ).decode("utf8")
                if self.msg == "Sunucuda yeni arkadaşlar var!":
                    self.usernamemsg = self.client_socket.recv(self.BUFSIZ).decode("utf8")
                    self.listWidget_2.clear()
                    self.listWidget_2.addItem(self.usernamemsg)
                self.msgneew = self.msg
                b = 41
                z = 0
                a = len(self.msg)
                t = int(round(a/41))
                if t >1:
                    for _ in range(t+1):
                        self.msgnew= self.msg[z:b]
                        self.listWidget.addItem(self.msgnew)
                        z = b
                        b += 41
                else:
                    self.listWidget.addItem(self.msgneew)
            
            except OSError:
                break
    
    def send(self):
        self.msg = self.lineEdit_8.text()
        self.lineEdit_8.setText("")
        if self.msg == "{quit}":
            self.client_socket.close()

        else:
            self.client_socket.send(bytes(self.msg, "utf8"))

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "MSAGE Windows App 'beta'"))
        self.label.setText(_translate("Form", "Ad Soyad *"))
        self.label_2.setText(_translate("Form", "E-Posta *"))
        self.pushButton.setText(_translate("Form", "MSAGE\'le"))
        self.label_3.setText(_translate("Form", "Website"))
        self.label_4.setText(_translate("Form", "Meslek"))
        self.label_5.setText(_translate("Form", "* İşaretli alanların girilmesi zorunludur."))
        self.label_6.setText(_translate("Form", "HOST:"))
        self.label_7.setText(_translate("Form", "PORT:"))
        self.label_8.setText(_translate("Form", "Ad Soyad"))
        self.pushButton_2.setText(_translate("Form", "GİR"))
        self.label_9.setText(_translate("Form", "Kendinize ait sunucunuza yukarıda bilgileri girerek"))
        self.label_10.setText(_translate("Form", "GELİŞMİŞ GİRİŞ"))
        self.label_11.setText(_translate("Form", "bağlanabilirsiniz."))
        self.label_12.setText(_translate("Form", "UYGULAMA HAKKINDA"))
        self.label_13.setText(_translate("Form", "MSAGE açık kaynak kodlu bir mesajlaşma uygulamasıdır."))
        self.label_14.setText(_translate("Form", "Tüm hakları MIT lisansı ile lisanlanmıştır."))
        self.label_15.setText(_translate("Form", "Kullanıcı verileri kötü amaçla kullanılmayacaktır."))
        self.label_16.setText(_translate("Form", "Özel olarak açılan sunucularda yaptığınız hareketlerden"))
        self.label_17.setText(_translate("Form", "MSAGE sorumlu değildir."))
        self.label_20.setText(_translate("Form", "Yeni versiyonlar için takip etmeyi unutmayın. Powered by BEE"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("Form", "Giriş Yap"))
        self.pushButton_3.setText(_translate("Form", "<"))
        self.label_18.setText(_translate("Form", "ANAODA"))
        self.label_19.setText(_translate("Form", "ÇEVRİM İÇİ"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("Form", "MSAGE"))

        
if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Form = QtWidgets.QWidget()
    ui = Ui_Form()
    ui.setupUi(Form)
    Form.show()
    try:
        sys.exit(app.exec_())
    except SystemExit:
        ui.client_socket.send("**quit".encode("utf8"))


            

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

from PyQt5 import QtCore, QtGui, QtWidgets
from socket import AF_INET, socket, SOCK_STREAM
from threading import Thread
import sys

class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(413, 694)
        Form.setWindowIcon(QtGui.QIcon('sndbtn2.png'))
        Form.setStyleSheet("*{\n"
"   background:#dfe3ee;\n"
"}")
        self.tabWidget = QtWidgets.QTabWidget(Form)
        self.tabWidget.setGeometry(QtCore.QRect(0, 0, 421, 701))
        font = QtGui.QFont()
        font.setFamily("HoloLens MDL2 Assets")
        font.setPointSize(10)
        font.setBold(False)
        font.setWeight(50)
        self.tabWidget.setFont(font)
        self.tabWidget.setStyleSheet("*{\n"
"   background:#8b9dc3;\n"
"}\n"
"\n"
"\n"
"QLineEdit\n"
"{\n"
"background: #dfe3ee;\n"
"border-radius:10px;\n"
"}\n"
"\n"
"QPushButton\n"
"{\n"
"background: #3b5998;\n"
"border-radius:15px;\n"
"}\n"
"\n"
"QListWidget\n"
"{\n"
"background: #dfe3ee;\n"
"border-radius:15px;\n"
"}\n"
"")
        self.tabWidget.setLocale(QtCore.QLocale(QtCore.QLocale.Turkish, QtCore.QLocale.Turkey))
        self.tabWidget.setObjectName("tabWidget")
        self.tab = QtWidgets.QWidget()
        self.tab.setObjectName("tab")
        self.label = QtWidgets.QLabel(self.tab)
        self.label.setGeometry(QtCore.QRect(10, 50, 81, 21))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(self.tab)
        self.label_2.setGeometry(QtCore.QRect(20, 80, 71, 21))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.label_2.setFont(font)
        self.label_2.setObjectName("label_2")
        self.lineEdit = QtWidgets.QLineEdit(self.tab)
        self.lineEdit.setGeometry(QtCore.QRect(90, 50, 141, 21))
        self.lineEdit.setObjectName("lineEdit")
        self.lineEdit_2 = QtWidgets.QLineEdit(self.tab)
        self.lineEdit_2.setGeometry(QtCore.QRect(90, 140, 141, 21))
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.pushButton = QtWidgets.QPushButton(self.tab)
        self.pushButton.setGeometry(QtCore.QRect(260, 120, 91, 41))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton.setFont(font)
        self.pushButton.setObjectName("pushButton")
        self.pushButton.clicked.connect(self.firstsend)
        self.label_3 = QtWidgets.QLabel(self.tab)
        self.label_3.setGeometry(QtCore.QRect(30, 110, 51, 21))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_3.setFont(font)
        self.label_3.setObjectName("label_3")
        self.label_4 = QtWidgets.QLabel(self.tab)
        self.label_4.setGeometry(QtCore.QRect(40, 140, 51, 20))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_4.setFont(font)
        self.label_4.setObjectName("label_4")
        self.lineEdit_3 = QtWidgets.QLineEdit(self.tab)
        self.lineEdit_3.setGeometry(QtCore.QRect(90, 80, 141, 21))
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.lineEdit_4 = QtWidgets.QLineEdit(self.tab)
        self.lineEdit_4.setGeometry(QtCore.QRect(90, 110, 141, 21))
        self.lineEdit_4.setObjectName("lineEdit_4")
        self.label_5 = QtWidgets.QLabel(self.tab)
        self.label_5.setGeometry(QtCore.QRect(40, 170, 241, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_5.setFont(font)
        self.label_5.setObjectName("label_5")
        self.label_6 = QtWidgets.QLabel(self.tab)
        self.label_6.setGeometry(QtCore.QRect(40, 290, 47, 21))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.label_6.setFont(font)
        self.label_6.setObjectName("label_6")
        self.label_7 = QtWidgets.QLabel(self.tab)
        self.label_7.setGeometry(QtCore.QRect(40, 320, 47, 21))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.label_7.setFont(font)
        self.label_7.setObjectName("label_7")
        self.label_8 = QtWidgets.QLabel(self.tab)
        self.label_8.setGeometry(QtCore.QRect(20, 350, 61, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_8.setFont(font)
        self.label_8.setObjectName("label_8")
        self.lineEdit_5 = QtWidgets.QLineEdit(self.tab)
        self.lineEdit_5.setGeometry(QtCore.QRect(100, 350, 141, 21))
        self.lineEdit_5.setObjectName("lineEdit_5")
        self.lineEdit_6 = QtWidgets.QLineEdit(self.tab)
        self.lineEdit_6.setGeometry(QtCore.QRect(100, 290, 141, 21))
        self.lineEdit_6.setObjectName("lineEdit_6")
        self.lineEdit_7 = QtWidgets.QLineEdit(self.tab)
        self.lineEdit_7.setGeometry(QtCore.QRect(100, 320, 141, 21))
        self.lineEdit_7.setObjectName("lineEdit_7")
        self.pushButton_2 = QtWidgets.QPushButton(self.tab)
        self.pushButton_2.setGeometry(QtCore.QRect(270, 330, 81, 41))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_2.setFont(font)
        self.pushButton_2.setObjectName("pushButton_2")
        self.label_9 = QtWidgets.QLabel(self.tab)
        self.label_9.setGeometry(QtCore.QRect(30, 380, 311, 31))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_9.setFont(font)
        self.label_9.setObjectName("label_9")
        self.label_10 = QtWidgets.QLabel(self.tab)
        self.label_10.setGeometry(QtCore.QRect(120, 260, 101, 21))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_10.setFont(font)
        self.label_10.setObjectName("label_10")
        self.label_11 = QtWidgets.QLabel(self.tab)
        self.label_11.setGeometry(QtCore.QRect(30, 400, 101, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_11.setFont(font)
        self.label_11.setObjectName("label_11")
        self.label_12 = QtWidgets.QLabel(self.tab)
        self.label_12.setGeometry(QtCore.QRect(10, 500, 171, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(11)
        font.setBold(True)
        font.setWeight(75)
        self.label_12.setFont(font)
        self.label_12.setObjectName("label_12")
        self.label_13 = QtWidgets.QLabel(self.tab)
        self.label_13.setGeometry(QtCore.QRect(10, 520, 341, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_13.setFont(font)
        self.label_13.setObjectName("label_13")
        self.label_14 = QtWidgets.QLabel(self.tab)
        self.label_14.setGeometry(QtCore.QRect(10, 540, 341, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_14.setFont(font)
        self.label_14.setObjectName("label_14")
        self.label_15 = QtWidgets.QLabel(self.tab)
        self.label_15.setGeometry(QtCore.QRect(10, 560, 361, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_15.setFont(font)
        self.label_15.setObjectName("label_15")
        self.label_16 = QtWidgets.QLabel(self.tab)
        self.label_16.setGeometry(QtCore.QRect(10, 580, 351, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_16.setFont(font)
        self.label_16.setObjectName("label_16")
        self.label_17 = QtWidgets.QLabel(self.tab)
        self.label_17.setGeometry(QtCore.QRect(10, 587, 161, 31))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_17.setFont(font)
        self.label_17.setObjectName("label_17")
        self.label_20 = QtWidgets.QLabel(self.tab)
        self.label_20.setGeometry(QtCore.QRect(10, 620, 381, 31))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.label_20.setFont(font)
        self.label_20.setObjectName("label_20")
        self.label_20.raise_()
        self.label_17.raise_()
        self.label.raise_()
        self.label_2.raise_()
        self.lineEdit.raise_()
        self.lineEdit_2.raise_()
        self.pushButton.raise_()
        self.label_3.raise_()
        self.label_4.raise_()
        self.lineEdit_3.raise_()
        self.lineEdit_4.raise_()
        self.label_5.raise_()
        self.label_6.raise_()
        self.label_7.raise_()
        self.label_8.raise_()
        self.lineEdit_5.raise_()
        self.lineEdit_6.raise_()
        self.lineEdit_7.raise_()
        self.pushButton_2.raise_()
        self.label_9.raise_()
        self.label_10.raise_()
        self.label_11.raise_()
        self.label_12.raise_()
        self.label_13.raise_()
        self.label_14.raise_()
        self.label_15.raise_()
        self.label_16.raise_()
        self.tabWidget.addTab(self.tab, "")
        self.tab_2 = QtWidgets.QWidget()
        self.tab_2.setObjectName("tab_2")
        self.listWidget = QtWidgets.QListWidget(self.tab_2)
        self.listWidget.setGeometry(QtCore.QRect(10, 10, 281, 611))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.listWidget.setFont(font)
        self.listWidget.setObjectName("listWidget")
        self.lineEdit_8 = QtWidgets.QLineEdit(self.tab_2)
        self.lineEdit_8.setGeometry(QtCore.QRect(50, 630, 351, 31))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.lineEdit_8.setFont(font)
        self.lineEdit_8.setObjectName("lineEdit_8")
        self.lineEdit_8.returnPressed.connect(self.send)
        self.pushButton_3 = QtWidgets.QPushButton(self.tab_2)
        self.pushButton_3.setGeometry(QtCore.QRect(10, 630, 31, 31))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.pushButton_3.setFont(font)
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton_3.clicked.connect(self.send)
        self.listWidget_2 = QtWidgets.QListWidget(self.tab_2)
        self.listWidget_2.setGeometry(QtCore.QRect(300, 30, 101, 281))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.listWidget_2.setFont(font)
        self.listWidget_2.setObjectName("listWidget_2")
        self.listWidget_3 = QtWidgets.QListWidget(self.tab_2)
        self.listWidget_3.setGeometry(QtCore.QRect(300, 320, 101, 281))
        font = QtGui.QFont()
        font.setFamily("Raleway SemiBold")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.listWidget_3.setFont(font)
        self.listWidget_3.setObjectName("listWidget_3")
        self.label_18 = QtWidgets.QLabel(self.tab_2)
        self.label_18.setGeometry(QtCore.QRect(320, 599, 61, 31))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.label_18.setFont(font)
        self.label_18.setObjectName("label_18")
        self.label_19 = QtWidgets.QLabel(self.tab_2)
        self.label_19.setGeometry(QtCore.QRect(320, 10, 71, 16))
        font = QtGui.QFont()
        font.setFamily("Raleway ExtraBold")
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.label_19.setFont(font)
        self.label_19.setObjectName("label_19")
        self.label_18.raise_()
        self.listWidget.raise_()
        self.lineEdit_8.raise_()
        self.pushButton_3.raise_()
        self.listWidget_2.raise_()
        self.listWidget_3.raise_()
        self.label_19.raise_()
        self.tabWidget.addTab(self.tab_2, "")

        self.retranslateUi(Form)
        self.tabWidget.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(Form)

        HOST= "127.0.0.1"
        PORT= 25565
        self.BUFSIZ = 2048
        ADDR = (HOST, PORT)
        self.client_socket = socket(AF_INET, SOCK_STREAM)
        self.client_socket.connect(ADDR)
        client_socket = self.client_socket

        receive_thread = Thread(target=self.receive)
        receive_thread.start()

    def firstsend(self):
        self.firstmsg = self.lineEdit.text()
        self.client_socket.send(bytes(self.firstmsg, "utf8"))
        self.lineEdit.setText("")
        self.lineEdit_3.setText("")
        self.tabWidget.setCurrentIndex(1)


    def receive(self):
        self.roommsg = self.client_socket.recv(self.BUFSIZ).decode("utf8")
        self.listWidget_3.addItem(self.roommsg)
        self.usernamemsg = self.client_socket.recv(self.BUFSIZ).decode("utf8")
        self.listWidget_2.addItem(self.usernamemsg)
        while True:
            try:
                self.msg = self.client_socket.recv(self.BUFSIZ).decode("utf8")
                if self.msg == "Sunucuda yeni arkadaşlar var!":
                    self.usernamemsg = self.client_socket.recv(self.BUFSIZ).decode("utf8")
                    self.listWidget_2.clear()
                    self.listWidget_2.addItem(self.usernamemsg)
                self.msgneew = self.msg
                b = 41
                z = 0
                a = len(self.msg)
                t = int(round(a/41))
                if t >1:
                    for _ in range(t+1):
                        self.msgnew= self.msg[z:b]
                        self.listWidget.addItem(self.msgnew)
                        z = b
                        b += 41
                else:
                    self.listWidget.addItem(self.msgneew)
            
            except OSError:
                break
    
    def send(self):
        self.msg = self.lineEdit_8.text()
        self.lineEdit_8.setText("")
        if self.msg == "{quit}":
            self.client_socket.close()

        else:
            self.client_socket.send(bytes(self.msg, "utf8"))

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "MSAGE Windows App 'beta'"))
        self.label.setText(_translate("Form", "Ad Soyad *"))
        self.label_2.setText(_translate("Form", "E-Posta *"))
        self.pushButton.setText(_translate("Form", "MSAGE\'le"))
        self.label_3.setText(_translate("Form", "Website"))
        self.label_4.setText(_translate("Form", "Meslek"))
        self.label_5.setText(_translate("Form", "* İşaretli alanların girilmesi zorunludur."))
        self.label_6.setText(_translate("Form", "HOST:"))
        self.label_7.setText(_translate("Form", "PORT:"))
        self.label_8.setText(_translate("Form", "Ad Soyad"))
        self.pushButton_2.setText(_translate("Form", "GİR"))
        self.label_9.setText(_translate("Form", "Kendinize ait sunucunuza yukarıda bilgileri girerek"))
        self.label_10.setText(_translate("Form", "GELİŞMİŞ GİRİŞ"))
        self.label_11.setText(_translate("Form", "bağlanabilirsiniz."))
        self.label_12.setText(_translate("Form", "UYGULAMA HAKKINDA"))
        self.label_13.setText(_translate("Form", "MSAGE açık kaynak kodlu bir mesajlaşma uygulamasıdır."))
        self.label_14.setText(_translate("Form", "Tüm hakları MIT lisansı ile lisanlanmıştır."))
        self.label_15.setText(_translate("Form", "Kullanıcı verileri kötü amaçla kullanılmayacaktır."))
        self.label_16.setText(_translate("Form", "Özel olarak açılan sunucularda yaptığınız hareketlerden"))
        self.label_17.setText(_translate("Form", "MSAGE sorumlu değildir."))
        self.label_20.setText(_translate("Form", "Yeni versiyonlar için takip etmeyi unutmayın. Powered by BEE"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("Form", "Giriş Yap"))
        self.pushButton_3.setText(_translate("Form", "<"))
        self.label_18.setText(_translate("Form", "ANAODA"))
        self.label_19.setText(_translate("Form", "ÇEVRİM İÇİ"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("Form", "MSAGE"))

        
if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Form = QtWidgets.QWidget()
    ui = Ui_Form()
    ui.setupUi(Form)
    Form.show()
    try:
        sys.exit(app.exec_())
    except SystemExit:
        ui.client_socket.send("**quit".encode("utf8"))


            

# -*- coding: utf-8 -*- #dfe3ee;\n" #8b9dc3;\n" #dfe3ee;\n" #3b5998;\n" #dfe3ee;\n"