import sys
from PyQt5 import QtWidgets

from src.gui.mainGui import MainWindow
from src.controller.monitor import DirectoryMonitor
from src.controller.mediator import Mediator
from src.controller.converter import DataConverter
from src.gui.plotter import PlotWidget
from src.controller.controller import Controller
from src.controller.passportFormer import PassportFormer


def main():
    app = QtWidgets.QApplication(sys.argv)
    monitor = DirectoryMonitor()
    data_converter = DataConverter()
    plot_widget_builder = PlotWidget()
    controller = Controller()
    passport_former = PassportFormer()
    window = MainWindow(controller)
    mediator = Mediator(monitor, data_converter, passport_former, plot_widget_builder, controller)
    window.show()

    controller.signal_widgets.connect(window.show_plot_tabs)
    controller.signal_settings.connect(mediator.push_settings)

    window.push_settings()

    sys.exit(app.exec_())


if __name__ == '__main__':
    main()
