/*
* This file is part of project OpenEmbroidery. It's copyrighted by
* the contributors recorded in the version control history of the file.
* Original project location https://code.electrolab.fr/openEmbroidery/openEmbroidery_software
*
* SPDX-License-Identifier: CECILL-2.1
* License-Filename: Licence_CeCILL_V2.1-en.txt
*/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtWidgets/qlabel.h>
#include <memory>
#include <machine.h>

#include <QWidget>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QFormLayout>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QWidget>
#include <QtWidgets/qlabel.h>
#include <qtmaterialbutton.h>
#include <qtmaterialiconbutton.h>

class Machine;
namespace Ui {
class MainWindow;
}

class OE_interfaceDisplay;
class OE_root;
class OE_ui_toolBox;
class OE_ui_viewportOptions;
class OE_ui_stitchList;

class MainWindow : public QMainWindow
{
	Q_OBJECT

public:
	explicit MainWindow(QWidget *parent = nullptr);
	~MainWindow();
	void addTab();

	OE_ui_toolBox* m_leftToolTab;
    OE_ui_viewportOptions* m_viewportOptionBar;
    //QBoxLayout* topGlWindowBar();
	QBoxLayout* stitchParam();
	OE_ui_stitchList *stitchesList;

	void keyPressEvent(QKeyEvent* event);
	void keyReleaseEvent(QKeyEvent* event);

	void machineRun();
	void machineLoad();

	OE_root* getCurrentRoot();

private:
	OE_interfaceDisplay* getItfDisplay();
	void sendKeyPulse(Qt::Key key, Qt::KeyboardModifiers modifiers);

private slots:

	void on_tabWidget_tabCloseRequested(int index);

	void on_actionNew_triggered();

	void on_actionClose_triggered();

	void on_actionOpen_triggered();

	void on_actionSave_triggered();

	void on_actionLine_triggered();

	void on_actionUndo_triggered();

	void on_actionRedo_triggered();

	void on_actionBirail_triggered();

	void on_actionPattern1_triggered();
	void on_actionPattern2_triggered();
	void on_actionPattern3_triggered();
	void on_actionPattern4_triggered();
	void on_actionPattern5_triggered();
	void on_actionPattern6_triggered();
	void on_actionPattern7_triggered();
	void on_actionPattern8_triggered();
	void on_actionPattern9_triggered();

	void on_tabWidget_currentChanged(int index);

	void on_actionCloseCurve_triggered();

	void on_actionReverse_curve_R_triggered();

	void on_actionFill_triggered();

	void on_actionConnectToMachine_triggered(bool checked);

	void on_machineConnectionChanged(bool connected);
	void on_machineStateChanged(Machine::SlaveInfo info);

	void on_actionMachineRun_triggered();

	void on_actionMachineLoad_triggered();
signals:
	void machineConnectionChanged(bool connected);

	private:
	Ui::MainWindow *ui;
	QLabel status;
	std::unique_ptr<Machine> machine;
};

#endif // MAINWINDOW_H
