From c59678594bbd81c6ddb7d39b32f48b8ae9471f6a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 13 Dec 2019 12:35:42 +0100 Subject: [PATCH] [welcome] More QML support - start of a class to hold configuration information; this can later be substituted into the WelcomeViewStep and filled from setConfigurationMap() In the example application: - register the Config type --- src/modules/welcome/CMakeLists.txt | 11 ++++++-- src/modules/welcome/Config.cpp | 27 ++++++++++++++++++++ src/modules/welcome/Config.h | 40 ++++++++++++++++++++++++++++++ src/modules/welcome/qmlmain.cpp | 10 ++++++++ src/modules/welcome/welcome.qml | 1 + 5 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 src/modules/welcome/Config.cpp create mode 100644 src/modules/welcome/Config.h diff --git a/src/modules/welcome/CMakeLists.txt b/src/modules/welcome/CMakeLists.txt index e0fbcfca1..b25bb6720 100644 --- a/src/modules/welcome/CMakeLists.txt +++ b/src/modules/welcome/CMakeLists.txt @@ -41,5 +41,12 @@ calamares_add_plugin( welcome SHARED_LIB ) -add_executable( welcomeqmltest qmlmain.cpp ) -target_link_libraries( welcomeqmltest calamaresui ) +add_executable( welcomeqmltest qmlmain.cpp Config.cpp ) +target_link_libraries( welcomeqmltest PRIVATE calamaresui Qt5::Core ) +set_target_properties( welcomeqmltest + PROPERTIES + ENABLE_EXPORTS TRUE + RUNTIME_OUTPUT_NAME welcomeqmltest +) +calamares_automoc( welcomeqmltest ) +calamares_autouic( welcomeqmltest ) diff --git a/src/modules/welcome/Config.cpp b/src/modules/welcome/Config.cpp new file mode 100644 index 000000000..35ce99184 --- /dev/null +++ b/src/modules/welcome/Config.cpp @@ -0,0 +1,27 @@ +/* === This file is part of Calamares - === + * + * Copyright 2019, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#include "Config.h" + +Config::Config() +{ +} + +Config::~Config() +{ +} diff --git a/src/modules/welcome/Config.h b/src/modules/welcome/Config.h new file mode 100644 index 000000000..91f5bec5c --- /dev/null +++ b/src/modules/welcome/Config.h @@ -0,0 +1,40 @@ +/* === This file is part of Calamares - === + * + * Copyright 2019, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#ifndef WELCOME_CONFIG_H +#define WELCOME_CONFIG_H + +#include +#include + +class Config : public QObject +{ + Q_OBJECT + Q_PROPERTY( QUrl helpUrl READ helpUrl WRITE setHelpUrl ) +public: + Config(); + virtual ~Config(); + + QUrl helpUrl() const { return m_helpUrl; } + void setHelpUrl( const QUrl& url ) { m_helpUrl = url; } + +private: + QUrl m_helpUrl; +}; + +#endif diff --git a/src/modules/welcome/qmlmain.cpp b/src/modules/welcome/qmlmain.cpp index 81bf08df5..cc538747a 100644 --- a/src/modules/welcome/qmlmain.cpp +++ b/src/modules/welcome/qmlmain.cpp @@ -16,6 +16,8 @@ #include "utils/Logger.h" +#include "Config.h" + int main(int argc, char **argv) { QApplication a( argc, argv ); @@ -46,6 +48,14 @@ int main(int argc, char **argv) mw.resize( QSize( 400, 400 ) ); mw.show(); + Config cnf; + if ( argc > 1 ) + { + cnf.setHelpUrl( QUrl( argv[1] ) ); + } + + qmlRegisterType< Config >( "io.calamares.modules.welcome", 1, 0, "Config" ); + qqw.setSource( QUrl::fromLocalFile("../src/modules/welcome/welcome.qml") ); return a.exec(); diff --git a/src/modules/welcome/welcome.qml b/src/modules/welcome/welcome.qml index f73b66571..d442bfa11 100644 --- a/src/modules/welcome/welcome.qml +++ b/src/modules/welcome/welcome.qml @@ -1,4 +1,5 @@ import QtQuick 2.0; +import io.calamares.modules.welcome 1.0; Rectangle { width: 200;