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

# Form implementation generated from reading ui file 'InsertTopic.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# 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 Barangnya import Topic
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QMessageBox


class Ui_InsertTopic(object):
    def setupUi(self, InsertTopic):
        InsertTopic.setObjectName("InsertTopic")
        InsertTopic.resize(800, 600)
        InsertTopic.setStyleSheet("background-color: rgb(255, 235, 235);")
        self.centralwidget = QtWidgets.QWidget(InsertTopic)
        self.centralwidget.setObjectName("centralwidget")
        self.groupBox = QtWidgets.QGroupBox(self.centralwidget)
        self.groupBox.setGeometry(QtCore.QRect(60, 80, 681, 441))
        self.groupBox.setStyleSheet("background-color: rgb(0, 255, 127);")
        self.groupBox.setTitle("")
        self.groupBox.setObjectName("groupBox")
        self.label = QtWidgets.QLabel(self.groupBox)
        self.label.setGeometry(QtCore.QRect(130, 20, 421, 71))
        font = QtGui.QFont()
        font.setFamily("Adobe Gothic Std B")
        font.setPointSize(26)
        font.setBold(True)
        font.setWeight(75)
        self.label.setFont(font)
        self.label.setAlignment(QtCore.Qt.AlignCenter)
        self.label.setObjectName("label")
        self.BackIcon = QtWidgets.QLabel(self.groupBox)
        self.BackIcon.setGeometry(QtCore.QRect(10, 10, 31, 31))
        self.BackIcon.setText("")
        self.BackIcon.setPixmap(QtGui.QPixmap("TubesPBO/icon/BackIcon.png"))
        self.BackIcon.setScaledContents(True)
        self.BackIcon.setObjectName("BackIcon")
        self.BackButton = QtWidgets.QPushButton(self.groupBox)
        self.BackButton.setGeometry(QtCore.QRect(10, 10, 31, 31))
        font = QtGui.QFont()
        font.setKerning(False)
        self.BackButton.setFont(font)
        self.BackButton.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
        self.BackButton.setMouseTracking(False)
        self.BackButton.setAutoFillBackground(False)
        self.BackButton.setStyleSheet("color: rgb(170, 255, 255);\n"
"background-color: transparent;\n"
"")
        self.BackButton.setText("")
        self.BackButton.setObjectName("BackButton")
        self.frame = QtWidgets.QFrame(self.groupBox)
        self.frame.setGeometry(QtCore.QRect(60, 120, 561, 241))
        self.frame.setStyleSheet("background-color: rgb(240, 240, 240);")
        self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame.setObjectName("frame")
        self.formLayoutWidget = QtWidgets.QWidget(self.frame)
        self.formLayoutWidget.setGeometry(QtCore.QRect(20, 50, 521, 111))
        self.formLayoutWidget.setObjectName("formLayoutWidget")
        self.formLayout = QtWidgets.QFormLayout(self.formLayoutWidget)
        self.formLayout.setContentsMargins(0, 0, 0, 0)
        self.formLayout.setObjectName("formLayout")
        self.label_4 = QtWidgets.QLabel(self.formLayoutWidget)
        self.label_4.setObjectName("label_4")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.label_4)
        self.Judul = QtWidgets.QLineEdit(self.formLayoutWidget)
        self.Judul.setObjectName("Judul")
        self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.Judul)
        self.label_5 = QtWidgets.QLabel(self.formLayoutWidget)
        self.label_5.setObjectName("label_5")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.label_5)
        self.FolderName = QtWidgets.QLineEdit(self.formLayoutWidget)
        self.FolderName.setText("")
        self.FolderName.setObjectName("FolderName")
        self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.FolderName)
        self.InsertButton = QtWidgets.QPushButton(self.frame)
        self.InsertButton.setGeometry(QtCore.QRect(450, 200, 93, 28))
        self.InsertButton.setObjectName("InsertButton")
        InsertTopic.setCentralWidget(self.centralwidget)

        self.retranslateUi(InsertTopic)
        QtCore.QMetaObject.connectSlotsByName(InsertTopic)

        #code here
        self.InsertButton.pressed.connect(self.Inputin)

    def retranslateUi(self, InsertTopic):
        _translate = QtCore.QCoreApplication.translate
        InsertTopic.setWindowTitle(_translate("InsertTopic", "Insert Topic"))
        self.label.setText(_translate("InsertTopic", "Insert New Topic"))
        self.label_4.setText(_translate("InsertTopic", "Judul Topik"))
        self.Judul.setPlaceholderText(_translate("InsertTopic", "Judul Topik"))
        self.label_5.setText(_translate("InsertTopic", "Nama Folder"))
        self.FolderName.setPlaceholderText(_translate("InsertTopic", "Nama Folder"))
        self.InsertButton.setText(_translate("InsertTopic", "Insert"))

    def Inputin(self):
        Judul = self.Judul.text()
        FName = self.FolderName.text()
        if not(FName and Judul):
            self.show_Popup("Harap Isi Semua Kelengkapan Data")
            return 0
        default = 'C:\ Users\ Username\ Documents\ '+ FName+ '\ '
        default = default.replace(" ",'')
        FName = default+FName+'\ '
        FName = FName[0:-1]
        self.a = Topic(FName, Judul)
        self.a.masukin()

    def show_Popup(self,message):
        msg = QMessageBox()
        msg.setWindowTitle("Message")
        msg.setText(message)
        x = msg.exec_()


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    InsertTopic = QtWidgets.QMainWindow()
    ui = Ui_InsertTopic()
    ui.setupUi(InsertTopic)
    InsertTopic.show()
    sys.exit(app.exec_())
