#include <QApplication>
#include <QTimer>
#include "serverdesigner.h"
#include "qsingleapplication.h"
#include "slider.h"
#include "stackedwidget.h"
#include "scrollarea.h"
#include "SH_builtin.h"
#include "SH_plugins_manager.h"


int main(int argc, char * argv[]) {
	QApplication app(argc, argv);
	QApplication::setApplicationName("server_designer");
	QApplication::setWindowIcon(QIcon(":/icons/MS_designer.png"));
	app.setAttribute(Qt::AA_DontUseNativeMenuBar);
	enableHighDPI();

	RUNTIME->plugins_manager = new SHPluginsManager();
	ServerDesigner w;
	if (!w.isFirst()) {
		delete RUNTIME->plugins_manager;
		return 0;
	}
	w.showMain();

	/*SHSStackedWidget w;
	w.setAnimationDuration(1000);
	w.setSwipeDirection(QBoxLayout::LeftToRight);
	//w.setSwipeMoveToFirstPage(true);
	QWidget * p = new QWidget();
	p->setLayout(new QBoxLayout(QBoxLayout::TopToBottom));
	p->layout()->addWidget(new QLabel("123"));
	auto * b = new QPushButton("button 1");
	QObject::connect(b, &QPushButton::clicked, &w, [&w](){w.gotoPage(1);});
	p->layout()->addWidget(b);
	w.addWidget(p);
	p = new QWidget();
	p->setLayout(new QBoxLayout(QBoxLayout::TopToBottom));
	p->layout()->addWidget(new SHSSlider());
	b = new QPushButton("button 2");
	QObject::connect(b, &QPushButton::clicked, &w, [&w](){w.gotoPage(0);});
	p->layout()->addWidget(b);
	p->layout()->addItem(new QSpacerItem(1, 1, QSizePolicy::Preferred, QSizePolicy::Expanding));
	w.addWidget(p);
	w.setCurrentIndex(0);
	w.show();*/

	/*SHSScrollArea w;
	QWidget * p = new QWidget();
	p->setLayout(new QBoxLayout(QBoxLayout::TopToBottom));
	piForTimes(5) {
		p->layout()->addWidget(new QLabel("123"));
		auto * b = new QPushButton("button 1");
		p->layout()->addWidget(b);
		p->layout()->addWidget(new SHSSlider());
		b = new QPushButton("button 2");
		p->layout()->addWidget(b);
		p->layout()->addItem(new QSpacerItem(1, 1, QSizePolicy::Preferred, QSizePolicy::Expanding));
	}
	w.setWidget(p);
	w.show();*/

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

	return ret;
}
