[welcome] Put Config object into context
This commit is contained in:
parent
c59678594b
commit
d41d8df2a5
@ -19,6 +19,7 @@
|
||||
#include "Config.h"
|
||||
|
||||
Config::Config()
|
||||
: m_helpUrl( "https://www.kde.org/" )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
class Config : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY( QUrl helpUrl READ helpUrl WRITE setHelpUrl )
|
||||
Q_PROPERTY( QUrl helpUrl READ helpUrl WRITE setHelpUrl CONSTANT )
|
||||
public:
|
||||
Config();
|
||||
virtual ~Config();
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <QApplication>
|
||||
#include <QLabel>
|
||||
#include <QMainWindow>
|
||||
#include <QQmlEngine>
|
||||
#include <QQuickWidget>
|
||||
#include <QString>
|
||||
#include <QTimer>
|
||||
@ -18,6 +19,12 @@
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
static Config* theConfig()
|
||||
{
|
||||
static Config* cnf = new Config();
|
||||
return cnf;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication a( argc, argv );
|
||||
@ -54,7 +61,7 @@ int main(int argc, char **argv)
|
||||
cnf.setHelpUrl( QUrl( argv[1] ) );
|
||||
}
|
||||
|
||||
qmlRegisterType< Config >( "io.calamares.modules.welcome", 1, 0, "Config" );
|
||||
qmlRegisterSingletonType< Config >( "io.calamares.modules.welcome", 1, 0, "PotatoConfig", [](QQmlEngine*, QJSEngine*) -> QObject* { return theConfig(); });
|
||||
|
||||
qqw.setSource( QUrl::fromLocalFile("../src/modules/welcome/welcome.qml") );
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import QtQuick 2.0;
|
||||
import QtQuick.Controls 2.3;
|
||||
import io.calamares.modules.welcome 1.0;
|
||||
|
||||
Rectangle {
|
||||
@ -6,8 +7,15 @@ Rectangle {
|
||||
height: 200;
|
||||
color: "pink";
|
||||
|
||||
Text {
|
||||
Label {
|
||||
id: label;
|
||||
anchors.centerIn: parent;
|
||||
text: "Welcome to Calamares";
|
||||
}
|
||||
|
||||
Button {
|
||||
anchors.top: label.bottom;
|
||||
text: PotatoConfig.helpUrl;
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user