2022-09-26 17:51:28 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the 3-clause BSD License
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2022-12-03 17:19:07 +01:00
|
|
|
#include "Window.h"
|
|
|
|
#include "GeometricShape.h"
|
2022-12-02 16:30:01 +01:00
|
|
|
#include "Stroke.h"
|
2022-09-26 17:51:28 +02:00
|
|
|
|
2022-12-03 17:19:07 +01:00
|
|
|
#include <QskQml.h>
|
2022-09-26 17:51:28 +02:00
|
|
|
#include <QskObjectCounter.h>
|
|
|
|
|
|
|
|
#include <SkinnyShortcut.h>
|
|
|
|
#include <QGuiApplication>
|
|
|
|
|
2022-12-03 17:19:07 +01:00
|
|
|
#include <QQmlApplicationEngine>
|
2022-09-29 16:50:46 +02:00
|
|
|
|
2022-12-03 17:19:07 +01:00
|
|
|
template< typename T >
|
|
|
|
static inline int registerType( const char* qmlName )
|
|
|
|
{
|
|
|
|
return qmlRegisterType< T >( "Shapes", 1, 0, qmlName );
|
|
|
|
}
|
2022-09-29 16:50:46 +02:00
|
|
|
|
2022-12-03 17:19:07 +01:00
|
|
|
template< typename T >
|
|
|
|
static inline int registerValueType( const char* qmlName )
|
|
|
|
{
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
|
|
|
|
QByteArray name = qmlName;
|
|
|
|
name.data()[0] = std::tolower( name.data()[0] );
|
2022-12-03 17:24:25 +01:00
|
|
|
return registerType< T >( name.constData() );
|
2022-12-03 17:19:07 +01:00
|
|
|
#else
|
|
|
|
return qmlRegisterUncreatableType< T >( "Shapes", 1, 0, qmlName, QString() );
|
2022-10-13 19:39:57 +02:00
|
|
|
#endif
|
2022-12-03 17:19:07 +01:00
|
|
|
}
|
2022-10-13 19:39:57 +02:00
|
|
|
|
2022-12-03 17:19:07 +01:00
|
|
|
static bool doQml( int argc, char* argv[] )
|
|
|
|
{
|
|
|
|
for ( int i = 1; i < argc; i++ )
|
2022-10-13 19:39:57 +02:00
|
|
|
{
|
2022-12-03 17:19:07 +01:00
|
|
|
if ( strcmp( argv[i], "-qml" ) == 0 )
|
|
|
|
return true;
|
|
|
|
}
|
2022-10-13 19:39:57 +02:00
|
|
|
|
2022-12-03 17:19:07 +01:00
|
|
|
return false;
|
2022-09-26 17:51:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int main( int argc, char* argv[] )
|
|
|
|
{
|
|
|
|
#ifdef ITEM_STATISTICS
|
|
|
|
QskObjectCounter counter( true );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QGuiApplication app( argc, argv );
|
|
|
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
|
|
|
|
2022-12-03 17:19:07 +01:00
|
|
|
if ( doQml( argc, argv ) )
|
|
|
|
{
|
|
|
|
qDebug() << "Running QML";
|
|
|
|
|
|
|
|
QskQml::registerTypes();
|
|
|
|
|
|
|
|
registerType< GeometricShape >( "Shape" );
|
|
|
|
registerValueType< Stroke >( "Stroke" );
|
|
|
|
|
|
|
|
QQmlApplicationEngine engine( QUrl( "qrc:/qml/shapes.qml" ) );
|
|
|
|
|
|
|
|
return app.exec();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
qDebug() << "Running C++";
|
|
|
|
|
|
|
|
Window window;
|
|
|
|
window.show();
|
2022-09-26 17:51:28 +02:00
|
|
|
|
2022-12-03 17:19:07 +01:00
|
|
|
return app.exec();
|
|
|
|
}
|
2022-09-26 17:51:28 +02:00
|
|
|
}
|