2019-12-01 17:40:10 +03:00
|
|
|
#include <QtQuick>
|
2023-02-17 23:29:12 +03:00
|
|
|
#include <QVariant>
|
|
|
|
#include <QDBusConnection>
|
2019-12-01 17:40:10 +03:00
|
|
|
|
|
|
|
#include <sailfishapp.h>
|
2019-12-01 17:55:55 +03:00
|
|
|
#include <src/ippdiscovery.h>
|
|
|
|
#include <src/ippprinter.h>
|
2022-02-19 19:33:59 +03:00
|
|
|
#include <src/imageitem.h>
|
2020-02-18 22:40:31 +03:00
|
|
|
#include <src/mimer.h>
|
2020-05-11 21:44:53 +03:00
|
|
|
#include <src/convertchecker.h>
|
2021-06-19 18:47:11 +03:00
|
|
|
#include <src/settings.h>
|
2022-08-13 17:30:13 +03:00
|
|
|
#include <src/rangelistchecker.h>
|
2023-02-17 23:29:12 +03:00
|
|
|
#include <src/dbusadaptor.h>
|
|
|
|
#include "argget.h"
|
|
|
|
#include <iostream>
|
2019-12-01 17:40:10 +03:00
|
|
|
|
2021-12-14 22:01:52 +03:00
|
|
|
Q_DECLARE_METATYPE(CURLcode)
|
|
|
|
Q_DECLARE_METATYPE(Bytestream)
|
2022-03-19 19:31:55 +03:00
|
|
|
Q_DECLARE_METATYPE(PrintParameters)
|
2021-12-14 22:01:52 +03:00
|
|
|
|
2020-02-18 22:40:31 +03:00
|
|
|
template <class T>
|
|
|
|
static QObject* singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
|
2020-01-05 20:41:24 +03:00
|
|
|
{
|
|
|
|
Q_UNUSED(engine)
|
|
|
|
Q_UNUSED(scriptEngine)
|
|
|
|
|
2020-02-18 22:40:31 +03:00
|
|
|
T *inst = T::instance();
|
|
|
|
return inst;
|
2020-01-05 20:41:24 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-12-01 17:40:10 +03:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2023-02-17 23:29:12 +03:00
|
|
|
bool prestart = false;
|
|
|
|
std::string FileName;
|
|
|
|
SwitchArg<bool> pretsartOpt(prestart, {"--prestart"}, "Run prestart");
|
|
|
|
|
|
|
|
PosArg fileArg(FileName, "File to print", true);
|
|
|
|
ArgGet args({&pretsartOpt}, {&fileArg});
|
|
|
|
if(!args.get_args(argc, argv))
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-12-14 22:01:52 +03:00
|
|
|
qRegisterMetaType<CURLcode>();
|
|
|
|
qRegisterMetaType<Bytestream>();
|
2022-03-19 19:31:55 +03:00
|
|
|
qRegisterMetaType<PrintParameters>();
|
2021-12-14 22:01:52 +03:00
|
|
|
|
2022-01-19 22:03:19 +03:00
|
|
|
// Turn on/off logging according to setting
|
|
|
|
QLoggingCategory::defaultCategory()->setEnabled(QtMsgType::QtDebugMsg, Settings::instance()->debugLog());
|
|
|
|
|
2019-12-20 00:59:56 +03:00
|
|
|
QGuiApplication* app = SailfishApp::application(argc, argv);
|
|
|
|
|
2021-06-01 19:29:57 +03:00
|
|
|
app->setOrganizationName(QStringLiteral("net.attah"));
|
|
|
|
app->setApplicationName(QStringLiteral("seaprint"));
|
2019-12-20 00:59:56 +03:00
|
|
|
app->setApplicationVersion(QStringLiteral(SEAPRINT_VERSION));
|
|
|
|
|
2020-02-18 22:40:31 +03:00
|
|
|
qmlRegisterSingletonType<IppDiscovery>("seaprint.ippdiscovery", 1, 0, "IppDiscovery", singletontype_provider<IppDiscovery>);
|
|
|
|
qmlRegisterSingletonType<Mimer>("seaprint.mimer", 1, 0, "Mimer", singletontype_provider<Mimer>);
|
2020-05-11 21:44:53 +03:00
|
|
|
qmlRegisterSingletonType<ConvertChecker>("seaprint.convertchecker", 1, 0, "ConvertChecker", singletontype_provider<ConvertChecker>);
|
2022-08-13 17:30:13 +03:00
|
|
|
qmlRegisterSingletonType<Settings>("seaprint.settings", 1, 0, "SeaPrintSettings", singletontype_provider<Settings>);
|
|
|
|
qmlRegisterSingletonType<RangeListChecker>("seaprint.rangelistchecker", 1, 0, "RangeListChecker", singletontype_provider<RangeListChecker>);
|
|
|
|
|
2019-12-01 17:55:55 +03:00
|
|
|
qmlRegisterType<IppPrinter>("seaprint.ippprinter", 1, 0, "IppPrinter");
|
2022-02-19 19:33:59 +03:00
|
|
|
qmlRegisterType<ImageItem>("seaprint.imageitem", 1, 0, "ImageItem");
|
2020-06-06 18:20:30 +03:00
|
|
|
qmlRegisterUncreatableType<IppMsg>("seaprint.ippmsg", 1, 0, "IppMsg", "Only used to supply an enum type");
|
2019-12-01 17:55:55 +03:00
|
|
|
|
2020-01-05 20:41:24 +03:00
|
|
|
QQuickView* view = SailfishApp::createView();
|
|
|
|
|
|
|
|
view->engine()->addImportPath(SailfishApp::pathTo("qml/pages").toString());
|
|
|
|
view->setSource(SailfishApp::pathToMainQml());
|
2023-02-17 23:29:12 +03:00
|
|
|
|
|
|
|
DBusAdaptor dbus(view);
|
|
|
|
|
|
|
|
if (!QDBusConnection::sessionBus().registerObject("/net/attah/seaprint", view))
|
|
|
|
qWarning() << "Could not register /net/attah/seaprint D-Bus object.";
|
|
|
|
|
|
|
|
if (!QDBusConnection::sessionBus().registerService("net.attah.seaprint"))
|
|
|
|
qWarning() << "Could not register net.attah.seaprint D-Bus service.";
|
|
|
|
|
|
|
|
if(!FileName.empty())
|
|
|
|
{
|
|
|
|
qDebug() << "Opening" << FileName.c_str();
|
|
|
|
QVariant fileNameVariant(FileName.c_str());
|
|
|
|
QMetaObject::invokeMethod(view->rootObject(), "openFile", Q_ARG(QVariant, fileNameVariant));
|
|
|
|
}
|
|
|
|
if(!prestart)
|
|
|
|
{
|
|
|
|
view->show();
|
|
|
|
}
|
2020-01-05 20:41:24 +03:00
|
|
|
return app->exec();
|
2019-12-01 17:40:10 +03:00
|
|
|
}
|