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


def main():
    app = QtWidgets.QApplication(sys.argv)
    monitor = DirectoryMonitor()
    data_converter = DataConverter()
    plot_widget_builder = PlotWidget()
    controller = Controller()
    window = MainWindow(controller)
    mediator = Mediator(monitor, data_converter, 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()
