2021-04-29 07:49:08 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Copyright (C) 2021 Edelhirsch Software GmbH
|
2023-04-06 09:23:37 +02:00
|
|
|
* SPDX-License-Identifier: BSD-3-Claus
|
2021-04-29 07:49:08 +02:00
|
|
|
*****************************************************************************/
|
2021-04-26 06:22:35 +02:00
|
|
|
|
|
|
|
#include "MainWindow.h"
|
2021-08-26 17:02:31 +02:00
|
|
|
#include "GraphicProvider.h"
|
2021-04-26 06:22:35 +02:00
|
|
|
#include "Skin.h"
|
|
|
|
|
2023-04-05 17:47:15 +02:00
|
|
|
#ifdef USE_SHORTCUTS
|
2021-04-26 06:22:35 +02:00
|
|
|
#include <SkinnyShortcut.h>
|
2023-04-05 17:47:15 +02:00
|
|
|
#endif
|
2021-04-26 06:22:35 +02:00
|
|
|
|
|
|
|
#include <QskSetup.h>
|
|
|
|
#include <QskShortcutMap.h>
|
|
|
|
#include <QskSkinFactory.h>
|
|
|
|
#include <QskSkinManager.h>
|
|
|
|
#include <QskWindow.h>
|
2021-08-05 11:06:48 +02:00
|
|
|
#include <QskObjectCounter.h>
|
2021-04-26 06:22:35 +02:00
|
|
|
|
|
|
|
#include <QGuiApplication>
|
2023-04-05 17:47:15 +02:00
|
|
|
#include <QTimer>
|
2021-04-26 06:22:35 +02:00
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
class SkinFactory : public QskSkinFactory
|
|
|
|
{
|
2021-08-04 09:31:16 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
SkinFactory( QObject* parent = nullptr )
|
|
|
|
: QskSkinFactory( parent )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList skinNames() const override
|
|
|
|
{
|
|
|
|
return { "DaytimeSkin", "NighttimeSkin" };
|
|
|
|
}
|
|
|
|
|
|
|
|
QskSkin* createSkin( const QString& skinName ) override
|
|
|
|
{
|
|
|
|
if( skinName == "DaytimeSkin" )
|
2021-04-26 06:22:35 +02:00
|
|
|
{
|
2021-08-04 09:31:16 +02:00
|
|
|
return new DaytimeSkin;
|
2021-04-26 06:22:35 +02:00
|
|
|
}
|
|
|
|
|
2021-08-04 09:31:16 +02:00
|
|
|
if( skinName == "NighttimeSkin" )
|
2021-04-26 06:22:35 +02:00
|
|
|
{
|
2021-08-04 09:31:16 +02:00
|
|
|
return new NighttimeSkin;
|
2021-04-26 06:22:35 +02:00
|
|
|
}
|
|
|
|
|
2021-08-04 09:31:16 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2021-04-26 06:22:35 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
int main( int argc, char* argv[] )
|
|
|
|
{
|
2021-08-05 11:06:48 +02:00
|
|
|
#ifdef ITEM_STATISTICS
|
|
|
|
QskObjectCounter counter( true );
|
|
|
|
#endif
|
|
|
|
|
2021-04-26 06:22:35 +02:00
|
|
|
QGuiApplication app( argc, argv );
|
|
|
|
|
2022-05-18 13:45:09 +02:00
|
|
|
qskSetup->setItemUpdateFlag( QskQuickItem::PreferRasterForTextures, true );
|
|
|
|
|
2021-08-26 17:02:31 +02:00
|
|
|
Qsk::addGraphicProvider( QString(), new GraphicProvider() );
|
|
|
|
|
2021-08-05 11:06:48 +02:00
|
|
|
// disable default skins
|
2021-04-26 06:22:35 +02:00
|
|
|
qskSkinManager->setPluginPaths( QStringList() ); // no plugins
|
2022-07-05 09:18:52 +02:00
|
|
|
qskSkinManager->unregisterFactory( "materialfactory" );
|
2022-07-05 08:36:25 +02:00
|
|
|
qskSkinManager->unregisterFactory( "material3factory" );
|
2021-04-26 06:22:35 +02:00
|
|
|
qskSkinManager->unregisterFactory( "squiekfactory" );
|
|
|
|
|
2021-08-05 11:06:48 +02:00
|
|
|
qskSkinManager->registerFactory(
|
|
|
|
QStringLiteral( "SampleSkinFactory" ), new SkinFactory() );
|
2021-04-26 06:22:35 +02:00
|
|
|
|
|
|
|
qskSetup->setSkin( "DaytimeSkin" );
|
|
|
|
|
2023-04-05 17:47:15 +02:00
|
|
|
#ifdef USE_SHORTCUTS
|
2021-04-26 06:22:35 +02:00
|
|
|
// With CTRL-B you can rotate a couple of visual debug modes
|
|
|
|
SkinnyShortcut::enable( SkinnyShortcut::RotateSkin | SkinnyShortcut::DebugBackground |
|
2021-08-04 09:31:16 +02:00
|
|
|
SkinnyShortcut::DebugStatistics | SkinnyShortcut::Quit );
|
2023-04-05 17:47:15 +02:00
|
|
|
#endif
|
2021-04-26 06:22:35 +02:00
|
|
|
|
|
|
|
MainWindow window;
|
|
|
|
window.show();
|
|
|
|
|
2023-04-05 17:47:15 +02:00
|
|
|
for( int i = 1; i < argc; i++ )
|
|
|
|
{
|
|
|
|
if( argv[i] == QStringLiteral("--screenshot") && i + 1 < argc )
|
|
|
|
{
|
|
|
|
QTimer::singleShot( 500, &window, [&app, &window, filename = QString(argv[i + 1])]()
|
|
|
|
{ auto image = window.grabWindow(); image.save(filename); } );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-26 06:22:35 +02:00
|
|
|
return app.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "main.moc"
|