#include <QApplication>
#include <QStyleFactory>
#include <QTimer>
#include <qsingleapplication.h>
#include "device_designer.h"
#include "SH_runtime.h"
#include "SH_plugins_manager.h"


int main(int argc, char * argv[]) {
	QApplication app(argc, argv);
	QApplication::setApplicationName("device_designer");
	enableHighDPI();
	app.setStyle(QStyleFactory::create("Fusion"));

	QSingleApplication qsa;
	if (!qsa.isFirst()) {
		qsa.sendMessage(qSerialize(app.arguments(), QDataStream::Qt_5_13));
		return 0;
	}

	RUNTIME->plugins_manager = new SHPluginsManager();
	DeviceDesigner w;
	QObject::connect(&qsa, SIGNAL(messageReceived(QByteArray)), &w, SLOT(anotherAppMessage(QByteArray)));
	w.showMain();

	int ret = app.exec();
	delete RUNTIME->plugins_manager;

	return ret;
}
