Commit f285b949 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Smoother initializing experience of ApplicationListPage

Check whether the reason that the !ResourcesProxyModel.isBusy is that
the backends aren't all populated yet.

This way we make sure we don't get a flash of the error message in the
placeholder.
parent e1383ed7
Pipeline #209608 passed with stage
in 2 minutes and 56 seconds
......@@ -157,8 +157,10 @@ DiscoverPage {
}
Item {
readonly property bool nothingFound: apps.count == 0 && !appsModel.isBusy && !ResourcesModel.isInitializing && (!page.searchPage || appsModel.search.length > 0)
anchors.fill: parent
opacity: apps.count == 0 && !appsModel.isBusy && (!page.searchPage || appsModel.search.length > 0) ? 1 : 0
opacity: nothingFound ? 1 : 0
visible: opacity > 0
Behavior on opacity { NumberAnimation { duration: Kirigami.Units.longDuration; easing.type: Easing.InOutQuad } }
......
......@@ -88,8 +88,10 @@ void ResourcesModel::init(bool load)
m_allInitializedEmitter->setSingleShot(true);
m_allInitializedEmitter->setInterval(0);
connect(m_allInitializedEmitter, &QTimer::timeout, this, [this]() {
if (m_initializingBackends == 0)
if (m_initializingBackends == 0) {
m_initializingBackends = false;
Q_EMIT allInitialized();
}
});
if (load)
......@@ -261,6 +263,11 @@ bool ResourcesModel::isFetching() const
return m_isFetching;
}
bool ResourcesModel::isInitializing() const
{
return m_isInitializing;
}
void ResourcesModel::slotFetching()
{
bool newFetching = false;
......
......@@ -74,6 +74,7 @@ class DISCOVERCOMMON_EXPORT ResourcesModel : public QObject
Q_PROPERTY(int updatesCount READ updatesCount NOTIFY updatesCountChanged)
Q_PROPERTY(bool hasSecurityUpdates READ hasSecurityUpdates NOTIFY updatesCountChanged)
Q_PROPERTY(bool isFetching READ isFetching NOTIFY fetchingChanged)
Q_PROPERTY(bool isInitializing READ isInitializing NOTIFY allInitialized)
Q_PROPERTY(AbstractResourcesBackend *currentApplicationBackend READ currentApplicationBackend WRITE setCurrentApplicationBackend NOTIFY
currentApplicationBackendChanged)
Q_PROPERTY(DiscoverAction *updateAction READ updateAction CONSTANT)
......@@ -96,6 +97,7 @@ public:
bool isBusy() const;
bool isFetching() const;
bool isInitializing() const;
Q_SCRIPTABLE bool isExtended(const QString &id);
......@@ -151,6 +153,7 @@ private:
void slotFetching();
bool m_isFetching;
bool m_isInitializing = true;
QVector<AbstractResourcesBackend *> m_backends;
int m_initializingBackends;
DiscoverAction *m_updateAction = nullptr;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment