#ifndef SERVER_H
#define SERVER_H

#include <QMainWindow>
#include <QMessageBox>
#include <QBoxLayout>
#include <QMenu>
#include "emainwindow.h"
#include "server_core.h"
#include "ui_server.h"


class Server: public EMainWindow, protected Ui::Server {
	Q_OBJECT
public:
	Server(bool reservation = false);
	~Server();
	
	void prepare();
	void disableGraphics();

	ServerCore core;

protected:
	void timerEvent(QTimerEvent *);
	void closeEvent(QCloseEvent * e);
	bool eventFilter(QObject * o, QEvent * e);
	void showVariables();
	
	QMap<int, QString> log_category;
	QString cur_sel_var;
	QMap<int, QIcon> packet_icons;
	QIcon icon_property;
	QHash<QString, int> vars_num;
	QMenu * menu_log = nullptr, * menu_debug = nullptr;
	int timer_update = 0, timer_log = 0;
	bool no_graphics = false;
	
private slots:
	void loadedUI ();
	void loadedDAT();
	void loadedCM ();
	void loadedVAR();
	void startedAsMain();
	void startedAsReserve();
	void variableHistoryAdded(QString vname, QPair<QDateTime, double> value);
	void variableHistoryRemoved(QString vname, int count);
	void on_buttonKeyShow_pressed() {labelKey->setEchoMode(QLineEdit::Normal);}
	void on_buttonKeyShow_released() {labelKey->setEchoMode(QLineEdit::Password);}
	void on_buttonRestart_clicked();
	void on_buttonCloudNameCopy_clicked();

signals:
	void restartRequest();
	
};

#endif // SERVER_H
