Skip to content
main.cpp 3.03 KiB
Newer Older
3dsman's avatar
3dsman committed
/*
* 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
*/

raoul's avatar
raoul committed
#include "src/qt/mainwindow.h"
#include <QApplication>
#include <QCommandLineParser>
#include <QDebug>
#include "main.h"

// TODO: fix qwerty mapping
// TODO: handlers, qui a besoin de qui et quand, pas de redondance ? chemins les + simples ?
// TODO: lock pour la modif, histoire de péter tout le backend sans que l'ihm explose
raoul's avatar
raoul committed
// TODO: list les features présentes et à venir, disons jusqu'à la v1.0 alpha pour commencer
// TODO MF: intégration/merge avec autre doc, gaffe aux scaling, normalisation générale des coords pour nos fichiers ?
// TODO: stitch de remplissage de formes
// TODO: rotation des selections
// TODO: creation des groupes
// TODO: export des .pes
// TODO: edition des motifs
// TODO: set des motifs des linestitchs avec miniature
3dsman's avatar
3dsman committed
// TODO: echelle dans la vue (cm/mm)
// TODO: actual exit logo is under CC license, https://thenounproject.com/search/?q=exit&i=1039024, change it or conform to license agreement
// TODO: fix bug on OE_actions::curDocument that can't work on multiple documents
// liste des bugs identifiés a corriger
// TODO bug dans OE_interfaceDisplay::selectApply la selection ne clear qu'un seul type (curve ou stitch) quand on selection uniquement des objets de l'autre type
// TODO bug dans les selections avec ajout sur les stitchs

// TODO cleanup actions on shortcut vs action on key event direct
// TODO put all actions on release by default

raoul's avatar
raoul committed
int main(int argc, char *argv[])
3dsman's avatar
3dsman committed
{
raoul's avatar
raoul committed
	QApplication a(argc, argv);

	QCommandLineParser parser;
	parser.setApplicationDescription("OE Designer CLI interface");
	parser.addHelpOption();
	parser.addOptions({
	       {"headless", QCoreApplication::translate("main", "Do not start GUI")},
	       {"export", QCoreApplication::translate("main", "Export active document to file."), QCoreApplication::translate("main", "exportFile")},
	   });
	parser.addPositionalArgument("open", QCoreApplication::translate("main", "Load file as active document."));
	parser.process(a);
	bool headless = parser.isSet("headless");

	QString openFile = parser.positionalArguments().empty() ? "" : parser.positionalArguments().first();

	if (!headless)
	{
		MainWindow w;
		w.setWindowState(Qt::WindowMaximized);
		w.show();
		if (openFile != "")
		{
			OE_interfaceDisplay* display = w.getCurrentRoot()->interfaceDisplay;
			display->loadFile(openFile.toStdString());
			display->zoomSelection();
			display->update();
		}
		return a.exec();
	}

	OE_document doc;
	if (openFile != "")
	{
		if (!doc.loadFromFile(openFile.toStdString()))
		{
			qDebug() << "Failed to open" << parser.value("open");
			return 1;
		}
	}
	if (parser.isSet("export"))
	{
		if (!doc.saveToFile(parser.value("export").toStdString()))
		{
			qDebug() << "Failed to save" << parser.value("export");
			return 1;
		}
	}
	return 0;
3dsman's avatar
3dsman committed
}