import sys

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QDialog

from main_window import MainWindow


class FirstWindow(QDialog):
    def __init__(self, main_window):
        self.main_window = main_window
        super().__init__(self.main_window)
        self.main_window.resize(686, 658)
        central_widget = QtWidgets.QWidget(self.main_window)
        widget = QtWidgets.QWidget(central_widget)
        widget.setGeometry(QtCore.QRect(30, 40, 622, 561))
        vertical_layout2 = QtWidgets.QVBoxLayout(widget)
        vertical_layout2.setContentsMargins(0, 0, 0, 0)
        horizontal_layout2 = QtWidgets.QHBoxLayout()
        spacer_item = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        horizontal_layout2.addItem(spacer_item)
        logo_label = QtWidgets.QLabel(widget)
        logo_label.setMaximumSize(QtCore.QSize(300, 300))
        logo_label.setAutoFillBackground(False)
        logo_label.setText("")
        logo_label.setPixmap(QtGui.QPixmap("img/ytu_logo.png"))
        logo_label.setScaledContents(True)
        horizontal_layout2.addWidget(logo_label)
        spacer_item1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        horizontal_layout2.addItem(spacer_item1)
        vertical_layout2.addLayout(horizontal_layout2)
        spacer_item2 = QtWidgets.QSpacerItem(17, 13, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        vertical_layout2.addItem(spacer_item2)
        vertical_layout = QtWidgets.QVBoxLayout()
        course_label = QtWidgets.QLabel(widget)
        font24_bold = QtGui.QFont()
        font24_bold.setPointSize(24)
        font24_bold.setBold(True)
        font24_bold.setWeight(75)
        course_label.setFont(font24_bold)
        course_label.setAlignment(QtCore.Qt.AlignCenter)
        vertical_layout.addWidget(course_label)
        term_label = QtWidgets.QLabel(widget)
        term_label.setFont(font24_bold)
        term_label.setAlignment(QtCore.Qt.AlignCenter)
        vertical_layout.addWidget(term_label)
        vertical_layout2.addLayout(vertical_layout)
        spacer_item3 = QtWidgets.QSpacerItem(17, 13, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        vertical_layout2.addItem(spacer_item3)
        horizontal_layout3 = QtWidgets.QHBoxLayout()
        spacer_item4 = QtWidgets.QSpacerItem(78, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        horizontal_layout3.addItem(spacer_item4)
        line = QtWidgets.QFrame(widget)
        line.setMinimumSize(QtCore.QSize(450, 0))
        line.setFrameShape(QtWidgets.QFrame.HLine)
        line.setFrameShadow(QtWidgets.QFrame.Sunken)
        horizontal_layout3.addWidget(line)
        spacer_item5 = QtWidgets.QSpacerItem(78, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        horizontal_layout3.addItem(spacer_item5)
        vertical_layout2.addLayout(horizontal_layout3)
        program_label = QtWidgets.QLabel(widget)
        font20 = QtGui.QFont()
        font20.setPointSize(20)
        program_label.setFont(font20)
        program_label.setAlignment(QtCore.Qt.AlignCenter)
        vertical_layout2.addWidget(program_label)
        spacer_item6 = QtWidgets.QSpacerItem(20, 13, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        vertical_layout2.addItem(spacer_item6)
        horizontal_layout = QtWidgets.QHBoxLayout()
        spacer_item7 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        horizontal_layout.addItem(spacer_item7)
        next_button = QtWidgets.QPushButton(widget)
        next_button.setMinimumSize(QtCore.QSize(200, 30))
        next_button.setMaximumSize(QtCore.QSize(200, 90))
        font16 = QtGui.QFont()
        font16.setPointSize(16)
        next_button.setFont(font16)
        horizontal_layout.addWidget(next_button)
        spacer_item8 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        horizontal_layout.addItem(spacer_item8)
        vertical_layout2.addLayout(horizontal_layout)
        self.main_window.setCentralWidget(central_widget)
        menubar = QtWidgets.QMenuBar(self.main_window)
        menubar.setGeometry(QtCore.QRect(0, 0, 686, 21))
        self.main_window.setMenuBar(menubar)
        self.statusbar = QtWidgets.QStatusBar(self.main_window)
        self.main_window.setStatusBar(self.statusbar)

        self.main_window.setWindowTitle("MainWindow")
        course_label.setText("Big Data Processing and Analytics")
        term_label.setText("Term Project")
        program_label.setText("Amazon Fine Food Reviews")
        next_button.setText("NEXT")

        QtCore.QMetaObject.connectSlotsByName(self.main_window)

        # self.BrowseQPushButton.clicked.connect(self.browse_file)
        next_button.clicked.connect(self.open_window)

    def open_window(self):
        self.inner_ui = MainWindow(QtWidgets.QMainWindow())
        self.main_window.hide()
        self.inner_ui.main_window.show()


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    ui = FirstWindow(QtWidgets.QMainWindow())
    ui.main_window.show()
    sys.exit(app.exec_())
