diff --git a/src/qtquick/qml/DialogContent.qml b/src/qtquick/qml/DialogContent.qml --- a/src/qtquick/qml/DialogContent.qml +++ b/src/qtquick/qml/DialogContent.qml @@ -63,9 +63,16 @@ pageStack.globalToolBar.style: Kirigami.ApplicationHeaderStyle.Auto pageStack.initialPage: NewStuff.Page { id: newStuffPage - onMessage: component.showPassiveNotification(message); - onIdleMessage: component.showPassiveNotification(message); - onBusyMessage: component.showPassiveNotification(message); - onErrorMessage: component.showPassiveNotification(message); + function showMessage(message) { + // As the Page shows something nice and friendly while loading, + // there's no reason to do the passive notification thing for those. + if (!engine.isLoading) { + component.showPassiveNotification(message); + } + } + onMessage: showMessage(message); + onIdleMessage: showMessage(message); + onBusyMessage: showMessage(message); + onErrorMessage: showMessage(message); } } diff --git a/src/qtquick/qml/Page.qml b/src/qtquick/qml/Page.qml --- a/src/qtquick/qml/Page.qml +++ b/src/qtquick/qml/Page.qml @@ -87,10 +87,23 @@ title: newStuffEngine.name NewStuff.Engine { id: newStuffEngine; - onMessage: root.message(message); - onIdleMessage: root.idleMessage(message); - onBusyMessage: root.busyMessage(message); - onErrorMessage: root.errorMessage(message); + property string statusMessage; + onMessage: { + root.message(message); + statusMessage = message; + } + onIdleMessage: { + root.idleMessage(message); + statusMessage = message; + } + onBusyMessage: { + root.busyMessage(message); + statusMessage = message; + } + onErrorMessage: { + root.errorMessage(message); + statusMessage = message; + } } NewStuff.QuestionAsker {} @@ -229,4 +242,34 @@ id: detailsPage; NewStuff.EntryDetails { } } + + Item { + anchors.fill: parent + opacity: newStuffEngine.isLoading ? 1 : 0 + Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration; } } + visible: opacity > 0 + Rectangle { + anchors.fill: parent + color: Kirigami.Theme.backgroundColor + opacity: 0.7 + } + QtControls.BusyIndicator { + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.verticalCenter + bottomMargin: Kirigami.Units.largeSpacing + } + running: newStuffEngine.isLoading + } + QtControls.Label { + anchors { + top: parent.verticalCenter + left: parent.left + right: parent.right + margins: Kirigami.Units.largeSpacing + } + horizontalAlignment: Text.AlignHCenter + text: newStuffEngine.statusMessage + } + } } diff --git a/src/qtquick/quickengine.h b/src/qtquick/quickengine.h --- a/src/qtquick/quickengine.h +++ b/src/qtquick/quickengine.h @@ -39,6 +39,7 @@ Q_PROPERTY(bool allowedByKiosk READ allowedByKiosk CONSTANT) Q_PROPERTY(QString configFile READ configFile WRITE setConfigFile NOTIFY configFileChanged) Q_PROPERTY(QObject* engine READ engine NOTIFY engineChanged) + Q_PROPERTY(bool isLoading READ isLoading NOTIFY isLoadingChanged) Q_PROPERTY(bool hasAdoptionCommand READ hasAdoptionCommand NOTIFY engineInitialized) Q_PROPERTY(QString name READ name NOTIFY engineInitialized) Q_PROPERTY(QObject* categories READ categories NOTIFY categoriesChanged) @@ -61,6 +62,9 @@ QObject *engine() const; Q_SIGNAL void engineChanged(); + bool isLoading() const; + Q_SIGNAL void isLoadingChanged(); + bool hasAdoptionCommand() const; QString name() const; Q_SIGNAL void engineInitialized(); diff --git a/src/qtquick/quickengine.cpp b/src/qtquick/quickengine.cpp --- a/src/qtquick/quickengine.cpp +++ b/src/qtquick/quickengine.cpp @@ -37,6 +37,7 @@ , categoriesModel(nullptr) {} KNSCore::Engine *engine; + bool isLoading{false}; CategoriesModel *categoriesModel; QString configFile; KNSCore::EntryInternal::List changedEntries; @@ -66,17 +67,30 @@ void Engine::setConfigFile(const QString &newFile) { if (d->configFile != newFile) { + d->isLoading = true; + emit isLoadingChanged(); d->configFile = newFile; emit configFileChanged(); if (allowedByKiosk()) { if (!d->engine) { d->engine = new KNSCore::Engine(this); + connect(d->engine, &KNSCore::Engine::signalProvidersLoaded, this, [=](){ + d->isLoading = false; + emit isLoadingChanged(); + }); connect(d->engine, &KNSCore::Engine::signalMessage, this, &Engine::message); connect(d->engine, &KNSCore::Engine::signalIdle, this, &Engine::idleMessage); connect(d->engine, &KNSCore::Engine::signalBusy, this, &Engine::busyMessage); connect(d->engine, &KNSCore::Engine::signalError, this, &Engine::errorMessage); - connect(d->engine, &KNSCore::Engine::signalErrorCode, this, [=](const KNSCore::ErrorCode &/*errorCode*/, const QString &message, const QVariant &/*metadata*/) { + connect(d->engine, &KNSCore::Engine::signalErrorCode, this, [=](const KNSCore::ErrorCode &errorCode, const QString &message, const QVariant &/*metadata*/) { + if (errorCode == KNSCore::ProviderError) { + // This means loading the providers file failed entirely and we cannot complete the + // initialisation. It also means the engine is done loading, but that nothing will + // work, and we need to inform the user of this. + d->isLoading = false; + emit isLoadingChanged(); + } emit errorMessage(message); }); connect(d->engine, &KNSCore::Engine::signalEntryChanged, this, [this](const KNSCore::EntryInternal &entry){ @@ -104,6 +118,11 @@ return d->engine; } +bool Engine::isLoading() const +{ + return d->isLoading; +} + bool Engine::hasAdoptionCommand() const { if (d->engine) {