mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
applicationlistmodel: Space out application list refreshes
Use the same behavior as kickoff on desktop, to limit application list refreshes to once every 100ms. https://invent.kde.org/plasma/plasma-mobile/-/issues/440
This commit is contained in:
parent
bbfb367f23
commit
7d9054f74e
4 changed files with 36 additions and 14 deletions
|
|
@ -18,10 +18,19 @@
|
|||
#include <KSharedConfig>
|
||||
#include <KSycoca>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
ApplicationListModel::ApplicationListModel(HomeScreen *parent)
|
||||
: QAbstractListModel(parent)
|
||||
, m_reloadAppsTimer{new QTimer{this}}
|
||||
{
|
||||
connect(KSycoca::self(), &KSycoca::databaseChanged, this, &ApplicationListModel::sycocaDbChanged);
|
||||
m_reloadAppsTimer->setSingleShot(true);
|
||||
m_reloadAppsTimer->setInterval(100ms);
|
||||
connect(m_reloadAppsTimer, &QTimer::timeout, this, &ApplicationListModel::sycocaDbChanged);
|
||||
|
||||
connect(KSycoca::self(), &KSycoca::databaseChanged, m_reloadAppsTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
||||
|
||||
// initialize wayland window checking
|
||||
KWayland::Client::ConnectionThread *connection = KWayland::Client::ConnectionThread::fromApplication(this);
|
||||
|
|
@ -51,12 +60,6 @@ void ApplicationListModel::load()
|
|||
|
||||
const QStringList blacklist = blgroup.readEntry("blacklist", QStringList());
|
||||
|
||||
beginResetModel();
|
||||
|
||||
m_delegates.clear();
|
||||
|
||||
QList<FolioDelegate *> unorderedList;
|
||||
|
||||
auto filter = [blacklist](const KService::Ptr &service) -> bool {
|
||||
if (service->noDisplay()) {
|
||||
return false;
|
||||
|
|
@ -73,6 +76,12 @@ void ApplicationListModel::load()
|
|||
return true;
|
||||
};
|
||||
|
||||
beginResetModel();
|
||||
|
||||
m_delegates.clear();
|
||||
|
||||
QList<FolioDelegate *> unorderedList;
|
||||
|
||||
const KService::List apps = KApplicationTrader::query(filter);
|
||||
|
||||
for (const KService::Ptr &service : apps) {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ public Q_SLOTS:
|
|||
protected:
|
||||
HomeScreen *m_homeScreen{nullptr};
|
||||
QList<FolioDelegate *> m_delegates;
|
||||
|
||||
QTimer *m_reloadAppsTimer{nullptr};
|
||||
};
|
||||
|
||||
class ApplicationListSearchModel : public QSortFilterProxyModel
|
||||
|
|
|
|||
|
|
@ -18,10 +18,19 @@
|
|||
#include <KSharedConfig>
|
||||
#include <KSycoca>
|
||||
|
||||
#include <chrono>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
ApplicationListModel::ApplicationListModel(QObject *parent)
|
||||
: QAbstractListModel(parent)
|
||||
, m_reloadAppsTimer{new QTimer{this}}
|
||||
{
|
||||
connect(KSycoca::self(), &KSycoca::databaseChanged, this, &ApplicationListModel::sycocaDbChanged);
|
||||
m_reloadAppsTimer->setSingleShot(true);
|
||||
m_reloadAppsTimer->setInterval(100ms);
|
||||
connect(m_reloadAppsTimer, &QTimer::timeout, this, &ApplicationListModel::sycocaDbChanged);
|
||||
|
||||
connect(KSycoca::self(), &KSycoca::databaseChanged, m_reloadAppsTimer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
||||
}
|
||||
|
||||
ApplicationListModel::~ApplicationListModel() = default;
|
||||
|
|
@ -49,12 +58,6 @@ void ApplicationListModel::loadApplications()
|
|||
|
||||
const QStringList blacklist = blgroup.readEntry("blacklist", QStringList());
|
||||
|
||||
beginResetModel();
|
||||
|
||||
m_applicationList.clear();
|
||||
|
||||
QList<Application *> unorderedList;
|
||||
|
||||
auto filter = [blacklist](const KService::Ptr &service) -> bool {
|
||||
if (service->noDisplay()) {
|
||||
return false;
|
||||
|
|
@ -71,6 +74,12 @@ void ApplicationListModel::loadApplications()
|
|||
return true;
|
||||
};
|
||||
|
||||
beginResetModel();
|
||||
|
||||
m_applicationList.clear();
|
||||
|
||||
QList<Application *> unorderedList;
|
||||
|
||||
const KService::List apps = KApplicationTrader::query(filter);
|
||||
|
||||
for (const KService::Ptr &service : apps) {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <QObject>
|
||||
#include <QQuickItem>
|
||||
#include <QSet>
|
||||
#include <QTimer>
|
||||
|
||||
/**
|
||||
* @short The base application list, used directly by the full app list page.
|
||||
|
|
@ -37,4 +38,5 @@ public Q_SLOTS:
|
|||
|
||||
protected:
|
||||
QList<Application *> m_applicationList;
|
||||
QTimer *m_reloadAppsTimer{nullptr};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue