qskinny/qmlexport/QskMainQml.cpp

70 lines
2.1 KiB
C++
Raw Normal View History

2020-10-29 18:53:43 +01:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#include "QskMainQml.h"
#include <QskSkinManager.h>
#include <QskSkin.h>
static void qskRegisterConverter()
{
QMetaType::registerConverter< int, QskSetupFlagsQml >();
}
Q_CONSTRUCTOR_FUNCTION( qskRegisterConverter )
QskMain::QskMain( QObject* parent )
: QObject( parent )
{
// how to supress warnings about a missing skinListChanged
// as we don't have it ??
connect( setup(), &QskSetup::skinChanged,
this, &QskMain::skinChanged, Qt::QueuedConnection );
2021-02-09 08:13:20 +01:00
connect( setup(), &QskSetup::itemUpdateFlagsChanged,
this, &QskMain::itemUpdateFlagsChanged, Qt::QueuedConnection );
2020-10-29 18:53:43 +01:00
}
QStringList QskMain::skinList() const
{
auto manager = QskSkinManager::instance();
return manager ? manager->skinNames() : QStringList();
}
QQmlListProperty< QObject > QskMain::data()
{
2020-11-21 20:36:47 +01:00
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
using SizeType = qsizetype;
#else
using SizeType = int;
#endif
2020-10-29 18:53:43 +01:00
return QQmlListProperty< QObject >(
this, nullptr,
[]( QQmlListProperty< QObject >* property, QObject* value )
{
auto main = static_cast< QskMain* >( property->object );
main->m_data.append( value );
},
[]( QQmlListProperty< QObject >* property )
{
auto main = static_cast< const QskMain* >( property->object );
2020-11-21 20:36:47 +01:00
return static_cast< SizeType >( main->m_data.count() );
2020-10-29 18:53:43 +01:00
},
2020-11-21 20:36:47 +01:00
[]( QQmlListProperty< QObject >* property, SizeType index )
2020-10-29 18:53:43 +01:00
{
auto main = static_cast< const QskMain* >( property->object );
return main->m_data.at( index );
},
[]( QQmlListProperty< QObject >* property )
{
auto main = static_cast< QskMain* >( property->object );
main->m_data.clear();
}
);
}
#include "moc_QskMainQml.cpp"