From 156d78feb3d65ed158956dd9be8ba3eb9d57334d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 13 Dec 2019 11:50:12 +0100 Subject: [PATCH] [welcome] Add QML support - test application to display the QML (this will be extended with adding the locale model to it) - sample QML that does nothing useful yet (will display the locale model once it's there) --- src/modules/welcome/CMakeLists.txt | 3 ++ src/modules/welcome/qmlmain.cpp | 52 ++++++++++++++++++++++++++++++ src/modules/welcome/welcome.qml | 12 +++++++ 3 files changed, 67 insertions(+) create mode 100644 src/modules/welcome/qmlmain.cpp create mode 100644 src/modules/welcome/welcome.qml diff --git a/src/modules/welcome/CMakeLists.txt b/src/modules/welcome/CMakeLists.txt index e25b7f5d0..e0fbcfca1 100644 --- a/src/modules/welcome/CMakeLists.txt +++ b/src/modules/welcome/CMakeLists.txt @@ -40,3 +40,6 @@ calamares_add_plugin( welcome Qt5::Network SHARED_LIB ) + +add_executable( welcomeqmltest qmlmain.cpp ) +target_link_libraries( welcomeqmltest calamaresui ) diff --git a/src/modules/welcome/qmlmain.cpp b/src/modules/welcome/qmlmain.cpp new file mode 100644 index 000000000..81bf08df5 --- /dev/null +++ b/src/modules/welcome/qmlmain.cpp @@ -0,0 +1,52 @@ +/* Example executable showing a QML page and using the + * models from libcalamares for displaying a welcome. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "utils/Logger.h" + +int main(int argc, char **argv) +{ + QApplication a( argc, argv ); + + KAboutData aboutData( "calamares", + "Calamares", + "0.1", + "Calamares QML Test Application", + KAboutLicense::GPL_V3, + QString(), + QString(), + "https://calamares.io", + "https://github.com/calamares/calamares/issues" ); + KAboutData::setApplicationData( aboutData ); + a.setApplicationDisplayName( QString() ); // To avoid putting an extra "Calamares/" into the log-file + + Logger::setupLogLevel( Logger::LOGVERBOSE ); + + QMainWindow mw; + QWidget background; + QVBoxLayout vl; + QLabel l( "Hello, world", &mw ); + QQuickWidget qqw( &mw ); + vl.addWidget( &qqw ); + vl.addWidget( &l ); + background.setLayout( &vl ); + mw.setCentralWidget( &background ); + mw.resize( QSize( 400, 400 ) ); + mw.show(); + + 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 new file mode 100644 index 000000000..f73b66571 --- /dev/null +++ b/src/modules/welcome/welcome.qml @@ -0,0 +1,12 @@ +import QtQuick 2.0; + +Rectangle { + width: 200; + height: 200; + color: "pink"; + + Text { + anchors.centerIn: parent; + text: "Welcome to Calamares"; + } +}