File tree Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -37,10 +37,9 @@ int main( int argc, char* argv[] )
3737
3838 QGuiApplication app ( argc, argv ); // ... note next line...
3939 // QQuickStyle::setStyle( "Fusion" ); // <-- call setStyle after creating app (if style is needed)
40- project::CliOptions cliOptions ( app );
4140
4241 // ViewModels must OUTLIVE the qml engine, so create them first:
43- project::ViewModelCollection vms ( cliOptions );
42+ project::ViewModelCollection vms ( app );
4443
4544 // For antialiasing: https://stackoverflow.com/a/49576756/10278
4645 // QSurfaceFormat format;
@@ -63,7 +62,7 @@ int main( int argc, char* argv[] )
6362
6463 engine.addImportPath ( " qrc:///" ); // needed for finding qml in our plugins
6564 engine.load ( QUrl ( QStringLiteral ( " qrc:///qml/main.qml" ) ) );
66- if ( cliOptions .ShowColorPalette () )
65+ if ( vms. Options () .ShowColorPalette () )
6766 {
6867 // This second app window will cause the FASSERT about root objects
6968 // count to trigger below, but just choose 'c' to continue beyond the
Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ namespace project
2424using str = std::string;
2525
2626// clang-format off
27- ViewModelCollection::ViewModelCollection ( const CliOptions& opts )
28- : m_opts( &opts ),
27+ ViewModelCollection::ViewModelCollection ( const QCoreApplication& app )
28+ : m_opts( std::make_unique<CliOptions>( app ) ),
2929 m_eventFilter ( std::make_unique<EventFilter>() ),
3030 m_qmlLogger( std::make_unique<QmlMessageInterceptor>( !m_opts->MaximumQtLogging () ) ),
3131 m_logging( std::make_unique<LoggingTags>( *m_opts ) )
@@ -39,6 +39,11 @@ ViewModelCollection::ViewModelCollection( const CliOptions& opts )
3939
4040ViewModelCollection::~ViewModelCollection () = default ;
4141
42+ const CliOptions& ViewModelCollection::Options () const
43+ {
44+ return *m_opts;
45+ }
46+
4247void ViewModelCollection::ExportContextPropertiesToQml ( QQmlApplicationEngine* engine )
4348{
4449 // Sort of a "silly" demo usage of project::Log<>
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ class QmlMessageInterceptor;
2525class ViewModelCollection
2626{
2727public:
28- explicit ViewModelCollection ( const CliOptions& opts );
28+ explicit ViewModelCollection ( const QCoreApplication& app );
2929 ~ViewModelCollection ();
3030
3131 ViewModelCollection ( const ViewModelCollection& ) = delete ;
@@ -35,8 +35,10 @@ class ViewModelCollection
3535
3636 void SetRootObject ( QObject* object );
3737
38+ const CliOptions& Options () const ;
39+
3840private:
39- const CliOptions* const m_opts;
41+ std::unique_ptr< const CliOptions> m_opts;
4042 std::unique_ptr<EventFilter> m_eventFilter;
4143 std::unique_ptr<QmlMessageInterceptor> m_qmlLogger;
4244 std::unique_ptr<LoggingTags> m_logging;
You can’t perform that action at this time.
0 commit comments