#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QDebug>
#include <QTimer>
#include "StdOutRedirector.h"
#include "json/cJSON.h"
#include "loginwindow.h"

namespace Ui {
	class MainWindow;
}
class GUIMessageDialog;
class QTabWidget;
class QGestureEvent;
class QSwipeGesture;
class QPanGesture;
class QDockWidget;

class MainWindow : public QMainWindow
{
	Q_OBJECT

public:
	explicit MainWindow(QWidget* parent = nullptr);
	~MainWindow();
	static  void QMessageOutput(QtMsgType, const QMessageLogContext&, const QString& msg);
	void centerWidgetHide();
	void centerWidgetShow();
	void requestLogin();
	QTextEdit* getEdit();
	void debugConsoleOn();

	void grabGestures(const QList<Qt::GestureType>& gestures);
public slots:
	void triggerError(const QString&);
protected:
	void changeEvent(QEvent* event);
	bool event(QEvent* event) override;

private:
	bool gestureEvent(QGestureEvent* event);
	void swipeTriggered(QSwipeGesture*);
	void panTriggered(QPanGesture*);
	void loadStyleSheet(const QString& sheetName);
	cJSON* json_root = nullptr;

	Ui::MainWindow* ui;
	QDockWidget* dockWidget;
	GUIMessageDialog* msgDialog = nullptr;
	StdOutRedirector* redir = nullptr;
	QTextEdit* console = nullptr;
	bool m_bLoaded = false;
	QTabWidget* tab = nullptr;
	int admin_tab_index = -1;
	LoginWindow* l;
	QThread* t;
	bool debugMode = false;
};

#endif // MAINWINDOW_H
